mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-27 19:09:47 +00:00
Bug 1068489 - Robocop: Provide error message where device screen may be sleeping, r=nalexander
This commit is contained in:
parent
062a92d254
commit
cbb6f45a31
@ -15,6 +15,8 @@ import org.mozilla.gecko.FennecTalosAssert;
|
||||
import org.mozilla.gecko.AppConstants;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.os.PowerManager;
|
||||
import android.test.ActivityInstrumentationTestCase2;
|
||||
import android.util.Log;
|
||||
|
||||
@ -107,4 +109,13 @@ public abstract class BaseRobocopTest extends ActivityInstrumentationTestCase2<A
|
||||
mAsserter.setLogFile(mLogFile);
|
||||
mAsserter.setTestName(getClass().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that the screen on the test device is powered on during tests.
|
||||
*/
|
||||
public void throwIfScreenNotOn() {
|
||||
final PowerManager pm = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE);
|
||||
mAsserter.ok(pm.isScreenOn(),
|
||||
"Robocop tests need the test device screen to be powered on.", "");
|
||||
}
|
||||
}
|
||||
|
@ -121,6 +121,9 @@ abstract class BaseTest extends BaseRobocopTest {
|
||||
mActions = new FennecNativeActions(mActivity, mSolo, getInstrumentation(), mAsserter);
|
||||
mDevice = new Device();
|
||||
mDatabaseHelper = new DatabaseHelper(mActivity, mAsserter);
|
||||
|
||||
// Ensure Robocop tests are run with Display powered on.
|
||||
throwIfScreenNotOn();
|
||||
}
|
||||
|
||||
protected void initializeProfile() {
|
||||
|
@ -74,6 +74,9 @@ abstract class UITest extends BaseRobocopTest
|
||||
// Helpers depend on components so initialize them first.
|
||||
initComponents();
|
||||
initHelpers();
|
||||
|
||||
// Ensure Robocop tests are run with Display powered on.
|
||||
throwIfScreenNotOn();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user