summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authoraurimas@google.com <aurimas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-25 23:25:17 +0000
committeraurimas@google.com <aurimas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-25 23:25:17 +0000
commitad41034b8ed6eea454e13f0ff95c578ddc214f63 (patch)
tree0a1fb859953994cc74d72a696e295298ac6d555c /content
parent1579bd72783cc161ee85050fb3fa3c032eb826cf (diff)
downloadchromium_src-ad41034b8ed6eea454e13f0ff95c578ddc214f63.zip
chromium_src-ad41034b8ed6eea454e13f0ff95c578ddc214f63.tar.gz
chromium_src-ad41034b8ed6eea454e13f0ff95c578ddc214f63.tar.bz2
Merge 178904
> Do not show IME of selection change. > > BUG=169616 > > > Review URL: https://chromiumcodereview.appspot.com/11877007 TBR=aurimas@chromium.org Review URL: https://codereview.chromium.org/12079007 git-svn-id: svn://svn.chromium.org/chrome/branches/1364/src@178937 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java8
-rw-r--r--content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java7
-rw-r--r--content/public/android/javatests/src/org/chromium/content/browser/ImeTest.java63
-rw-r--r--content/renderer/render_view_impl.cc2
4 files changed, 78 insertions, 2 deletions
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
index 2a73261..3ecaf5c 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java
@@ -342,10 +342,16 @@ public class ContentViewCore implements MotionEventDelegate {
};
}
- public ImeAdapter getImeAdapterForTest() {
+ @VisibleForTesting
+ protected ImeAdapter getImeAdapterForTest() {
return mImeAdapter;
}
+ @VisibleForTesting
+ protected ImeAdapter.AdapterInputConnection getInputConnectionForTest() {
+ return mInputConnection;
+ }
+
private ImeAdapter createImeAdapter(Context context) {
return new ImeAdapter(context, getSelectionHandleController(),
getInsertionHandleController(),
diff --git a/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java b/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java
index 808009d..d1e2ad0 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ImeAdapter.java
@@ -19,6 +19,8 @@ import android.view.inputmethod.ExtractedText;
import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputMethodManager;
+import com.google.common.annotations.VisibleForTesting;
+
import org.chromium.base.CalledByNative;
import org.chromium.base.JNINamespace;
@@ -136,6 +138,9 @@ class ImeAdapter {
private DelayedDismissInput mDismissInput = null;
+ @VisibleForTesting
+ protected boolean mIsShowWithoutHideOutstanding = false;
+
// Delay introduced to avoid hiding the keyboard if new show requests are received.
// The time required by the unfocus-focus events triggered by tab has been measured in soju:
// Mean: 18.633 ms, Standard deviation: 7.9837 ms.
@@ -251,6 +256,7 @@ class ImeAdapter {
private void showKeyboard() {
mInputDialogContainer.dismissDialog();
+ mIsShowWithoutHideOutstanding = true;
InputMethodManager manager = (InputMethodManager)
mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
manager.showSoftInput(mViewEmbedder.getAttachedView(), 0,
@@ -263,6 +269,7 @@ class ImeAdapter {
}
private void hideKeyboard(boolean unzoomIfNeeded) {
+ mIsShowWithoutHideOutstanding = false;
InputMethodManager manager = (InputMethodManager)
mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
View view = mViewEmbedder.getAttachedView();
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ImeTest.java b/content/public/android/javatests/src/org/chromium/content/browser/ImeTest.java
new file mode 100644
index 0000000..2b0cf27
--- /dev/null
+++ b/content/public/android/javatests/src/org/chromium/content/browser/ImeTest.java
@@ -0,0 +1,63 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.content.browser;
+
+import android.test.suitebuilder.annotation.MediumTest;
+import android.view.inputmethod.EditorInfo;
+
+import org.chromium.base.test.util.Feature;
+import org.chromium.content.browser.test.util.Criteria;
+import org.chromium.content.browser.test.util.CriteriaHelper;
+import org.chromium.content.browser.test.util.DOMUtils;
+import org.chromium.content.browser.test.util.TestCallbackHelperContainer;
+import org.chromium.content.browser.test.util.UiUtils;
+import org.chromium.content_shell.ContentShellTestBase;
+
+public class ImeTest extends ContentShellTestBase {
+
+ private static final String DATA_URL =
+ "data:text/html;utf-8,<html><body>" +
+ "<input id=\"input_text\" type=\"text\" />" +
+ "</body></html>";
+
+ @MediumTest
+ @Feature({"TextInput", "Main"})
+ public void testKeyboardDismissedAfterClickingGo() throws Throwable {
+ launchContentShellWithUrl(DATA_URL);
+ assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading());
+
+ final ContentView view = getActivity().getActiveContentView();
+ final TestCallbackHelperContainer viewClient =
+ new TestCallbackHelperContainer(view);
+ DOMUtils.clickNode(this, view, viewClient, "input_text");
+ assertWaitForKeyboardStatus(true);
+
+ getAdapterInputConnection().setComposingText("hello", 5);
+ getAdapterInputConnection().performEditorAction(EditorInfo.IME_ACTION_GO);
+
+ // Since hiding the keyboard is an asynchronous task, it might take an arbitrary amount
+ // of time. settleDownUI will wait for one second and hopefully allowing the keyboard to
+ // get to it's final state.
+ UiUtils.settleDownUI(getInstrumentation());
+ assertWaitForKeyboardStatus(false);
+ }
+
+ private void assertWaitForKeyboardStatus(final boolean show) throws Throwable {
+ assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ return show == getImeAdapter().mIsShowWithoutHideOutstanding;
+ }
+ }));
+ }
+
+ private ImeAdapter getImeAdapter() {
+ return getContentViewCore().getImeAdapterForTest();
+ }
+
+ private ImeAdapter.AdapterInputConnection getAdapterInputConnection() {
+ return getContentViewCore().getInputConnectionForTest();
+ }
+}
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 0438d75..3715f70 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -4671,7 +4671,7 @@ void RenderViewImpl::SyncSelectionIfRequired() {
selection_text_offset_ = offset;
selection_range_ = range;
Send(new ViewHostMsg_SelectionChanged(routing_id_, text, offset, range));
- UpdateTextInputState(SHOW_IME_IF_NEEDED);
+ UpdateTextInputState(DO_NOT_SHOW_IME);
}
}