| OLD | NEW |
| 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/window_finder.h" | 5 #include "components/mus/ws/window_finder.h" |
| 6 | 6 |
| 7 #include "components/mus/ws/server_window.h" | 7 #include "components/mus/ws/server_window.h" |
| 8 #include "components/mus/ws/server_window_surface_manager.h" | 8 #include "components/mus/ws/server_window_surface_manager.h" |
| 9 #include "components/mus/ws/server_window_surface_manager_test_api.h" | 9 #include "components/mus/ws/server_window_surface_manager_test_api.h" |
| 10 #include "components/mus/ws/test_server_window_delegate.h" | 10 #include "components/mus/ws/test_server_window_delegate.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 local_point.SetPoint(13, 14); | 40 local_point.SetPoint(13, 14); |
| 41 EXPECT_EQ(&child1, FindDeepestVisibleWindowForEvents(&root, &local_point)); | 41 EXPECT_EQ(&child1, FindDeepestVisibleWindowForEvents(&root, &local_point)); |
| 42 EXPECT_EQ(gfx::Point(3, 4), local_point); | 42 EXPECT_EQ(gfx::Point(3, 4), local_point); |
| 43 | 43 |
| 44 child2.set_extended_hit_test_region(gfx::Insets(10, 10, 10, 10)); | 44 child2.set_extended_hit_test_region(gfx::Insets(10, 10, 10, 10)); |
| 45 local_point.SetPoint(13, 14); | 45 local_point.SetPoint(13, 14); |
| 46 EXPECT_EQ(&child2, FindDeepestVisibleWindowForEvents(&root, &local_point)); | 46 EXPECT_EQ(&child2, FindDeepestVisibleWindowForEvents(&root, &local_point)); |
| 47 EXPECT_EQ(gfx::Point(-2, -1), local_point); | 47 EXPECT_EQ(gfx::Point(-2, -1), local_point); |
| 48 } | 48 } |
| 49 | 49 |
| 50 TEST(WindowFinderTest, FindDeepestVisibleWindowHitTestMask) { |
| 51 TestServerWindowDelegate window_delegate; |
| 52 ServerWindow root(&window_delegate, WindowId(1, 2)); |
| 53 window_delegate.set_root_window(&root); |
| 54 EnableHitTest(&root); |
| 55 root.SetVisible(true); |
| 56 root.SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 57 |
| 58 ServerWindow child_with_mask(&window_delegate, WindowId(1, 4)); |
| 59 root.Add(&child_with_mask); |
| 60 EnableHitTest(&child_with_mask); |
| 61 child_with_mask.SetVisible(true); |
| 62 child_with_mask.SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 63 child_with_mask.SetHitTestMask(gfx::Rect(2, 2, 16, 16)); |
| 64 |
| 65 // Test a point inside the window but outside the mask. |
| 66 gfx::Point point_outside_mask(11, 11); |
| 67 EXPECT_EQ(&root, |
| 68 FindDeepestVisibleWindowForEvents(&root, &point_outside_mask)); |
| 69 EXPECT_EQ(gfx::Point(11, 11), point_outside_mask); |
| 70 |
| 71 // Test a point inside the window and inside the mask. |
| 72 gfx::Point point_inside_mask(15, 15); |
| 73 EXPECT_EQ(&child_with_mask, |
| 74 FindDeepestVisibleWindowForEvents(&root, &point_inside_mask)); |
| 75 EXPECT_EQ(gfx::Point(5, 5), point_inside_mask); |
| 76 } |
| 77 |
| 50 } // namespace ws | 78 } // namespace ws |
| 51 } // namespace mus | 79 } // namespace mus |
| OLD | NEW |