| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/aura/client/screen_position_client.h" | 10 #include "ui/aura/client/screen_position_client.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 views_tsc_factory_(new ViewsTouchEditingControllerFactory) { | 68 views_tsc_factory_(new ViewsTouchEditingControllerFactory) { |
| 69 ui::TouchEditingControllerFactory::SetInstance(views_tsc_factory_.get()); | 69 ui::TouchEditingControllerFactory::SetInstance(views_tsc_factory_.get()); |
| 70 } | 70 } |
| 71 | 71 |
| 72 ~TouchSelectionControllerImplTest() override { | 72 ~TouchSelectionControllerImplTest() override { |
| 73 ui::TouchEditingControllerFactory::SetInstance(nullptr); | 73 ui::TouchEditingControllerFactory::SetInstance(nullptr); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void SetUp() override { | 76 void SetUp() override { |
| 77 ViewsTestBase::SetUp(); | 77 ViewsTestBase::SetUp(); |
| 78 // TODO: test uses GetContext(), which is not applicable to aura-mus. |
| 79 // http://crbug.com/663809. |
| 80 if (IsAuraMusClient()) |
| 81 return; |
| 78 test_cursor_client_.reset(new aura::test::TestCursorClient(GetContext())); | 82 test_cursor_client_.reset(new aura::test::TestCursorClient(GetContext())); |
| 79 } | 83 } |
| 80 | 84 |
| 81 void TearDown() override { | 85 void TearDown() override { |
| 82 test_cursor_client_.reset(); | 86 test_cursor_client_.reset(); |
| 83 if (textfield_widget_ && !textfield_widget_->IsClosed()) | 87 if (textfield_widget_ && !textfield_widget_->IsClosed()) |
| 84 textfield_widget_->Close(); | 88 textfield_widget_->Close(); |
| 85 if (widget_ && !widget_->IsClosed()) | 89 if (widget_ && !widget_->IsClosed()) |
| 86 widget_->Close(); | 90 widget_->Close(); |
| 87 ViewsTestBase::TearDown(); | 91 ViewsTestBase::TearDown(); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 std::unique_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_; | 315 std::unique_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_; |
| 312 std::unique_ptr<aura::test::TestCursorClient> test_cursor_client_; | 316 std::unique_ptr<aura::test::TestCursorClient> test_cursor_client_; |
| 313 | 317 |
| 314 private: | 318 private: |
| 315 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerImplTest); | 319 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerImplTest); |
| 316 }; | 320 }; |
| 317 | 321 |
| 318 // Tests that the selection handles are placed appropriately when selection in | 322 // Tests that the selection handles are placed appropriately when selection in |
| 319 // a Textfield changes. | 323 // a Textfield changes. |
| 320 TEST_F(TouchSelectionControllerImplTest, SelectionInTextfieldTest) { | 324 TEST_F(TouchSelectionControllerImplTest, SelectionInTextfieldTest) { |
| 325 // TODO: see comment in SetUp(). |
| 326 if (IsAuraMusClient()) |
| 327 return; |
| 328 |
| 321 CreateTextfield(); | 329 CreateTextfield(); |
| 322 textfield_->SetText(ASCIIToUTF16("some text")); | 330 textfield_->SetText(ASCIIToUTF16("some text")); |
| 323 // Tap the textfield to invoke touch selection. | 331 // Tap the textfield to invoke touch selection. |
| 324 ui::GestureEventDetails details(ui::ET_GESTURE_TAP); | 332 ui::GestureEventDetails details(ui::ET_GESTURE_TAP); |
| 325 details.set_tap_count(1); | 333 details.set_tap_count(1); |
| 326 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), details); | 334 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), details); |
| 327 textfield_->OnGestureEvent(&tap); | 335 textfield_->OnGestureEvent(&tap); |
| 328 | 336 |
| 329 // Test selecting a range. | 337 // Test selecting a range. |
| 330 textfield_->SelectRange(gfx::Range(3, 7)); | 338 textfield_->SelectRange(gfx::Range(3, 7)); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 344 | 352 |
| 345 // Test with focus re-gained. | 353 // Test with focus re-gained. |
| 346 textfield_widget_->GetFocusManager()->SetFocusedView(textfield_); | 354 textfield_widget_->GetFocusManager()->SetFocusedView(textfield_); |
| 347 EXPECT_FALSE(GetSelectionController()); | 355 EXPECT_FALSE(GetSelectionController()); |
| 348 textfield_->OnGestureEvent(&tap); | 356 textfield_->OnGestureEvent(&tap); |
| 349 VerifyHandlePositions(false, true, FROM_HERE); | 357 VerifyHandlePositions(false, true, FROM_HERE); |
| 350 } | 358 } |
| 351 | 359 |
| 352 // Tests that the selection handles are placed appropriately in bidi text. | 360 // Tests that the selection handles are placed appropriately in bidi text. |
| 353 TEST_F(TouchSelectionControllerImplTest, SelectionInBidiTextfieldTest) { | 361 TEST_F(TouchSelectionControllerImplTest, SelectionInBidiTextfieldTest) { |
| 362 // TODO: see comment in SetUp(). |
| 363 if (IsAuraMusClient()) |
| 364 return; |
| 365 |
| 354 CreateTextfield(); | 366 CreateTextfield(); |
| 355 textfield_->SetText(WideToUTF16(L"abc\x05d0\x05d1\x05d2")); | 367 textfield_->SetText(WideToUTF16(L"abc\x05d0\x05d1\x05d2")); |
| 356 // Tap the textfield to invoke touch selection. | 368 // Tap the textfield to invoke touch selection. |
| 357 ui::GestureEventDetails details(ui::ET_GESTURE_TAP); | 369 ui::GestureEventDetails details(ui::ET_GESTURE_TAP); |
| 358 details.set_tap_count(1); | 370 details.set_tap_count(1); |
| 359 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), details); | 371 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), details); |
| 360 textfield_->OnGestureEvent(&tap); | 372 textfield_->OnGestureEvent(&tap); |
| 361 | 373 |
| 362 // Test cursor at run boundary and with empty selection. | 374 // Test cursor at run boundary and with empty selection. |
| 363 textfield_->SelectSelectionModel( | 375 textfield_->SelectSelectionModel( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 396 textfield_->SelectRange(gfx::Range(1, 4)); | 408 textfield_->SelectRange(gfx::Range(1, 4)); |
| 397 VerifyHandlePositions(false, true, FROM_HERE); | 409 VerifyHandlePositions(false, true, FROM_HERE); |
| 398 | 410 |
| 399 textfield_->SelectRange(gfx::Range(4, 1)); | 411 textfield_->SelectRange(gfx::Range(4, 1)); |
| 400 VerifyHandlePositions(false, true, FROM_HERE); | 412 VerifyHandlePositions(false, true, FROM_HERE); |
| 401 } | 413 } |
| 402 | 414 |
| 403 // Tests if the SelectRect callback is called appropriately when selection | 415 // Tests if the SelectRect callback is called appropriately when selection |
| 404 // handles are moved. | 416 // handles are moved. |
| 405 TEST_F(TouchSelectionControllerImplTest, SelectRectCallbackTest) { | 417 TEST_F(TouchSelectionControllerImplTest, SelectRectCallbackTest) { |
| 418 // TODO: see comment in SetUp(). |
| 419 if (IsAuraMusClient()) |
| 420 return; |
| 421 |
| 406 CreateTextfield(); | 422 CreateTextfield(); |
| 407 textfield_->SetText(ASCIIToUTF16("textfield with selected text")); | 423 textfield_->SetText(ASCIIToUTF16("textfield with selected text")); |
| 408 // Tap the textfield to invoke touch selection. | 424 // Tap the textfield to invoke touch selection. |
| 409 ui::GestureEventDetails details(ui::ET_GESTURE_TAP); | 425 ui::GestureEventDetails details(ui::ET_GESTURE_TAP); |
| 410 details.set_tap_count(1); | 426 details.set_tap_count(1); |
| 411 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), details); | 427 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), details); |
| 412 textfield_->OnGestureEvent(&tap); | 428 textfield_->OnGestureEvent(&tap); |
| 413 textfield_->SelectRange(gfx::Range(3, 7)); | 429 textfield_->SelectRange(gfx::Range(3, 7)); |
| 414 | 430 |
| 415 gfx::Point textfield_origin; | 431 gfx::Point textfield_origin; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 438 VerifyHandlePositions(true, true, FROM_HERE); | 454 VerifyHandlePositions(true, true, FROM_HERE); |
| 439 | 455 |
| 440 // Drag selection handle 2 across selection handle 1. | 456 // Drag selection handle 2 across selection handle 1. |
| 441 x = gfx::Canvas::GetStringWidth(ASCIIToUTF16("with selected "), font_list); | 457 x = gfx::Canvas::GetStringWidth(ASCIIToUTF16("with selected "), font_list); |
| 442 SimulateSelectionHandleDrag(gfx::Vector2d(x, 0), 2); | 458 SimulateSelectionHandleDrag(gfx::Vector2d(x, 0), 2); |
| 443 EXPECT_EQ("selected ", UTF16ToUTF8(textfield_->GetSelectedText())); | 459 EXPECT_EQ("selected ", UTF16ToUTF8(textfield_->GetSelectedText())); |
| 444 VerifyHandlePositions(false, true, FROM_HERE); | 460 VerifyHandlePositions(false, true, FROM_HERE); |
| 445 } | 461 } |
| 446 | 462 |
| 447 TEST_F(TouchSelectionControllerImplTest, SelectRectInBidiCallbackTest) { | 463 TEST_F(TouchSelectionControllerImplTest, SelectRectInBidiCallbackTest) { |
| 464 // TODO: see comment in SetUp(). |
| 465 if (IsAuraMusClient()) |
| 466 return; |
| 467 |
| 448 CreateTextfield(); | 468 CreateTextfield(); |
| 449 textfield_->SetText(WideToUTF16(L"abc\x05e1\x05e2\x05e3" L"def")); | 469 textfield_->SetText(WideToUTF16(L"abc\x05e1\x05e2\x05e3" L"def")); |
| 450 // Tap the textfield to invoke touch selection. | 470 // Tap the textfield to invoke touch selection. |
| 451 ui::GestureEventDetails details(ui::ET_GESTURE_TAP); | 471 ui::GestureEventDetails details(ui::ET_GESTURE_TAP); |
| 452 details.set_tap_count(1); | 472 details.set_tap_count(1); |
| 453 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), details); | 473 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), details); |
| 454 textfield_->OnGestureEvent(&tap); | 474 textfield_->OnGestureEvent(&tap); |
| 455 | 475 |
| 456 // Select [c] from left to right. | 476 // Select [c] from left to right. |
| 457 textfield_->SelectRange(gfx::Range(2, 3)); | 477 textfield_->SelectRange(gfx::Range(2, 3)); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 | 586 |
| 567 // Drag selection handle 2 to right by 1 char. | 587 // Drag selection handle 2 to right by 1 char. |
| 568 x = gfx::Canvas::GetStringWidth(WideToUTF16(L"\x05e2"), font_list); | 588 x = gfx::Canvas::GetStringWidth(WideToUTF16(L"\x05e2"), font_list); |
| 569 SimulateSelectionHandleDrag(gfx::Vector2d(x, 0), 2); | 589 SimulateSelectionHandleDrag(gfx::Vector2d(x, 0), 2); |
| 570 EXPECT_EQ(WideToUTF16(L"c\x05e1"), textfield_->GetSelectedText()); | 590 EXPECT_EQ(WideToUTF16(L"c\x05e1"), textfield_->GetSelectedText()); |
| 571 VerifyHandlePositions(false, false, FROM_HERE); | 591 VerifyHandlePositions(false, false, FROM_HERE); |
| 572 } | 592 } |
| 573 | 593 |
| 574 TEST_F(TouchSelectionControllerImplTest, | 594 TEST_F(TouchSelectionControllerImplTest, |
| 575 HiddenSelectionHandleRetainsCursorPosition) { | 595 HiddenSelectionHandleRetainsCursorPosition) { |
| 596 // TODO: see comment in SetUp(). |
| 597 if (IsAuraMusClient()) |
| 598 return; |
| 599 |
| 576 static const uint32_t selection_start = 10u; | 600 static const uint32_t selection_start = 10u; |
| 577 SetupSelectionInvisibleHandle(selection_start); | 601 SetupSelectionInvisibleHandle(selection_start); |
| 578 // Drag the visible handle around and make sure the selection end point of the | 602 // Drag the visible handle around and make sure the selection end point of the |
| 579 // invisible handle does not change. | 603 // invisible handle does not change. |
| 580 size_t visible_handle_position = textfield_->GetSelectedRange().end(); | 604 size_t visible_handle_position = textfield_->GetSelectedRange().end(); |
| 581 for (int i = 0; i < 10; ++i) { | 605 for (int i = 0; i < 10; ++i) { |
| 582 static const int drag_diff = -10; | 606 static const int drag_diff = -10; |
| 583 SimulateSelectionHandleDrag(gfx::Vector2d(drag_diff, 0), 2); | 607 SimulateSelectionHandleDrag(gfx::Vector2d(drag_diff, 0), 2); |
| 584 // Make sure that the visible handle is being dragged. | 608 // Make sure that the visible handle is being dragged. |
| 585 EXPECT_NE(visible_handle_position, textfield_->GetSelectedRange().end()); | 609 EXPECT_NE(visible_handle_position, textfield_->GetSelectedRange().end()); |
| 586 visible_handle_position = textfield_->GetSelectedRange().end(); | 610 visible_handle_position = textfield_->GetSelectedRange().end(); |
| 587 EXPECT_EQ((size_t) 10, textfield_->GetSelectedRange().start()); | 611 EXPECT_EQ((size_t) 10, textfield_->GetSelectedRange().start()); |
| 588 } | 612 } |
| 589 } | 613 } |
| 590 | 614 |
| 591 // Tests that we can handle the hidden handle getting exposed as a result of a | 615 // Tests that we can handle the hidden handle getting exposed as a result of a |
| 592 // drag and that it maintains the correct orientation when exposed. | 616 // drag and that it maintains the correct orientation when exposed. |
| 593 TEST_F(TouchSelectionControllerImplTest, HiddenSelectionHandleExposed) { | 617 TEST_F(TouchSelectionControllerImplTest, HiddenSelectionHandleExposed) { |
| 618 // TODO: see comment in SetUp(). |
| 619 if (IsAuraMusClient()) |
| 620 return; |
| 621 |
| 594 static const uint32_t selection_start = 0u; | 622 static const uint32_t selection_start = 0u; |
| 595 SetupSelectionInvisibleHandle(selection_start); | 623 SetupSelectionInvisibleHandle(selection_start); |
| 596 | 624 |
| 597 // Drag the handle until the selection shrinks such that the other handle | 625 // Drag the handle until the selection shrinks such that the other handle |
| 598 // becomes visible. | 626 // becomes visible. |
| 599 while (!IsSelectionHandle1Visible()) { | 627 while (!IsSelectionHandle1Visible()) { |
| 600 static const int drag_diff = -10; | 628 static const int drag_diff = -10; |
| 601 SimulateSelectionHandleDrag(gfx::Vector2d(drag_diff, 0), 2); | 629 SimulateSelectionHandleDrag(gfx::Vector2d(drag_diff, 0), 2); |
| 602 } | 630 } |
| 603 | 631 |
| 604 // Confirm that the exposed handle maintains the LEFT orientation | 632 // Confirm that the exposed handle maintains the LEFT orientation |
| 605 // (and does not reset to gfx::SelectionBound::Type::CENTER). | 633 // (and does not reset to gfx::SelectionBound::Type::CENTER). |
| 606 EXPECT_EQ(gfx::SelectionBound::Type::LEFT, GetSelectionHandle1Type()); | 634 EXPECT_EQ(gfx::SelectionBound::Type::LEFT, GetSelectionHandle1Type()); |
| 607 } | 635 } |
| 608 | 636 |
| 609 TEST_F(TouchSelectionControllerImplTest, | 637 TEST_F(TouchSelectionControllerImplTest, |
| 610 DoubleTapInTextfieldWithCursorHandleShouldSelectText) { | 638 DoubleTapInTextfieldWithCursorHandleShouldSelectText) { |
| 639 // TODO: see comment in SetUp(). |
| 640 if (IsAuraMusClient()) |
| 641 return; |
| 642 |
| 611 CreateTextfield(); | 643 CreateTextfield(); |
| 612 textfield_->SetText(ASCIIToUTF16("some text")); | 644 textfield_->SetText(ASCIIToUTF16("some text")); |
| 613 ui::test::EventGenerator generator( | 645 ui::test::EventGenerator generator( |
| 614 textfield_->GetWidget()->GetNativeView()->GetRootWindow()); | 646 textfield_->GetWidget()->GetNativeView()->GetRootWindow()); |
| 615 | 647 |
| 616 // Tap the textfield to invoke touch selection. | 648 // Tap the textfield to invoke touch selection. |
| 617 generator.GestureTapAt(gfx::Point(10, 10)); | 649 generator.GestureTapAt(gfx::Point(10, 10)); |
| 618 | 650 |
| 619 // Cursor handle should be visible. | 651 // Cursor handle should be visible. |
| 620 EXPECT_FALSE(textfield_->HasSelection()); | 652 EXPECT_FALSE(textfield_->HasSelection()); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 //gfx::Rect cursor_rect_; | 732 //gfx::Rect cursor_rect_; |
| 701 gfx::SelectionBound cursor_bound_; | 733 gfx::SelectionBound cursor_bound_; |
| 702 | 734 |
| 703 DISALLOW_COPY_AND_ASSIGN(TestTouchEditable); | 735 DISALLOW_COPY_AND_ASSIGN(TestTouchEditable); |
| 704 }; | 736 }; |
| 705 | 737 |
| 706 // Tests if the touch editing handle is shown or hidden properly according to | 738 // Tests if the touch editing handle is shown or hidden properly according to |
| 707 // the cursor position relative to the client boundaries. | 739 // the cursor position relative to the client boundaries. |
| 708 TEST_F(TouchSelectionControllerImplTest, | 740 TEST_F(TouchSelectionControllerImplTest, |
| 709 VisibilityOfHandleRegardingClientBounds) { | 741 VisibilityOfHandleRegardingClientBounds) { |
| 742 // TODO: see comment in SetUp(). |
| 743 if (IsAuraMusClient()) |
| 744 return; |
| 745 |
| 710 CreateWidget(); | 746 CreateWidget(); |
| 711 | 747 |
| 712 TestTouchEditable touch_editable(widget_->GetNativeView()); | 748 TestTouchEditable touch_editable(widget_->GetNativeView()); |
| 713 std::unique_ptr<ui::TouchEditingControllerDeprecated> | 749 std::unique_ptr<ui::TouchEditingControllerDeprecated> |
| 714 touch_selection_controller( | 750 touch_selection_controller( |
| 715 ui::TouchEditingControllerDeprecated::Create(&touch_editable)); | 751 ui::TouchEditingControllerDeprecated::Create(&touch_editable)); |
| 716 | 752 |
| 717 touch_editable.set_bounds(gfx::Rect(0, 0, 100, 20)); | 753 touch_editable.set_bounds(gfx::Rect(0, 0, 100, 20)); |
| 718 | 754 |
| 719 // Put the cursor completely inside the client bounds. Handle should be | 755 // Put the cursor completely inside the client bounds. Handle should be |
| (...skipping 27 matching lines...) Expand all Loading... |
| 747 // out of the client bounds. Handle should be hidden. | 783 // out of the client bounds. Handle should be hidden. |
| 748 touch_editable.set_cursor_rect( | 784 touch_editable.set_cursor_rect( |
| 749 gfx::RectF(2.f, kBarBottomAllowance + 1.f, 1.f, 20.f)); | 785 gfx::RectF(2.f, kBarBottomAllowance + 1.f, 1.f, 20.f)); |
| 750 touch_selection_controller->SelectionChanged(); | 786 touch_selection_controller->SelectionChanged(); |
| 751 EXPECT_FALSE(IsCursorHandleVisibleFor(touch_selection_controller.get())); | 787 EXPECT_FALSE(IsCursorHandleVisibleFor(touch_selection_controller.get())); |
| 752 | 788 |
| 753 touch_selection_controller.reset(); | 789 touch_selection_controller.reset(); |
| 754 } | 790 } |
| 755 | 791 |
| 756 TEST_F(TouchSelectionControllerImplTest, HandlesStackAboveParent) { | 792 TEST_F(TouchSelectionControllerImplTest, HandlesStackAboveParent) { |
| 793 // TODO: see comment in SetUp(). |
| 794 if (IsAuraMusClient()) |
| 795 return; |
| 796 |
| 757 ui::EventTarget* root = GetContext(); | 797 ui::EventTarget* root = GetContext(); |
| 758 ui::EventTargeter* targeter = root->GetEventTargeter(); | 798 ui::EventTargeter* targeter = root->GetEventTargeter(); |
| 759 | 799 |
| 760 // Create the first window containing a Views::Textfield. | 800 // Create the first window containing a Views::Textfield. |
| 761 CreateTextfield(); | 801 CreateTextfield(); |
| 762 aura::Window* window1 = textfield_widget_->GetNativeView(); | 802 aura::Window* window1 = textfield_widget_->GetNativeView(); |
| 763 | 803 |
| 764 // Start touch editing, check that the handle is above the first window, and | 804 // Start touch editing, check that the handle is above the first window, and |
| 765 // end touch editing. | 805 // end touch editing. |
| 766 StartTouchEditing(); | 806 StartTouchEditing(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 785 // Move the first window to top and check that the handle is kept above the | 825 // Move the first window to top and check that the handle is kept above the |
| 786 // first window. | 826 // first window. |
| 787 window1->GetRootWindow()->StackChildAtTop(window1); | 827 window1->GetRootWindow()->StackChildAtTop(window1); |
| 788 ui::MouseEvent test_event3(ui::ET_MOUSE_MOVED, test_point, test_point, | 828 ui::MouseEvent test_event3(ui::ET_MOUSE_MOVED, test_point, test_point, |
| 789 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 829 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 790 EXPECT_EQ(GetCursorHandleNativeView(), | 830 EXPECT_EQ(GetCursorHandleNativeView(), |
| 791 targeter->FindTargetForEvent(root, &test_event3)); | 831 targeter->FindTargetForEvent(root, &test_event3)); |
| 792 } | 832 } |
| 793 | 833 |
| 794 TEST_F(TouchSelectionControllerImplTest, MouseEventDeactivatesTouchSelection) { | 834 TEST_F(TouchSelectionControllerImplTest, MouseEventDeactivatesTouchSelection) { |
| 835 // TODO: see comment in SetUp(). |
| 836 if (IsAuraMusClient()) |
| 837 return; |
| 838 |
| 795 CreateTextfield(); | 839 CreateTextfield(); |
| 796 EXPECT_FALSE(GetSelectionController()); | 840 EXPECT_FALSE(GetSelectionController()); |
| 797 | 841 |
| 798 ui::test::EventGenerator generator( | 842 ui::test::EventGenerator generator( |
| 799 textfield_widget_->GetNativeView()->GetRootWindow()); | 843 textfield_widget_->GetNativeView()->GetRootWindow()); |
| 800 | 844 |
| 801 generator.set_current_location(gfx::Point(5, 5)); | 845 generator.set_current_location(gfx::Point(5, 5)); |
| 802 RunPendingMessages(); | 846 RunPendingMessages(); |
| 803 | 847 |
| 804 // Start touch editing; then move mouse over the textfield and ensure it | 848 // Start touch editing; then move mouse over the textfield and ensure it |
| (...skipping 21 matching lines...) Expand all Loading... |
| 826 // Start touch editing; then move mouse out of the textfield and window and | 870 // Start touch editing; then move mouse out of the textfield and window and |
| 827 // ensure it deactivates touch selection. | 871 // ensure it deactivates touch selection. |
| 828 StartTouchEditing(); | 872 StartTouchEditing(); |
| 829 EXPECT_TRUE(GetSelectionController()); | 873 EXPECT_TRUE(GetSelectionController()); |
| 830 generator.MoveMouseTo(5, 505); | 874 generator.MoveMouseTo(5, 505); |
| 831 RunPendingMessages(); | 875 RunPendingMessages(); |
| 832 EXPECT_FALSE(GetSelectionController()); | 876 EXPECT_FALSE(GetSelectionController()); |
| 833 } | 877 } |
| 834 | 878 |
| 835 TEST_F(TouchSelectionControllerImplTest, MouseCaptureChangedEventIgnored) { | 879 TEST_F(TouchSelectionControllerImplTest, MouseCaptureChangedEventIgnored) { |
| 880 // TODO: see comment in SetUp(). |
| 881 if (IsAuraMusClient()) |
| 882 return; |
| 883 |
| 836 CreateTextfield(); | 884 CreateTextfield(); |
| 837 EXPECT_FALSE(GetSelectionController()); | 885 EXPECT_FALSE(GetSelectionController()); |
| 838 | 886 |
| 839 ui::test::EventGenerator generator( | 887 ui::test::EventGenerator generator( |
| 840 textfield_widget_->GetNativeView()->GetRootWindow()); | 888 textfield_widget_->GetNativeView()->GetRootWindow()); |
| 841 RunPendingMessages(); | 889 RunPendingMessages(); |
| 842 | 890 |
| 843 // Start touch editing; then generate a mouse-capture-changed event and ensure | 891 // Start touch editing; then generate a mouse-capture-changed event and ensure |
| 844 // it does not deactivate touch selection. | 892 // it does not deactivate touch selection. |
| 845 StartTouchEditing(); | 893 StartTouchEditing(); |
| 846 EXPECT_TRUE(GetSelectionController()); | 894 EXPECT_TRUE(GetSelectionController()); |
| 847 ui::MouseEvent capture_changed(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(5, 5), | 895 ui::MouseEvent capture_changed(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(5, 5), |
| 848 gfx::Point(5, 5), base::TimeTicks(), 0, 0); | 896 gfx::Point(5, 5), base::TimeTicks(), 0, 0); |
| 849 generator.Dispatch(&capture_changed); | 897 generator.Dispatch(&capture_changed); |
| 850 RunPendingMessages(); | 898 RunPendingMessages(); |
| 851 EXPECT_TRUE(GetSelectionController()); | 899 EXPECT_TRUE(GetSelectionController()); |
| 852 } | 900 } |
| 853 | 901 |
| 854 TEST_F(TouchSelectionControllerImplTest, KeyEventDeactivatesTouchSelection) { | 902 TEST_F(TouchSelectionControllerImplTest, KeyEventDeactivatesTouchSelection) { |
| 903 // TODO: see comment in SetUp(). |
| 904 if (IsAuraMusClient()) |
| 905 return; |
| 906 |
| 855 CreateTextfield(); | 907 CreateTextfield(); |
| 856 EXPECT_FALSE(GetSelectionController()); | 908 EXPECT_FALSE(GetSelectionController()); |
| 857 | 909 |
| 858 ui::test::EventGenerator generator( | 910 ui::test::EventGenerator generator( |
| 859 textfield_widget_->GetNativeView()->GetRootWindow()); | 911 textfield_widget_->GetNativeView()->GetRootWindow()); |
| 860 | 912 |
| 861 RunPendingMessages(); | 913 RunPendingMessages(); |
| 862 | 914 |
| 863 // Start touch editing; then press a key and ensure it deactivates touch | 915 // Start touch editing; then press a key and ensure it deactivates touch |
| 864 // selection. | 916 // selection. |
| 865 StartTouchEditing(); | 917 StartTouchEditing(); |
| 866 EXPECT_TRUE(GetSelectionController()); | 918 EXPECT_TRUE(GetSelectionController()); |
| 867 generator.PressKey(ui::VKEY_A, 0); | 919 generator.PressKey(ui::VKEY_A, 0); |
| 868 RunPendingMessages(); | 920 RunPendingMessages(); |
| 869 EXPECT_FALSE(GetSelectionController()); | 921 EXPECT_FALSE(GetSelectionController()); |
| 870 } | 922 } |
| 871 | 923 |
| 872 } // namespace views | 924 } // namespace views |
| OLD | NEW |