| 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_manager.h" | 5 #include "ash/display/display_manager.h" |
| 6 #include "ash/root_window_controller.h" | 6 #include "ash/root_window_controller.h" |
| 7 #include "ash/screen_util.h" | 7 #include "ash/screen_util.h" |
| 8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 9 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 10 #include "ash/system/tray/system_tray.h" | 10 #include "ash/system/tray/system_tray.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/wm/coordinate_conversion.h" | 12 #include "ash/wm/aura/wm_window_aura.h" |
| 13 #include "ash/wm/common/root_window_finder.h" |
| 13 #include "ash/wm/window_properties.h" | 14 #include "ash/wm/window_properties.h" |
| 14 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
| 15 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 16 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 17 #include "ui/aura/client/capture_client.h" | 18 #include "ui/aura/client/capture_client.h" |
| 18 #include "ui/aura/client/focus_client.h" | 19 #include "ui/aura/client/focus_client.h" |
| 19 #include "ui/aura/test/test_windows.h" | 20 #include "ui/aura/test/test_windows.h" |
| 20 #include "ui/aura/test/window_test_api.h" | 21 #include "ui/aura/test/window_test_api.h" |
| 21 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
| 22 #include "ui/aura/window_event_dispatcher.h" | 23 #include "ui/aura/window_event_dispatcher.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 } | 308 } |
| 308 | 309 |
| 309 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { | 310 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { |
| 310 if (!SupportsMultipleDisplays()) | 311 if (!SupportsMultipleDisplays()) |
| 311 return; | 312 return; |
| 312 | 313 |
| 313 UpdateDisplay("700x500,500x500"); | 314 UpdateDisplay("700x500,500x500"); |
| 314 SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT); | 315 SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT); |
| 315 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 316 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 316 | 317 |
| 317 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); | 318 EXPECT_EQ(root_windows[1], wm::WmWindowAura::GetAuraWindow( |
| 318 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); | 319 wm::GetRootWindowAt(gfx::Point(-400, 100)))); |
| 319 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300))); | 320 EXPECT_EQ(root_windows[1], wm::WmWindowAura::GetAuraWindow( |
| 320 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700, 300))); | 321 wm::GetRootWindowAt(gfx::Point(-1, 100)))); |
| 322 EXPECT_EQ(root_windows[0], wm::WmWindowAura::GetAuraWindow( |
| 323 wm::GetRootWindowAt(gfx::Point(0, 300)))); |
| 324 EXPECT_EQ(root_windows[0], wm::WmWindowAura::GetAuraWindow( |
| 325 wm::GetRootWindowAt(gfx::Point(700, 300)))); |
| 321 | 326 |
| 322 // Zero origin. | 327 // Zero origin. |
| 323 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0))); | 328 EXPECT_EQ(root_windows[0], wm::WmWindowAura::GetAuraWindow( |
| 329 wm::GetRootWindowAt(gfx::Point(0, 0)))); |
| 324 | 330 |
| 325 // Out of range point should return the nearest root window | 331 // Out of range point should return the nearest root window |
| 326 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-600, 0))); | 332 EXPECT_EQ(root_windows[1], wm::WmWindowAura::GetAuraWindow( |
| 327 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100))); | 333 wm::GetRootWindowAt(gfx::Point(-600, 0)))); |
| 334 EXPECT_EQ(root_windows[0], wm::WmWindowAura::GetAuraWindow( |
| 335 wm::GetRootWindowAt(gfx::Point(701, 100)))); |
| 328 } | 336 } |
| 329 | 337 |
| 330 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { | 338 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { |
| 331 if (!SupportsMultipleDisplays()) | 339 if (!SupportsMultipleDisplays()) |
| 332 return; | 340 return; |
| 333 | 341 |
| 334 UpdateDisplay("700x500,500x500"); | 342 UpdateDisplay("700x500,500x500"); |
| 335 SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT); | 343 SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT); |
| 336 | 344 |
| 337 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 345 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 338 | 346 |
| 339 // Containing rect. | 347 // Containing rect. |
| 340 EXPECT_EQ(root_windows[1], | 348 EXPECT_EQ(root_windows[1], |
| 341 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); | 349 wm::WmWindowAura::GetAuraWindow( |
| 350 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50)))); |
| 342 EXPECT_EQ(root_windows[0], | 351 EXPECT_EQ(root_windows[0], |
| 343 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); | 352 wm::WmWindowAura::GetAuraWindow( |
| 353 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50)))); |
| 344 | 354 |
| 345 // Intersecting rect. | 355 // Intersecting rect. |
| 346 EXPECT_EQ(root_windows[1], | 356 EXPECT_EQ(root_windows[1], |
| 347 wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300))); | 357 wm::WmWindowAura::GetAuraWindow( |
| 358 wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300)))); |
| 348 EXPECT_EQ(root_windows[0], | 359 EXPECT_EQ(root_windows[0], |
| 349 wm::GetRootWindowMatching(gfx::Rect(-100, 0, 300, 300))); | 360 wm::WmWindowAura::GetAuraWindow( |
| 361 wm::GetRootWindowMatching(gfx::Rect(-100, 0, 300, 300)))); |
| 350 | 362 |
| 351 // Zero origin. | 363 // Zero origin. |
| 352 EXPECT_EQ(root_windows[0], | 364 EXPECT_EQ(root_windows[0], |
| 353 wm::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0))); | 365 wm::WmWindowAura::GetAuraWindow( |
| 366 wm::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0)))); |
| 354 EXPECT_EQ(root_windows[0], | 367 EXPECT_EQ(root_windows[0], |
| 355 wm::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1))); | 368 wm::WmWindowAura::GetAuraWindow( |
| 369 wm::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1)))); |
| 356 | 370 |
| 357 // Empty rect. | 371 // Empty rect. |
| 358 EXPECT_EQ(root_windows[1], | 372 EXPECT_EQ(root_windows[1], |
| 359 wm::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0))); | 373 wm::WmWindowAura::GetAuraWindow( |
| 374 wm::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0)))); |
| 360 EXPECT_EQ(root_windows[0], | 375 EXPECT_EQ(root_windows[0], |
| 361 wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0))); | 376 wm::WmWindowAura::GetAuraWindow( |
| 377 wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0)))); |
| 362 | 378 |
| 363 // Out of range rect should return the primary root window. | 379 // Out of range rect should return the primary root window. |
| 364 EXPECT_EQ(root_windows[0], | 380 EXPECT_EQ(root_windows[0], |
| 365 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); | 381 wm::WmWindowAura::GetAuraWindow( |
| 382 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50)))); |
| 366 EXPECT_EQ(root_windows[0], | 383 EXPECT_EQ(root_windows[0], |
| 367 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); | 384 wm::WmWindowAura::GetAuraWindow( |
| 385 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50)))); |
| 368 } | 386 } |
| 369 | 387 |
| 370 TEST_F(ExtendedDesktopTest, Capture) { | 388 TEST_F(ExtendedDesktopTest, Capture) { |
| 371 if (!SupportsMultipleDisplays()) | 389 if (!SupportsMultipleDisplays()) |
| 372 return; | 390 return; |
| 373 | 391 |
| 374 UpdateDisplay("1000x600,600x400"); | 392 UpdateDisplay("1000x600,600x400"); |
| 375 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 393 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 376 | 394 |
| 377 aura::test::EventCountDelegate r1_d1; | 395 aura::test::EventCountDelegate r1_d1; |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 generator.ReleaseLeftButton(); | 947 generator.ReleaseLeftButton(); |
| 930 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); | 948 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); |
| 931 | 949 |
| 932 generator.MoveMouseTo(400, 150); | 950 generator.MoveMouseTo(400, 150); |
| 933 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); | 951 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); |
| 934 | 952 |
| 935 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 953 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 936 } | 954 } |
| 937 | 955 |
| 938 } // namespace ash | 956 } // namespace ash |
| OLD | NEW |