| 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/display_manager.h" | 6 #include "ash/display/display_manager.h" |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| 11 #include "ash/system/tray/system_tray.h" | 11 #include "ash/system/tray/system_tray.h" |
| 12 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
| 13 #include "ash/wm/coordinate_conversion.h" | 13 #include "ash/wm/coordinate_conversion.h" |
| 14 #include "ash/wm/window_cycle_controller.h" | |
| 15 #include "ash/wm/window_properties.h" | 14 #include "ash/wm/window_properties.h" |
| 16 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
| 17 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
| 18 #include "ui/aura/client/activation_client.h" | 17 #include "ui/aura/client/activation_client.h" |
| 19 #include "ui/aura/client/capture_client.h" | 18 #include "ui/aura/client/capture_client.h" |
| 20 #include "ui/aura/client/focus_client.h" | 19 #include "ui/aura/client/focus_client.h" |
| 21 #include "ui/aura/test/event_generator.h" | 20 #include "ui/aura/test/event_generator.h" |
| 22 #include "ui/aura/test/test_windows.h" | 21 #include "ui/aura/test/test_windows.h" |
| 23 #include "ui/aura/test/window_test_api.h" | 22 #include "ui/aura/test/window_test_api.h" |
| 24 #include "ui/aura/window.h" | 23 #include "ui/aura/window.h" |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); | 278 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); |
| 280 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString()); | 279 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString()); |
| 281 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); | 280 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); |
| 282 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); | 281 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); |
| 283 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); | 282 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); |
| 284 EXPECT_EQ("20,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); | 283 EXPECT_EQ("20,10", Shell::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, CycleWindows) { | |
| 290 if (!SupportsMultipleDisplays()) | |
| 291 return; | |
| 292 | |
| 293 UpdateDisplay("700x500,500x500"); | |
| 294 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
| 295 | |
| 296 WindowCycleController* controller = | |
| 297 Shell::GetInstance()->window_cycle_controller(); | |
| 298 | |
| 299 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | |
| 300 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow()); | |
| 301 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); | |
| 302 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow()); | |
| 303 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | |
| 304 | |
| 305 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); | |
| 306 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); | |
| 307 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); | |
| 308 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | |
| 309 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); | |
| 310 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); | |
| 311 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); | |
| 312 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | |
| 313 | |
| 314 // Cycle through all windows across root windows. | |
| 315 views::Widget* d1_w2 = CreateTestWidget(gfx::Rect(10, 200, 100, 100)); | |
| 316 EXPECT_EQ(root_windows[0], d1_w2->GetNativeView()->GetRootWindow()); | |
| 317 views::Widget* d2_w2 = CreateTestWidget(gfx::Rect(800, 200, 100, 100)); | |
| 318 EXPECT_EQ(root_windows[1], d2_w2->GetNativeView()->GetRootWindow()); | |
| 319 | |
| 320 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | |
| 321 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); | |
| 322 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | |
| 323 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | |
| 324 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | |
| 325 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); | |
| 326 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | |
| 327 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); | |
| 328 | |
| 329 // Backwards | |
| 330 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | |
| 331 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); | |
| 332 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | |
| 333 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | |
| 334 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | |
| 335 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); | |
| 336 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | |
| 337 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); | |
| 338 } | |
| 339 | |
| 340 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { | 288 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { |
| 341 if (!SupportsMultipleDisplays()) | 289 if (!SupportsMultipleDisplays()) |
| 342 return; | 290 return; |
| 343 | 291 |
| 344 UpdateDisplay("700x500,500x500"); | 292 UpdateDisplay("700x500,500x500"); |
| 345 SetSecondaryDisplayLayout(DisplayLayout::LEFT); | 293 SetSecondaryDisplayLayout(DisplayLayout::LEFT); |
| 346 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 294 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 347 | 295 |
| 348 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); | 296 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); |
| 349 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); | 297 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 generator.ReleaseLeftButton(); | 799 generator.ReleaseLeftButton(); |
| 852 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); | 800 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); |
| 853 | 801 |
| 854 generator.MoveMouseTo(400, 150); | 802 generator.MoveMouseTo(400, 150); |
| 855 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); | 803 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); |
| 856 | 804 |
| 857 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 805 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 858 } | 806 } |
| 859 | 807 |
| 860 } // namespace ash | 808 } // namespace ash |
| OLD | NEW |