Reputation: 5393
I'm tryig to build a test farm, but I found one large hurdle with it. The Espresso tests can't run when the phone is asleep.
android.support.test.espresso.NoActivityResumedException: No activities in stage RESUMED. Did you forget to launch the activity. (test.getActivity() or similar)?
Yeah, I know I can set it to never sleep in Developer options, but I don't want do kill the phone's displays. I also tried enabling Daydream, but it has the same issue.
Any idea how to solve that?
Upvotes: 3
Views: 186
Reputation: 5393
Modify your Activity
's onCreate
method like this:
@Override
protected void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (BuildConfig.DEBUG) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
//
// Your code ...
//
}
You shouldn't need any permissions for that, and it happens only on DEBUG
builds.
Upvotes: 1