| Index: content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java
|
| diff --git a/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java b/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java
|
| index 7962ff713adfd819ff93a8b31b245facfa58e9b6..695da615dda3172e9c7fe42a7d5f43eaa3e43953 100644
|
| --- a/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java
|
| +++ b/content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java
|
| @@ -6,9 +6,13 @@ package org.chromium.content_shell_apk;
|
|
|
| import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
|
|
|
| +import android.annotation.TargetApi;
|
| import android.content.ComponentName;
|
| +import android.content.Context;
|
| import android.content.Intent;
|
| import android.net.Uri;
|
| +import android.os.Build;
|
| +import android.os.PowerManager;
|
| import android.text.TextUtils;
|
| import android.view.ViewGroup;
|
|
|
| @@ -52,6 +56,24 @@ public class ContentShellTestBase
|
| super(ContentShellActivity.class);
|
| }
|
|
|
| + @Override
|
| + protected void setUp() throws Exception {
|
| + assertScreenIsOn();
|
| + }
|
| +
|
| + @TargetApi(Build.VERSION_CODES.KITKAT_WATCH)
|
| + @SuppressWarnings("deprecation")
|
| + private void assertScreenIsOn() {
|
| + PowerManager pm = (PowerManager) getInstrumentation().getContext().getSystemService(
|
| + Context.POWER_SERVICE);
|
| +
|
| + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
|
| + assertTrue("Many tests will fail if the screen is not on.", pm.isInteractive());
|
| + } else {
|
| + assertTrue("Many tests will fail if the screen is not on.", pm.isScreenOn());
|
| + }
|
| + }
|
| +
|
| /**
|
| * Starts the ContentShell activity and loads the given URL.
|
| * The URL can be null, in which case will default to ContentShellActivity.DEFAULT_SHELL_URL.
|
|
|