Commit d57d3f34 authored by yabinh's avatar yabinh Committed by Commit bot

Check whether screen is on when it fails to click node in ImeTest.

Sometimes ImeTest failed because it failed to click node. We suspect it's
because the screen is locked. So we add assertion to check whether that's
the case.

BUG=628964

Review-Url: https://codereview.chromium.org/2440353002
Cr-Commit-Position: refs/heads/master@{#427023}
parent 6d767117
......@@ -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 {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment