Android Wireless test-uiautomator Uidevice API Introduction Six

Source: Internet
Author: User

First, screen and wake-up related knowledge:

1) Kill screen: Press the power button to turn off the screen

2) Wake-up screen: Press the Power key to wake up the screen while in the off-screen state

Second, the screen and screen-related API:

return value Method name Describe
void WakeUp () Analog Press the Power key if the screen is awake without any effect
void Sleep () Simulates pressing the Power key if the screen is turned off without any effect
Boolean Isscreenon () Check whether the screen is lit

Third, API application examples:

 Packagecom.uiautomatortest;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 voidTestsleepandwakeup ()throwsremoteexception{if(Uidevice.getinstance (). Isscreenon () = =true) {uidevice.getinstance (). Sleep (); Sleep (2000);            Uidevice.getinstance (). WakeUp (); Sleep (2000); //(159,515) (320,515)            intStartX, Starty, EndX, EndY, steps; StartX=159; Starty=515; EndX=320; EndY=515; Steps=100;        Uidevice.getinstance (). Drag (StartX, Starty, EndX, EndY, steps); }    }}
Test.java

Android Wireless test-uiautomator Uidevice API Introduction Six

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.