Bug 1068489 - Robocop: Provide error message where device screen may be sleeping, r=nalexander

This commit is contained in:
Mark Capella 2014-09-30 18:52:48 -04:00
parent d1632dc85c
commit 7da2dcd236
3 changed files with 17 additions and 0 deletions

View File

@ -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.", "");
}
}

View File

@ -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() {

View File

@ -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