| 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); | 276 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); |
| 278 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString()); | 277 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString()); |
| 279 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); | 278 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); |
| 280 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); | 279 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); |
| 281 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); | 280 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); |
| 282 EXPECT_EQ("20,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); | 281 EXPECT_EQ("20,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); |
| 283 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); | 282 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); |
| 284 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); | 283 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); |
| 285 } | 284 } |
| 286 | 285 |
| 287 TEST_F(ExtendedDesktopTest, CycleWindows) { | |
| 288 if (!SupportsMultipleDisplays()) | |
| 289 return; | |
| 290 | |
| 291 UpdateDisplay("700x500,500x500"); | |
| 292 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | |
| 293 | |
| 294 WindowCycleController* controller = | |
| 295 Shell::GetInstance()->window_cycle_controller(); | |
| 296 | |
| 297 views::Widget* d1_w1 = CreateTestWidget(gfx::Rect(10, 10, 100, 100)); | |
| 298 EXPECT_EQ(root_windows[0], d1_w1->GetNativeView()->GetRootWindow()); | |
| 299 views::Widget* d2_w1 = CreateTestWidget(gfx::Rect(800, 10, 100, 100)); | |
| 300 EXPECT_EQ(root_windows[1], d2_w1->GetNativeView()->GetRootWindow()); | |
| 301 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | |
| 302 | |
| 303 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); | |
| 304 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); | |
| 305 controller->HandleCycleWindow(WindowCycleController::FORWARD, false); | |
| 306 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | |
| 307 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); | |
| 308 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); | |
| 309 controller->HandleCycleWindow(WindowCycleController::BACKWARD, false); | |
| 310 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | |
| 311 | |
| 312 // Cycle through all windows across root windows. | |
| 313 views::Widget* d1_w2 = CreateTestWidget(gfx::Rect(10, 200, 100, 100)); | |
| 314 EXPECT_EQ(root_windows[0], d1_w2->GetNativeView()->GetRootWindow()); | |
| 315 views::Widget* d2_w2 = CreateTestWidget(gfx::Rect(800, 200, 100, 100)); | |
| 316 EXPECT_EQ(root_windows[1], d2_w2->GetNativeView()->GetRootWindow()); | |
| 317 | |
| 318 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | |
| 319 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); | |
| 320 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | |
| 321 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | |
| 322 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | |
| 323 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); | |
| 324 controller->HandleCycleWindow(WindowCycleController::FORWARD, true); | |
| 325 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); | |
| 326 | |
| 327 // Backwards | |
| 328 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | |
| 329 EXPECT_TRUE(wm::IsActiveWindow(d1_w1->GetNativeView())); | |
| 330 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | |
| 331 EXPECT_TRUE(wm::IsActiveWindow(d2_w1->GetNativeView())); | |
| 332 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | |
| 333 EXPECT_TRUE(wm::IsActiveWindow(d1_w2->GetNativeView())); | |
| 334 controller->HandleCycleWindow(WindowCycleController::BACKWARD, true); | |
| 335 EXPECT_TRUE(wm::IsActiveWindow(d2_w2->GetNativeView())); | |
| 336 } | |
| 337 | |
| 338 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { | 286 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { |
| 339 if (!SupportsMultipleDisplays()) | 287 if (!SupportsMultipleDisplays()) |
| 340 return; | 288 return; |
| 341 | 289 |
| 342 UpdateDisplay("700x500,500x500"); | 290 UpdateDisplay("700x500,500x500"); |
| 343 SetSecondaryDisplayLayout(DisplayLayout::LEFT); | 291 SetSecondaryDisplayLayout(DisplayLayout::LEFT); |
| 344 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 292 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 345 | 293 |
| 346 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); | 294 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-400, 100))); |
| 347 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); | 295 EXPECT_EQ(root_windows[1], wm::GetRootWindowAt(gfx::Point(-1, 100))); |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 generator.ReleaseLeftButton(); | 797 generator.ReleaseLeftButton(); |
| 850 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); | 798 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); |
| 851 | 799 |
| 852 generator.MoveMouseTo(400, 150); | 800 generator.MoveMouseTo(400, 150); |
| 853 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); | 801 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); |
| 854 | 802 |
| 855 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 803 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
| 856 } | 804 } |
| 857 | 805 |
| 858 } // namespace ash | 806 } // namespace ash |
| OLD | NEW |