Android espresso testing lock and unlock screen
Asked Answered
D

1

6

I am trying to write an automated test to an android application that appears when you unlock your screen using the espresso framework. I would like to add a test case to ensure that an activity appears when the screen is unlocked.

How can I programmatically lock or unlock the screen using espresso?

Derrik answered 1/9, 2015 at 16:33 Comment(0)
D
6

I found that UiDevice has the desired methods. My final code:

UiDevice uiDevice = UiDevice.getInstance(getInstrumentation());
    try {
        uiDevice.sleep();
        Thread.sleep(1000);
        uiDevice.wakeUp();
        Thread.sleep(1000);
    } catch (RemoteException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
Derrik answered 4/9, 2015 at 12:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.