| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "services/ui/ws/event_dispatcher.h" | 5 #include "services/ui/ws/event_dispatcher.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 test_event_dispatcher_delegate_ = | 330 test_event_dispatcher_delegate_ = |
| 331 base::MakeUnique<TestEventDispatcherDelegate>(this); | 331 base::MakeUnique<TestEventDispatcherDelegate>(this); |
| 332 event_dispatcher_ = | 332 event_dispatcher_ = |
| 333 base::MakeUnique<EventDispatcher>(test_event_dispatcher_delegate_.get()); | 333 base::MakeUnique<EventDispatcher>(test_event_dispatcher_delegate_.get()); |
| 334 test_event_dispatcher_delegate_->set_root(root_window_.get()); | 334 test_event_dispatcher_delegate_->set_root(root_window_.get()); |
| 335 } | 335 } |
| 336 | 336 |
| 337 TEST_F(EventDispatcherTest, ProcessEvent) { | 337 TEST_F(EventDispatcherTest, ProcessEvent) { |
| 338 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 338 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 339 | 339 |
| 340 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 340 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 341 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 341 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 342 | 342 |
| 343 // Send event that is over child. | 343 // Send event that is over child. |
| 344 const ui::PointerEvent ui_event(ui::MouseEvent( | 344 const ui::PointerEvent ui_event(ui::MouseEvent( |
| 345 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), | 345 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 346 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 346 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 347 event_dispatcher()->ProcessEvent(ui_event, | 347 event_dispatcher()->ProcessEvent(ui_event, |
| 348 EventDispatcher::AcceleratorMatchPhase::ANY); | 348 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 349 | 349 |
| 350 std::unique_ptr<DispatchedEventDetails> details = | 350 std::unique_ptr<DispatchedEventDetails> details = |
| 351 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 351 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 543 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 543 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 544 ASSERT_TRUE(details); | 544 ASSERT_TRUE(details); |
| 545 ASSERT_TRUE(details->accelerator); | 545 ASSERT_TRUE(details->accelerator); |
| 546 EXPECT_EQ(post_id, details->accelerator->id()); | 546 EXPECT_EQ(post_id, details->accelerator->id()); |
| 547 } | 547 } |
| 548 | 548 |
| 549 TEST_F(EventDispatcherTest, Capture) { | 549 TEST_F(EventDispatcherTest, Capture) { |
| 550 ServerWindow* root = root_window(); | 550 ServerWindow* root = root_window(); |
| 551 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 551 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 552 | 552 |
| 553 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 553 root->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 554 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 554 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 555 | 555 |
| 556 MouseEventTest tests[] = { | 556 MouseEventTest tests[] = { |
| 557 // Send a mouse down event over child. | 557 // Send a mouse down event over child. |
| 558 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), | 558 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), |
| 559 gfx::Point(20, 25), base::TimeTicks(), | 559 gfx::Point(20, 25), base::TimeTicks(), |
| 560 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 560 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), |
| 561 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, | 561 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, |
| 562 gfx::Point(), gfx::Point()}, | 562 gfx::Point(), gfx::Point()}, |
| 563 | 563 |
| 564 // Capture should be activated. Let's send a mouse move outside the bounds | 564 // Capture should be activated. Let's send a mouse move outside the bounds |
| (...skipping 20 matching lines...) Expand all Loading... |
| 585 gfx::Point(50, 50), gfx::Point(50, 50)}, | 585 gfx::Point(50, 50), gfx::Point(50, 50)}, |
| 586 | 586 |
| 587 }; | 587 }; |
| 588 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 588 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 589 tests, arraysize(tests)); | 589 tests, arraysize(tests)); |
| 590 } | 590 } |
| 591 | 591 |
| 592 TEST_F(EventDispatcherTest, CaptureMultipleMouseButtons) { | 592 TEST_F(EventDispatcherTest, CaptureMultipleMouseButtons) { |
| 593 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 593 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 594 | 594 |
| 595 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 595 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 596 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 596 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 597 | 597 |
| 598 MouseEventTest tests[] = { | 598 MouseEventTest tests[] = { |
| 599 // Send a mouse down event over child with a left mouse button | 599 // Send a mouse down event over child with a left mouse button |
| 600 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), | 600 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), |
| 601 gfx::Point(20, 25), base::TimeTicks(), | 601 gfx::Point(20, 25), base::TimeTicks(), |
| 602 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 602 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), |
| 603 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, | 603 child.get(), gfx::Point(20, 25), gfx::Point(10, 15), nullptr, |
| 604 gfx::Point(), gfx::Point()}, | 604 gfx::Point(), gfx::Point()}, |
| 605 | 605 |
| 606 // Capture should be activated. Let's send a mouse move outside the bounds | 606 // Capture should be activated. Let's send a mouse move outside the bounds |
| (...skipping 21 matching lines...) Expand all Loading... |
| 628 gfx::Point(), gfx::Point()}, | 628 gfx::Point(), gfx::Point()}, |
| 629 | 629 |
| 630 }; | 630 }; |
| 631 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 631 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 632 tests, arraysize(tests)); | 632 tests, arraysize(tests)); |
| 633 } | 633 } |
| 634 | 634 |
| 635 TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) { | 635 TEST_F(EventDispatcherTest, ClientAreaGoesToOwner) { |
| 636 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 636 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 637 | 637 |
| 638 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 638 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 639 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 639 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 640 | 640 |
| 641 child->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); | 641 child->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); |
| 642 | 642 |
| 643 TestEventDispatcherDelegate* event_dispatcher_delegate = | 643 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 644 test_event_dispatcher_delegate(); | 644 test_event_dispatcher_delegate(); |
| 645 EventDispatcher* dispatcher = event_dispatcher(); | 645 EventDispatcher* dispatcher = event_dispatcher(); |
| 646 | 646 |
| 647 // Start move loop by sending mouse event over non-client area. | 647 // Start move loop by sending mouse event over non-client area. |
| 648 const ui::PointerEvent press_event(ui::MouseEvent( | 648 const ui::PointerEvent press_event(ui::MouseEvent( |
| 649 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), | 649 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 701 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 702 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 702 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 703 ASSERT_EQ(child.get(), details->window); | 703 ASSERT_EQ(child.get(), details->window); |
| 704 EXPECT_TRUE(details->IsClientArea()); | 704 EXPECT_TRUE(details->IsClientArea()); |
| 705 EXPECT_EQ(ui::ET_POINTER_DOWN, details->event->type()); | 705 EXPECT_EQ(ui::ET_POINTER_DOWN, details->event->type()); |
| 706 } | 706 } |
| 707 | 707 |
| 708 TEST_F(EventDispatcherTest, AdditionalClientArea) { | 708 TEST_F(EventDispatcherTest, AdditionalClientArea) { |
| 709 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 709 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 710 | 710 |
| 711 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 711 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 712 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 712 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 713 | 713 |
| 714 std::vector<gfx::Rect> additional_client_areas; | 714 std::vector<gfx::Rect> additional_client_areas; |
| 715 additional_client_areas.push_back(gfx::Rect(18, 0, 2, 2)); | 715 additional_client_areas.push_back(gfx::Rect(18, 0, 2, 2)); |
| 716 child->SetClientArea(gfx::Insets(5, 5, 5, 5), additional_client_areas); | 716 child->SetClientArea(gfx::Insets(5, 5, 5, 5), additional_client_areas); |
| 717 | 717 |
| 718 TestEventDispatcherDelegate* event_dispatcher_delegate = | 718 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 719 test_event_dispatcher_delegate(); | 719 test_event_dispatcher_delegate(); |
| 720 // Press in the additional client area, it should go to the child. | 720 // Press in the additional client area, it should go to the child. |
| 721 const ui::PointerEvent press_event(ui::MouseEvent( | 721 const ui::PointerEvent press_event(ui::MouseEvent( |
| 722 ui::ET_MOUSE_PRESSED, gfx::Point(28, 11), gfx::Point(28, 11), | 722 ui::ET_MOUSE_PRESSED, gfx::Point(28, 11), gfx::Point(28, 11), |
| 723 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 723 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 724 event_dispatcher()->ProcessEvent(press_event, | 724 event_dispatcher()->ProcessEvent(press_event, |
| 725 EventDispatcher::AcceleratorMatchPhase::ANY); | 725 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 726 | 726 |
| 727 // Events should target child and be in the client area. | 727 // Events should target child and be in the client area. |
| 728 std::unique_ptr<DispatchedEventDetails> details = | 728 std::unique_ptr<DispatchedEventDetails> details = |
| 729 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 729 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 730 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 730 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 731 ASSERT_EQ(child.get(), details->window); | 731 ASSERT_EQ(child.get(), details->window); |
| 732 EXPECT_TRUE(details->IsClientArea()); | 732 EXPECT_TRUE(details->IsClientArea()); |
| 733 } | 733 } |
| 734 | 734 |
| 735 TEST_F(EventDispatcherTest, HitTestMask) { | 735 TEST_F(EventDispatcherTest, HitTestMask) { |
| 736 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 736 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 737 | 737 |
| 738 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 738 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 739 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 739 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 740 child->SetHitTestMask(gfx::Rect(2, 2, 16, 16)); | 740 child->SetHitTestMask(gfx::Rect(2, 2, 16, 16)); |
| 741 | 741 |
| 742 // Move in the masked area. | 742 // Move in the masked area. |
| 743 const ui::PointerEvent move1(ui::MouseEvent( | 743 const ui::PointerEvent move1(ui::MouseEvent( |
| 744 ui::ET_MOUSE_MOVED, gfx::Point(11, 11), gfx::Point(11, 11), | 744 ui::ET_MOUSE_MOVED, gfx::Point(11, 11), gfx::Point(11, 11), |
| 745 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); | 745 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, 0)); |
| 746 event_dispatcher()->ProcessEvent(move1, | 746 event_dispatcher()->ProcessEvent(move1, |
| 747 EventDispatcher::AcceleratorMatchPhase::ANY); | 747 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 748 | 748 |
| 749 // Event went through the child window and hit the root. | 749 // Event went through the child window and hit the root. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 770 std::unique_ptr<DispatchedEventDetails> details3 = | 770 std::unique_ptr<DispatchedEventDetails> details3 = |
| 771 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 771 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 772 EXPECT_EQ(child.get(), details3->window); | 772 EXPECT_EQ(child.get(), details3->window); |
| 773 EXPECT_TRUE(details3->IsClientArea()); | 773 EXPECT_TRUE(details3->IsClientArea()); |
| 774 } | 774 } |
| 775 | 775 |
| 776 TEST_F(EventDispatcherTest, DontFocusOnSecondDown) { | 776 TEST_F(EventDispatcherTest, DontFocusOnSecondDown) { |
| 777 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); | 777 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| 778 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); | 778 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| 779 | 779 |
| 780 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 780 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 781 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 781 child1->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 782 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); | 782 child2->SetBounds(gfx::Rect(50, 51, 11, 12), cc::LocalFrameId()); |
| 783 | 783 |
| 784 TestEventDispatcherDelegate* event_dispatcher_delegate = | 784 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 785 test_event_dispatcher_delegate(); | 785 test_event_dispatcher_delegate(); |
| 786 EventDispatcher* dispatcher = event_dispatcher(); | 786 EventDispatcher* dispatcher = event_dispatcher(); |
| 787 | 787 |
| 788 // Press on child1. First press event should change focus. | 788 // Press on child1. First press event should change focus. |
| 789 const ui::PointerEvent press_event(ui::MouseEvent( | 789 const ui::PointerEvent press_event(ui::MouseEvent( |
| 790 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), | 790 ui::ET_MOUSE_PRESSED, gfx::Point(12, 12), gfx::Point(12, 12), |
| 791 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 791 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 792 dispatcher->ProcessEvent(press_event, | 792 dispatcher->ProcessEvent(press_event, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 807 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 807 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 808 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 808 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 809 EXPECT_EQ(child2.get(), details->window); | 809 EXPECT_EQ(child2.get(), details->window); |
| 810 EXPECT_EQ(nullptr, event_dispatcher_delegate->GetAndClearLastFocusedWindow()); | 810 EXPECT_EQ(nullptr, event_dispatcher_delegate->GetAndClearLastFocusedWindow()); |
| 811 } | 811 } |
| 812 | 812 |
| 813 TEST_F(EventDispatcherTest, TwoPointersActive) { | 813 TEST_F(EventDispatcherTest, TwoPointersActive) { |
| 814 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); | 814 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| 815 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); | 815 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| 816 | 816 |
| 817 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 817 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 818 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 818 child1->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 819 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); | 819 child2->SetBounds(gfx::Rect(50, 51, 11, 12), cc::LocalFrameId()); |
| 820 | 820 |
| 821 TestEventDispatcherDelegate* event_dispatcher_delegate = | 821 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 822 test_event_dispatcher_delegate(); | 822 test_event_dispatcher_delegate(); |
| 823 EventDispatcher* dispatcher = event_dispatcher(); | 823 EventDispatcher* dispatcher = event_dispatcher(); |
| 824 | 824 |
| 825 // Press on child1. | 825 // Press on child1. |
| 826 const ui::PointerEvent touch_event1(ui::TouchEvent( | 826 const ui::PointerEvent touch_event1(ui::TouchEvent( |
| 827 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeTicks())); | 827 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeTicks())); |
| 828 dispatcher->ProcessEvent(touch_event1, | 828 dispatcher->ProcessEvent(touch_event1, |
| 829 EventDispatcher::AcceleratorMatchPhase::ANY); | 829 EventDispatcher::AcceleratorMatchPhase::ANY); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), 2, base::TimeTicks())); | 872 ui::ET_TOUCH_PRESSED, gfx::Point(54, 55), 2, base::TimeTicks())); |
| 873 dispatcher->ProcessEvent(touch_event3, | 873 dispatcher->ProcessEvent(touch_event3, |
| 874 EventDispatcher::AcceleratorMatchPhase::ANY); | 874 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 875 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 875 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 876 EXPECT_EQ(child2.get(), details->window); | 876 EXPECT_EQ(child2.get(), details->window); |
| 877 } | 877 } |
| 878 | 878 |
| 879 TEST_F(EventDispatcherTest, DestroyWindowWhileGettingEvents) { | 879 TEST_F(EventDispatcherTest, DestroyWindowWhileGettingEvents) { |
| 880 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 880 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 881 | 881 |
| 882 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 882 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 883 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 883 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 884 | 884 |
| 885 TestEventDispatcherDelegate* event_dispatcher_delegate = | 885 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 886 test_event_dispatcher_delegate(); | 886 test_event_dispatcher_delegate(); |
| 887 EventDispatcher* dispatcher = event_dispatcher(); | 887 EventDispatcher* dispatcher = event_dispatcher(); |
| 888 | 888 |
| 889 // Press on child. | 889 // Press on child. |
| 890 const ui::PointerEvent touch_event1(ui::TouchEvent( | 890 const ui::PointerEvent touch_event1(ui::TouchEvent( |
| 891 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeTicks())); | 891 ui::ET_TOUCH_PRESSED, gfx::Point(12, 13), 1, base::TimeTicks())); |
| 892 dispatcher->ProcessEvent(touch_event1, | 892 dispatcher->ProcessEvent(touch_event1, |
| 893 EventDispatcher::AcceleratorMatchPhase::ANY); | 893 EventDispatcher::AcceleratorMatchPhase::ANY); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 904 dispatcher->ProcessEvent(drag_event1, | 904 dispatcher->ProcessEvent(drag_event1, |
| 905 EventDispatcher::AcceleratorMatchPhase::ANY); | 905 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 906 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 906 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 907 EXPECT_EQ(nullptr, details.get()); | 907 EXPECT_EQ(nullptr, details.get()); |
| 908 } | 908 } |
| 909 | 909 |
| 910 TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) { | 910 TEST_F(EventDispatcherTest, MouseInExtendedHitTestRegion) { |
| 911 ServerWindow* root = root_window(); | 911 ServerWindow* root = root_window(); |
| 912 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 912 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 913 | 913 |
| 914 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 914 root->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 915 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 915 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 916 | 916 |
| 917 TestEventDispatcherDelegate* event_dispatcher_delegate = | 917 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 918 test_event_dispatcher_delegate(); | 918 test_event_dispatcher_delegate(); |
| 919 EventDispatcher* dispatcher = event_dispatcher(); | 919 EventDispatcher* dispatcher = event_dispatcher(); |
| 920 | 920 |
| 921 // Send event that is not over child. | 921 // Send event that is not over child. |
| 922 const ui::PointerEvent ui_event(ui::MouseEvent( | 922 const ui::PointerEvent ui_event(ui::MouseEvent( |
| 923 ui::ET_MOUSE_PRESSED, gfx::Point(8, 9), gfx::Point(8, 9), | 923 ui::ET_MOUSE_PRESSED, gfx::Point(8, 9), gfx::Point(8, 9), |
| 924 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 924 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 925 dispatcher->ProcessEvent(ui_event, | 925 dispatcher->ProcessEvent(ui_event, |
| (...skipping 30 matching lines...) Expand all Loading... |
| 956 EXPECT_EQ(ui::ET_POINTER_DOWN, details->event->type()); | 956 EXPECT_EQ(ui::ET_POINTER_DOWN, details->event->type()); |
| 957 ASSERT_TRUE(details->event.get()); | 957 ASSERT_TRUE(details->event.get()); |
| 958 ASSERT_TRUE(details->event->IsPointerEvent()); | 958 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 959 EXPECT_EQ(gfx::Point(-2, -1), details->event->AsPointerEvent()->location()); | 959 EXPECT_EQ(gfx::Point(-2, -1), details->event->AsPointerEvent()->location()); |
| 960 } | 960 } |
| 961 | 961 |
| 962 TEST_F(EventDispatcherTest, WheelWhileDown) { | 962 TEST_F(EventDispatcherTest, WheelWhileDown) { |
| 963 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); | 963 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| 964 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); | 964 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| 965 | 965 |
| 966 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 966 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 967 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 967 child1->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 968 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); | 968 child2->SetBounds(gfx::Rect(50, 51, 11, 12), cc::LocalFrameId()); |
| 969 | 969 |
| 970 MouseEventTest tests[] = { | 970 MouseEventTest tests[] = { |
| 971 // Send a mouse down event over child1. | 971 // Send a mouse down event over child1. |
| 972 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), | 972 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), |
| 973 gfx::Point(15, 15), base::TimeTicks(), | 973 gfx::Point(15, 15), base::TimeTicks(), |
| 974 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 974 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), |
| 975 child1.get(), gfx::Point(15, 15), gfx::Point(5, 5), nullptr, | 975 child1.get(), gfx::Point(15, 15), gfx::Point(5, 5), nullptr, |
| 976 gfx::Point(), gfx::Point()}, | 976 gfx::Point(), gfx::Point()}, |
| 977 // Send mouse wheel over child2, should go to child1 as it has capture. | 977 // Send mouse wheel over child2, should go to child1 as it has capture. |
| 978 {ui::MouseWheelEvent(gfx::Vector2d(1, 0), gfx::Point(53, 54), | 978 {ui::MouseWheelEvent(gfx::Vector2d(1, 0), gfx::Point(53, 54), |
| 979 gfx::Point(53, 54), base::TimeTicks(), ui::EF_NONE, | 979 gfx::Point(53, 54), base::TimeTicks(), ui::EF_NONE, |
| 980 ui::EF_NONE), | 980 ui::EF_NONE), |
| 981 child1.get(), gfx::Point(53, 54), gfx::Point(43, 44), nullptr, | 981 child1.get(), gfx::Point(53, 54), gfx::Point(43, 44), nullptr, |
| 982 gfx::Point(), gfx::Point()}, | 982 gfx::Point(), gfx::Point()}, |
| 983 }; | 983 }; |
| 984 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 984 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 985 tests, arraysize(tests)); | 985 tests, arraysize(tests)); |
| 986 } | 986 } |
| 987 | 987 |
| 988 // Tests that when explicit capture has been set that all events go to the | 988 // Tests that when explicit capture has been set that all events go to the |
| 989 // designated window, and that when capture is cleared, events find the | 989 // designated window, and that when capture is cleared, events find the |
| 990 // appropriate target window. | 990 // appropriate target window. |
| 991 TEST_F(EventDispatcherTest, SetExplicitCapture) { | 991 TEST_F(EventDispatcherTest, SetExplicitCapture) { |
| 992 ServerWindow* root = root_window(); | 992 ServerWindow* root = root_window(); |
| 993 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 993 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 994 | 994 |
| 995 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 995 root->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 996 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 996 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 997 | 997 |
| 998 TestEventDispatcherDelegate* event_dispatcher_delegate = | 998 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 999 test_event_dispatcher_delegate(); | 999 test_event_dispatcher_delegate(); |
| 1000 EventDispatcher* dispatcher = event_dispatcher(); | 1000 EventDispatcher* dispatcher = event_dispatcher(); |
| 1001 | 1001 |
| 1002 { | 1002 { |
| 1003 // Send all pointer events to the child. | 1003 // Send all pointer events to the child. |
| 1004 dispatcher->SetCaptureWindow(child.get(), kClientAreaId); | 1004 dispatcher->SetCaptureWindow(child.get(), kClientAreaId); |
| 1005 | 1005 |
| 1006 // The mouse press should go to the child even though its outside its | 1006 // The mouse press should go to the child even though its outside its |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 ASSERT_EQ(root, details->window); | 1086 ASSERT_EQ(root, details->window); |
| 1087 } | 1087 } |
| 1088 } | 1088 } |
| 1089 | 1089 |
| 1090 // This test verifies that explicit capture overrides and resets implicit | 1090 // This test verifies that explicit capture overrides and resets implicit |
| 1091 // capture. | 1091 // capture. |
| 1092 TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) { | 1092 TEST_F(EventDispatcherTest, ExplicitCaptureOverridesImplicitCapture) { |
| 1093 ServerWindow* root = root_window(); | 1093 ServerWindow* root = root_window(); |
| 1094 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1094 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1095 | 1095 |
| 1096 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1096 root->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1097 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1097 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 1098 | 1098 |
| 1099 TestEventDispatcherDelegate* event_dispatcher_delegate = | 1099 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 1100 test_event_dispatcher_delegate(); | 1100 test_event_dispatcher_delegate(); |
| 1101 EventDispatcher* dispatcher = event_dispatcher(); | 1101 EventDispatcher* dispatcher = event_dispatcher(); |
| 1102 | 1102 |
| 1103 // Run some implicit capture tests. | 1103 // Run some implicit capture tests. |
| 1104 MouseEventTest tests[] = { | 1104 MouseEventTest tests[] = { |
| 1105 // Send a mouse down event over child with a left mouse button | 1105 // Send a mouse down event over child with a left mouse button |
| 1106 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), | 1106 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), |
| 1107 gfx::Point(20, 25), base::TimeTicks(), | 1107 gfx::Point(20, 25), base::TimeTicks(), |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1174 details = event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1175 ASSERT_TRUE(details); | 1175 ASSERT_TRUE(details); |
| 1176 ASSERT_EQ(root, details->window); | 1176 ASSERT_EQ(root, details->window); |
| 1177 ASSERT_TRUE(details->IsNonclientArea()); | 1177 ASSERT_TRUE(details->IsNonclientArea()); |
| 1178 } | 1178 } |
| 1179 | 1179 |
| 1180 // Tests that setting capture does delete active pointer targets for the capture | 1180 // Tests that setting capture does delete active pointer targets for the capture |
| 1181 // window. | 1181 // window. |
| 1182 TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { | 1182 TEST_F(EventDispatcherTest, CaptureUpdatesActivePointerTargets) { |
| 1183 ServerWindow* root = root_window(); | 1183 ServerWindow* root = root_window(); |
| 1184 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1184 root->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1185 | 1185 |
| 1186 EventDispatcher* dispatcher = event_dispatcher(); | 1186 EventDispatcher* dispatcher = event_dispatcher(); |
| 1187 { | 1187 { |
| 1188 const ui::PointerEvent press_event(ui::MouseEvent( | 1188 const ui::PointerEvent press_event(ui::MouseEvent( |
| 1189 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 1189 ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1190 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1190 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1191 dispatcher->ProcessEvent(press_event, | 1191 dispatcher->ProcessEvent(press_event, |
| 1192 EventDispatcher::AcceleratorMatchPhase::ANY); | 1192 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1193 | 1193 |
| 1194 std::unique_ptr<DispatchedEventDetails> details = | 1194 std::unique_ptr<DispatchedEventDetails> details = |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1213 EXPECT_FALSE(AreAnyPointersDown()); | 1213 EXPECT_FALSE(AreAnyPointersDown()); |
| 1214 EXPECT_FALSE(IsWindowPointerTarget(root)); | 1214 EXPECT_FALSE(IsWindowPointerTarget(root)); |
| 1215 } | 1215 } |
| 1216 | 1216 |
| 1217 // Tests that when explicit capture is changed, that the previous window with | 1217 // Tests that when explicit capture is changed, that the previous window with |
| 1218 // capture is no longer being observed. | 1218 // capture is no longer being observed. |
| 1219 TEST_F(EventDispatcherTest, UpdatingCaptureStopsObservingPreviousCapture) { | 1219 TEST_F(EventDispatcherTest, UpdatingCaptureStopsObservingPreviousCapture) { |
| 1220 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); | 1220 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| 1221 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); | 1221 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| 1222 | 1222 |
| 1223 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1223 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1224 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1224 child1->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 1225 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); | 1225 child2->SetBounds(gfx::Rect(50, 51, 11, 12), cc::LocalFrameId()); |
| 1226 | 1226 |
| 1227 EventDispatcher* dispatcher = event_dispatcher(); | 1227 EventDispatcher* dispatcher = event_dispatcher(); |
| 1228 ASSERT_FALSE(AreAnyPointersDown()); | 1228 ASSERT_FALSE(AreAnyPointersDown()); |
| 1229 ASSERT_FALSE(IsWindowPointerTarget(child1.get())); | 1229 ASSERT_FALSE(IsWindowPointerTarget(child1.get())); |
| 1230 ASSERT_FALSE(IsWindowPointerTarget(child2.get())); | 1230 ASSERT_FALSE(IsWindowPointerTarget(child2.get())); |
| 1231 dispatcher->SetCaptureWindow(child1.get(), kClientAreaId); | 1231 dispatcher->SetCaptureWindow(child1.get(), kClientAreaId); |
| 1232 dispatcher->SetCaptureWindow(child2.get(), kClientAreaId); | 1232 dispatcher->SetCaptureWindow(child2.get(), kClientAreaId); |
| 1233 EXPECT_EQ(child1.get(), | 1233 EXPECT_EQ(child1.get(), |
| 1234 test_event_dispatcher_delegate()->lost_capture_window()); | 1234 test_event_dispatcher_delegate()->lost_capture_window()); |
| 1235 | 1235 |
| 1236 // If observing does not stop during the capture update this crashes. | 1236 // If observing does not stop during the capture update this crashes. |
| 1237 child1->AddObserver(dispatcher); | 1237 child1->AddObserver(dispatcher); |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 // Tests that destroying a window with explicit capture clears the capture | 1240 // Tests that destroying a window with explicit capture clears the capture |
| 1241 // state. | 1241 // state. |
| 1242 TEST_F(EventDispatcherTest, DestroyingCaptureWindowRemovesExplicitCapture) { | 1242 TEST_F(EventDispatcherTest, DestroyingCaptureWindowRemovesExplicitCapture) { |
| 1243 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1243 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1244 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1244 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 1245 | 1245 |
| 1246 EventDispatcher* dispatcher = event_dispatcher(); | 1246 EventDispatcher* dispatcher = event_dispatcher(); |
| 1247 dispatcher->SetCaptureWindow(child.get(), kClientAreaId); | 1247 dispatcher->SetCaptureWindow(child.get(), kClientAreaId); |
| 1248 EXPECT_EQ(child.get(), dispatcher->capture_window()); | 1248 EXPECT_EQ(child.get(), dispatcher->capture_window()); |
| 1249 | 1249 |
| 1250 ServerWindow* lost_capture_window = child.get(); | 1250 ServerWindow* lost_capture_window = child.get(); |
| 1251 child.reset(); | 1251 child.reset(); |
| 1252 EXPECT_EQ(nullptr, dispatcher->capture_window()); | 1252 EXPECT_EQ(nullptr, dispatcher->capture_window()); |
| 1253 EXPECT_EQ(lost_capture_window, | 1253 EXPECT_EQ(lost_capture_window, |
| 1254 test_event_dispatcher_delegate()->lost_capture_window()); | 1254 test_event_dispatcher_delegate()->lost_capture_window()); |
| 1255 } | 1255 } |
| 1256 | 1256 |
| 1257 // Tests that when |client_id| is set for a window performing capture, that this | 1257 // Tests that when |client_id| is set for a window performing capture, that this |
| 1258 // preference is used regardless of whether an event targets the client region. | 1258 // preference is used regardless of whether an event targets the client region. |
| 1259 TEST_F(EventDispatcherTest, CaptureInNonClientAreaOverridesActualPoint) { | 1259 TEST_F(EventDispatcherTest, CaptureInNonClientAreaOverridesActualPoint) { |
| 1260 ServerWindow* root = root_window(); | 1260 ServerWindow* root = root_window(); |
| 1261 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1261 root->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1262 | 1262 |
| 1263 root->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); | 1263 root->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); |
| 1264 EventDispatcher* dispatcher = event_dispatcher(); | 1264 EventDispatcher* dispatcher = event_dispatcher(); |
| 1265 dispatcher->SetCaptureWindow(root, kNonclientAreaId); | 1265 dispatcher->SetCaptureWindow(root, kNonclientAreaId); |
| 1266 | 1266 |
| 1267 TestEventDispatcherDelegate* event_dispatcher_delegate = | 1267 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 1268 test_event_dispatcher_delegate(); | 1268 test_event_dispatcher_delegate(); |
| 1269 // Press in the client area, it should be marked as non client. | 1269 // Press in the client area, it should be marked as non client. |
| 1270 const ui::PointerEvent press_event(ui::MouseEvent( | 1270 const ui::PointerEvent press_event(ui::MouseEvent( |
| 1271 ui::ET_MOUSE_PRESSED, gfx::Point(6, 6), gfx::Point(6, 6), | 1271 ui::ET_MOUSE_PRESSED, gfx::Point(6, 6), gfx::Point(6, 6), |
| 1272 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1272 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1273 event_dispatcher()->ProcessEvent(press_event, | 1273 event_dispatcher()->ProcessEvent(press_event, |
| 1274 EventDispatcher::AcceleratorMatchPhase::ANY); | 1274 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1275 | 1275 |
| 1276 // Events should target child and be in the client area. | 1276 // Events should target child and be in the client area. |
| 1277 std::unique_ptr<DispatchedEventDetails> details = | 1277 std::unique_ptr<DispatchedEventDetails> details = |
| 1278 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 1278 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 1279 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 1279 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 1280 ASSERT_EQ(root, details->window); | 1280 ASSERT_EQ(root, details->window); |
| 1281 EXPECT_TRUE(details->IsNonclientArea()); | 1281 EXPECT_TRUE(details->IsNonclientArea()); |
| 1282 } | 1282 } |
| 1283 | 1283 |
| 1284 TEST_F(EventDispatcherTest, ProcessPointerEvents) { | 1284 TEST_F(EventDispatcherTest, ProcessPointerEvents) { |
| 1285 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1285 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1286 | 1286 |
| 1287 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1287 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1288 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1288 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 1289 | 1289 |
| 1290 { | 1290 { |
| 1291 const ui::PointerEvent pointer_event(ui::MouseEvent( | 1291 const ui::PointerEvent pointer_event(ui::MouseEvent( |
| 1292 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), | 1292 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 1293 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1293 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1294 event_dispatcher()->ProcessEvent( | 1294 event_dispatcher()->ProcessEvent( |
| 1295 pointer_event, EventDispatcher::AcceleratorMatchPhase::ANY); | 1295 pointer_event, EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1296 | 1296 |
| 1297 std::unique_ptr<DispatchedEventDetails> details = | 1297 std::unique_ptr<DispatchedEventDetails> details = |
| 1298 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1298 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1326 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1326 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1327 EXPECT_EQ(gfx::Point(25, 20), dispatched_event->root_location()); | 1327 EXPECT_EQ(gfx::Point(25, 20), dispatched_event->root_location()); |
| 1328 EXPECT_EQ(gfx::Point(15, 10), dispatched_event->location()); | 1328 EXPECT_EQ(gfx::Point(15, 10), dispatched_event->location()); |
| 1329 EXPECT_EQ(touch_id, dispatched_event->pointer_id()); | 1329 EXPECT_EQ(touch_id, dispatched_event->pointer_id()); |
| 1330 } | 1330 } |
| 1331 } | 1331 } |
| 1332 | 1332 |
| 1333 TEST_F(EventDispatcherTest, ResetClearsPointerDown) { | 1333 TEST_F(EventDispatcherTest, ResetClearsPointerDown) { |
| 1334 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1334 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1335 | 1335 |
| 1336 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1336 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1337 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1337 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 1338 | 1338 |
| 1339 // Send event that is over child. | 1339 // Send event that is over child. |
| 1340 const ui::PointerEvent ui_event(ui::MouseEvent( | 1340 const ui::PointerEvent ui_event(ui::MouseEvent( |
| 1341 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), | 1341 ui::ET_MOUSE_PRESSED, gfx::Point(20, 25), gfx::Point(20, 25), |
| 1342 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1342 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1343 event_dispatcher()->ProcessEvent(ui_event, | 1343 event_dispatcher()->ProcessEvent(ui_event, |
| 1344 EventDispatcher::AcceleratorMatchPhase::ANY); | 1344 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1345 | 1345 |
| 1346 std::unique_ptr<DispatchedEventDetails> details = | 1346 std::unique_ptr<DispatchedEventDetails> details = |
| 1347 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1347 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1348 ASSERT_TRUE(details); | 1348 ASSERT_TRUE(details); |
| 1349 ASSERT_EQ(child.get(), details->window); | 1349 ASSERT_EQ(child.get(), details->window); |
| 1350 | 1350 |
| 1351 EXPECT_TRUE(AreAnyPointersDown()); | 1351 EXPECT_TRUE(AreAnyPointersDown()); |
| 1352 | 1352 |
| 1353 event_dispatcher()->Reset(); | 1353 event_dispatcher()->Reset(); |
| 1354 EXPECT_FALSE(test_event_dispatcher_delegate()->has_queued_events()); | 1354 EXPECT_FALSE(test_event_dispatcher_delegate()->has_queued_events()); |
| 1355 EXPECT_FALSE(AreAnyPointersDown()); | 1355 EXPECT_FALSE(AreAnyPointersDown()); |
| 1356 } | 1356 } |
| 1357 | 1357 |
| 1358 TEST_F(EventDispatcherTest, ResetClearsCapture) { | 1358 TEST_F(EventDispatcherTest, ResetClearsCapture) { |
| 1359 ServerWindow* root = root_window(); | 1359 ServerWindow* root = root_window(); |
| 1360 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1360 root->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1361 | 1361 |
| 1362 root->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); | 1362 root->SetClientArea(gfx::Insets(5, 5, 5, 5), std::vector<gfx::Rect>()); |
| 1363 EventDispatcher* dispatcher = event_dispatcher(); | 1363 EventDispatcher* dispatcher = event_dispatcher(); |
| 1364 dispatcher->SetCaptureWindow(root, kNonclientAreaId); | 1364 dispatcher->SetCaptureWindow(root, kNonclientAreaId); |
| 1365 | 1365 |
| 1366 event_dispatcher()->Reset(); | 1366 event_dispatcher()->Reset(); |
| 1367 EXPECT_FALSE(test_event_dispatcher_delegate()->has_queued_events()); | 1367 EXPECT_FALSE(test_event_dispatcher_delegate()->has_queued_events()); |
| 1368 EXPECT_EQ(nullptr, event_dispatcher()->capture_window()); | 1368 EXPECT_EQ(nullptr, event_dispatcher()->capture_window()); |
| 1369 } | 1369 } |
| 1370 | 1370 |
| 1371 // Tests that events on a modal parent target the modal child. | 1371 // Tests that events on a modal parent target the modal child. |
| 1372 TEST_F(EventDispatcherTest, ModalWindowEventOnModalParent) { | 1372 TEST_F(EventDispatcherTest, ModalWindowEventOnModalParent) { |
| 1373 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1373 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1374 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); | 1374 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); |
| 1375 | 1375 |
| 1376 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1376 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1377 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1377 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 1378 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1378 w2->SetBounds(gfx::Rect(50, 10, 10, 10), cc::LocalFrameId()); |
| 1379 | 1379 |
| 1380 w1->AddTransientWindow(w2.get()); | 1380 w1->AddTransientWindow(w2.get()); |
| 1381 w2->SetModal(); | 1381 w2->SetModal(); |
| 1382 | 1382 |
| 1383 // Send event that is over |w1|. | 1383 // Send event that is over |w1|. |
| 1384 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1384 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1385 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1385 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1386 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1386 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1387 event_dispatcher()->ProcessEvent(mouse_pressed, | 1387 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1388 EventDispatcher::AcceleratorMatchPhase::ANY); | 1388 EventDispatcher::AcceleratorMatchPhase::ANY); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1399 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1399 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1400 EXPECT_EQ(gfx::Point(15, 15), dispatched_event->root_location()); | 1400 EXPECT_EQ(gfx::Point(15, 15), dispatched_event->root_location()); |
| 1401 EXPECT_EQ(gfx::Point(-35, 5), dispatched_event->location()); | 1401 EXPECT_EQ(gfx::Point(-35, 5), dispatched_event->location()); |
| 1402 } | 1402 } |
| 1403 | 1403 |
| 1404 // Tests that events on a modal child target the modal child itself. | 1404 // Tests that events on a modal child target the modal child itself. |
| 1405 TEST_F(EventDispatcherTest, ModalWindowEventOnModalChild) { | 1405 TEST_F(EventDispatcherTest, ModalWindowEventOnModalChild) { |
| 1406 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1406 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1407 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); | 1407 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); |
| 1408 | 1408 |
| 1409 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1409 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1410 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1410 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 1411 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1411 w2->SetBounds(gfx::Rect(50, 10, 10, 10), cc::LocalFrameId()); |
| 1412 | 1412 |
| 1413 w1->AddTransientWindow(w2.get()); | 1413 w1->AddTransientWindow(w2.get()); |
| 1414 w2->SetModal(); | 1414 w2->SetModal(); |
| 1415 | 1415 |
| 1416 // Send event that is over |w2|. | 1416 // Send event that is over |w2|. |
| 1417 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1417 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1418 ui::ET_MOUSE_PRESSED, gfx::Point(55, 15), gfx::Point(55, 15), | 1418 ui::ET_MOUSE_PRESSED, gfx::Point(55, 15), gfx::Point(55, 15), |
| 1419 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1419 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1420 event_dispatcher()->ProcessEvent(mouse_pressed, | 1420 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1421 EventDispatcher::AcceleratorMatchPhase::ANY); | 1421 EventDispatcher::AcceleratorMatchPhase::ANY); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1434 EXPECT_EQ(gfx::Point(5, 5), dispatched_event->location()); | 1434 EXPECT_EQ(gfx::Point(5, 5), dispatched_event->location()); |
| 1435 } | 1435 } |
| 1436 | 1436 |
| 1437 // Tests that events on an unrelated window are not affected by the modal | 1437 // Tests that events on an unrelated window are not affected by the modal |
| 1438 // window. | 1438 // window. |
| 1439 TEST_F(EventDispatcherTest, ModalWindowEventOnUnrelatedWindow) { | 1439 TEST_F(EventDispatcherTest, ModalWindowEventOnUnrelatedWindow) { |
| 1440 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1440 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1441 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); | 1441 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); |
| 1442 std::unique_ptr<ServerWindow> w3 = CreateChildWindow(WindowId(1, 6)); | 1442 std::unique_ptr<ServerWindow> w3 = CreateChildWindow(WindowId(1, 6)); |
| 1443 | 1443 |
| 1444 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1444 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1445 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1445 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 1446 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1446 w2->SetBounds(gfx::Rect(50, 10, 10, 10), cc::LocalFrameId()); |
| 1447 w3->SetBounds(gfx::Rect(70, 10, 10, 10)); | 1447 w3->SetBounds(gfx::Rect(70, 10, 10, 10), cc::LocalFrameId()); |
| 1448 | 1448 |
| 1449 w1->AddTransientWindow(w2.get()); | 1449 w1->AddTransientWindow(w2.get()); |
| 1450 w2->SetModal(); | 1450 w2->SetModal(); |
| 1451 | 1451 |
| 1452 // Send event that is over |w3|. | 1452 // Send event that is over |w3|. |
| 1453 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1453 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1454 ui::ET_MOUSE_PRESSED, gfx::Point(75, 15), gfx::Point(75, 15), | 1454 ui::ET_MOUSE_PRESSED, gfx::Point(75, 15), gfx::Point(75, 15), |
| 1455 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1455 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1456 event_dispatcher()->ProcessEvent(mouse_pressed, | 1456 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1457 EventDispatcher::AcceleratorMatchPhase::ANY); | 1457 EventDispatcher::AcceleratorMatchPhase::ANY); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1471 } | 1471 } |
| 1472 | 1472 |
| 1473 // Tests that events events on a descendant of a modal parent target the modal | 1473 // Tests that events events on a descendant of a modal parent target the modal |
| 1474 // child. | 1474 // child. |
| 1475 TEST_F(EventDispatcherTest, ModalWindowEventOnDescendantOfModalParent) { | 1475 TEST_F(EventDispatcherTest, ModalWindowEventOnDescendantOfModalParent) { |
| 1476 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1476 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1477 std::unique_ptr<ServerWindow> w11 = | 1477 std::unique_ptr<ServerWindow> w11 = |
| 1478 CreateChildWindowWithParent(WindowId(1, 4), w1.get()); | 1478 CreateChildWindowWithParent(WindowId(1, 4), w1.get()); |
| 1479 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); | 1479 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); |
| 1480 | 1480 |
| 1481 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1481 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1482 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1482 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 1483 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); | 1483 w11->SetBounds(gfx::Rect(10, 10, 10, 10), cc::LocalFrameId()); |
| 1484 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1484 w2->SetBounds(gfx::Rect(50, 10, 10, 10), cc::LocalFrameId()); |
| 1485 | 1485 |
| 1486 w1->AddTransientWindow(w2.get()); | 1486 w1->AddTransientWindow(w2.get()); |
| 1487 w2->SetModal(); | 1487 w2->SetModal(); |
| 1488 | 1488 |
| 1489 // Send event that is over |w11|. | 1489 // Send event that is over |w11|. |
| 1490 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1490 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1491 ui::ET_MOUSE_PRESSED, gfx::Point(25, 25), gfx::Point(25, 25), | 1491 ui::ET_MOUSE_PRESSED, gfx::Point(25, 25), gfx::Point(25, 25), |
| 1492 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1492 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1493 event_dispatcher()->ProcessEvent(mouse_pressed, | 1493 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1494 EventDispatcher::AcceleratorMatchPhase::ANY); | 1494 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1495 | 1495 |
| 1496 std::unique_ptr<DispatchedEventDetails> details = | 1496 std::unique_ptr<DispatchedEventDetails> details = |
| 1497 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1497 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1498 ASSERT_TRUE(details); | 1498 ASSERT_TRUE(details); |
| 1499 EXPECT_EQ(w2.get(), details->window); | 1499 EXPECT_EQ(w2.get(), details->window); |
| 1500 EXPECT_TRUE(details->IsNonclientArea()); | 1500 EXPECT_TRUE(details->IsNonclientArea()); |
| 1501 | 1501 |
| 1502 ASSERT_TRUE(details->event); | 1502 ASSERT_TRUE(details->event); |
| 1503 ASSERT_TRUE(details->event->IsPointerEvent()); | 1503 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 1504 | 1504 |
| 1505 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1505 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1506 EXPECT_EQ(gfx::Point(25, 25), dispatched_event->root_location()); | 1506 EXPECT_EQ(gfx::Point(25, 25), dispatched_event->root_location()); |
| 1507 EXPECT_EQ(gfx::Point(-25, 15), dispatched_event->location()); | 1507 EXPECT_EQ(gfx::Point(-25, 15), dispatched_event->location()); |
| 1508 } | 1508 } |
| 1509 | 1509 |
| 1510 // Tests that events on a system modal window target the modal window itself. | 1510 // Tests that events on a system modal window target the modal window itself. |
| 1511 TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) { | 1511 TEST_F(EventDispatcherTest, ModalWindowEventOnSystemModal) { |
| 1512 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1512 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1513 | 1513 |
| 1514 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1514 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1515 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1515 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 1516 w1->SetModal(); | 1516 w1->SetModal(); |
| 1517 | 1517 |
| 1518 // Send event that is over |w1|. | 1518 // Send event that is over |w1|. |
| 1519 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1519 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1520 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1520 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1521 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1521 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1522 event_dispatcher()->ProcessEvent(mouse_pressed, | 1522 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1523 EventDispatcher::AcceleratorMatchPhase::ANY); | 1523 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1524 | 1524 |
| 1525 std::unique_ptr<DispatchedEventDetails> details = | 1525 std::unique_ptr<DispatchedEventDetails> details = |
| 1526 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); | 1526 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 1527 ASSERT_TRUE(details); | 1527 ASSERT_TRUE(details); |
| 1528 EXPECT_EQ(w1.get(), details->window); | 1528 EXPECT_EQ(w1.get(), details->window); |
| 1529 EXPECT_TRUE(details->IsClientArea()); | 1529 EXPECT_TRUE(details->IsClientArea()); |
| 1530 | 1530 |
| 1531 ASSERT_TRUE(details->event); | 1531 ASSERT_TRUE(details->event); |
| 1532 ASSERT_TRUE(details->event->IsPointerEvent()); | 1532 ASSERT_TRUE(details->event->IsPointerEvent()); |
| 1533 | 1533 |
| 1534 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); | 1534 ui::PointerEvent* dispatched_event = details->event->AsPointerEvent(); |
| 1535 EXPECT_EQ(gfx::Point(15, 15), dispatched_event->root_location()); | 1535 EXPECT_EQ(gfx::Point(15, 15), dispatched_event->root_location()); |
| 1536 EXPECT_EQ(gfx::Point(5, 5), dispatched_event->location()); | 1536 EXPECT_EQ(gfx::Point(5, 5), dispatched_event->location()); |
| 1537 } | 1537 } |
| 1538 | 1538 |
| 1539 // Tests that events outside of system modal window target the modal window. | 1539 // Tests that events outside of system modal window target the modal window. |
| 1540 TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { | 1540 TEST_F(EventDispatcherTest, ModalWindowEventOutsideSystemModal) { |
| 1541 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1541 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1542 | 1542 |
| 1543 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1543 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1544 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1544 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 1545 w1->SetModal(); | 1545 w1->SetModal(); |
| 1546 event_dispatcher()->AddSystemModalWindow(w1.get()); | 1546 event_dispatcher()->AddSystemModalWindow(w1.get()); |
| 1547 | 1547 |
| 1548 // Send event that is over |w1|. | 1548 // Send event that is over |w1|. |
| 1549 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1549 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1550 ui::ET_MOUSE_PRESSED, gfx::Point(45, 15), gfx::Point(45, 15), | 1550 ui::ET_MOUSE_PRESSED, gfx::Point(45, 15), gfx::Point(45, 15), |
| 1551 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1551 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1552 event_dispatcher()->ProcessEvent(mouse_pressed, | 1552 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1553 EventDispatcher::AcceleratorMatchPhase::ANY); | 1553 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1554 | 1554 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1566 EXPECT_EQ(gfx::Point(35, 5), dispatched_event->location()); | 1566 EXPECT_EQ(gfx::Point(35, 5), dispatched_event->location()); |
| 1567 } | 1567 } |
| 1568 | 1568 |
| 1569 // Tests that setting capture to a descendant of a modal parent fails. | 1569 // Tests that setting capture to a descendant of a modal parent fails. |
| 1570 TEST_F(EventDispatcherTest, ModalWindowSetCaptureDescendantOfModalParent) { | 1570 TEST_F(EventDispatcherTest, ModalWindowSetCaptureDescendantOfModalParent) { |
| 1571 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1571 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1572 std::unique_ptr<ServerWindow> w11 = | 1572 std::unique_ptr<ServerWindow> w11 = |
| 1573 CreateChildWindowWithParent(WindowId(1, 4), w1.get()); | 1573 CreateChildWindowWithParent(WindowId(1, 4), w1.get()); |
| 1574 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); | 1574 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); |
| 1575 | 1575 |
| 1576 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1576 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1577 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1577 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 1578 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); | 1578 w11->SetBounds(gfx::Rect(10, 10, 10, 10), cc::LocalFrameId()); |
| 1579 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1579 w2->SetBounds(gfx::Rect(50, 10, 10, 10), cc::LocalFrameId()); |
| 1580 | 1580 |
| 1581 w1->AddTransientWindow(w2.get()); | 1581 w1->AddTransientWindow(w2.get()); |
| 1582 w2->SetModal(); | 1582 w2->SetModal(); |
| 1583 | 1583 |
| 1584 EXPECT_FALSE(event_dispatcher()->SetCaptureWindow(w11.get(), kClientAreaId)); | 1584 EXPECT_FALSE(event_dispatcher()->SetCaptureWindow(w11.get(), kClientAreaId)); |
| 1585 EXPECT_EQ(nullptr, event_dispatcher()->capture_window()); | 1585 EXPECT_EQ(nullptr, event_dispatcher()->capture_window()); |
| 1586 } | 1586 } |
| 1587 | 1587 |
| 1588 // Tests that setting capture to a window unrelated to a modal parent works. | 1588 // Tests that setting capture to a window unrelated to a modal parent works. |
| 1589 TEST_F(EventDispatcherTest, ModalWindowSetCaptureUnrelatedWindow) { | 1589 TEST_F(EventDispatcherTest, ModalWindowSetCaptureUnrelatedWindow) { |
| 1590 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1590 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1591 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 4)); | 1591 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 4)); |
| 1592 std::unique_ptr<ServerWindow> w3 = CreateChildWindow(WindowId(1, 5)); | 1592 std::unique_ptr<ServerWindow> w3 = CreateChildWindow(WindowId(1, 5)); |
| 1593 | 1593 |
| 1594 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1594 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1595 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1595 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 1596 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1596 w2->SetBounds(gfx::Rect(50, 10, 10, 10), cc::LocalFrameId()); |
| 1597 w3->SetBounds(gfx::Rect(70, 10, 10, 10)); | 1597 w3->SetBounds(gfx::Rect(70, 10, 10, 10), cc::LocalFrameId()); |
| 1598 | 1598 |
| 1599 w1->AddTransientWindow(w2.get()); | 1599 w1->AddTransientWindow(w2.get()); |
| 1600 w2->SetModal(); | 1600 w2->SetModal(); |
| 1601 | 1601 |
| 1602 EXPECT_TRUE(event_dispatcher()->SetCaptureWindow(w3.get(), kClientAreaId)); | 1602 EXPECT_TRUE(event_dispatcher()->SetCaptureWindow(w3.get(), kClientAreaId)); |
| 1603 EXPECT_EQ(w3.get(), event_dispatcher()->capture_window()); | 1603 EXPECT_EQ(w3.get(), event_dispatcher()->capture_window()); |
| 1604 } | 1604 } |
| 1605 | 1605 |
| 1606 // Tests that setting capture fails when there is a system modal window. | 1606 // Tests that setting capture fails when there is a system modal window. |
| 1607 TEST_F(EventDispatcherTest, ModalWindowSystemSetCapture) { | 1607 TEST_F(EventDispatcherTest, ModalWindowSystemSetCapture) { |
| 1608 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1608 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1609 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 4)); | 1609 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 4)); |
| 1610 | 1610 |
| 1611 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1611 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1612 w1->SetBounds(gfx::Rect(10, 10, 30, 30)); | 1612 w1->SetBounds(gfx::Rect(10, 10, 30, 30), cc::LocalFrameId()); |
| 1613 w2->SetBounds(gfx::Rect(50, 10, 10, 10)); | 1613 w2->SetBounds(gfx::Rect(50, 10, 10, 10), cc::LocalFrameId()); |
| 1614 | 1614 |
| 1615 event_dispatcher()->AddSystemModalWindow(w2.get()); | 1615 event_dispatcher()->AddSystemModalWindow(w2.get()); |
| 1616 | 1616 |
| 1617 EXPECT_FALSE(event_dispatcher()->SetCaptureWindow(w1.get(), kClientAreaId)); | 1617 EXPECT_FALSE(event_dispatcher()->SetCaptureWindow(w1.get(), kClientAreaId)); |
| 1618 EXPECT_EQ(nullptr, event_dispatcher()->capture_window()); | 1618 EXPECT_EQ(nullptr, event_dispatcher()->capture_window()); |
| 1619 } | 1619 } |
| 1620 | 1620 |
| 1621 // Tests having multiple system modal windows. | 1621 // Tests having multiple system modal windows. |
| 1622 TEST_F(EventDispatcherTest, ModalWindowMultipleSystemModals) { | 1622 TEST_F(EventDispatcherTest, ModalWindowMultipleSystemModals) { |
| 1623 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1623 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1662 } | 1662 } |
| 1663 | 1663 |
| 1664 TEST_F(EventDispatcherTest, CaptureNotResetOnParentChange) { | 1664 TEST_F(EventDispatcherTest, CaptureNotResetOnParentChange) { |
| 1665 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); | 1665 std::unique_ptr<ServerWindow> w1 = CreateChildWindow(WindowId(1, 3)); |
| 1666 DisableHitTest(w1.get()); | 1666 DisableHitTest(w1.get()); |
| 1667 std::unique_ptr<ServerWindow> w11 = | 1667 std::unique_ptr<ServerWindow> w11 = |
| 1668 CreateChildWindowWithParent(WindowId(1, 4), w1.get()); | 1668 CreateChildWindowWithParent(WindowId(1, 4), w1.get()); |
| 1669 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); | 1669 std::unique_ptr<ServerWindow> w2 = CreateChildWindow(WindowId(1, 5)); |
| 1670 DisableHitTest(w2.get()); | 1670 DisableHitTest(w2.get()); |
| 1671 | 1671 |
| 1672 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1672 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1673 w1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1673 w1->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1674 w11->SetBounds(gfx::Rect(10, 10, 10, 10)); | 1674 w11->SetBounds(gfx::Rect(10, 10, 10, 10), cc::LocalFrameId()); |
| 1675 w2->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1675 w2->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1676 | 1676 |
| 1677 // Send event that is over |w11|. | 1677 // Send event that is over |w11|. |
| 1678 const ui::PointerEvent mouse_pressed(ui::MouseEvent( | 1678 const ui::PointerEvent mouse_pressed(ui::MouseEvent( |
| 1679 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), | 1679 ui::ET_MOUSE_PRESSED, gfx::Point(15, 15), gfx::Point(15, 15), |
| 1680 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); | 1680 base::TimeTicks(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON)); |
| 1681 event_dispatcher()->ProcessEvent(mouse_pressed, | 1681 event_dispatcher()->ProcessEvent(mouse_pressed, |
| 1682 EventDispatcher::AcceleratorMatchPhase::ANY); | 1682 EventDispatcher::AcceleratorMatchPhase::ANY); |
| 1683 event_dispatcher()->SetCaptureWindow(w11.get(), kClientAreaId); | 1683 event_dispatcher()->SetCaptureWindow(w11.get(), kClientAreaId); |
| 1684 | 1684 |
| 1685 std::unique_ptr<DispatchedEventDetails> details = | 1685 std::unique_ptr<DispatchedEventDetails> details = |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1709 test_event_dispatcher_delegate()->lost_capture_window()); | 1709 test_event_dispatcher_delegate()->lost_capture_window()); |
| 1710 EXPECT_EQ(child.get(), event_dispatcher()->capture_window()); | 1710 EXPECT_EQ(child.get(), event_dispatcher()->capture_window()); |
| 1711 EXPECT_EQ(kClientAreaId, event_dispatcher()->capture_window_client_id()); | 1711 EXPECT_EQ(kClientAreaId, event_dispatcher()->capture_window_client_id()); |
| 1712 } | 1712 } |
| 1713 | 1713 |
| 1714 TEST_F(EventDispatcherTest, MoveMouseFromNoTargetToValidTarget) { | 1714 TEST_F(EventDispatcherTest, MoveMouseFromNoTargetToValidTarget) { |
| 1715 ServerWindow* root = root_window(); | 1715 ServerWindow* root = root_window(); |
| 1716 DisableHitTest(root); | 1716 DisableHitTest(root); |
| 1717 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1717 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1718 | 1718 |
| 1719 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1719 root->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1720 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1720 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 1721 | 1721 |
| 1722 MouseEventTest tests[] = { | 1722 MouseEventTest tests[] = { |
| 1723 // Send a mouse down over the root, but not the child. No event should | 1723 // Send a mouse down over the root, but not the child. No event should |
| 1724 // be generated. | 1724 // be generated. |
| 1725 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(5, 5), gfx::Point(5, 5), | 1725 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1726 base::TimeTicks(), 0, 0), | 1726 base::TimeTicks(), 0, 0), |
| 1727 nullptr, gfx::Point(), gfx::Point(), nullptr, gfx::Point(), | 1727 nullptr, gfx::Point(), gfx::Point(), nullptr, gfx::Point(), |
| 1728 gfx::Point()}, | 1728 gfx::Point()}, |
| 1729 | 1729 |
| 1730 // Move into child. | 1730 // Move into child. |
| 1731 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(12, 12), | 1731 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(12, 12), |
| 1732 gfx::Point(12, 12), base::TimeTicks(), 0, 0), | 1732 gfx::Point(12, 12), base::TimeTicks(), 0, 0), |
| 1733 child.get(), gfx::Point(12, 12), gfx::Point(2, 2), nullptr, gfx::Point(), | 1733 child.get(), gfx::Point(12, 12), gfx::Point(2, 2), nullptr, gfx::Point(), |
| 1734 gfx::Point()}}; | 1734 gfx::Point()}}; |
| 1735 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 1735 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 1736 tests, arraysize(tests)); | 1736 tests, arraysize(tests)); |
| 1737 } | 1737 } |
| 1738 | 1738 |
| 1739 TEST_F(EventDispatcherTest, NoTargetToTargetWithMouseDown) { | 1739 TEST_F(EventDispatcherTest, NoTargetToTargetWithMouseDown) { |
| 1740 ServerWindow* root = root_window(); | 1740 ServerWindow* root = root_window(); |
| 1741 DisableHitTest(root); | 1741 DisableHitTest(root); |
| 1742 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); | 1742 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 1743 | 1743 |
| 1744 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1744 root->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1745 child->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1745 child->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 1746 | 1746 |
| 1747 MouseEventTest tests[] = { | 1747 MouseEventTest tests[] = { |
| 1748 // Mouse over the root, but not the child. No event should be generated. | 1748 // Mouse over the root, but not the child. No event should be generated. |
| 1749 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(5, 5), gfx::Point(5, 5), | 1749 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(5, 5), gfx::Point(5, 5), |
| 1750 base::TimeTicks(), 0, 0), | 1750 base::TimeTicks(), 0, 0), |
| 1751 nullptr, gfx::Point(), gfx::Point(), nullptr, gfx::Point(), | 1751 nullptr, gfx::Point(), gfx::Point(), nullptr, gfx::Point(), |
| 1752 gfx::Point()}, | 1752 gfx::Point()}, |
| 1753 | 1753 |
| 1754 // Press in same location, still no target. | 1754 // Press in same location, still no target. |
| 1755 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), | 1755 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(5, 5), gfx::Point(5, 5), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1767 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 1767 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 1768 tests, arraysize(tests)); | 1768 tests, arraysize(tests)); |
| 1769 } | 1769 } |
| 1770 | 1770 |
| 1771 TEST_F(EventDispatcherTest, DontSendExitToSameClientWhenCaptureChanges) { | 1771 TEST_F(EventDispatcherTest, DontSendExitToSameClientWhenCaptureChanges) { |
| 1772 ServerWindow* root = root_window(); | 1772 ServerWindow* root = root_window(); |
| 1773 DisableHitTest(root); | 1773 DisableHitTest(root); |
| 1774 std::unique_ptr<ServerWindow> c1 = CreateChildWindow(WindowId(1, 3)); | 1774 std::unique_ptr<ServerWindow> c1 = CreateChildWindow(WindowId(1, 3)); |
| 1775 std::unique_ptr<ServerWindow> c2 = CreateChildWindow(WindowId(1, 4)); | 1775 std::unique_ptr<ServerWindow> c2 = CreateChildWindow(WindowId(1, 4)); |
| 1776 | 1776 |
| 1777 root->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1777 root->SetBounds(gfx::Rect(0, 0, 100, 100), cc::LocalFrameId()); |
| 1778 c1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 1778 c1->SetBounds(gfx::Rect(10, 10, 20, 20), cc::LocalFrameId()); |
| 1779 c2->SetBounds(gfx::Rect(15, 15, 20, 20)); | 1779 c2->SetBounds(gfx::Rect(15, 15, 20, 20), cc::LocalFrameId()); |
| 1780 | 1780 |
| 1781 MouseEventTest tests[] = { | 1781 MouseEventTest tests[] = { |
| 1782 // Mouse over |c2|. | 1782 // Mouse over |c2|. |
| 1783 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(16, 16), | 1783 {ui::MouseEvent(ui::ET_MOUSE_MOVED, gfx::Point(16, 16), |
| 1784 gfx::Point(16, 16), base::TimeTicks(), 0, 0), | 1784 gfx::Point(16, 16), base::TimeTicks(), 0, 0), |
| 1785 c2.get(), gfx::Point(16, 16), gfx::Point(1, 1), nullptr, gfx::Point(), | 1785 c2.get(), gfx::Point(16, 16), gfx::Point(1, 1), nullptr, gfx::Point(), |
| 1786 gfx::Point()}, | 1786 gfx::Point()}, |
| 1787 | 1787 |
| 1788 // Press in same location. | 1788 // Press in same location. |
| 1789 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(16, 16), | 1789 {ui::MouseEvent(ui::ET_MOUSE_PRESSED, gfx::Point(16, 16), |
| 1790 gfx::Point(16, 16), base::TimeTicks(), | 1790 gfx::Point(16, 16), base::TimeTicks(), |
| 1791 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), | 1791 ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON), |
| 1792 c2.get(), gfx::Point(16, 16), gfx::Point(1, 1), nullptr, gfx::Point(), | 1792 c2.get(), gfx::Point(16, 16), gfx::Point(1, 1), nullptr, gfx::Point(), |
| 1793 gfx::Point()}}; | 1793 gfx::Point()}}; |
| 1794 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), | 1794 RunMouseEventTests(event_dispatcher(), test_event_dispatcher_delegate(), |
| 1795 tests, arraysize(tests)); | 1795 tests, arraysize(tests)); |
| 1796 | 1796 |
| 1797 // Set capture on |c1|. No events should be sent as |c1| is in the same | 1797 // Set capture on |c1|. No events should be sent as |c1| is in the same |
| 1798 // client. | 1798 // client. |
| 1799 event_dispatcher()->SetCaptureWindow(c1.get(), kClientAreaId); | 1799 event_dispatcher()->SetCaptureWindow(c1.get(), kClientAreaId); |
| 1800 EXPECT_FALSE(test_event_dispatcher_delegate()->has_queued_events()); | 1800 EXPECT_FALSE(test_event_dispatcher_delegate()->has_queued_events()); |
| 1801 } | 1801 } |
| 1802 | 1802 |
| 1803 } // namespace test | 1803 } // namespace test |
| 1804 } // namespace ws | 1804 } // namespace ws |
| 1805 } // namespace ui | 1805 } // namespace ui |
| OLD | NEW |