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

Side by Side Diff: components/mus/ws/event_dispatcher_unittest.cc

Issue 1991973003: mash: Preliminary support for widget hit test masks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 7 months 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
« no previous file with comments | « components/mus/ws/default_access_policy.cc ('k') | components/mus/ws/server_window.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 633 matching lines...) Expand 10 before | Expand all | Expand 10 after
644 event_dispatcher()->ProcessEvent(press_event); 644 event_dispatcher()->ProcessEvent(press_event);
645 645
646 // Events should target child and be in the client area. 646 // Events should target child and be in the client area.
647 std::unique_ptr<DispatchedEventDetails> details = 647 std::unique_ptr<DispatchedEventDetails> details =
648 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails(); 648 event_dispatcher_delegate->GetAndAdvanceDispatchedEventDetails();
649 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events()); 649 EXPECT_FALSE(event_dispatcher_delegate->has_queued_events());
650 ASSERT_EQ(child.get(), details->window); 650 ASSERT_EQ(child.get(), details->window);
651 EXPECT_FALSE(details->in_nonclient_area); 651 EXPECT_FALSE(details->in_nonclient_area);
652 } 652 }
653 653
654 TEST_F(EventDispatcherTest, HitTestMask) {
655 std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3));
656
657 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
658 child->SetBounds(gfx::Rect(10, 10, 20, 20));
659 child->SetHitTestMask(gfx::Rect(2, 2, 16, 16));
660
661 // Move in the masked area.
662 const ui::PointerEvent move1(ui::MouseEvent(
663 ui::ET_MOUSE_MOVED, gfx::Point(11, 11), gfx::Point(11, 11),
664 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, 0));
665 event_dispatcher()->ProcessEvent(move1);
666
667 // Event went through the child window and hit the root.
668 std::unique_ptr<DispatchedEventDetails> details1 =
669 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
670 EXPECT_EQ(root_window(), details1->window);
671 EXPECT_FALSE(details1->in_nonclient_area);
672
673 child->ClearHitTestMask();
674
675 // Move right in the same part of the window.
676 const ui::PointerEvent move2(ui::MouseEvent(
677 ui::ET_MOUSE_MOVED, gfx::Point(11, 12), gfx::Point(11, 12),
678 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, 0));
679 event_dispatcher()->ProcessEvent(move2);
680
681 // Mouse exits the root.
682 std::unique_ptr<DispatchedEventDetails> details2 =
683 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
684 EXPECT_EQ(ui::ET_POINTER_EXITED, details2->event->type());
685
686 // Mouse hits the child.
687 std::unique_ptr<DispatchedEventDetails> details3 =
688 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
689 EXPECT_EQ(child.get(), details3->window);
690 EXPECT_FALSE(details3->in_nonclient_area);
691 }
692
654 TEST_F(EventDispatcherTest, DontFocusOnSecondDown) { 693 TEST_F(EventDispatcherTest, DontFocusOnSecondDown) {
655 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); 694 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3));
656 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); 695 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4));
657 696
658 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 697 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
659 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); 698 child1->SetBounds(gfx::Rect(10, 10, 20, 20));
660 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); 699 child2->SetBounds(gfx::Rect(50, 51, 11, 12));
661 700
662 TestEventDispatcherDelegate* event_dispatcher_delegate = 701 TestEventDispatcherDelegate* event_dispatcher_delegate =
663 test_event_dispatcher_delegate(); 702 test_event_dispatcher_delegate();
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 1540
1502 // Remove the last remaining system modal window. There should be no active 1541 // Remove the last remaining system modal window. There should be no active
1503 // one anymore. 1542 // one anymore.
1504 w3.reset(); 1543 w3.reset();
1505 EXPECT_EQ(nullptr, GetActiveSystemModalWindow()); 1544 EXPECT_EQ(nullptr, GetActiveSystemModalWindow());
1506 } 1545 }
1507 1546
1508 } // namespace test 1547 } // namespace test
1509 } // namespace ws 1548 } // namespace ws
1510 } // namespace mus 1549 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/ws/default_access_policy.cc ('k') | components/mus/ws/server_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698