| 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
|
|
|