| 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/public/cpp/shell_window_ids.h" | 5 #include "ash/public/cpp/shell_window_ids.h" |
| 6 #include "ash/root_window_controller.h" | 6 #include "ash/root_window_controller.h" |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/system/tray/system_tray.h" | 8 #include "ash/system/tray/system_tray.h" |
| 9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 10 #include "ash/wm/root_window_finder.h" | 10 #include "ash/wm/root_window_finder.h" |
| 11 #include "ash/wm/window_properties.h" | 11 #include "ash/wm/window_properties.h" |
| 12 #include "ash/wm/window_util.h" | 12 #include "ash/wm/window_util.h" |
| 13 #include "ash/wm_window.h" | |
| 14 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 16 #include "ui/aura/client/capture_client.h" | 15 #include "ui/aura/client/capture_client.h" |
| 17 #include "ui/aura/client/focus_client.h" | 16 #include "ui/aura/client/focus_client.h" |
| 18 #include "ui/aura/test/test_windows.h" | 17 #include "ui/aura/test/test_windows.h" |
| 19 #include "ui/aura/test/window_test_api.h" | 18 #include "ui/aura/test/window_test_api.h" |
| 20 #include "ui/aura/window.h" | 19 #include "ui/aura/window.h" |
| 21 #include "ui/aura/window_event_dispatcher.h" | 20 #include "ui/aura/window_event_dispatcher.h" |
| 22 #include "ui/base/cursor/cursor.h" | 21 #include "ui/base/cursor/cursor.h" |
| 23 #include "ui/display/display.h" | 22 #include "ui/display/display.h" |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 display::Screen::GetScreen()->GetCursorScreenPoint().ToString()); | 283 display::Screen::GetScreen()->GetCursorScreenPoint().ToString()); |
| 285 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); | 284 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); |
| 286 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); | 285 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); |
| 287 } | 286 } |
| 288 | 287 |
| 289 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { | 288 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { |
| 290 UpdateDisplay("700x500,500x500"); | 289 UpdateDisplay("700x500,500x500"); |
| 291 SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT); | 290 SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT); |
| 292 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 291 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 293 | 292 |
| 294 EXPECT_EQ(root_windows[1], WmWindow::GetAuraWindow( | 293 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); |
| 295 wm::GetRootWindowAt(gfx::Point(-400, 100)))); | 294 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); |
| 296 EXPECT_EQ(root_windows[1], | 295 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 300))); |
| 297 WmWindow::GetAuraWindow(wm::GetRootWindowAt(gfx::Point(-1, 100)))); | 296 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(700, 300))); |
| 298 EXPECT_EQ(root_windows[0], | |
| 299 WmWindow::GetAuraWindow(wm::GetRootWindowAt(gfx::Point(0, 300)))); | |
| 300 EXPECT_EQ(root_windows[0], | |
| 301 WmWindow::GetAuraWindow(wm::GetRootWindowAt(gfx::Point(700, 300)))); | |
| 302 | 297 |
| 303 // Zero origin. | 298 // Zero origin. |
| 304 EXPECT_EQ(root_windows[0], | 299 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(0, 0))); |
| 305 WmWindow::GetAuraWindow(wm::GetRootWindowAt(gfx::Point(0, 0)))); | |
| 306 | 300 |
| 307 // Out of range point should return the nearest root window | 301 // Out of range point should return the nearest root window |
| 308 EXPECT_EQ(root_windows[1], | 302 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-600, 0))); |
| 309 WmWindow::GetAuraWindow(wm::GetRootWindowAt(gfx::Point(-600, 0)))); | 303 EXPECT_EQ(root_windows[0], wm::GetRootWindowAt(gfx::Point(701, 100))); |
| 310 EXPECT_EQ(root_windows[0], | |
| 311 WmWindow::GetAuraWindow(wm::GetRootWindowAt(gfx::Point(701, 100)))); | |
| 312 } | 304 } |
| 313 | 305 |
| 314 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { | 306 TEST_F(ExtendedDesktopTest, GetRootWindowMatching) { |
| 315 UpdateDisplay("700x500,500x500"); | 307 UpdateDisplay("700x500,500x500"); |
| 316 SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT); | 308 SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT); |
| 317 | 309 |
| 318 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 310 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 319 | 311 |
| 320 // Containing rect. | 312 // Containing rect. |
| 321 EXPECT_EQ(root_windows[1], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 313 EXPECT_EQ(root_windows[1], |
| 322 gfx::Rect(-300, 10, 50, 50)))); | 314 wm::GetRootWindowMatching(gfx::Rect(-300, 10, 50, 50))); |
| 323 EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 315 EXPECT_EQ(root_windows[0], |
| 324 gfx::Rect(100, 10, 50, 50)))); | 316 wm::GetRootWindowMatching(gfx::Rect(100, 10, 50, 50))); |
| 325 | 317 |
| 326 // Intersecting rect. | 318 // Intersecting rect. |
| 327 EXPECT_EQ(root_windows[1], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 319 EXPECT_EQ(root_windows[1], |
| 328 gfx::Rect(-200, 0, 300, 300)))); | 320 wm::GetRootWindowMatching(gfx::Rect(-200, 0, 300, 300))); |
| 329 EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 321 EXPECT_EQ(root_windows[0], |
| 330 gfx::Rect(-100, 0, 300, 300)))); | 322 wm::GetRootWindowMatching(gfx::Rect(-100, 0, 300, 300))); |
| 331 | 323 |
| 332 // Zero origin. | 324 // Zero origin. |
| 333 EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 325 EXPECT_EQ(root_windows[0], wm::GetRootWindowMatching(gfx::Rect(0, 0, 0, 0))); |
| 334 gfx::Rect(0, 0, 0, 0)))); | 326 EXPECT_EQ(root_windows[0], wm::GetRootWindowMatching(gfx::Rect(0, 0, 1, 1))); |
| 335 EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | |
| 336 gfx::Rect(0, 0, 1, 1)))); | |
| 337 | 327 |
| 338 // Empty rect. | 328 // Empty rect. |
| 339 EXPECT_EQ(root_windows[1], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 329 EXPECT_EQ(root_windows[1], |
| 340 gfx::Rect(-400, 100, 0, 0)))); | 330 wm::GetRootWindowMatching(gfx::Rect(-400, 100, 0, 0))); |
| 341 EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 331 EXPECT_EQ(root_windows[0], |
| 342 gfx::Rect(100, 100, 0, 0)))); | 332 wm::GetRootWindowMatching(gfx::Rect(100, 100, 0, 0))); |
| 343 | 333 |
| 344 // Out of range rect should return the primary root window. | 334 // Out of range rect should return the primary root window. |
| 345 EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 335 EXPECT_EQ(root_windows[0], |
| 346 gfx::Rect(-600, -300, 50, 50)))); | 336 wm::GetRootWindowMatching(gfx::Rect(-600, -300, 50, 50))); |
| 347 EXPECT_EQ(root_windows[0], WmWindow::GetAuraWindow(wm::GetRootWindowMatching( | 337 EXPECT_EQ(root_windows[0], |
| 348 gfx::Rect(0, 1000, 50, 50)))); | 338 wm::GetRootWindowMatching(gfx::Rect(0, 1000, 50, 50))); |
| 349 } | 339 } |
| 350 | 340 |
| 351 TEST_F(ExtendedDesktopTest, Capture) { | 341 TEST_F(ExtendedDesktopTest, Capture) { |
| 352 UpdateDisplay("1000x600,600x400"); | 342 UpdateDisplay("1000x600,600x400"); |
| 353 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 343 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 354 | 344 |
| 355 aura::test::EventCountDelegate r1_d1; | 345 aura::test::EventCountDelegate r1_d1; |
| 356 aura::test::EventCountDelegate r1_d2; | 346 aura::test::EventCountDelegate r1_d2; |
| 357 aura::test::EventCountDelegate r2_d1; | 347 aura::test::EventCountDelegate r2_d1; |
| 358 | 348 |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 generator.ReleaseLeftButton(); | 843 generator.ReleaseLeftButton(); |
| 854 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); | 844 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); |
| 855 | 845 |
| 856 generator.MoveMouseTo(400, 150); | 846 generator.MoveMouseTo(400, 150); |
| 857 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); | 847 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); |
| 858 | 848 |
| 859 ash::Shell::Get()->RemovePreTargetHandler(&event_handler); | 849 ash::Shell::Get()->RemovePreTargetHandler(&event_handler); |
| 860 } | 850 } |
| 861 | 851 |
| 862 } // namespace ash | 852 } // namespace ash |
| OLD | NEW |