| 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 f81783012b81c81cff640f3af476f6384b94811d..16cdee6ad6311fe2e01551b705ec5a70ddc8194d 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
|
| @@ -8,6 +8,7 @@ import android.app.Activity;
|
| import android.content.ClipData;
|
| import android.content.ClipboardManager;
|
| import android.content.Context;
|
| +import android.content.res.Configuration;
|
| import android.test.suitebuilder.annotation.MediumTest;
|
| import android.test.suitebuilder.annotation.SmallTest;
|
| import android.text.Editable;
|
| @@ -248,6 +249,53 @@ public class ImeTest extends ContentShellTestBase {
|
| }));
|
| }
|
|
|
| + @SmallTest
|
| + @Feature({"TextInput"})
|
| + public void testAttachDetachPhysicalKeyboard() throws Exception {
|
| + final int showCount = mInputMethodManagerWrapper.getShowSoftInputCounter();
|
| + final int hideCount = mInputMethodManagerWrapper.getHideSoftInputCounter();
|
| +
|
| + // Attaching physical keyboard.
|
| + Configuration hardKeyboardConfig =
|
| + new Configuration(mContentViewCore.getContext().getResources().getConfiguration());
|
| + hardKeyboardConfig.keyboard = Configuration.KEYBOARD_QWERTY;
|
| + hardKeyboardConfig.keyboardHidden = Configuration.KEYBOARDHIDDEN_YES;
|
| + hardKeyboardConfig.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_NO;
|
| + onConfigurationChanged(hardKeyboardConfig);
|
| +
|
| + // Make sure that we try to hide soft keyboard. This is triggered by
|
| + // View#onConfigurationChanged().
|
| + assertTrue("Base hideCount: " + hideCount + ", actual hideCount: "
|
| + + mInputMethodManagerWrapper.getHideSoftInputCounter(),
|
| + CriteriaHelper.pollForCriteria(new Criteria() {
|
| + @Override
|
| + public boolean isSatisfied() {
|
| + return mInputMethodManagerWrapper.getHideSoftInputCounter()
|
| + == hideCount + 1;
|
| + }
|
| + }));
|
| +
|
| + // Detaching physical keyboard.
|
| + Configuration softKeyboardConfig =
|
| + new Configuration(mContentViewCore.getContext().getResources().getConfiguration());
|
| + softKeyboardConfig.keyboard = Configuration.KEYBOARD_NOKEYS;
|
| + softKeyboardConfig.keyboardHidden = Configuration.KEYBOARDHIDDEN_NO;
|
| + softKeyboardConfig.hardKeyboardHidden = Configuration.HARDKEYBOARDHIDDEN_YES;
|
| + onConfigurationChanged(softKeyboardConfig);
|
| +
|
| + // Make sure that we try to show soft keyboard. This is triggered by
|
| + // ContentViewCore#onConfigurationChanged().
|
| + assertTrue("Base showCount: " + showCount + ", actual showCount: "
|
| + + mInputMethodManagerWrapper.getShowSoftInputCounter(),
|
| + CriteriaHelper.pollForCriteria(new Criteria() {
|
| + @Override
|
| + public boolean isSatisfied() {
|
| + return mInputMethodManagerWrapper.getShowSoftInputCounter()
|
| + == showCount + 1;
|
| + }
|
| + }));
|
| + }
|
| +
|
| /*
|
| @SmallTest
|
| @Feature({"TextInput"})
|
| @@ -1224,6 +1272,15 @@ public class ImeTest extends ContentShellTestBase {
|
| waitAndVerifyStatesAndCalls(0, "", 0, 0, -1, -1);
|
| }
|
|
|
| + private void onConfigurationChanged(final Configuration config) {
|
| + ThreadUtils.postOnUiThread(new Runnable() {
|
| + @Override
|
| + public void run() {
|
| + mContentViewCore.onConfigurationChanged(config);
|
| + }
|
| + });
|
| + }
|
| +
|
| private static class TestAdapterInputConnectionFactory extends
|
| ImeAdapter.AdapterInputConnectionFactory {
|
| @Override
|
|
|