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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java

Issue 2440353002: Check whether screen is on when it fails to click node in ImeTest. (Closed)
Patch Set: Address changwan@'s review Created 4 years, 2 months 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java
index 8b309724c797639cfa6ff1c80a0ffc9a882b32af..44402ca53d71353a66fd6b069de815a7153f0fd5 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java
@@ -4,13 +4,16 @@
package org.chromium.content.browser.input;
+import android.annotation.TargetApi;
import android.app.Activity;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.res.Configuration;
+import android.os.Build;
import android.os.Handler;
import android.os.Looper;
+import android.os.PowerManager;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
import android.text.InputType;
@@ -97,6 +100,9 @@ public class ImeTest extends ContentShellTestBase {
mCallbackContainer = new TestCallbackHelperContainer(mContentViewCore);
DOMUtils.waitForNonZeroNodeBounds(mWebContents, "input_text");
boolean result = DOMUtils.clickNode(this, mContentViewCore, "input_text");
+
+ // TODO(yabinh): Sometimes |result| is false. We suspect it's because the screen is locked.
+ if (!result) assertScreenIsOn();
assertEquals("Failed to dispatch touch event.", true, result);
assertWaitForKeyboardStatus(true);
@@ -117,6 +123,19 @@ public class ImeTest extends ContentShellTestBase {
resetAllStates();
}
+ @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());
+ }
+ }
+
@MediumTest
@Feature({"TextInput", "Main"})
public void testKeyboardDismissedAfterClickingGo() throws Throwable {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698