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

Unified Diff: services/ui/ws/window_finder_unittest.cc

Issue 2667073002: mash: changes can_accept_events to an enum (Closed)
Patch Set: merge Created 3 years, 11 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 | « services/ui/ws/window_finder.cc ('k') | services/ui/ws/window_manager_access_policy.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/ws/window_finder_unittest.cc
diff --git a/services/ui/ws/window_finder_unittest.cc b/services/ui/ws/window_finder_unittest.cc
index 71b6c9456f97c767e5ac54b3b1722f7372226a93..1663033c8a59c55c4a79045085ddddd230c411a6 100644
--- a/services/ui/ws/window_finder_unittest.cc
+++ b/services/ui/ws/window_finder_unittest.cc
@@ -17,19 +17,19 @@ namespace ws {
TEST(WindowFinderTest, FindDeepestVisibleWindow) {
TestServerWindowDelegate window_delegate;
ServerWindow root(&window_delegate, WindowId(1, 2));
+ root.set_event_targeting_policy(
+ mojom::EventTargetingPolicy::DESCENDANTS_ONLY);
window_delegate.set_root_window(&root);
root.SetVisible(true);
root.SetBounds(gfx::Rect(0, 0, 100, 100));
ServerWindow child1(&window_delegate, WindowId(1, 3));
root.Add(&child1);
- EnableHitTest(&child1);
child1.SetVisible(true);
child1.SetBounds(gfx::Rect(10, 10, 20, 20));
ServerWindow child2(&window_delegate, WindowId(1, 4));
root.Add(&child2);
- EnableHitTest(&child2);
child2.SetVisible(true);
child2.SetBounds(gfx::Rect(15, 15, 20, 20));
@@ -41,7 +41,7 @@ TEST(WindowFinderTest, FindDeepestVisibleWindow) {
&child1,
FindDeepestVisibleWindowForEvents(&root, gfx::Point(13, 14)).window);
- child1.set_can_accept_events(false);
+ child1.set_event_targeting_policy(mojom::EventTargetingPolicy::NONE);
EXPECT_EQ(
nullptr,
FindDeepestVisibleWindowForEvents(&root, gfx::Point(13, 14)).window);
@@ -55,14 +55,12 @@ TEST(WindowFinderTest, FindDeepestVisibleWindow) {
TEST(WindowFinderTest, FindDeepestVisibleWindowNonClientArea) {
TestServerWindowDelegate window_delegate;
ServerWindow root(&window_delegate, WindowId(1, 2));
- EnableHitTest(&root);
window_delegate.set_root_window(&root);
root.SetVisible(true);
root.SetBounds(gfx::Rect(0, 0, 100, 100));
ServerWindow child1(&window_delegate, WindowId(1, 3));
root.Add(&child1);
- EnableHitTest(&child1);
child1.SetVisible(true);
child1.SetBounds(gfx::Rect(10, 10, 20, 20));
@@ -86,15 +84,15 @@ TEST(WindowFinderTest, FindDeepestVisibleWindowNonClientArea) {
EXPECT_EQ(&child1, result.window);
EXPECT_FALSE(result.in_non_client_area);
- // set_can_accept_events(false) should not impact the result for the
+ // EventTargetingPolicy::NONE should not impact the result for the
// non-client area.
- child1.set_can_accept_events(false);
+ child1.set_event_targeting_policy(mojom::EventTargetingPolicy::NONE);
result = FindDeepestVisibleWindowForEvents(&root, gfx::Point(11, 11));
child1.SetClientArea(gfx::Insets(2, 3, 4, 5), std::vector<gfx::Rect>());
EXPECT_EQ(&child1, result.window);
EXPECT_TRUE(result.in_non_client_area);
- // set_can_accept_events(false) means the client area won't be matched though.
+ // EventTargetingPolicy::NONE means the client area won't be matched though.
result = FindDeepestVisibleWindowForEvents(&root, gfx::Point(15, 15));
EXPECT_EQ(&root, result.window);
EXPECT_FALSE(result.in_non_client_area);
@@ -104,13 +102,11 @@ TEST(WindowFinderTest, FindDeepestVisibleWindowHitTestMask) {
TestServerWindowDelegate window_delegate;
ServerWindow root(&window_delegate, WindowId(1, 2));
window_delegate.set_root_window(&root);
- EnableHitTest(&root);
root.SetVisible(true);
root.SetBounds(gfx::Rect(0, 0, 100, 100));
ServerWindow child_with_mask(&window_delegate, WindowId(1, 4));
root.Add(&child_with_mask);
- EnableHitTest(&child_with_mask);
child_with_mask.SetVisible(true);
child_with_mask.SetBounds(gfx::Rect(10, 10, 20, 20));
child_with_mask.SetHitTestMask(gfx::Rect(2, 2, 16, 16));
@@ -137,12 +133,12 @@ TEST(WindowFinderTest, FindDeepestVisibleWindowOverNonTarget) {
// not a valid event target.
ServerWindow child1(&window_delegate, WindowId(1, 3));
root.Add(&child1);
- EnableHitTest(&child1);
child1.SetVisible(true);
child1.SetBounds(gfx::Rect(10, 10, 20, 20));
ServerWindow child2(&window_delegate, WindowId(1, 4));
root.Add(&child2);
+ child2.set_event_targeting_policy(mojom::EventTargetingPolicy::NONE);
child2.SetVisible(true);
child2.SetBounds(gfx::Rect(15, 15, 20, 20));
@@ -153,5 +149,31 @@ TEST(WindowFinderTest, FindDeepestVisibleWindowOverNonTarget) {
FindDeepestVisibleWindowForEvents(&root, gfx::Point(16, 16)).window);
}
+TEST(WindowFinderTest, NonClientPreferredOverChild) {
+ TestServerWindowDelegate window_delegate;
+ ServerWindow root(&window_delegate, WindowId(1, 2));
+ window_delegate.set_root_window(&root);
+ root.SetVisible(true);
+ root.SetBounds(gfx::Rect(0, 0, 100, 100));
+
+ // Create two windows, |child| and |child_child|; |child| is a child of the
+ // root and |child_child| and child of |child|. All share the same size with
+ // |child| having a non-client area.
+ ServerWindow child(&window_delegate, WindowId(1, 3));
+ root.Add(&child);
+ child.SetVisible(true);
+ child.SetBounds(gfx::Rect(0, 0, 100, 100));
+ child.SetClientArea(gfx::Insets(2, 3, 4, 5), std::vector<gfx::Rect>());
+
+ ServerWindow child_child(&window_delegate, WindowId(1, 4));
+ child.Add(&child_child);
+ child_child.SetVisible(true);
+ child_child.SetBounds(gfx::Rect(0, 0, 100, 100));
+
+ // |child| was should be returned as the event is over the non-client area.
+ EXPECT_EQ(&child,
+ FindDeepestVisibleWindowForEvents(&root, gfx::Point(1, 1)).window);
+}
+
} // namespace ws
} // namespace ui
« no previous file with comments | « services/ui/ws/window_finder.cc ('k') | services/ui/ws/window_manager_access_policy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698