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

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: add bug link for SkPath conversion 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
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 636 matching lines...) Expand 10 before | Expand all | Expand 10 after
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->set_hit_test_mask(gfx::Rect(2, 2, 16, 16));
663
664 // Press in the masked out area.
665 const ui::PointerEvent press_event(ui::MouseEvent(
666 ui::ET_MOUSE_PRESSED, gfx::Point(11, 11), gfx::Point(11, 11),
667 base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON));
668 event_dispatcher()->ProcessEvent(press_event);
669
670 // Event went through the child window and hit the root.
671 std::unique_ptr<DispatchedEventDetails> details =
672 test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
673 EXPECT_EQ(root_window(), details->window);
674 EXPECT_FALSE(details->in_nonclient_area);
675 }
676
657 TEST_F(EventDispatcherTest, DontFocusOnSecondDown) { 677 TEST_F(EventDispatcherTest, DontFocusOnSecondDown) {
658 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3)); 678 std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3));
659 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4)); 679 std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4));
660 680
661 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100)); 681 root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
662 child1->SetBounds(gfx::Rect(10, 10, 20, 20)); 682 child1->SetBounds(gfx::Rect(10, 10, 20, 20));
663 child2->SetBounds(gfx::Rect(50, 51, 11, 12)); 683 child2->SetBounds(gfx::Rect(50, 51, 11, 12));
664 684
665 TestEventDispatcherDelegate* event_dispatcher_delegate = 685 TestEventDispatcherDelegate* event_dispatcher_delegate =
666 test_event_dispatcher_delegate(); 686 test_event_dispatcher_delegate();
(...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 1524
1505 // Remove the last remaining system modal window. There should be no active 1525 // Remove the last remaining system modal window. There should be no active
1506 // one anymore. 1526 // one anymore.
1507 w3.reset(); 1527 w3.reset();
1508 EXPECT_EQ(nullptr, GetActiveSystemModalWindow()); 1528 EXPECT_EQ(nullptr, GetActiveSystemModalWindow());
1509 } 1529 }
1510 1530
1511 } // namespace test 1531 } // namespace test
1512 } // namespace ws 1532 } // namespace ws
1513 } // namespace mus 1533 } // namespace mus
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698