OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "grit/ui_resources.h" | 7 #include "grit/ui_resources.h" |
8 #include "ui/base/resource/resource_bundle.h" | 8 #include "ui/base/resource/resource_bundle.h" |
9 #include "ui/base/touch/touch_editing_controller.h" | 9 #include "ui/base/touch/touch_editing_controller.h" |
10 #include "ui/base/ui_base_switches.h" | 10 #include "ui/base/ui_base_switches.h" |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 // a Textfield changes. | 193 // a Textfield changes. |
194 TEST_F(TouchSelectionControllerImplTest, SelectionInTextfieldTest) { | 194 TEST_F(TouchSelectionControllerImplTest, SelectionInTextfieldTest) { |
195 CreateTextfield(); | 195 CreateTextfield(); |
196 textfield_->SetText(ASCIIToUTF16("some text")); | 196 textfield_->SetText(ASCIIToUTF16("some text")); |
197 // Tap the textfield to invoke touch selection. | 197 // Tap the textfield to invoke touch selection. |
198 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), | 198 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), |
199 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f), 0); | 199 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f), 0); |
200 textfield_view_->OnGestureEvent(&tap); | 200 textfield_view_->OnGestureEvent(&tap); |
201 | 201 |
202 // Test selecting a range. | 202 // Test selecting a range. |
203 textfield_->SelectRange(ui::Range(3, 7)); | 203 textfield_->SelectRange(gfx::Range(3, 7)); |
204 VERIFY_HANDLE_POSITIONS(false); | 204 VERIFY_HANDLE_POSITIONS(false); |
205 | 205 |
206 // Test selecting everything. | 206 // Test selecting everything. |
207 textfield_->SelectAll(false); | 207 textfield_->SelectAll(false); |
208 VERIFY_HANDLE_POSITIONS(false); | 208 VERIFY_HANDLE_POSITIONS(false); |
209 | 209 |
210 // Test with no selection. | 210 // Test with no selection. |
211 textfield_->ClearSelection(); | 211 textfield_->ClearSelection(); |
212 VERIFY_HANDLE_POSITIONS(false); | 212 VERIFY_HANDLE_POSITIONS(false); |
213 | 213 |
(...skipping 16 matching lines...) Expand all Loading... |
230 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), | 230 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), |
231 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f), 0); | 231 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f), 0); |
232 textfield_view_->OnGestureEvent(&tap); | 232 textfield_view_->OnGestureEvent(&tap); |
233 | 233 |
234 // Test cursor at run boundary and with empty selection. | 234 // Test cursor at run boundary and with empty selection. |
235 textfield_->SelectSelectionModel( | 235 textfield_->SelectSelectionModel( |
236 gfx::SelectionModel(3, gfx::CURSOR_BACKWARD)); | 236 gfx::SelectionModel(3, gfx::CURSOR_BACKWARD)); |
237 VERIFY_HANDLE_POSITIONS(false); | 237 VERIFY_HANDLE_POSITIONS(false); |
238 | 238 |
239 // Test selection range inside one run and starts or ends at run boundary. | 239 // Test selection range inside one run and starts or ends at run boundary. |
240 textfield_->SelectRange(ui::Range(2, 3)); | 240 textfield_->SelectRange(gfx::Range(2, 3)); |
241 VERIFY_HANDLE_POSITIONS(false); | 241 VERIFY_HANDLE_POSITIONS(false); |
242 | 242 |
243 textfield_->SelectRange(ui::Range(3, 2)); | 243 textfield_->SelectRange(gfx::Range(3, 2)); |
244 VERIFY_HANDLE_POSITIONS(false); | 244 VERIFY_HANDLE_POSITIONS(false); |
245 | 245 |
246 textfield_->SelectRange(ui::Range(3, 4)); | 246 textfield_->SelectRange(gfx::Range(3, 4)); |
247 VERIFY_HANDLE_POSITIONS(false); | 247 VERIFY_HANDLE_POSITIONS(false); |
248 | 248 |
249 textfield_->SelectRange(ui::Range(4, 3)); | 249 textfield_->SelectRange(gfx::Range(4, 3)); |
250 VERIFY_HANDLE_POSITIONS(false); | 250 VERIFY_HANDLE_POSITIONS(false); |
251 | 251 |
252 textfield_->SelectRange(ui::Range(3, 6)); | 252 textfield_->SelectRange(gfx::Range(3, 6)); |
253 VERIFY_HANDLE_POSITIONS(false); | 253 VERIFY_HANDLE_POSITIONS(false); |
254 | 254 |
255 textfield_->SelectRange(ui::Range(6, 3)); | 255 textfield_->SelectRange(gfx::Range(6, 3)); |
256 VERIFY_HANDLE_POSITIONS(false); | 256 VERIFY_HANDLE_POSITIONS(false); |
257 | 257 |
258 // Test selection range accross runs. | 258 // Test selection range accross runs. |
259 textfield_->SelectRange(ui::Range(0, 6)); | 259 textfield_->SelectRange(gfx::Range(0, 6)); |
260 VERIFY_HANDLE_POSITIONS(false); | 260 VERIFY_HANDLE_POSITIONS(false); |
261 | 261 |
262 textfield_->SelectRange(ui::Range(6, 0)); | 262 textfield_->SelectRange(gfx::Range(6, 0)); |
263 VERIFY_HANDLE_POSITIONS(false); | 263 VERIFY_HANDLE_POSITIONS(false); |
264 | 264 |
265 textfield_->SelectRange(ui::Range(1, 4)); | 265 textfield_->SelectRange(gfx::Range(1, 4)); |
266 VERIFY_HANDLE_POSITIONS(false); | 266 VERIFY_HANDLE_POSITIONS(false); |
267 | 267 |
268 textfield_->SelectRange(ui::Range(4, 1)); | 268 textfield_->SelectRange(gfx::Range(4, 1)); |
269 VERIFY_HANDLE_POSITIONS(false); | 269 VERIFY_HANDLE_POSITIONS(false); |
270 } | 270 } |
271 | 271 |
272 // Tests if the SelectRect callback is called appropriately when selection | 272 // Tests if the SelectRect callback is called appropriately when selection |
273 // handles are moved. | 273 // handles are moved. |
274 TEST_F(TouchSelectionControllerImplTest, SelectRectCallbackTest) { | 274 TEST_F(TouchSelectionControllerImplTest, SelectRectCallbackTest) { |
275 CreateTextfield(); | 275 CreateTextfield(); |
276 textfield_->SetText(ASCIIToUTF16("textfield with selected text")); | 276 textfield_->SetText(ASCIIToUTF16("textfield with selected text")); |
277 // Tap the textfield to invoke touch selection. | 277 // Tap the textfield to invoke touch selection. |
278 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), | 278 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), |
279 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f), 0); | 279 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f), 0); |
280 textfield_view_->OnGestureEvent(&tap); | 280 textfield_view_->OnGestureEvent(&tap); |
281 textfield_->SelectRange(ui::Range(3, 7)); | 281 textfield_->SelectRange(gfx::Range(3, 7)); |
282 | 282 |
283 EXPECT_EQ(UTF16ToUTF8(textfield_->GetSelectedText()), "tfie"); | 283 EXPECT_EQ(UTF16ToUTF8(textfield_->GetSelectedText()), "tfie"); |
284 VERIFY_HANDLE_POSITIONS(false); | 284 VERIFY_HANDLE_POSITIONS(false); |
285 | 285 |
286 // Drag selection handle 2 to right by 3 chars. | 286 // Drag selection handle 2 to right by 3 chars. |
287 const gfx::Font& font = textfield_->GetPrimaryFont(); | 287 const gfx::Font& font = textfield_->GetPrimaryFont(); |
288 int x = font.GetStringWidth(ASCIIToUTF16("ld ")); | 288 int x = font.GetStringWidth(ASCIIToUTF16("ld ")); |
289 SimulateSelectionHandleDrag(gfx::Point(x, 0), 2); | 289 SimulateSelectionHandleDrag(gfx::Point(x, 0), 2); |
290 EXPECT_EQ(UTF16ToUTF8(textfield_->GetSelectedText()), "tfield "); | 290 EXPECT_EQ(UTF16ToUTF8(textfield_->GetSelectedText()), "tfield "); |
291 VERIFY_HANDLE_POSITIONS(false); | 291 VERIFY_HANDLE_POSITIONS(false); |
(...skipping 19 matching lines...) Expand all Loading... |
311 | 311 |
312 TEST_F(TouchSelectionControllerImplTest, SelectRectInBidiCallbackTest) { | 312 TEST_F(TouchSelectionControllerImplTest, SelectRectInBidiCallbackTest) { |
313 CreateTextfield(); | 313 CreateTextfield(); |
314 textfield_->SetText(WideToUTF16(L"abc\x05e1\x05e2\x05e3" L"def")); | 314 textfield_->SetText(WideToUTF16(L"abc\x05e1\x05e2\x05e3" L"def")); |
315 // Tap the textfield to invoke touch selection. | 315 // Tap the textfield to invoke touch selection. |
316 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), | 316 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), |
317 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f), 0); | 317 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f), 0); |
318 textfield_view_->OnGestureEvent(&tap); | 318 textfield_view_->OnGestureEvent(&tap); |
319 | 319 |
320 // Select [c] from left to right. | 320 // Select [c] from left to right. |
321 textfield_->SelectRange(ui::Range(2, 3)); | 321 textfield_->SelectRange(gfx::Range(2, 3)); |
322 EXPECT_EQ(WideToUTF16(L"c"), textfield_->GetSelectedText()); | 322 EXPECT_EQ(WideToUTF16(L"c"), textfield_->GetSelectedText()); |
323 VERIFY_HANDLE_POSITIONS(false); | 323 VERIFY_HANDLE_POSITIONS(false); |
324 | 324 |
325 // Drag selection handle 2 to right by 1 char. | 325 // Drag selection handle 2 to right by 1 char. |
326 const gfx::Font& font = textfield_->GetPrimaryFont(); | 326 const gfx::Font& font = textfield_->GetPrimaryFont(); |
327 int x = font.GetStringWidth(WideToUTF16(L"\x05e3")); | 327 int x = font.GetStringWidth(WideToUTF16(L"\x05e3")); |
328 SimulateSelectionHandleDrag(gfx::Point(x, 0), 2); | 328 SimulateSelectionHandleDrag(gfx::Point(x, 0), 2); |
329 EXPECT_EQ(WideToUTF16(L"c\x05e1\x05e2"), textfield_->GetSelectedText()); | 329 EXPECT_EQ(WideToUTF16(L"c\x05e1\x05e2"), textfield_->GetSelectedText()); |
330 VERIFY_HANDLE_POSITIONS(false); | 330 VERIFY_HANDLE_POSITIONS(false); |
331 | 331 |
332 // Drag selection handle 1 to left by 1 char. | 332 // Drag selection handle 1 to left by 1 char. |
333 x = font.GetStringWidth(WideToUTF16(L"b")); | 333 x = font.GetStringWidth(WideToUTF16(L"b")); |
334 SimulateSelectionHandleDrag(gfx::Point(-x, 0), 1); | 334 SimulateSelectionHandleDrag(gfx::Point(-x, 0), 1); |
335 EXPECT_EQ(WideToUTF16(L"bc\x05e1\x05e2"), textfield_->GetSelectedText()); | 335 EXPECT_EQ(WideToUTF16(L"bc\x05e1\x05e2"), textfield_->GetSelectedText()); |
336 VERIFY_HANDLE_POSITIONS(true); | 336 VERIFY_HANDLE_POSITIONS(true); |
337 | 337 |
338 // Select [c] from right to left. | 338 // Select [c] from right to left. |
339 textfield_->SelectRange(ui::Range(3, 2)); | 339 textfield_->SelectRange(gfx::Range(3, 2)); |
340 EXPECT_EQ(WideToUTF16(L"c"), textfield_->GetSelectedText()); | 340 EXPECT_EQ(WideToUTF16(L"c"), textfield_->GetSelectedText()); |
341 VERIFY_HANDLE_POSITIONS(false); | 341 VERIFY_HANDLE_POSITIONS(false); |
342 | 342 |
343 // Drag selection handle 1 to right by 1 char. | 343 // Drag selection handle 1 to right by 1 char. |
344 x = font.GetStringWidth(WideToUTF16(L"\x05e3")); | 344 x = font.GetStringWidth(WideToUTF16(L"\x05e3")); |
345 SimulateSelectionHandleDrag(gfx::Point(x, 0), 1); | 345 SimulateSelectionHandleDrag(gfx::Point(x, 0), 1); |
346 EXPECT_EQ(WideToUTF16(L"c\x05e1\x05e2"), textfield_->GetSelectedText()); | 346 EXPECT_EQ(WideToUTF16(L"c\x05e1\x05e2"), textfield_->GetSelectedText()); |
347 VERIFY_HANDLE_POSITIONS(true); | 347 VERIFY_HANDLE_POSITIONS(true); |
348 | 348 |
349 // Drag selection handle 2 to left by 1 char. | 349 // Drag selection handle 2 to left by 1 char. |
350 x = font.GetStringWidth(WideToUTF16(L"b")); | 350 x = font.GetStringWidth(WideToUTF16(L"b")); |
351 SimulateSelectionHandleDrag(gfx::Point(-x, 0), 2); | 351 SimulateSelectionHandleDrag(gfx::Point(-x, 0), 2); |
352 EXPECT_EQ(WideToUTF16(L"bc\x05e1\x05e2"), textfield_->GetSelectedText()); | 352 EXPECT_EQ(WideToUTF16(L"bc\x05e1\x05e2"), textfield_->GetSelectedText()); |
353 VERIFY_HANDLE_POSITIONS(false); | 353 VERIFY_HANDLE_POSITIONS(false); |
354 | 354 |
355 // Select [\x5e1] from right to left. | 355 // Select [\x5e1] from right to left. |
356 textfield_->SelectRange(ui::Range(3, 4)); | 356 textfield_->SelectRange(gfx::Range(3, 4)); |
357 EXPECT_EQ(WideToUTF16(L"\x05e1"), textfield_->GetSelectedText()); | 357 EXPECT_EQ(WideToUTF16(L"\x05e1"), textfield_->GetSelectedText()); |
358 VERIFY_HANDLE_POSITIONS(false); | 358 VERIFY_HANDLE_POSITIONS(false); |
359 | 359 |
360 /* TODO(xji): for bidi text "abcDEF" whose display is "abcFEDhij", when click | 360 /* TODO(xji): for bidi text "abcDEF" whose display is "abcFEDhij", when click |
361 right of 'D' and select [D] then move the left selection handle to left | 361 right of 'D' and select [D] then move the left selection handle to left |
362 by one character, it should select [ED], instead it selects [F]. | 362 by one character, it should select [ED], instead it selects [F]. |
363 Reason: click right of 'D' and left of 'h' return the same x-axis position, | 363 Reason: click right of 'D' and left of 'h' return the same x-axis position, |
364 pass this position to FindCursorPosition() returns index of 'h'. which | 364 pass this position to FindCursorPosition() returns index of 'h'. which |
365 means the selection start changed from 3 to 6. | 365 means the selection start changed from 3 to 6. |
366 Need further investigation on whether this is a bug in Pango and how to | 366 Need further investigation on whether this is a bug in Pango and how to |
367 work around it. | 367 work around it. |
368 // Drag selection handle 2 to left by 1 char. | 368 // Drag selection handle 2 to left by 1 char. |
369 x = font.GetStringWidth(WideToUTF16(L"\x05e2")); | 369 x = font.GetStringWidth(WideToUTF16(L"\x05e2")); |
370 SimulateSelectionHandleDrag(gfx::Point(-x, 0), 2); | 370 SimulateSelectionHandleDrag(gfx::Point(-x, 0), 2); |
371 EXPECT_EQ(WideToUTF16(L"\x05e1\x05e2"), textfield_->GetSelectedText()); | 371 EXPECT_EQ(WideToUTF16(L"\x05e1\x05e2"), textfield_->GetSelectedText()); |
372 VERIFY_HANDLE_POSITIONS(false); | 372 VERIFY_HANDLE_POSITIONS(false); |
373 */ | 373 */ |
374 | 374 |
375 // Drag selection handle 1 to right by 1 char. | 375 // Drag selection handle 1 to right by 1 char. |
376 x = font.GetStringWidth(WideToUTF16(L"d")); | 376 x = font.GetStringWidth(WideToUTF16(L"d")); |
377 SimulateSelectionHandleDrag(gfx::Point(x, 0), 1); | 377 SimulateSelectionHandleDrag(gfx::Point(x, 0), 1); |
378 EXPECT_EQ(WideToUTF16(L"\x05e2\x05e3" L"d"), textfield_->GetSelectedText()); | 378 EXPECT_EQ(WideToUTF16(L"\x05e2\x05e3" L"d"), textfield_->GetSelectedText()); |
379 VERIFY_HANDLE_POSITIONS(true); | 379 VERIFY_HANDLE_POSITIONS(true); |
380 | 380 |
381 // Select [\x5e1] from left to right. | 381 // Select [\x5e1] from left to right. |
382 textfield_->SelectRange(ui::Range(4, 3)); | 382 textfield_->SelectRange(gfx::Range(4, 3)); |
383 EXPECT_EQ(WideToUTF16(L"\x05e1"), textfield_->GetSelectedText()); | 383 EXPECT_EQ(WideToUTF16(L"\x05e1"), textfield_->GetSelectedText()); |
384 VERIFY_HANDLE_POSITIONS(false); | 384 VERIFY_HANDLE_POSITIONS(false); |
385 | 385 |
386 /* TODO(xji): see detail of above commented out test case. | 386 /* TODO(xji): see detail of above commented out test case. |
387 // Drag selection handle 1 to left by 1 char. | 387 // Drag selection handle 1 to left by 1 char. |
388 x = font.GetStringWidth(WideToUTF16(L"\x05e2")); | 388 x = font.GetStringWidth(WideToUTF16(L"\x05e2")); |
389 SimulateSelectionHandleDrag(gfx::Point(-x, 0), 1); | 389 SimulateSelectionHandleDrag(gfx::Point(-x, 0), 1); |
390 EXPECT_EQ(WideToUTF16(L"\x05e1\x05e2"), textfield_->GetSelectedText()); | 390 EXPECT_EQ(WideToUTF16(L"\x05e1\x05e2"), textfield_->GetSelectedText()); |
391 VERIFY_HANDLE_POSITIONS(true); | 391 VERIFY_HANDLE_POSITIONS(true); |
392 */ | 392 */ |
393 | 393 |
394 // Drag selection handle 2 to right by 1 char. | 394 // Drag selection handle 2 to right by 1 char. |
395 x = font.GetStringWidth(WideToUTF16(L"d")); | 395 x = font.GetStringWidth(WideToUTF16(L"d")); |
396 SimulateSelectionHandleDrag(gfx::Point(x, 0), 2); | 396 SimulateSelectionHandleDrag(gfx::Point(x, 0), 2); |
397 EXPECT_EQ(WideToUTF16(L"\x05e2\x05e3" L"d"), textfield_->GetSelectedText()); | 397 EXPECT_EQ(WideToUTF16(L"\x05e2\x05e3" L"d"), textfield_->GetSelectedText()); |
398 VERIFY_HANDLE_POSITIONS(false); | 398 VERIFY_HANDLE_POSITIONS(false); |
399 | 399 |
400 // Select [\x05r3] from right to left. | 400 // Select [\x05r3] from right to left. |
401 textfield_->SelectRange(ui::Range(5, 6)); | 401 textfield_->SelectRange(gfx::Range(5, 6)); |
402 EXPECT_EQ(WideToUTF16(L"\x05e3"), textfield_->GetSelectedText()); | 402 EXPECT_EQ(WideToUTF16(L"\x05e3"), textfield_->GetSelectedText()); |
403 VERIFY_HANDLE_POSITIONS(false); | 403 VERIFY_HANDLE_POSITIONS(false); |
404 | 404 |
405 // Drag selection handle 2 to left by 1 char. | 405 // Drag selection handle 2 to left by 1 char. |
406 x = font.GetStringWidth(WideToUTF16(L"c")); | 406 x = font.GetStringWidth(WideToUTF16(L"c")); |
407 SimulateSelectionHandleDrag(gfx::Point(-x, 0), 2); | 407 SimulateSelectionHandleDrag(gfx::Point(-x, 0), 2); |
408 EXPECT_EQ(WideToUTF16(L"c\x05e1\x05e2"), textfield_->GetSelectedText()); | 408 EXPECT_EQ(WideToUTF16(L"c\x05e1\x05e2"), textfield_->GetSelectedText()); |
409 VERIFY_HANDLE_POSITIONS(false); | 409 VERIFY_HANDLE_POSITIONS(false); |
410 | 410 |
411 // Drag selection handle 1 to right by 1 char. | 411 // Drag selection handle 1 to right by 1 char. |
412 x = font.GetStringWidth(WideToUTF16(L"\x05e2")); | 412 x = font.GetStringWidth(WideToUTF16(L"\x05e2")); |
413 SimulateSelectionHandleDrag(gfx::Point(x, 0), 1); | 413 SimulateSelectionHandleDrag(gfx::Point(x, 0), 1); |
414 EXPECT_EQ(WideToUTF16(L"c\x05e1"), textfield_->GetSelectedText()); | 414 EXPECT_EQ(WideToUTF16(L"c\x05e1"), textfield_->GetSelectedText()); |
415 VERIFY_HANDLE_POSITIONS(true); | 415 VERIFY_HANDLE_POSITIONS(true); |
416 | 416 |
417 // Select [\x05r3] from left to right. | 417 // Select [\x05r3] from left to right. |
418 textfield_->SelectRange(ui::Range(6, 5)); | 418 textfield_->SelectRange(gfx::Range(6, 5)); |
419 EXPECT_EQ(WideToUTF16(L"\x05e3"), textfield_->GetSelectedText()); | 419 EXPECT_EQ(WideToUTF16(L"\x05e3"), textfield_->GetSelectedText()); |
420 VERIFY_HANDLE_POSITIONS(false); | 420 VERIFY_HANDLE_POSITIONS(false); |
421 | 421 |
422 // Drag selection handle 1 to left by 1 char. | 422 // Drag selection handle 1 to left by 1 char. |
423 x = font.GetStringWidth(WideToUTF16(L"c")); | 423 x = font.GetStringWidth(WideToUTF16(L"c")); |
424 SimulateSelectionHandleDrag(gfx::Point(-x, 0), 1); | 424 SimulateSelectionHandleDrag(gfx::Point(-x, 0), 1); |
425 EXPECT_EQ(WideToUTF16(L"c\x05e1\x05e2"), textfield_->GetSelectedText()); | 425 EXPECT_EQ(WideToUTF16(L"c\x05e1\x05e2"), textfield_->GetSelectedText()); |
426 VERIFY_HANDLE_POSITIONS(true); | 426 VERIFY_HANDLE_POSITIONS(true); |
427 | 427 |
428 // Drag selection handle 2 to right by 1 char. | 428 // Drag selection handle 2 to right by 1 char. |
(...skipping 11 matching lines...) Expand all Loading... |
440 for (int i = 0; i < 10; ++i) | 440 for (int i = 0; i < 10; ++i) |
441 textfield_text += textfield_text; | 441 textfield_text += textfield_text; |
442 textfield_->SetText(ASCIIToUTF16(textfield_text)); | 442 textfield_->SetText(ASCIIToUTF16(textfield_text)); |
443 | 443 |
444 // Tap the textfield to invoke selection. | 444 // Tap the textfield to invoke selection. |
445 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), | 445 ui::GestureEvent tap(ui::ET_GESTURE_TAP, 0, 0, 0, base::TimeDelta(), |
446 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f), 0); | 446 ui::GestureEventDetails(ui::ET_GESTURE_TAP, 1.0f, 0.0f), 0); |
447 textfield_view_->OnGestureEvent(&tap); | 447 textfield_view_->OnGestureEvent(&tap); |
448 | 448 |
449 // Select some text such that one handle is hidden. | 449 // Select some text such that one handle is hidden. |
450 textfield_->SelectRange(ui::Range(10, textfield_text.length())); | 450 textfield_->SelectRange(gfx::Range(10, textfield_text.length())); |
451 | 451 |
452 // Check that one selection handle is hidden. | 452 // Check that one selection handle is hidden. |
453 EXPECT_FALSE(IsSelectionHandle1Visible()); | 453 EXPECT_FALSE(IsSelectionHandle1Visible()); |
454 EXPECT_TRUE(IsSelectionHandle2Visible()); | 454 EXPECT_TRUE(IsSelectionHandle2Visible()); |
455 EXPECT_EQ(ui::Range(10, textfield_text.length()), | 455 EXPECT_EQ(gfx::Range(10, textfield_text.length()), |
456 textfield_->GetSelectedRange()); | 456 textfield_->GetSelectedRange()); |
457 | 457 |
458 // Drag the visible handle around and make sure the selection end point of the | 458 // Drag the visible handle around and make sure the selection end point of the |
459 // invisible handle does not change. | 459 // invisible handle does not change. |
460 size_t visible_handle_position = textfield_->GetSelectedRange().end(); | 460 size_t visible_handle_position = textfield_->GetSelectedRange().end(); |
461 for (int i = 0; i < 10; ++i) { | 461 for (int i = 0; i < 10; ++i) { |
462 SimulateSelectionHandleDrag(gfx::Point(-10, 0), 2); | 462 SimulateSelectionHandleDrag(gfx::Point(-10, 0), 2); |
463 // Make sure that the visible handle is being dragged. | 463 // Make sure that the visible handle is being dragged. |
464 EXPECT_NE(visible_handle_position, textfield_->GetSelectedRange().end()); | 464 EXPECT_NE(visible_handle_position, textfield_->GetSelectedRange().end()); |
465 visible_handle_position = textfield_->GetSelectedRange().end(); | 465 visible_handle_position = textfield_->GetSelectedRange().end(); |
(...skipping 22 matching lines...) Expand all Loading... |
488 gfx::Point cursor_pos = GetCursorHandlePosition(); | 488 gfx::Point cursor_pos = GetCursorHandlePosition(); |
489 cursor_pos.Offset(GetHandleImageSize().width() / 2 + kPadding, 0); | 489 cursor_pos.Offset(GetHandleImageSize().width() / 2 + kPadding, 0); |
490 generator.GestureTapAt(cursor_pos); | 490 generator.GestureTapAt(cursor_pos); |
491 generator.GestureTapAt(cursor_pos); | 491 generator.GestureTapAt(cursor_pos); |
492 EXPECT_TRUE(textfield_->HasSelection()); | 492 EXPECT_TRUE(textfield_->HasSelection()); |
493 VERIFY_HANDLE_POSITIONS(false); | 493 VERIFY_HANDLE_POSITIONS(false); |
494 } | 494 } |
495 #endif | 495 #endif |
496 | 496 |
497 } // namespace views | 497 } // namespace views |
OLD | NEW |