The content of the invention
In view of the above the shortcomings that prior art, it is an object of the invention to provide a kind of based on android system
The automated testing method of intelligent terminal RAM leakage, it is whole come monitoring intelligent by obtaining the parameter of RAM and CPU in intelligent terminal
The internal memory running situation at end, to judge whether internal memory is revealed, and it can be consumed at most during the operation of real-time display intelligent terminal
RAM program and the program of consumption most multi -CPU.
In order to achieve the above objects and other related objects, the present invention provides a kind of intelligent terminal based on android system
The automated testing method of RAM leakage, comprises the following steps:Step S1, intelligent terminal is set to be active;Step S2,
Obtain intelligent terminal current RAM values and CPU values;Step S3, the RAM values of acquisition and CPU values are ranked up;Step S4, according to
Turned off after all APP on secondary opening intelligent terminal, RAM values and CPU values are monitored;Step S5, when the abnormal shape of appearance
During condition, LOG crawl functions are opened, record test mode automatically.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein:It is described
Comprise the following steps in step S1:
1) Root authority of intelligent terminal is opened, obtains the parameter of intelligent terminal;
2) intelligent terminal is set to be in the state of activation for screen not screen protection of not going out.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein:It is described
In step S2, the RAM values of intelligent terminal and CPU values are obtained with JAVA technologies.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein:It is described
RAM values and CPU values are respectively RAM utilization rates parameter and CPU usage parameter.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein:It is described
During step S4, each APP in intelligent terminal is called using fully automatic operation mode iterative cycles, then checks whether to perform RAM
The operation of release.
Further, according to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system,
Wherein:During automatic running APP, APP can be set and reruned number and separate run times.
Further, according to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system,
Wherein:During automatic running APP, successively run according to APP title, type or size.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein:It is described
In step S5, the unusual condition includes intelligent terminal and crashes, restarts and interface exception.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein:It is described
In step S5, when the RAM values or CPU values of intelligent terminal are more than 80%, then LOG crawl functions, automatic record test shape are opened
State.
According to the automated testing method of the above-mentioned intelligent terminal RAM leakage based on android system, wherein:It is described
In step S3, additionally it is possible to which real-time display intelligent terminal consumes most RAM program and the program of consumption most multi -CPU when running.
As described above, the automated testing method of the intelligent terminal RAM leakage based on android system of the present invention, tool
There is following beneficial effect:
(1) it is applied to any Android phone or Android device;
(2) automatic in the case of no manpower APP all in intelligent terminal, strong operability can be run successively;
(3) observe intelligent terminal running situation by RAM and CPU curves and the process of operation curve can be recorded automatically,
The problem of so as to effectively detect the operation of the internal memory in intelligent terminal.
Embodiment
Illustrate embodiments of the present invention below by way of specific instantiation, those skilled in the art can be by this specification
Disclosed content understands other advantages and effect of the present invention easily.The present invention can also pass through specific realities different in addition
The mode of applying is embodied or practiced, the various details in this specification can also be based on different viewpoints with application, without departing from
Various modifications or alterations are carried out under the spirit of the present invention.
It should be noted that the diagram provided in the present embodiment only illustrates the basic conception of the present invention in a schematic way,
Then the component relevant with the present invention is only shown in schema rather than is painted according to component count, shape and the size during actual implement
System, kenel, quantity and the ratio of each component can be a kind of random change during its actual implementation, and its assembly layout kenel also may be used
Can be increasingly complex.
It should be noted that intelligent terminal involved in the present invention include being not limited to smart mobile phone, tablet personal computer,
PDA, and other have the terminal device of data processing function.Generally, intelligent terminal refers to there is independent operating system, can
Voluntarily to install the program of the third party service providers such as software, game offer by user, constantly set by this class method to hand-held
Standby function is expanded, and such terminal equipment 1 of wireless network access can be realized by mobile communication network.
Reference picture 1, the automated testing method of the intelligent terminal RAM leakage of the invention based on android system include
Following steps:
Step S1, intelligent terminal is set to be active.
Specifically, the Root authority of intelligent terminal is first turned on, to obtain the parameter of intelligent terminal;Secondly, intelligence is set
Terminal is in the state of activation for screen not screen protection of not going out, and is easy to automated execution to test.
In the present invention by using embedded software and external software, using the JAVA instruments of carrying computer end to intelligent end
End carries out data wire connection and monitoring, and the built-in application APP in intelligent terminal, and APP is carried out using APP directional operations program
Directional operation.Due to using application interfaces of the APP as intelligent terminal, therefore the compatibility and applicability of the present invention are stronger.
Step S2, intelligent terminal current RAM values and CPU values are obtained.
CPU is intelligent terminal operation and standby important devices.Therefore, the various states of intelligent terminal have directly with CPU
Connect the relation with brief introduction.The value for obtaining CPU is in RAM leakage, confirm whether CPU value changes are to cause internal memory to be let out
Reveal or cause the condition and factor of RAM leakage.
The reason for RAM leakage for causing intelligent terminal is diversified.Most it is exactly intuitively to look into RAM leakage
See RAM and CPU parameter value, and Parameters variation situation before.If single parameter value, it is difficult to find out the prominent of problem
Breakpoint, RAM and CPU data summarization can just only be found out into the time point position of problem generation, and further analyze and lead into curve
The reason for causing device memory leakage.
Specifically, when carrying out automatic test, key triggering starts APP and APP directional operation programs.Start internal memory simultaneously
Monitoring programme, test and record internal memory situation.
Specifically, the value of the RAM and CPU of JAVA technical limit spacing intelligent terminals currently can be used in the present invention.Wherein,
Order adb shell cat/proc/meminfo are used to obtain memory value;Order adb shell top-n 1-m 1 are used to obtain
Take CPU values.Current RAM values and CPU values can be obtained by character field intercept method.
Preferably, also the current RAM values of intelligent terminal can will be obtained and CPU values is depicted as curve respectively, so as to intuitively
Observed.
It should be noted that above-mentioned RAM values and CPU values can be RAM utilization rates parameter and CPU usage parameter.
Preferably, the present invention carries out mapping operation with JAVA ChartPanel, RAM the and CPU values of acquisition are plotted
Curve map, and show, as shown in Figures 2 and 3.
Step S3, the RAM values of acquisition and CPU values are ranked up.
In order to allow user to be clearly apparent current RAM and CPU service condition, RAM and CPU ratio is particularly taken
Weight.During investigation device memory leakage, sorting to check the layout structure of application for occupancy RAM and CPU is relied on, so as to
The reason for causing RAM leakage to infer.
Specifically, obtained while RAM and CPU is obtained according in descending order by all RAM values and the progress of CPU values
Sequence, facilitates user to check the running situation of intelligent terminal.Wherein, by ordering adb shell top-s rss to be arranged
Sequence.
Step S4, turned off after opening all APP on intelligent terminal successively, RAM values and CPU values are monitored.
In actual use, any one mode below generally use realizes 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
Can iterative cycles call intelligent terminal in each APP, then check whether perform RAM release operation, without
Manpower intervention.
Preferably, the test of intelligent terminal internal memory is carried out in the present invention using fully automatic operation mode.Wherein, use
Android technologies write the application of all APP programs of an integration testing mobile phone, and all APP are ranked up.Android
Order Intent.ACTION_MAIN and Intent.CATEGORY_LAUNCHER in system are respectively used to obtain intelligent terminal
APP is simultaneously opened.Function Drawable getFullResIcon (ActivityInfo info) are used to obtain each APP of intelligent terminal
Icon show, line number of going forward side by side rowization sequence.Using uiatuomator technologies, APP quantity is obtained.
In the present invention, APP number of run can also be set.User can carry out corresponding number setting according to demand.
Step S5, when there is unusual condition, LOG crawl functions is opened, record test mode automatically.
Wherein, occur the related unusual condition of RAM leakage to intelligent terminal and include crashing, restart, interface extremely etc..
When user select automatic running APP when, will one by one run intelligent terminal on each APP program, RAM values with
CPU values are in monitoring process.If internal memory does not discharge, RAM values and/or CPU value curves can be caused to ramp;If
Curve tends towards stability, and illustrates that intelligent terminal is in normal condition.If RAM values or CPU values are more than 80%, intelligent terminal fortune is represented
Row at high load conditions, will send prompting, and open LOG crawl functions, record test mode automatically.
For connection mobile phone and automatic running is carried out, the when JAVA used, bat and UIAUTOMATOR technologies, first will
The content for needing to write in bat is write in BAT by JAVA FileOutputStream and output.write methods, then is led to
Cross String [] cmd=new String [] { " cmd.exe ", "/C ", " XXX.bat " };Method runs bat files, wherein
XXX represents the title of bat files.What is run in Bat files is to write APP operation bags by UIAUTOMATOR technologies.As
Call method.
Specifically, in the automatic test side for the intelligent terminal RAM leakage based on android system for realizing the present invention
During method, for being log-on message in config files in the program on intelligent terminal, the principal function content for startup;Image
File is the icon for depositing the instrument;Jre7 files are the JAVA environments that storage starts the program;Lib files are to deposit the instrument
The required JAR bags generation file for using JAVA;The APP bags installed automatically during Applist.apk files, will be all in mobile phone
APP is integrated in a list, is easy to call;AppListTest.jar is the jar bags that JAVA programs are packaged into;
AppListTestG.jar is UIATUOMATOR files, is the program for operating APP.
NumberSetting.bat is click on the file automatically generated after determining, for receiving holding for user's input
Places number, and the operating procedure of automatic installation procedure and operation program Uninstaller, its content are 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 files, it is that the son called by NumberSetting.bat this documents performs file, is core
Operation operation part, the effects of the bat files is the AppListTestG.jar files for calling UIATUOMATOR to be generated,
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 is by completing JAVA combination Android and BAT and uiautomator technologies for intelligent length
It is big monitor and perform automatically, preferable test result can be obtained, so as to reduce human input and and fully excavate internal memory
Failure is revealed, improves efficiency.
The automated testing method of the present invention can be not only used for internal memory and the CPU monitorings of Android phone, while can be with
The product of Android PAD series is monitored.Wherein can also be in the light of actual conditions for the various combination mode of order
Changed.For automatic sequence operation APP mode, the change of certain rule can also be carried out, such as can be according to APP's
Title, type, size carry out priority operation, and can set APP separate run times length.
Specifically, when running APP according to APP title automatic sequence, priority that can be by APP title according to initial
Order is ranked up, if initial is identical, is ranked up according to second letter, the like.After APP titles sort,
Performed automatically successively according still further to order from front to back or from back to front.
When running APP according to APP type automatic sequence, APP can be ranked up according to its type, by same type
APP come together, the APP of same type is ranked up further according to certain rule.After the completion of APP sequences, according still further in the past
Performed automatically successively to order rear or from back to front.
When running APP according to APP size automatic sequence, APP can be sorted successively according to its size.Work as APP
After the completion of sequence, performed automatically successively according still further to order from big to small or from small to large.
In summary, the automated testing method of the intelligent terminal RAM leakage of the invention based on android system is fitted
For any Android phone or Android device;Automatic in the case of no manpower it can run successively in intelligent terminal
All APP, strong operability;Observe intelligent terminal running situation by RAM and CPU curves and operation curve can be recorded automatically
Process, so as to effectively detect in intelligent terminal internal memory operation the problem of.So the present invention effectively overcomes existing skill
Various shortcoming in art and have high industrial utilization.
The above-described embodiments merely illustrate the principles and effects of the present invention, not for the limitation present invention.It is any ripe
Know the personage of this technology all can carry out modifications and changes under the spirit and scope without prejudice to the present invention to above-described embodiment.Cause
This, those of ordinary skill in the art is complete without departing from disclosed spirit and institute under technological thought such as
Into all equivalent modifications or change, should by the present invention claim be covered.