Android Wireless test-uiautomator Uidevice API Introduction Seven

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.