OLD | NEW |
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 Loading... |
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 } |
OLD | NEW |