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

Side by Side Diff: ash/display/extended_mouse_warp_controller_unittest.cc

Issue 2653593004: chromeos: Remove AshTestBase::SupportsMultipleDisplays (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « ash/display/display_util_unittest.cc ('k') | ash/display/mouse_cursor_event_filter_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/mouse_cursor_event_filter.h" 7 #include "ash/display/mouse_cursor_event_filter.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ui/display/display.h" 10 #include "ui/display/display.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 const gfx::Rect& GetIndicatorBounds(int64_t id) { 43 const gfx::Rect& GetIndicatorBounds(int64_t id) {
44 return GetWarpRegion(0)->GetIndicatorBoundsForTest(id); 44 return GetWarpRegion(0)->GetIndicatorBoundsForTest(id);
45 } 45 }
46 46
47 private: 47 private:
48 DISALLOW_COPY_AND_ASSIGN(ExtendedMouseWarpControllerTest); 48 DISALLOW_COPY_AND_ASSIGN(ExtendedMouseWarpControllerTest);
49 }; 49 };
50 50
51 // Verifies if MouseCursorEventFilter's bounds calculation works correctly. 51 // Verifies if MouseCursorEventFilter's bounds calculation works correctly.
52 TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnRight) { 52 TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnRight) {
53 if (!SupportsMultipleDisplays())
54 return;
55
56 UpdateDisplay("360x360,700x700"); 53 UpdateDisplay("360x360,700x700");
57 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 54 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
58 int64_t display_0_id = display::Screen::GetScreen() 55 int64_t display_0_id = display::Screen::GetScreen()
59 ->GetDisplayNearestWindow(root_windows[0]) 56 ->GetDisplayNearestWindow(root_windows[0])
60 .id(); 57 .id();
61 int64_t display_1_id = display::Screen::GetScreen() 58 int64_t display_1_id = display::Screen::GetScreen()
62 ->GetDisplayNearestWindow(root_windows[1]) 59 ->GetDisplayNearestWindow(root_windows[1])
63 .id(); 60 .id();
64 61
65 std::unique_ptr<display::DisplayLayout> layout( 62 std::unique_ptr<display::DisplayLayout> layout(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // 16 px are reserved on 2nd display from top, so y must be 113 // 16 px are reserved on 2nd display from top, so y must be
117 // (16 - 5) = 11 114 // (16 - 5) = 11
118 ASSERT_EQ(1U, GetWarpRegionsCount()); 115 ASSERT_EQ(1U, GetWarpRegionsCount());
119 EXPECT_EQ(gfx::Rect(359, 0, 1, 360), GetIndicatorBounds(display_0_id)); 116 EXPECT_EQ(gfx::Rect(359, 0, 1, 360), GetIndicatorBounds(display_0_id));
120 EXPECT_EQ(gfx::Rect(360, 11, 1, 349), GetIndicatorBounds(display_1_id)); 117 EXPECT_EQ(gfx::Rect(360, 11, 1, 349), GetIndicatorBounds(display_1_id));
121 118
122 event_filter()->HideSharedEdgeIndicator(); 119 event_filter()->HideSharedEdgeIndicator();
123 } 120 }
124 121
125 TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnLeft) { 122 TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnLeft) {
126 if (!SupportsMultipleDisplays())
127 return;
128
129 UpdateDisplay("360x360,700x700"); 123 UpdateDisplay("360x360,700x700");
130 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 124 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
131 125
132 int64_t display_0_id = display::Screen::GetScreen() 126 int64_t display_0_id = display::Screen::GetScreen()
133 ->GetDisplayNearestWindow(root_windows[0]) 127 ->GetDisplayNearestWindow(root_windows[0])
134 .id(); 128 .id();
135 int64_t display_1_id = display::Screen::GetScreen() 129 int64_t display_1_id = display::Screen::GetScreen()
136 ->GetDisplayNearestWindow(root_windows[1]) 130 ->GetDisplayNearestWindow(root_windows[1])
137 .id(); 131 .id();
138 132
(...skipping 21 matching lines...) Expand all
160 154
161 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); 155 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
162 ASSERT_EQ(1U, GetWarpRegionsCount()); 156 ASSERT_EQ(1U, GetWarpRegionsCount());
163 EXPECT_EQ(gfx::Rect(0, 250, 1, 110), GetIndicatorBounds(display_0_id)); 157 EXPECT_EQ(gfx::Rect(0, 250, 1, 110), GetIndicatorBounds(display_0_id));
164 EXPECT_EQ(gfx::Rect(-1, 250, 1, 110), GetIndicatorBounds(display_1_id)); 158 EXPECT_EQ(gfx::Rect(-1, 250, 1, 110), GetIndicatorBounds(display_1_id));
165 159
166 event_filter()->HideSharedEdgeIndicator(); 160 event_filter()->HideSharedEdgeIndicator();
167 } 161 }
168 162
169 TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnTopBottom) { 163 TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestOnTopBottom) {
170 if (!SupportsMultipleDisplays())
171 return;
172
173 UpdateDisplay("360x360,700x700"); 164 UpdateDisplay("360x360,700x700");
174 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 165 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
175 int64_t display_0_id = display::Screen::GetScreen() 166 int64_t display_0_id = display::Screen::GetScreen()
176 ->GetDisplayNearestWindow(root_windows[0]) 167 ->GetDisplayNearestWindow(root_windows[0])
177 .id(); 168 .id();
178 int64_t display_1_id = display::Screen::GetScreen() 169 int64_t display_1_id = display::Screen::GetScreen()
179 ->GetDisplayNearestWindow(root_windows[1]) 170 ->GetDisplayNearestWindow(root_windows[1])
180 .id(); 171 .id();
181 172
182 std::unique_ptr<display::DisplayLayout> layout( 173 std::unique_ptr<display::DisplayLayout> layout(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */); 207 event_filter()->ShowSharedEdgeIndicator(root_windows[1] /* secondary */);
217 ASSERT_EQ(1U, GetWarpRegionsCount()); 208 ASSERT_EQ(1U, GetWarpRegionsCount());
218 EXPECT_EQ(gfx::Rect(0, 359, 360, 1), GetIndicatorBounds(display_0_id)); 209 EXPECT_EQ(gfx::Rect(0, 359, 360, 1), GetIndicatorBounds(display_0_id));
219 EXPECT_EQ(gfx::Rect(0, 360, 360, 1), GetIndicatorBounds(display_1_id)); 210 EXPECT_EQ(gfx::Rect(0, 360, 360, 1), GetIndicatorBounds(display_1_id));
220 211
221 event_filter()->HideSharedEdgeIndicator(); 212 event_filter()->HideSharedEdgeIndicator();
222 } 213 }
223 214
224 // Verify indicators show up as expected with 3+ displays. 215 // Verify indicators show up as expected with 3+ displays.
225 TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestThreeDisplays) { 216 TEST_F(ExtendedMouseWarpControllerTest, IndicatorBoundsTestThreeDisplays) {
226 if (!SupportsMultipleDisplays())
227 return;
228
229 UpdateDisplay("360x360,700x700,1000x1000"); 217 UpdateDisplay("360x360,700x700,1000x1000");
230 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 218 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
231 display::Screen* screen = display::Screen::GetScreen(); 219 display::Screen* screen = display::Screen::GetScreen();
232 int64_t display_0_id = screen->GetDisplayNearestWindow(root_windows[0]).id(); 220 int64_t display_0_id = screen->GetDisplayNearestWindow(root_windows[0]).id();
233 int64_t display_1_id = screen->GetDisplayNearestWindow(root_windows[1]).id(); 221 int64_t display_1_id = screen->GetDisplayNearestWindow(root_windows[1]).id();
234 int64_t display_2_id = screen->GetDisplayNearestWindow(root_windows[2]).id(); 222 int64_t display_2_id = screen->GetDisplayNearestWindow(root_windows[2]).id();
235 223
236 // Drag from left most display 224 // Drag from left most display
237 event_filter()->ShowSharedEdgeIndicator(root_windows[0]); 225 event_filter()->ShowSharedEdgeIndicator(root_windows[0]);
238 ASSERT_EQ(2U, GetWarpRegionsCount()); 226 ASSERT_EQ(2U, GetWarpRegionsCount());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 EXPECT_EQ(gfx::Rect(1059, 0, 1, 700), 261 EXPECT_EQ(gfx::Rect(1059, 0, 1, 700),
274 region_0->GetIndicatorBoundsForTest(display_1_id)); 262 region_0->GetIndicatorBoundsForTest(display_1_id));
275 EXPECT_EQ(gfx::Rect(1060, 16, 1, 684), 263 EXPECT_EQ(gfx::Rect(1060, 16, 1, 684),
276 region_0->GetIndicatorBoundsForTest(display_2_id)); 264 region_0->GetIndicatorBoundsForTest(display_2_id));
277 event_filter()->HideSharedEdgeIndicator(); 265 event_filter()->HideSharedEdgeIndicator();
278 // TODO(oshima): Add test cases primary swap. 266 // TODO(oshima): Add test cases primary swap.
279 } 267 }
280 268
281 TEST_F(ExtendedMouseWarpControllerTest, 269 TEST_F(ExtendedMouseWarpControllerTest,
282 IndicatorBoundsTestThreeDisplaysWithLayout) { 270 IndicatorBoundsTestThreeDisplaysWithLayout) {
283 if (!SupportsMultipleDisplays())
284 return;
285 UpdateDisplay("700x500,500x500,1000x1000"); 271 UpdateDisplay("700x500,500x500,1000x1000");
286 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 272 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
287 display::Screen* screen = display::Screen::GetScreen(); 273 display::Screen* screen = display::Screen::GetScreen();
288 int64_t display_0_id = screen->GetDisplayNearestWindow(root_windows[0]).id(); 274 int64_t display_0_id = screen->GetDisplayNearestWindow(root_windows[0]).id();
289 int64_t display_1_id = screen->GetDisplayNearestWindow(root_windows[1]).id(); 275 int64_t display_1_id = screen->GetDisplayNearestWindow(root_windows[1]).id();
290 int64_t display_2_id = screen->GetDisplayNearestWindow(root_windows[2]).id(); 276 int64_t display_2_id = screen->GetDisplayNearestWindow(root_windows[2]).id();
291 277
292 // Layout so that all displays touches togter like this: 278 // Layout so that all displays touches togter like this:
293 // +-----+---+ 279 // +-----+---+
294 // | 0 | 1 | 280 // | 0 | 1 |
(...skipping 28 matching lines...) Expand all
323 // between 1 and 0 309 // between 1 and 0
324 EXPECT_EQ(gfx::Rect(699, 16, 1, 484), 310 EXPECT_EQ(gfx::Rect(699, 16, 1, 484),
325 region_2->GetIndicatorBoundsForTest(display_0_id)); 311 region_2->GetIndicatorBoundsForTest(display_0_id));
326 EXPECT_EQ(gfx::Rect(700, 0, 1, 500), 312 EXPECT_EQ(gfx::Rect(700, 0, 1, 500),
327 region_2->GetIndicatorBoundsForTest(display_1_id)); 313 region_2->GetIndicatorBoundsForTest(display_1_id));
328 event_filter()->HideSharedEdgeIndicator(); 314 event_filter()->HideSharedEdgeIndicator();
329 } 315 }
330 316
331 TEST_F(ExtendedMouseWarpControllerTest, 317 TEST_F(ExtendedMouseWarpControllerTest,
332 IndicatorBoundsTestThreeDisplaysWithLayout2) { 318 IndicatorBoundsTestThreeDisplaysWithLayout2) {
333 if (!SupportsMultipleDisplays())
334 return;
335 UpdateDisplay("700x500,500x500,1000x1000"); 319 UpdateDisplay("700x500,500x500,1000x1000");
336 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 320 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
337 display::Screen* screen = display::Screen::GetScreen(); 321 display::Screen* screen = display::Screen::GetScreen();
338 int64_t display_0_id = screen->GetDisplayNearestWindow(root_windows[0]).id(); 322 int64_t display_0_id = screen->GetDisplayNearestWindow(root_windows[0]).id();
339 int64_t display_1_id = screen->GetDisplayNearestWindow(root_windows[1]).id(); 323 int64_t display_1_id = screen->GetDisplayNearestWindow(root_windows[1]).id();
340 int64_t display_2_id = screen->GetDisplayNearestWindow(root_windows[2]).id(); 324 int64_t display_2_id = screen->GetDisplayNearestWindow(root_windows[2]).id();
341 325
342 // Layout so that 0 and 1 displays are disconnected. 326 // Layout so that 0 and 1 displays are disconnected.
343 // +-----+ +---+ 327 // +-----+ +---+
344 // | 0 | |1 | 328 // | 0 | |1 |
(...skipping 21 matching lines...) Expand all
366 region_0->GetIndicatorBoundsForTest(display_2_id)); 350 region_0->GetIndicatorBoundsForTest(display_2_id));
367 // between 2 and 1 351 // between 2 and 1
368 EXPECT_EQ(gfx::Rect(900, 499, 200, 1), 352 EXPECT_EQ(gfx::Rect(900, 499, 200, 1),
369 region_1->GetIndicatorBoundsForTest(display_1_id)); 353 region_1->GetIndicatorBoundsForTest(display_1_id));
370 EXPECT_EQ(gfx::Rect(900, 500, 200, 1), 354 EXPECT_EQ(gfx::Rect(900, 500, 200, 1),
371 region_1->GetIndicatorBoundsForTest(display_2_id)); 355 region_1->GetIndicatorBoundsForTest(display_2_id));
372 event_filter()->HideSharedEdgeIndicator(); 356 event_filter()->HideSharedEdgeIndicator();
373 } 357 }
374 358
375 } // namespace ash 359 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_util_unittest.cc ('k') | ash/display/mouse_cursor_event_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698