and waiting for idle
First, and waiting for the relevant knowledge of idle:
1) Image zoom: Sample reduced from 100 to 50 pixels
2) Picture quality: Refers to the image size, the higher the quality of the picture, the lower the quality of the picture smaller
3) File class: Refers to a file or a folder
4) Image format: PNG format used in images
5) Idle state: The window is not updated is no action, the interface is in a fixed state
6) Window Update event: The window open process is an update event, open after the move is idle state
Second, the relevant API:
| return value |
Method name |
Describe |
| Boolean |
Takescreenshot (File Storepath) |
Put the current window and save it as PNG default 1.0f specification (original size) and 90% quality, parameter is file path of the files class |
| Boolen |
Takescreenshot (File Storepath, float scale, int quality) |
The current window is a PNG-formatted picture, and you can customize the scale and quality |
Parameter description:
Storepath: The storage path must be in PNG format
Scale: Zoom, 1.0 for original
Quality: Image compression quality with a range of 0-100
Third, API application examples:
Packagecom.uiautomatortest;ImportJava.io.File;ImportAndroid.graphics.Point;ImportAndroid.os.Bundle;Importandroid.os.RemoteException;Importandroid.view.KeyEvent;ImportCom.android.uiautomator.core.UiDevice;Importcom.android.uiautomator.testrunner.UiAutomatorTestCase; Public classTestextendsUiautomatortestcase { Public voidTestscreen () {uidevice.getinstance (). Presshome (); Sleep (1000); Uidevice.getinstance (). Pressmenu (); Sleep (2000); Uidevice.getinstance (). Takescreenshot (NewFile ("/sdcard/screen.png")); }}Test.java
Iv. waiting for idle related APIs:
| return value |
Method name |
Describe |
| void |
Waitforidle (Long Timeout) |
Custom timeout waiting for the current app to be idle |
| void |
Waitforidle () |
Waits for the current app to be idle, waiting for 10s by default |
| Boolean |
Waitforwindowupdate (String PackageName, long timeout) |
Wait for the window content update event to occur |
Five, waiting for the idle API
Packagecom.uiautomatortest;ImportJava.io.File;ImportAndroid.graphics.Point;ImportAndroid.os.Bundle;Importandroid.os.RemoteException;Importandroid.view.KeyEvent;ImportCom.android.uiautomator.core.UiDevice;Importcom.android.uiautomator.testrunner.UiAutomatorTestCase; Public classTestextendsUiautomatortestcase { Public voidtestwait () {//[256,577][320,640] intx, y; X= (320-256)/2+256; Y= (640-577)/2+577; Uidevice.getinstance (). Presshome (); Uidevice.getinstance (). Waitforidle (3000); Uidevice.getinstance (). Click (x, y); String PackageName= "Com.android.browser"; Uidevice.getinstance (). Waitforwindowupdate (PackageName,20000); }}Test.java
Android Wireless test-uiautomator Uidevice API Introduction Seven