| 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 "components/mus/ws/event_dispatcher.h" | 5 #include "components/mus/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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 event_dispatcher()->ProcessEvent(press_event); | 647 event_dispatcher()->ProcessEvent(press_event); |
| 648 | 648 |
| 649 // Events should target child and be in the client area. | 649 // Events should target child and be in the client area. |
| 650 std::unique_ptr<DispatchedEventDetails> details = | 650 std::unique_ptr<DispatchedEventDetails> details = |
| 651 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); | 651 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); |
| 652 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); | 652 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); |
| 653 ASSERT_EQ(child.get(), details->window); | 653 ASSERT_EQ(child.get(), details->window); |
| 654 EXPECT_FALSE(details->in_nonclient_area); | 654 EXPECT_FALSE(details->in_nonclient_area); |
| 655 } | 655 } |
| 656 | 656 |
| 657 TEST_F(EventDispatcherTest, HitTestMask) { |
| 658 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3)); |
| 659 |
| 660 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 661 child->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 662 child->SetHitTestMask(gfx::Rect(2, 2, 16, 16)); |
| 663 |
| 664 // Move in the masked area. |
| 665 const ui::PointerEvent move1(ui::MouseEvent( |
| 666 ui::ET_MOUSE_MOVED, gfx::Point(11, 11), gfx::Point(11, 11), |
| 667 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, 0)); |
| 668 event_dispatcher()->ProcessEvent(move1); |
| 669 |
| 670 // Event went through the child window and hit the root. |
| 671 std::unique_ptr<DispatchedEventDetails> details1 = |
| 672 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 673 EXPECT_EQ(root_window(), details1->window); |
| 674 EXPECT_FALSE(details1->in_nonclient_area); |
| 675 |
| 676 child->ClearHitTestMask(); |
| 677 |
| 678 // Move right in the same part of the window. |
| 679 const ui::PointerEvent move2(ui::MouseEvent( |
| 680 ui::ET_MOUSE_MOVED, gfx::Point(11, 12), gfx::Point(11, 12), |
| 681 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, 0)); |
| 682 event_dispatcher()->ProcessEvent(move2); |
| 683 |
| 684 // Mouse exits the root. |
| 685 std::unique_ptr<DispatchedEventDetails> details2 = |
| 686 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 687 EXPECT_EQ(ui::ET_POINTER_EXITED, details2->event->type()); |
| 688 |
| 689 // Mouse hits the child. |
| 690 std::unique_ptr<DispatchedEventDetails> details3 = |
| 691 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails(); |
| 692 EXPECT_EQ(child.get(), details3->window); |
| 693 EXPECT_FALSE(details3->in_nonclient_area); |
| 694 } |
| 695 |
| 657 TEST_F(EventDispatcherTest, DontFocusOnSecondDown) { | 696 TEST_F(EventDispatcherTest, DontFocusOnSecondDown) { |
| 658 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); | 697 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); |
| 659 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); | 698 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); |
| 660 | 699 |
| 661 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); | 700 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 662 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); | 701 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 663 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); | 702 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); |
| 664 | 703 |
| 665 TestEventDispatcherDelegate* event_dispatcher_delegate = | 704 TestEventDispatcherDelegate* event_dispatcher_delegate = |
| 666 test_event_dispatcher_delegate(); | 705 test_event_dispatcher_delegate(); |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 | 1543 |
| 1505 // Remove the last remaining system modal window. There should be no active | 1544 // Remove the last remaining system modal window. There should be no active |
| 1506 // one anymore. | 1545 // one anymore. |
| 1507 w3.reset(); | 1546 w3.reset(); |
| 1508 EXPECT_EQ(nullptr, GetActiveSystemModalWindow()); | 1547 EXPECT_EQ(nullptr, GetActiveSystemModalWindow()); |
| 1509 } | 1548 } |
| 1510 | 1549 |
| 1511 } // namespace test | 1550 } // namespace test |
| 1512 } // namespace ws | 1551 } // namespace ws |
| 1513 } // namespace mus | 1552 } // namespace mus |
| OLD | NEW |