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

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

Issue 1278593004: Introduce ThreadedInputConnection behind a switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed release test failures Created 4 years, 11 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.content.browser.input; 5 package org.chromium.content.browser.input;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 import android.os.IBinder; 8 import android.os.IBinder;
9 import android.os.ResultReceiver; 9 import android.os.ResultReceiver;
10 import android.test.suitebuilder.annotation.MediumTest; 10 import android.test.suitebuilder.annotation.MediumTest;
11 import android.test.suitebuilder.annotation.SmallTest; 11 import android.test.suitebuilder.annotation.SmallTest;
12 import android.text.Editable;
12 import android.view.View; 13 import android.view.View;
13 import android.view.inputmethod.EditorInfo; 14 import android.view.inputmethod.EditorInfo;
14 15
15 import org.chromium.base.test.util.Feature; 16 import org.chromium.base.test.util.Feature;
16 import org.chromium.content.browser.input.AdapterInputConnection.ImeState; 17 import org.chromium.content.browser.input.AdapterInputConnection.ImeState;
17 import org.chromium.content_shell_apk.ContentShellTestBase; 18 import org.chromium.content_shell_apk.ContentShellTestBase;
19 import org.chromium.ui.base.ime.TextInputType;
18 20
19 import java.util.ArrayList; 21 import java.util.ArrayList;
20 22
21 /** 23 /**
22 * Tests AdapterInputConnection class and its callbacks to ImeAdapter. 24 * Tests AdapterInputConnection class and its callbacks to ImeAdapter.
23 */ 25 */
24 public class AdapterInputConnectionTest extends ContentShellTestBase { 26 public class AdapterInputConnectionTest extends ContentShellTestBase {
25 27
26 private AdapterInputConnection mConnection; 28 private AdapterInputConnection mConnection;
27 private TestInputMethodManagerWrapper mWrapper; 29 private TestInputMethodManagerWrapper mWrapper;
28 private TestImeAdapter mImeAdapter; 30 private TestImeAdapter mImeAdapter;
29 31
30 @Override 32 @Override
31 public void setUp() throws Exception { 33 public void setUp() throws Exception {
32 super.setUp(); 34 super.setUp();
33 launchContentShellWithUrl("about:blank"); 35 launchContentShellWithUrl("about:blank");
34 waitForActiveShellToBeDoneLoading(); 36 waitForActiveShellToBeDoneLoading();
35 mWrapper = new TestInputMethodManagerWrapper(getActivity()); 37 mWrapper = new TestInputMethodManagerWrapper(getActivity());
36 TestImeAdapterDelegate imeAdapterDelegate = 38 TestImeAdapterDelegate imeAdapterDelegate =
37 new TestImeAdapterDelegate(getContentViewCore().getContainerView ()); 39 new TestImeAdapterDelegate(getContentViewCore().getContainerView ());
38 mImeAdapter = new TestImeAdapter(mWrapper, imeAdapterDelegate); 40 mImeAdapter = new TestImeAdapter(mWrapper, imeAdapterDelegate);
39 mConnection = new AdapterInputConnection( 41 Editable editable = Editable.Factory.getInstance().newEditable("");
40 getContentViewCore().getContainerView(), mImeAdapter, 0, 0, new EditorInfo()); 42 mConnection = new AdapterInputConnection(getContentViewCore().getContain erView(),
43 mImeAdapter, new AdapterInputConnection.ThreadManager(), editabl e,
44 TextInputType.TEXT, 0, new EditorInfo());
41 } 45 }
42 46
43 @SmallTest 47 @SmallTest
44 @Feature({"TextInput", "Main"}) 48 @Feature({"TextInput", "Main"})
45 public void testAdjustLengthBeforeAndAfterSelection() throws Throwable { 49 public void testAdjustLengthBeforeAndAfterSelection() throws Throwable {
46 final String ga = "\uAC00"; 50 final String ga = "\uAC00";
47 final String smiley = "\uD83D\uDE0A"; // multi character codepoint 51 final String smiley = "\uD83D\uDE0A"; // multi character codepoint
48 52
49 // No need to adjust length. 53 // No need to adjust length.
50 assertFalse(AdapterInputConnection.isIndexBetweenUtf16SurrogatePair("a", 0)); 54 assertFalse(AdapterInputConnection.isIndexBetweenUtf16SurrogatePair("a", 0));
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 161
158 private static void assertCorrectState(String text, int selectionStart, int selectionEnd, 162 private static void assertCorrectState(String text, int selectionStart, int selectionEnd,
159 int compositionStart, int compositionEnd, ImeState actual) { 163 int compositionStart, int compositionEnd, ImeState actual) {
160 assertEquals("Text did not match", text, actual.text); 164 assertEquals("Text did not match", text, actual.text);
161 assertEquals("Selection start did not match", selectionStart, actual.sel ectionStart); 165 assertEquals("Selection start did not match", selectionStart, actual.sel ectionStart);
162 assertEquals("Selection end did not match", selectionEnd, actual.selecti onEnd); 166 assertEquals("Selection end did not match", selectionEnd, actual.selecti onEnd);
163 assertEquals("Composition start did not match", compositionStart, actual .compositionStart); 167 assertEquals("Composition start did not match", compositionStart, actual .compositionStart);
164 assertEquals("Composition end did not match", compositionEnd, actual.com positionEnd); 168 assertEquals("Composition end did not match", compositionEnd, actual.com positionEnd);
165 } 169 }
166 } 170 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698