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

Side by Side Diff: ui/views/touchui/touch_selection_controller_impl_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698