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

Side by Side Diff: content/public/android/javatests/src/org/chromium/content/browser/input/RecreateInputConnectionTest.java

Issue 1278593004: Introduce ThreadedInputConnection behind a switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: removed ImeTest#testDoesNotHang_rendererCrashes which does not test anything Created 4 years, 9 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package org.chromium.content.browser.input;
6
7 import android.test.suitebuilder.annotation.SmallTest;
8 import android.view.inputmethod.EditorInfo;
9
10 import org.chromium.content.browser.ContentViewCore;
11 import org.chromium.content.browser.test.util.TestInputMethodManagerWrapper;
12 import org.chromium.content_shell_apk.ContentShellTestBase;
13 import org.chromium.ui.base.ime.TextInputType;
14
15 /**
16 * Tests that when InputConnection is recreated, the text is still retained.
17 */
18 public class RecreateInputConnectionTest extends ContentShellTestBase {
19 private ContentViewCore mContentViewCore;
20 private TestImeAdapter mImeAdapter;
21 private TestInputMethodManagerWrapper mInputMethodManagerWrapper;
22
23 private static class TestImeAdapter extends ImeAdapter {
24 public TestImeAdapter(
25 InputMethodManagerWrapper immw, ImeAdapterDelegate imeAdapterDel egate) {
26 super(immw, imeAdapterDelegate);
27 }
28 @Override
29 public boolean hasTextInputType() {
30 return true;
31 }
32 }
33
34 @Override
35 public void setUp() throws Exception {
36 super.setUp();
37 mContentViewCore = new ContentViewCore(getActivity());
38 mContentViewCore.createContentViewAndroidDelegate();
39 mContentViewCore.setContainerView(getActivity().getActiveShell().getCont entView());
40 mInputMethodManagerWrapper = new TestInputMethodManagerWrapper(mContentV iewCore);
41 mImeAdapter = new TestImeAdapter(mInputMethodManagerWrapper,
42 new TestImeAdapterDelegate(mContentViewCore.getContainerView())) ;
43 mImeAdapter.setInputMethodManagerWrapperForTest(
44 new TestInputMethodManagerWrapper(mContentViewCore));
45 mContentViewCore.setImeAdapterForTest(mImeAdapter);
46 }
47
48 /**
49 * When creating a new InputConnection (e.g. after switching software keyboa rd), make sure the
50 * text content in the Editable is not lost.
51 */
52 @SmallTest
53 @RerunWithUpdatedContainerView
54 public void testRecreateInputConnection() throws Exception {
55 EditorInfo info = new EditorInfo();
56
57 mImeAdapter.setInputTypeForTest(TextInputType.TEXT);
58 mContentViewCore.onCreateInputConnection(info);
59 AdapterInputConnection inputConnection = mImeAdapter.getInputConnectionF orTest();
60 inputConnection.updateState("Is this text restored?", 0, 0, 0, 0, true);
61
62 String text = mContentViewCore.getImeAdapterForTest().getEditable().toSt ring();
63 assertEquals("Check if the initial text is stored.", "Is this text resto red?", text);
64
65 // Create a new InputConnection.
66 EditorInfo info2 = new EditorInfo();
67 mContentViewCore.onCreateInputConnection(info2);
68
69 String newtext = mContentViewCore.getImeAdapterForTest().getEditable().t oString();
70 assertEquals("Check if the string is restored.", "Is this text restored? ", newtext);
71 }
72 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698