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.app.Activity; | 7 import android.app.Activity; |
8 import android.content.ClipData; | 8 import android.content.ClipData; |
9 import android.content.ClipboardManager; | 9 import android.content.ClipboardManager; |
10 import android.content.Context; | 10 import android.content.Context; |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 waitAndVerifyUpdateSelection(2, 2, 2, -1, -1); | 148 waitAndVerifyUpdateSelection(2, 2, 2, -1, -1); |
149 deleteSurroundingText(0, 0); | 149 deleteSurroundingText(0, 0); |
150 assertTextsAroundCursor("he", null, "llo"); | 150 assertTextsAroundCursor("he", null, "llo"); |
151 } | 151 } |
152 | 152 |
153 // When newCursorPosition != 1, setComposingText doesn't work for ReplicaInp
utConnection | 153 // When newCursorPosition != 1, setComposingText doesn't work for ReplicaInp
utConnection |
154 // because there is a bug in BaseInputConnection. | 154 // because there is a bug in BaseInputConnection. |
155 @CommandLineFlags.Add("enable-features=ImeThread") | 155 @CommandLineFlags.Add("enable-features=ImeThread") |
156 @SmallTest | 156 @SmallTest |
157 @Feature({"TextInput", "Main"}) | 157 @Feature({"TextInput", "Main"}) |
158 public void testSetComposingTextForDifferentnewCursorPositions() throws Thro
wable { | 158 public void testSetComposingTextForNewCursorPositions() throws Throwable { |
159 // Cursor is on the right of composing text when newCursorPosition > 0. | 159 // Cursor is on the right of composing text when newCursorPosition > 0. |
160 setComposingText("ab", 1); | 160 setComposingText("ab", 1); |
161 waitAndVerifyUpdateSelection(0, 2, 2, 0, 2); | 161 waitAndVerifyUpdateSelection(0, 2, 2, 0, 2); |
162 | 162 |
163 finishComposingText(); | 163 finishComposingText(); |
164 waitAndVerifyUpdateSelection(1, 2, 2, -1, -1); | 164 waitAndVerifyUpdateSelection(1, 2, 2, -1, -1); |
165 | 165 |
166 // Cursor exceeds the left boundary. | 166 // Cursor exceeds the left boundary. |
167 setComposingText("cdef", -100); | 167 setComposingText("cdef", -100); |
168 waitAndVerifyUpdateSelection(2, 0, 0, 2, 6); | 168 waitAndVerifyUpdateSelection(2, 0, 0, 2, 6); |
(...skipping 23 matching lines...) Expand all Loading... |
192 | 192 |
193 // Cursor is on the right boundary. | 193 // Cursor is on the right boundary. |
194 setComposingText("ef", 3); | 194 setComposingText("ef", 3); |
195 waitAndVerifyUpdateSelection(9, 6, 6, 2, 4); | 195 waitAndVerifyUpdateSelection(9, 6, 6, 2, 4); |
196 | 196 |
197 // Cursor exceeds the right boundary. | 197 // Cursor exceeds the right boundary. |
198 setComposingText("efgh", 100); | 198 setComposingText("efgh", 100); |
199 waitAndVerifyUpdateSelection(10, 8, 8, 2, 6); | 199 waitAndVerifyUpdateSelection(10, 8, 8, 2, 6); |
200 } | 200 } |
201 | 201 |
| 202 // When newCursorPosition != 1, commitText doesn't work for ReplicaInputConn
ection |
| 203 // because there is a bug in BaseInputConnection. |
| 204 @CommandLineFlags.Add("enable-features=ImeThread") |
| 205 @SmallTest |
| 206 @Feature({"TextInput", "Main"}) |
| 207 public void testCommitTextForNewCursorPositions() throws Throwable { |
| 208 // Cursor is on the left of committing text. |
| 209 commitText("ab", 0); |
| 210 waitAndVerifyUpdateSelection(0, 0, 0, -1, -1); |
| 211 |
| 212 // Cursor is on the right of committing text. |
| 213 commitText("cd", 1); |
| 214 waitAndVerifyUpdateSelection(1, 2, 2, -1, -1); |
| 215 |
| 216 // Cursor is between the committing text and the right boundary. |
| 217 commitText("ef", 2); |
| 218 waitAndVerifyUpdateSelection(2, 5, 5, -1, -1); |
| 219 |
| 220 // Cursor is between the left boundary and the committing text. |
| 221 commitText("gh", -3); |
| 222 waitAndVerifyUpdateSelection(3, 2, 2, -1, -1); |
| 223 |
| 224 // Cursor is on the right boundary. |
| 225 commitText("ij", 7); |
| 226 waitAndVerifyUpdateSelection(4, 10, 10, -1, -1); |
| 227 |
| 228 // Cursor is on the left boundary. |
| 229 commitText("kl", -10); |
| 230 waitAndVerifyUpdateSelection(5, 0, 0, -1, -1); |
| 231 |
| 232 // Cursor exceeds the right boundary. |
| 233 commitText("mn", 100); |
| 234 waitAndVerifyUpdateSelection(6, 14, 14, -1, -1); |
| 235 |
| 236 // Cursor exceeds the left boundary. |
| 237 commitText("op", -100); |
| 238 waitAndVerifyUpdateSelection(7, 0, 0, -1, -1); |
| 239 } |
| 240 |
202 @SmallTest | 241 @SmallTest |
203 @Feature({"TextInput", "Main"}) | 242 @Feature({"TextInput", "Main"}) |
204 public void testSetComposingTextWithEmptyText() throws Throwable { | 243 public void testSetComposingTextWithEmptyText() throws Throwable { |
205 commitText("hello", 1); | 244 commitText("hello", 1); |
206 waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); | 245 waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); |
207 | 246 |
208 setComposingText("AB", 1); | 247 setComposingText("AB", 1); |
209 waitAndVerifyUpdateSelection(1, 7, 7, 5, 7); | 248 waitAndVerifyUpdateSelection(1, 7, 7, 5, 7); |
210 | 249 |
211 // With previous composition. | 250 // With previous composition. |
212 setComposingText("", -3); | 251 setComposingText("", -3); |
213 waitAndVerifyUpdateSelection(2, 2, 2, -1, -1); | 252 waitAndVerifyUpdateSelection(2, 2, 2, -1, -1); |
214 assertTextsAroundCursor("he", null, "llo"); | 253 assertTextsAroundCursor("he", null, "llo"); |
215 | 254 |
216 // Without previous composition. | 255 // Without previous composition. |
217 setComposingText("", 3); | 256 setComposingText("", 3); |
218 waitAndVerifyUpdateSelection(3, 4, 4, -1, -1); | 257 waitAndVerifyUpdateSelection(3, 4, 4, -1, -1); |
219 assertTextsAroundCursor("hell", null, "o"); | 258 assertTextsAroundCursor("hell", null, "o"); |
220 } | 259 } |
221 | 260 |
222 @SmallTest | 261 @SmallTest |
223 @Feature({"TextInput", "Main"}) | 262 @Feature({"TextInput", "Main"}) |
| 263 public void testCommitTextWithEmptyText() throws Throwable { |
| 264 commitText("hello", 1); |
| 265 waitAndVerifyUpdateSelection(0, 5, 5, -1, -1); |
| 266 setSelection(2, 2); |
| 267 waitAndVerifyUpdateSelection(1, 2, 2, -1, -1); |
| 268 |
| 269 setComposingText("world", 1); |
| 270 waitAndVerifyUpdateSelection(2, 7, 7, 2, 7); |
| 271 // With previous composition. |
| 272 commitText("", 2); |
| 273 waitAndVerifyUpdateSelection(3, 3, 3, -1, -1); |
| 274 |
| 275 // Without previous composition. |
| 276 commitText("", -1); |
| 277 waitAndVerifyUpdateSelection(4, 2, 2, -1, -1); |
| 278 } |
| 279 |
| 280 @SmallTest |
| 281 @Feature({"TextInput", "Main"}) |
224 public void testCommitWhileComposingText() throws Throwable { | 282 public void testCommitWhileComposingText() throws Throwable { |
225 setComposingText("h", 1); | 283 setComposingText("h", 1); |
226 waitAndVerifyUpdateSelection(0, 1, 1, 0, 1); | 284 waitAndVerifyUpdateSelection(0, 1, 1, 0, 1); |
227 | 285 |
228 setComposingText("he", 1); | 286 setComposingText("he", 1); |
229 waitAndVerifyUpdateSelection(1, 2, 2, 0, 2); | 287 waitAndVerifyUpdateSelection(1, 2, 2, 0, 2); |
230 | 288 |
231 setComposingText("hel", 1); | 289 setComposingText("hel", 1); |
232 waitAndVerifyUpdateSelection(2, 3, 3, 0, 3); | 290 waitAndVerifyUpdateSelection(2, 3, 3, 0, 3); |
233 | 291 |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1733 public void onViewAttachedToWindow() { | 1791 public void onViewAttachedToWindow() { |
1734 mFactory.onViewAttachedToWindow(); | 1792 mFactory.onViewAttachedToWindow(); |
1735 } | 1793 } |
1736 | 1794 |
1737 @Override | 1795 @Override |
1738 public void onViewDetachedFromWindow() { | 1796 public void onViewDetachedFromWindow() { |
1739 mFactory.onViewDetachedFromWindow(); | 1797 mFactory.onViewDetachedFromWindow(); |
1740 } | 1798 } |
1741 } | 1799 } |
1742 } | 1800 } |
OLD | NEW |