forked from upstream-mirrors/OpenTracks
Run unlockAndWakeupDevice() on Ui thread.
This commit is contained in:
+12
-6
@@ -136,15 +136,21 @@ public class BigTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlocks the device screen.
|
* Unlocks and wake up the device.
|
||||||
*/
|
*/
|
||||||
public static void unlockDevice() {
|
public static void unlockAndWakeupDevice() {
|
||||||
// The menu item of setting should be found if the screen is not locked.
|
// The menu item of setting should be found if the screen is not locked.
|
||||||
try {
|
try {
|
||||||
Window wind = EndToEndTestUtils.SOLO.getCurrentActivity().getWindow();
|
EndToEndTestUtils.SOLO.getCurrentActivity().runOnUiThread(new Runnable() {
|
||||||
wind.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
|
@Override
|
||||||
wind.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
public void run() {
|
||||||
wind.addFlags(LayoutParams.FLAG_TURN_SCREEN_ON);
|
Window wind = EndToEndTestUtils.SOLO.getCurrentActivity().getWindow();
|
||||||
|
wind.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
|
||||||
|
wind.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
|
||||||
|
wind.addFlags(LayoutParams.FLAG_TURN_SCREEN_ON);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.i(EndToEndTestUtils.LOG_TAG,
|
Log.i(EndToEndTestUtils.LOG_TAG,
|
||||||
"Meet error when unlock device screen, may the device is not locked.");
|
"Meet error when unlock device screen, may the device is not locked.");
|
||||||
|
|||||||
+2
-2
@@ -63,7 +63,7 @@ public class ResourceUsageTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
context = trackListActivity.getApplicationContext();
|
context = trackListActivity.getApplicationContext();
|
||||||
instrumentation.waitForIdleSync();
|
instrumentation.waitForIdleSync();
|
||||||
EndToEndTestUtils.setupForDebug(instrumentation, trackListActivity);
|
EndToEndTestUtils.setupForDebug(instrumentation, trackListActivity);
|
||||||
BigTestUtils.unlockDevice();
|
BigTestUtils.unlockAndWakeupDevice();
|
||||||
if (!isUserConfirmed) {
|
if (!isUserConfirmed) {
|
||||||
confirmTest();
|
confirmTest();
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ public class ResourceUsageTest extends ActivityInstrumentationTestCase2<TrackLis
|
|||||||
EndToEndTestUtils.SOLO.clickOnText(trackListActivity.getString(tabNameId));
|
EndToEndTestUtils.SOLO.clickOnText(trackListActivity.getString(tabNameId));
|
||||||
}
|
}
|
||||||
BigTestUtils.moniterTest(context, INTERVALE_TO_CHECK, TEST_DURATION_IN_MILLISECONDS);
|
BigTestUtils.moniterTest(context, INTERVALE_TO_CHECK, TEST_DURATION_IN_MILLISECONDS);
|
||||||
BigTestUtils.unlockDevice();
|
BigTestUtils.unlockAndWakeupDevice();
|
||||||
EndToEndTestUtils.stopRecording(true);
|
EndToEndTestUtils.stopRecording(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user