OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/display_controller.h" | 5 #include "ash/display/display_controller.h" |
6 #include "ash/display/multi_display_manager.h" | 6 #include "ash/display/multi_display_manager.h" |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/test/ash_test_base.h" | 8 #include "ash/test/ash_test_base.h" |
| 9 #include "ash/wm/coordinate_conversion.h" |
9 #include "ash/wm/property_util.h" | 10 #include "ash/wm/property_util.h" |
10 #include "ash/wm/window_cycle_controller.h" | 11 #include "ash/wm/window_cycle_controller.h" |
11 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
12 #include "ui/aura/client/activation_client.h" | 13 #include "ui/aura/client/activation_client.h" |
13 #include "ui/aura/client/capture_client.h" | 14 #include "ui/aura/client/capture_client.h" |
14 #include "ui/aura/env.h" | 15 #include "ui/aura/env.h" |
15 #include "ui/aura/focus_manager.h" | 16 #include "ui/aura/focus_manager.h" |
16 #include "ui/aura/root_window.h" | 17 #include "ui/aura/root_window.h" |
17 #include "ui/aura/test/event_generator.h" | 18 #include "ui/aura/test/event_generator.h" |
18 #include "ui/aura/test/test_windows.h" | 19 #include "ui/aura/test/test_windows.h" |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | 239 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); |
239 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); | 240 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); |
240 } | 241 } |
241 | 242 |
242 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { | 243 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { |
243 UpdateDisplay("700x500,500x500"); | 244 UpdateDisplay("700x500,500x500"); |
244 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 245 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( |
245 internal::DisplayController::LEFT); | 246 internal::DisplayController::LEFT); |
246 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 247 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
247 | 248 |
248 EXPECT_EQ(root_windows[1], Shell::GetRootWindowAt(gfx::Point(-400, 100))); | 249 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); |
249 EXPECT_EQ(root_windows[1], Shell::GetRootWindowAt(gfx::Point(-1, 100))); | 250 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); |
250 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(0, 300))); | 251 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300))); |
251 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(700,300))); | 252 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700,300))); |
252 | 253 |
253 // Zero origin. | 254 // Zero origin. |
254 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(0, 0))); | 255 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0))); |
255 | 256 |
256 // Out of range point should return the primary root window | 257 // Out of range point should return the primary root window |
257 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(-600, 0))); | 258 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(-600, 0))); |
258 EXPECT_EQ(root_windows[0], Shell::GetRootWindowAt(gfx::Point(701, 100))); | 259 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100))); |
259 } | 260 } |
260 | 261 |
261 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { | 262 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { |
262 UpdateDisplay("700x500,500x500"); | 263 UpdateDisplay("700x500,500x500"); |
263 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( | 264 Shell::GetInstance()->display_controller()->SetSecondaryDisplayLayout( |
264 internal::DisplayController::LEFT); | 265 internal::DisplayController::LEFT); |
265 | 266 |
266 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 267 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
267 | 268 |
268 // Containing rect. | 269 // Containing rect. |
269 EXPECT_EQ(root_windows[1], | 270 EXPECT_EQ(root_windows[1], |
270 Shell::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); | 271 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); |
271 EXPECT_EQ(root_windows[0], | 272 EXPECT_EQ(root_windows[0], |
272 Shell::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); | 273 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); |
273 | 274 |
274 // Intersecting rect. | 275 // Intersecting rect. |
275 EXPECT_EQ(root_windows[1], | 276 EXPECT_EQ(root_windows[1], |
276 Shell::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300))); | 277 wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300))); |
277 EXPECT_EQ(root_windows[0], | 278 EXPECT_EQ(root_windows[0], |
278 Shell::GetRootWindowMatching(gfx::Rect(-100, 0, 300, 300))); | 279 wm::GetRootWindowMatching(gfx::Rect(-100, 0, 300, 300))); |
279 | 280 |
280 // Zero origin. | 281 // Zero origin. |
281 EXPECT_EQ(root_windows[0], | 282 EXPECT_EQ(root_windows[0], |
282 Shell::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0))); | 283 wm::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0))); |
283 EXPECT_EQ(root_windows[0], | 284 EXPECT_EQ(root_windows[0], |
284 Shell::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1))); | 285 wm::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1))); |
285 | 286 |
286 // Empty rect. | 287 // Empty rect. |
287 EXPECT_EQ(root_windows[1], | 288 EXPECT_EQ(root_windows[1], |
288 Shell::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0))); | 289 wm::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0))); |
289 EXPECT_EQ(root_windows[0], | 290 EXPECT_EQ(root_windows[0], |
290 Shell::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0))); | 291 wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0))); |
291 | 292 |
292 // Out of range rect should return the primary root window. | 293 // Out of range rect should return the primary root window. |
293 EXPECT_EQ(root_windows[0], | 294 EXPECT_EQ(root_windows[0], |
294 Shell::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); | 295 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); |
295 EXPECT_EQ(root_windows[0], | 296 EXPECT_EQ(root_windows[0], |
296 Shell::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); | 297 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); |
297 } | 298 } |
298 | 299 |
299 TEST_F(ExtendedDesktopTest, Capture) { | 300 TEST_F(ExtendedDesktopTest, Capture) { |
300 UpdateDisplay("1000x600,600x400"); | 301 UpdateDisplay("1000x600,600x400"); |
301 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 302 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
302 | 303 |
303 aura::test::EventCountDelegate r1_d1; | 304 aura::test::EventCountDelegate r1_d1; |
304 aura::test::EventCountDelegate r1_d2; | 305 aura::test::EventCountDelegate r1_d2; |
305 aura::test::EventCountDelegate r2_d1; | 306 aura::test::EventCountDelegate r2_d1; |
306 | 307 |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 p.SetPoint(0, 0); | 493 p.SetPoint(0, 0); |
493 aura::Window::ConvertPointToWindow(root_windows[0], root_windows[1], &p); | 494 aura::Window::ConvertPointToWindow(root_windows[0], root_windows[1], &p); |
494 EXPECT_EQ("0,-600", p.ToString()); | 495 EXPECT_EQ("0,-600", p.ToString()); |
495 p.SetPoint(0, 0); | 496 p.SetPoint(0, 0); |
496 aura::Window::ConvertPointToWindow(d1, d2, &p); | 497 aura::Window::ConvertPointToWindow(d1, d2, &p); |
497 EXPECT_EQ("-10,-610", p.ToString()); | 498 EXPECT_EQ("-10,-610", p.ToString()); |
498 } | 499 } |
499 | 500 |
500 } // namespace internal | 501 } // namespace internal |
501 } // namespace ash | 502 } // namespace ash |
OLD | NEW |