Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2355)

Unified Diff: content/shell/android/javatests/src/org/chromium/content_shell_apk/ContentShellTestBase.java

Issue 2465053002: Asserting screen is on for all content shell tests (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698