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 "ash/display/extended_mouse_warp_controller.h" | 5 #include "ash/display/extended_mouse_warp_controller.h" |
6 | 6 |
7 #include "ash/display/display_manager.h" | |
8 #include "ash/display/mouse_cursor_event_filter.h" | 7 #include "ash/display/mouse_cursor_event_filter.h" |
9 #include "ash/shell.h" | 8 #include "ash/shell.h" |
10 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
11 #include "ash/test/display_manager_test_api.h" | |
12 #include "ui/display/display.h" | 10 #include "ui/display/display.h" |
13 #include "ui/display/manager/display_layout.h" | 11 #include "ui/display/manager/display_layout.h" |
14 #include "ui/display/manager/display_layout_builder.h" | 12 #include "ui/display/manager/display_layout_builder.h" |
| 13 #include "ui/display/manager/display_manager.h" |
15 #include "ui/display/screen.h" | 14 #include "ui/display/screen.h" |
| 15 #include "ui/display/test/display_manager_test_api.h" |
16 #include "ui/events/test/event_generator.h" | 16 #include "ui/events/test/event_generator.h" |
17 | 17 |
18 namespace ash { | 18 namespace ash { |
19 | 19 |
20 class ExtendedMouseWarpControllerTest : public test::AshTestBase { | 20 class ExtendedMouseWarpControllerTest : public test::AshTestBase { |
21 public: | 21 public: |
22 ExtendedMouseWarpControllerTest() {} | 22 ExtendedMouseWarpControllerTest() {} |
23 ~ExtendedMouseWarpControllerTest() override {} | 23 ~ExtendedMouseWarpControllerTest() override {} |
24 | 24 |
25 protected: | 25 protected: |
(...skipping 29 matching lines...) Expand all Loading... |
55 | 55 |
56 UpdateDisplay("360x360,700x700"); | 56 UpdateDisplay("360x360,700x700"); |
57 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 57 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
58 int64_t display_0_id = display::Screen::GetScreen() | 58 int64_t display_0_id = display::Screen::GetScreen() |
59 ->GetDisplayNearestWindow(root_windows[0]) | 59 ->GetDisplayNearestWindow(root_windows[0]) |
60 .id(); | 60 .id(); |
61 int64_t display_1_id = display::Screen::GetScreen() | 61 int64_t display_1_id = display::Screen::GetScreen() |
62 ->GetDisplayNearestWindow(root_windows[1]) | 62 ->GetDisplayNearestWindow(root_windows[1]) |
63 .id(); | 63 .id(); |
64 | 64 |
65 std::unique_ptr<display::DisplayLayout> layout(test::CreateDisplayLayout( | 65 std::unique_ptr<display::DisplayLayout> layout( |
66 display_manager(), display::DisplayPlacement::RIGHT, 0)); | 66 display::test::CreateDisplayLayout(display_manager(), |
| 67 display::DisplayPlacement::RIGHT, 0)); |
67 | 68 |
68 display_manager()->SetLayoutForCurrentDisplays(layout->Copy()); | 69 display_manager()->SetLayoutForCurrentDisplays(layout->Copy()); |
69 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); | 70 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); |
70 | 71 |
71 ASSERT_EQ(1U, GetWarpRegionsCount()); | 72 ASSERT_EQ(1U, GetWarpRegionsCount()); |
72 EXPECT_EQ(gfx::Rect(359, 16, 1, 344), GetIndicatorBounds(display_0_id)); | 73 EXPECT_EQ(gfx::Rect(359, 16, 1, 344), GetIndicatorBounds(display_0_id)); |
73 EXPECT_EQ(gfx::Rect(360, 0, 1, 360), GetIndicatorBounds(display_1_id)); | 74 EXPECT_EQ(gfx::Rect(360, 0, 1, 360), GetIndicatorBounds(display_1_id)); |
74 | 75 |
75 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); | 76 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); |
76 EXPECT_EQ(gfx::Rect(359, 0, 1, 360), GetIndicatorBounds(display_0_id)); | 77 EXPECT_EQ(gfx::Rect(359, 0, 1, 360), GetIndicatorBounds(display_0_id)); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 UpdateDisplay("360x360,700x700"); | 129 UpdateDisplay("360x360,700x700"); |
129 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 130 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
130 | 131 |
131 int64_t display_0_id = display::Screen::GetScreen() | 132 int64_t display_0_id = display::Screen::GetScreen() |
132 ->GetDisplayNearestWindow(root_windows[0]) | 133 ->GetDisplayNearestWindow(root_windows[0]) |
133 .id(); | 134 .id(); |
134 int64_t display_1_id = display::Screen::GetScreen() | 135 int64_t display_1_id = display::Screen::GetScreen() |
135 ->GetDisplayNearestWindow(root_windows[1]) | 136 ->GetDisplayNearestWindow(root_windows[1]) |
136 .id(); | 137 .id(); |
137 | 138 |
138 std::unique_ptr<display::DisplayLayout> layout(test::CreateDisplayLayout( | 139 std::unique_ptr<display::DisplayLayout> layout( |
139 display_manager(), display::DisplayPlacement::LEFT, 0)); | 140 display::test::CreateDisplayLayout(display_manager(), |
| 141 display::DisplayPlacement::LEFT, 0)); |
140 display_manager()->SetLayoutForCurrentDisplays(layout->Copy()); | 142 display_manager()->SetLayoutForCurrentDisplays(layout->Copy()); |
141 | 143 |
142 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); | 144 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); |
143 ASSERT_EQ(1U, GetWarpRegionsCount()); | 145 ASSERT_EQ(1U, GetWarpRegionsCount()); |
144 EXPECT_EQ(gfx::Rect(0, 16, 1, 344), GetIndicatorBounds(display_0_id)); | 146 EXPECT_EQ(gfx::Rect(0, 16, 1, 344), GetIndicatorBounds(display_0_id)); |
145 EXPECT_EQ(gfx::Rect(-1, 0, 1, 360), GetIndicatorBounds(display_1_id)); | 147 EXPECT_EQ(gfx::Rect(-1, 0, 1, 360), GetIndicatorBounds(display_1_id)); |
146 | 148 |
147 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); | 149 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); |
148 ASSERT_EQ(1U, GetWarpRegionsCount()); | 150 ASSERT_EQ(1U, GetWarpRegionsCount()); |
149 EXPECT_EQ(gfx::Rect(0, 0, 1, 360), GetIndicatorBounds(display_0_id)); | 151 EXPECT_EQ(gfx::Rect(0, 0, 1, 360), GetIndicatorBounds(display_0_id)); |
(...skipping 20 matching lines...) Expand all Loading... |
170 | 172 |
171 UpdateDisplay("360x360,700x700"); | 173 UpdateDisplay("360x360,700x700"); |
172 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 174 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
173 int64_t display_0_id = display::Screen::GetScreen() | 175 int64_t display_0_id = display::Screen::GetScreen() |
174 ->GetDisplayNearestWindow(root_windows[0]) | 176 ->GetDisplayNearestWindow(root_windows[0]) |
175 .id(); | 177 .id(); |
176 int64_t display_1_id = display::Screen::GetScreen() | 178 int64_t display_1_id = display::Screen::GetScreen() |
177 ->GetDisplayNearestWindow(root_windows[1]) | 179 ->GetDisplayNearestWindow(root_windows[1]) |
178 .id(); | 180 .id(); |
179 | 181 |
180 std::unique_ptr<display::DisplayLayout> layout(test::CreateDisplayLayout( | 182 std::unique_ptr<display::DisplayLayout> layout( |
181 display_manager(), display::DisplayPlacement::TOP, 0)); | 183 display::test::CreateDisplayLayout(display_manager(), |
| 184 display::DisplayPlacement::TOP, 0)); |
182 display_manager()->SetLayoutForCurrentDisplays(layout->Copy()); | 185 display_manager()->SetLayoutForCurrentDisplays(layout->Copy()); |
183 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); | 186 event_filter()->ShowSharedEdgeIndicator(root_windows[0] /* primary */); |
184 ASSERT_EQ(1U, GetWarpRegionsCount()); | 187 ASSERT_EQ(1U, GetWarpRegionsCount()); |
185 EXPECT_EQ(gfx::Rect(0, 0, 360, 1), GetIndicatorBounds(display_0_id)); | 188 EXPECT_EQ(gfx::Rect(0, 0, 360, 1), GetIndicatorBounds(display_0_id)); |
186 EXPECT_EQ(gfx::Rect(0, -1, 360, 1), GetIndicatorBounds(display_1_id)); | 189 EXPECT_EQ(gfx::Rect(0, -1, 360, 1), GetIndicatorBounds(display_1_id)); |
187 | 190 |
188 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); | 191 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); |
189 ASSERT_EQ(1U, GetWarpRegionsCount()); | 192 ASSERT_EQ(1U, GetWarpRegionsCount()); |
190 EXPECT_EQ(gfx::Rect(0, 0, 360, 1), GetIndicatorBounds(display_0_id)); | 193 EXPECT_EQ(gfx::Rect(0, 0, 360, 1), GetIndicatorBounds(display_0_id)); |
191 EXPECT_EQ(gfx::Rect(0, -1, 360, 1), GetIndicatorBounds(display_1_id)); | 194 EXPECT_EQ(gfx::Rect(0, -1, 360, 1), GetIndicatorBounds(display_1_id)); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 region_0->GetIndicatorBoundsForTest(display_2_id)); | 366 region_0->GetIndicatorBoundsForTest(display_2_id)); |
364 // between 2 and 1 | 367 // between 2 and 1 |
365 EXPECT_EQ(gfx::Rect(900, 499, 200, 1), | 368 EXPECT_EQ(gfx::Rect(900, 499, 200, 1), |
366 region_1->GetIndicatorBoundsForTest(display_1_id)); | 369 region_1->GetIndicatorBoundsForTest(display_1_id)); |
367 EXPECT_EQ(gfx::Rect(900, 500, 200, 1), | 370 EXPECT_EQ(gfx::Rect(900, 500, 200, 1), |
368 region_1->GetIndicatorBoundsForTest(display_2_id)); | 371 region_1->GetIndicatorBoundsForTest(display_2_id)); |
369 event_filter()->HideSharedEdgeIndicator(); | 372 event_filter()->HideSharedEdgeIndicator(); |
370 } | 373 } |
371 | 374 |
372 } // namespace ash | 375 } // namespace ash |
OLD | NEW |