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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/ws/event_dispatcher_unittest.cc
diff --git a/components/mus/ws/event_dispatcher_unittest.cc b/components/mus/ws/event_dispatcher_unittest.cc
index 9f72d8fc44439c84b24ca5d6be360ba0bd8b026f..31ebba56fa599b76049d717b589cb1d80e6ffe0e 100644
--- a/components/mus/ws/event_dispatcher_unittest.cc
+++ b/components/mus/ws/event_dispatcher_unittest.cc
@@ -651,6 +651,45 @@ TEST_F(EventDispatcherTest, AdditionalClientArea) {
EXPECT_FALSE(details->in_nonclient_area);
}
+TEST_F(EventDispatcherTest, HitTestMask) {
+ std::unique_ptr<ServerWindow> child = CreateChildWindow(WindowId(1, 3));
+
+ root_window()->SetBounds(gfx::Rect(0, 0, 100, 100));
+ child->SetBounds(gfx::Rect(10, 10, 20, 20));
+ child->SetHitTestMask(gfx::Rect(2, 2, 16, 16));
+
+ // Move in the masked area.
+ const ui::PointerEvent move1(ui::MouseEvent(
+ ui::ET_MOUSE_MOVED, gfx::Point(11, 11), gfx::Point(11, 11),
+ base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, 0));
+ event_dispatcher()->ProcessEvent(move1);
+
+ // Event went through the child window and hit the root.
+ std::unique_ptr<DispatchedEventDetails> details1 =
+ test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
+ EXPECT_EQ(root_window(), details1->window);
+ EXPECT_FALSE(details1->in_nonclient_area);
+
+ child->ClearHitTestMask();
+
+ // Move right in the same part of the window.
+ const ui::PointerEvent move2(ui::MouseEvent(
+ ui::ET_MOUSE_MOVED, gfx::Point(11, 12), gfx::Point(11, 12),
+ base::TimeDelta(), ui::EF_LEFT_MOUSE_BUTTON, 0));
+ event_dispatcher()->ProcessEvent(move2);
+
+ // Mouse exits the root.
+ std::unique_ptr<DispatchedEventDetails> details2 =
+ test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
+ EXPECT_EQ(ui::ET_POINTER_EXITED, details2->event->type());
+
+ // Mouse hits the child.
+ std::unique_ptr<DispatchedEventDetails> details3 =
+ test_event_dispatcher_delegate()->GetAndAdvanceDispatchedEventDetails();
+ EXPECT_EQ(child.get(), details3->window);
+ EXPECT_FALSE(details3->in_nonclient_area);
+}
+
TEST_F(EventDispatcherTest, DontFocusOnSecondDown) {
std::unique_ptr<ServerWindow> child1 = CreateChildWindow(WindowId(1, 3));
std::unique_ptr<ServerWindow> child2 = CreateChildWindow(WindowId(1, 4));
« 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