OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "components/mus/ws/window_finder.h" |
| 6 |
| 7 #include "components/mus/ws/server_window.h" |
| 8 #include "components/mus/ws/server_window_surface_manager.h" |
| 9 #include "components/mus/ws/server_window_surface_manager_test_api.h" |
| 10 #include "components/mus/ws/test_server_window_delegate.h" |
| 11 #include "components/mus/ws/window_finder.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 |
| 14 namespace mus { |
| 15 namespace ws { |
| 16 |
| 17 TEST(WindowFinderTest, FindDeepestVisibleWindow) { |
| 18 TestServerWindowDelegate window_delegate; |
| 19 ServerWindow root(&window_delegate, WindowId(1, 2)); |
| 20 window_delegate.set_root_window(&root); |
| 21 root.SetVisible(true); |
| 22 root.SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 23 |
| 24 ServerWindow child1(&window_delegate, WindowId(1, 3)); |
| 25 root.Add(&child1); |
| 26 EnableHitTest(&child1); |
| 27 child1.SetVisible(true); |
| 28 child1.SetBounds(gfx::Rect(10, 10, 20, 20)); |
| 29 |
| 30 ServerWindow child2(&window_delegate, WindowId(1, 3)); |
| 31 root.Add(&child2); |
| 32 EnableHitTest(&child2); |
| 33 child2.SetVisible(true); |
| 34 child2.SetBounds(gfx::Rect(15, 15, 20, 20)); |
| 35 |
| 36 gfx::Point local_point(16, 16); |
| 37 EXPECT_EQ(&child2, FindDeepestVisibleWindowForEvents(&root, cc::SurfaceId(), |
| 38 &local_point)); |
| 39 EXPECT_EQ(gfx::Point(1, 1), local_point); |
| 40 |
| 41 local_point.SetPoint(13, 14); |
| 42 EXPECT_EQ(&child1, FindDeepestVisibleWindowForEvents(&root, cc::SurfaceId(), |
| 43 &local_point)); |
| 44 EXPECT_EQ(gfx::Point(3, 4), local_point); |
| 45 |
| 46 child2.set_extended_hit_test_region(gfx::Insets(10, 10, 10, 10)); |
| 47 local_point.SetPoint(13, 14); |
| 48 EXPECT_EQ(&child2, FindDeepestVisibleWindowForEvents(&root, cc::SurfaceId(), |
| 49 &local_point)); |
| 50 EXPECT_EQ(gfx::Point(-2, -1), local_point); |
| 51 } |
| 52 |
| 53 } // namespace ws |
| 54 } // namespace mus |
OLD | NEW |