Summary of the invention
The shortcoming of prior art in view of the above, the object of the present invention is to provide a kind of automated testing method of the intelligent terminal RAM leakage based on android system, the internal memory ruuning situation of monitoring intelligent terminal is carried out by the parameter obtaining RAM and CPU in intelligent terminal, to judge whether internal memory is revealed, and can show in real time and to consume the program of maximum RAM when intelligent terminal runs and consume the program of most multi-CPU.
For achieving the above object and other relevant objects, the invention provides a kind of automated testing method of the intelligent terminal RAM leakage based on android system, comprise the following steps: step S1, intelligent terminal is set is in state of activation; The RAM value that step S2, acquisition intelligent terminal are current and CPU value; Step S3, the RAM value of acquisition and CPU value to be sorted; Step S4, open on intelligent terminal all APP successively after close again, RAM value and CPU value are monitored; Step S5, when there is unusual condition, open LOG capture function, automatically record test mode.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein: comprise the following steps in described step S1:
1) open the Root authority of intelligent terminal, obtain the parameter of intelligent terminal;
2) arrange intelligent terminal to be in not go out and to shield the state of activation of not screen protection.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein: in described step S2, JAVA technology is used to obtain RAM value and the CPU value of intelligent terminal.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein: described RAM value and CPU value are respectively RAM utilization rate parameter and CPU usage parameter.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein: during described step S4, adopt fully automatic operation mode iterative cycles to call each APP in intelligent terminal, then check the operation whether performing RAM release.
Further, according to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein: when automatically running APP, APP can be set to rerun number of times and separate run times.
Further, according to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein: when automatically running APP, successively run according to the title of APP, type or size.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein: in described step S5, described unusual condition comprises intelligent terminal deadlock, restarts and interface exception.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein: in described step S5, when the RAM value of intelligent terminal or CPU value are greater than 80%, then open LOG and capture function, automatically record test mode.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein: in described step S3, can also show in real time and to consume the program of maximum RAM when intelligent terminal runs and consume the program of most multi-CPU.
As mentioned above, the automated testing method of the intelligent terminal RAM leakage based on android system of the present invention, has following beneficial effect:
(1) any Android phone or Android device is applicable to;
(2) automatically APP all in intelligent terminal can be run successively when there is no manpower, strong operability;
(3) observe by RAM and CPU curve the process that intelligent terminal ruuning situation also can record operation curve automatically, thus effectively detect the problem that the internal memory in intelligent terminal runs.
Embodiment
Below by way of specific instantiation, embodiments of the present invention are described, those skilled in the art the content disclosed by this instructions can understand other advantages of the present invention and effect easily.The present invention can also be implemented or be applied by embodiments different in addition, and the every details in this instructions also can based on different viewpoints and application, carries out various modification or change not deviating under spirit of the present invention.
It should be noted that, the diagram provided in the present embodiment only illustrates basic conception of the present invention in a schematic way, then only the assembly relevant with the present invention is shown in graphic but not component count, shape and size when implementing according to reality is drawn, it is actual when implementing, and the kenel of each assembly, quantity and ratio can be a kind of change arbitrarily, and its assembly layout kenel also may be more complicated.
It should be noted that, intelligent terminal involved in the present invention comprises and is not limited to smart mobile phone, panel computer, PDA, and other have the terminal device of data processing function.Usually, intelligent terminal refers to have independently operating system, can by user's program of providing of the third party service provider such as mounting software, game voluntarily, the function being carried out continuous handheld device by this class method is expanded, and can be realized such terminal equipment 1 of wireless network access by mobile communication network.
With reference to Fig. 1, the automated testing method of the intelligent terminal RAM leakage based on android system of the present invention comprises the following steps:
Step S1, intelligent terminal is set is in state of activation.
Particularly, first open the Root authority of intelligent terminal, to obtain the parameter of intelligent terminal; Secondly, intelligent terminal is set and is in not go out and shields the state of activation of not screen protection, be convenient to automated execution test.
In the present invention by adopting embedded software and external software, use the JAVA instrument carrying computer end to carry out data line connection and monitoring to intelligent terminal, and built-in application APP, employing APP directional operation program carry out directional operation to APP in intelligent terminal.Owing to adopting APP as the application interface of intelligent terminal, thus compatibility of the present invention and applicability stronger.
The RAM value that step S2, acquisition intelligent terminal are current and CPU value.
CPU is that intelligent terminal runs and standby important devices.Therefore, the various state of intelligent terminal and CPU have directly and the relation of brief introduction.The value obtaining CPU is in order to when RAM leakage, confirms whether the value change of CPU is the condition and the factor that cause RAM leakage or cause RAM leakage.
The reason of the RAM leakage of intelligent terminal is caused to be diversified.When RAM leakage, be exactly the parameter value checking RAM and CPU the most intuitively, and Parameters variation situation before.If single parameter value, be difficult to the breakthrough point of find problem, only have and the data summarization of RAM with CPU is become curve, the time point position that ability find problem occurs, and analyze the reason causing device memory to be revealed further.
Particularly, when carrying out automatic test, a key triggers and starts APP and APP directional operation program.Start internal memory monitoring program simultaneously, test and record internal memory situation.
Particularly, the current value of RAM and CPU of JAVA technical limit spacing intelligent terminal can be used in the present invention.Wherein, order adb shell cat/proc/meminfo for obtaining memory value; Order adb shell top-n 1-m 1 is for obtaining CPU value.Current RAM value and CPU value is obtained by character field intercept method.
Preferably, also RAM value current for acquisition intelligent terminal and CPU value can be depicted as curve, respectively to observe intuitively.
It should be noted that, above-mentioned RAM value and CPU value can be RAM utilization rate parameter and CPU usage parameter.
Preferably, the present invention uses the ChartPanel of JAVA to carry out mapping operation, RAM and the CPU value of acquisition is plotted curve map, and shows, as shown in Figures 2 and 3.
Step S3, the RAM value of acquisition and CPU value to be sorted.
In order to the service condition allowing user clearly can see current RAM and CPU, particularly take the proportion of RAM and CPU.In investigation device memory leakage process, the sequence taking RAM and CPU be relied on to check the layout structure of application, thus infer the reason causing RAM leakage.
Particularly, obtaining according in descending order all RAM values and CPU value being sorted while acquisition RAM and CPU, facilitating user to check the ruuning situation of intelligent terminal.Wherein, sorted by order adb shell top-s rss.
Step S4, open on intelligent terminal all APP successively after close again, RAM value and CPU value are monitored.
In actual use, any one mode following is usually adopted to realize the test of intelligent terminal internal memory:
(1) the semi-automatic method of operation
The various operations of user are coordinated to carry out intelligent terminal RAM and CPU curve monitoring.
(2) fully automatic operation mode
Each APP in intelligent terminal can be called by iterative cycles, then check the operation whether performing RAM release, without the need to manpower intervention.
Preferably, adopt fully automatic operation mode to carry out the test of intelligent terminal internal memory in the present invention.Wherein, use Android technology to write the application of an all APP program of integration testing mobile phone, and all APP are sorted.Order Intent.ACTION_MAIN and Intent.CATEGORY_LAUNCHER in android system is respectively used to obtain intelligent terminal APP and open.Function Drawable getFullResIcon (ActivityInfo info) is for obtaining the icon display of each APP of intelligent terminal, and line number of going forward side by side rowization sort.Adopt uiatuomator technology, obtain the quantity of APP.
In the present invention, APP number of run can also be set.User can carry out corresponding number of times setting according to demand.
Step S5, when there is unusual condition, open LOG capture function, automatically record test mode.
Wherein, occur to intelligent terminal unusual condition that RAM leakage is relevant comprise crash, restart, interface is abnormal etc.
When user selects automatically to run APP, will run each the APP program on intelligent terminal one by one, RAM value and CPU value are in observation process.If internal memory is release not, then RAM value and/or CPU value curve straight line can be caused to rise; If curve tends towards stability, illustrate that intelligent terminal is in normal condition.If when RAM value or CPU value are greater than 80%, represent that intelligent terminal runs at high load conditions, will prompting be sent, and open LOG crawl function, automatically record test mode.
For connecting mobile phone and automatically running, the time JAVA used, bat and UIAUTOMATOR technology, first the content needing in bat to write is write in BAT by FileOutputStream and the output.write method of JAVA, again by String [] cmd=new String [] { " cmd.exe ", "/C ", " XXX.bat " }; Method runs bat file, and wherein XXX represents the title of bat file.What run in Bat file is write APP operation bag by UIAUTOMATOR technology.As call method.
Particularly, when realizing the automated testing method of the intelligent terminal RAM leakage based on android system of the present invention, in the program on intelligent terminal, be log-on message in config file, for the principal function content started; Image file is the icon depositing this instrument; The JAVA environment starting this program deposited by jre7 file; The JAR bag spanned file using JAVA required for this instrument deposited by Lib file; During Applist.apk file, the APP bag of Auto-mounting, integrates APP all in mobile phone in a list, is convenient to call; AppListTest.jar is the jar bag that JAVA program is packaged into; AppListTestG.jar is UIATUOMATOR file, is used to the program operating APP.
NumberSetting.bat clicks the file determining rear automatic generation, for receiving the execution number of times of user's input, and the operation steps of install programs automatically and working procedure Uninstaller, its content is as follows:
@echo off
set a=3
adb install-r D:\CPU_and_RAM_V1.1\applist.apk
adb shell sleep 1
for/l%%i in(11%a%)do(
adb wait-for-device
call D:\CPU_and_RAM_V1.1\Running.bat
)
adb uninstall com.feixun.applist
In Running.bat file, by the sub-execute file that this file of NumberSetting.bat calls, be the operation part of core, the AppListTestG.jar file that UIATUOMATOR generates is called in the effect of this bat file, and its particular content is as follows:
@echo off
adb push AppListTestG.jar/data/local/tmp/
adb shell uiautomator runtest AppListTestG.jar-c
com.feixun.AppListTest.AppListTest
Therefore, the present invention to grow up for intelligence in conjunction with Android and BAT and uiautomator technology and automatically monitors by completing JAVA and perform, preferably test result can be obtained, thus reduce human input and also fully excavate RAM leakage fault, improve efficiency.
Automated testing method of the present invention not only may be used for internal memory and the CPU monitoring of Android phone, can monitor the product of Android PAD series simultaneously.Various combination mode wherein for order also can in the light of actual conditions be changed.Automatic sequence is run to the mode of APP, also can carry out the change of certain rule, such as can carry out priority and run, and APP separate run times length can be set according to the title of APP, type, size.
Particularly, when the title automatic sequence according to APP runs APP, the sequencing of the title of APP according to initial can be sorted, if initial is identical, then sort according to second letter, the like.When after the sequence of APP title, then automatically perform successively according to order from front to back or from back to front.
When the type automatic sequence according to APP runs APP, APP can be sorted according to its type, come together by the APP of identical type, the APP of identical type sorts according to certain rule again.After APP has sorted, then automatically perform successively according to order from front to back or from back to front.
When the size automatic sequence according to APP runs APP, APP can be sorted successively according to its size.After APP has sorted, then automatically perform successively according to order from big to small or from small to large.
In sum, the automated testing method of the intelligent terminal RAM leakage based on android system of the present invention is applicable to any Android phone or Android device; Automatically APP all in intelligent terminal can be run successively, strong operability when there is no manpower; Observe intelligent terminal ruuning situation by RAM and CPU curve and the process of meeting automatic record operation curve, thus effectively detect the problem that the internal memory in intelligent terminal runs.So the present invention effectively overcomes various shortcoming of the prior art and tool high industrial utilization.
Above-described embodiment is illustrative principle of the present invention and effect thereof only, but not for limiting the present invention.Any person skilled in the art scholar all without prejudice under spirit of the present invention and category, can modify above-described embodiment or changes.Therefore, such as have in art usually know the knowledgeable do not depart from complete under disclosed spirit and technological thought all equivalence modify or change, must be contained by claim of the present invention.