Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / public / android / javatests / src / org / chromium / content / browser / input / ImeTest.java
index c00b83b..bd9d98d 100644 (file)
@@ -19,7 +19,7 @@ import android.view.inputmethod.EditorInfo;
 import org.chromium.base.ThreadUtils;
 import org.chromium.base.test.util.Feature;
 import org.chromium.base.test.util.UrlUtils;
-import org.chromium.content.browser.ContentView;
+import org.chromium.content.browser.ContentViewCore;
 import org.chromium.content.browser.test.util.Criteria;
 import org.chromium.content.browser.test.util.CriteriaHelper;
 import org.chromium.content.browser.test.util.DOMUtils;
@@ -46,7 +46,8 @@ public class ImeTest extends ContentShellTestBase {
 
     private TestAdapterInputConnection mConnection;
     private ImeAdapter mImeAdapter;
-    private ContentView mContentView;
+
+    private ContentViewCore mContentViewCore;
     private TestCallbackHelperContainer mCallbackContainer;
     private TestInputMethodManagerWrapper mInputMethodManagerWrapper;
 
@@ -56,20 +57,20 @@ public class ImeTest extends ContentShellTestBase {
 
         launchContentShellWithUrl(DATA_URL);
         assertTrue("Page failed to load", waitForActiveShellToBeDoneLoading());
+        mContentViewCore = getContentViewCore();
 
-        mInputMethodManagerWrapper = new TestInputMethodManagerWrapper(getContentViewCore());
+        mInputMethodManagerWrapper = new TestInputMethodManagerWrapper(mContentViewCore);
         getImeAdapter().setInputMethodManagerWrapper(mInputMethodManagerWrapper);
         assertEquals(0, mInputMethodManagerWrapper.getShowSoftInputCounter());
-        getContentViewCore().setAdapterInputConnectionFactory(
+        mContentViewCore.setAdapterInputConnectionFactory(
                 new TestAdapterInputConnectionFactory());
 
-        mContentView = getActivity().getActiveContentView();
-        mCallbackContainer = new TestCallbackHelperContainer(mContentView);
+        mCallbackContainer = new TestCallbackHelperContainer(mContentViewCore);
         // TODO(aurimas) remove this wait once crbug.com/179511 is fixed.
         assertWaitForPageScaleFactorMatch(2);
-        assertTrue(
-                DOMUtils.waitForNonZeroNodeBounds(mContentView, mCallbackContainer, "input_text"));
-        DOMUtils.clickNode(this, mContentView, mCallbackContainer, "input_text");
+        assertTrue(DOMUtils.waitForNonZeroNodeBounds(
+                mContentViewCore, "input_text"));
+        DOMUtils.clickNode(this, mContentViewCore, "input_text");
         assertWaitForKeyboardStatus(true);
 
         mConnection = (TestAdapterInputConnection) getAdapterInputConnection();
@@ -132,10 +133,10 @@ public class ImeTest extends ContentShellTestBase {
         commitText(mConnection, "hello", 1);
         waitAndVerifyEditableCallback(mConnection.mImeUpdateQueue, 1, "hello", 5, 5, -1, -1);
 
-        DOMUtils.clickNode(this, mContentView, mCallbackContainer, "input_radio");
+        DOMUtils.clickNode(this, mContentViewCore, "input_radio");
         assertWaitForKeyboardStatus(false);
 
-        DOMUtils.clickNode(this, mContentView, mCallbackContainer, "input_text");
+        DOMUtils.clickNode(this, mContentViewCore, "input_text");
         assertWaitForKeyboardStatus(true);
         assertEquals(5, mInputMethodManagerWrapper.getEditorInfo().initialSelStart);
         assertEquals(5, mInputMethodManagerWrapper.getEditorInfo().initialSelEnd);
@@ -203,13 +204,13 @@ public class ImeTest extends ContentShellTestBase {
     @SmallTest
     @Feature({"TextInput", "Main"})
     public void testShowImeIfNeeded() throws Throwable {
-        DOMUtils.focusNode(this, mContentView, mCallbackContainer, "input_radio");
+        DOMUtils.focusNode(mContentViewCore, "input_radio");
         assertWaitForKeyboardStatus(false);
 
         performShowImeIfNeeded();
         assertWaitForKeyboardStatus(false);
 
-        DOMUtils.focusNode(this, mContentView, mCallbackContainer, "input_text");
+        DOMUtils.focusNode(mContentViewCore, "input_text");
         assertWaitForKeyboardStatus(false);
 
         performShowImeIfNeeded();
@@ -220,9 +221,9 @@ public class ImeTest extends ContentShellTestBase {
     @Feature({"TextInput", "Main"})
     public void testFinishComposingText() throws Throwable {
         // Focus the textarea. We need to do the following steps because we are focusing using JS.
-        DOMUtils.focusNode(this, mContentView, mCallbackContainer, "input_radio");
+        DOMUtils.focusNode(mContentViewCore, "input_radio");
         assertWaitForKeyboardStatus(false);
-        DOMUtils.focusNode(this, mContentView, mCallbackContainer, "textarea");
+        DOMUtils.focusNode(mContentViewCore, "textarea");
         assertWaitForKeyboardStatus(false);
         performShowImeIfNeeded();
         assertWaitForKeyboardStatus(true);
@@ -253,9 +254,9 @@ public class ImeTest extends ContentShellTestBase {
     @Feature({"TextInput", "Main"})
     public void testEnterKeyEventWhileComposingText() throws Throwable {
         // Focus the textarea. We need to do the following steps because we are focusing using JS.
-        DOMUtils.focusNode(this, mContentView, mCallbackContainer, "input_radio");
+        DOMUtils.focusNode(mContentViewCore, "input_radio");
         assertWaitForKeyboardStatus(false);
-        DOMUtils.focusNode(this, mContentView, mCallbackContainer, "textarea");
+        DOMUtils.focusNode(mContentViewCore, "textarea");
         assertWaitForKeyboardStatus(false);
         performShowImeIfNeeded();
         assertWaitForKeyboardStatus(true);
@@ -286,7 +287,7 @@ public class ImeTest extends ContentShellTestBase {
         ThreadUtils.runOnUiThreadBlocking(new Runnable() {
             @Override
             public void run() {
-                mContentView.getContentViewCore().showImeIfNeeded();
+                mContentViewCore.showImeIfNeeded();
             }
         });
     }
@@ -347,11 +348,11 @@ public class ImeTest extends ContentShellTestBase {
     }
 
     private ImeAdapter getImeAdapter() {
-        return getContentViewCore().getImeAdapterForTest();
+        return mContentViewCore.getImeAdapterForTest();
     }
 
     private AdapterInputConnection getAdapterInputConnection() {
-        return getContentViewCore().getInputConnectionForTest();
+        return mContentViewCore.getInputConnectionForTest();
     }
 
     private void copy(final ImeAdapter adapter) {