| 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/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/coordinate_conversion.h" | 10 #include "ash/wm/coordinate_conversion.h" |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type()); | 183 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type()); |
| 184 } | 184 } |
| 185 | 185 |
| 186 TEST_F(ExtendedDesktopTest, TestCursorLocation) { | 186 TEST_F(ExtendedDesktopTest, TestCursorLocation) { |
| 187 UpdateDisplay("0+0-1000x600,1001+0-600x400"); | 187 UpdateDisplay("0+0-1000x600,1001+0-600x400"); |
| 188 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 188 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 189 aura::Window::TestApi root_window0_test_api(root_windows[0]); | 189 aura::Window::TestApi root_window0_test_api(root_windows[0]); |
| 190 aura::Window::TestApi root_window1_test_api(root_windows[1]); | 190 aura::Window::TestApi root_window1_test_api(root_windows[1]); |
| 191 | 191 |
| 192 root_windows[0]->MoveCursorTo(gfx::Point(10, 10)); | 192 root_windows[0]->MoveCursorTo(gfx::Point(10, 10)); |
| 193 EXPECT_EQ("10,10", gfx::Screen::GetCursorScreenPoint().ToString()); | 193 EXPECT_EQ("10,10", gfx::Screen::GetCursorScreenPoint( |
| 194 ash::Shell::GetRootNativeView()).ToString()); |
| 194 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); | 195 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); |
| 195 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); | 196 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); |
| 196 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); | 197 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); |
| 197 EXPECT_EQ("1010,20", gfx::Screen::GetCursorScreenPoint().ToString()); | 198 EXPECT_EQ("1010,20", gfx::Screen::GetCursorScreenPoint( |
| 199 ash::Shell::GetRootNativeView()).ToString()); |
| 198 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); | 200 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); |
| 199 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); | 201 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); |
| 200 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); | 202 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); |
| 201 EXPECT_EQ("20,10", gfx::Screen::GetCursorScreenPoint().ToString()); | 203 EXPECT_EQ("20,10", gfx::Screen::GetCursorScreenPoint( |
| 204 ash::Shell::GetRootNativeView()).ToString()); |
| 202 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); | 205 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); |
| 203 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); | 206 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); |
| 204 } | 207 } |
| 205 | 208 |
| 206 TEST_F(ExtendedDesktopTest, CycleWindows) { | 209 TEST_F(ExtendedDesktopTest, CycleWindows) { |
| 207 UpdateDisplay("700x500,500x500"); | 210 UpdateDisplay("700x500,500x500"); |
| 208 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 211 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 209 | 212 |
| 210 WindowCycleController* controller = | 213 WindowCycleController* controller = |
| 211 Shell::GetInstance()->window_cycle_controller(); | 214 Shell::GetInstance()->window_cycle_controller(); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 // TODO(oshima): This one probably should pick the closest root window. | 405 // TODO(oshima): This one probably should pick the closest root window. |
| 403 d1->SetBounds(gfx::Rect(200, 10, 100, 100)); | 406 d1->SetBounds(gfx::Rect(200, 10, 100, 100)); |
| 404 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); | 407 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
| 405 } | 408 } |
| 406 | 409 |
| 407 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) { | 410 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) { |
| 408 UpdateDisplay("1000x1000,1000x1000"); | 411 UpdateDisplay("1000x1000,1000x1000"); |
| 409 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 412 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 410 | 413 |
| 411 gfx::Display display0 = | 414 gfx::Display display0 = |
| 412 gfx::Screen::GetDisplayMatching(root_windows[0]->GetBoundsInScreen()); | 415 gfx::Screen::GetDisplayMatching( |
| 416 ash::Shell::GetRootNativeView(), |
| 417 root_windows[0]->GetBoundsInScreen()); |
| 413 gfx::Display display1 = | 418 gfx::Display display1 = |
| 414 gfx::Screen::GetDisplayMatching(root_windows[1]->GetBoundsInScreen()); | 419 gfx::Screen::GetDisplayMatching( |
| 420 ash::Shell::GetRootNativeView(), |
| 421 root_windows[1]->GetBoundsInScreen()); |
| 415 EXPECT_NE(display0.id(), display1.id()); | 422 EXPECT_NE(display0.id(), display1.id()); |
| 416 | 423 |
| 417 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); | 424 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); |
| 418 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); | 425 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
| 419 | 426 |
| 420 // Move the window where the window spans both root windows. Since the second | 427 // Move the window where the window spans both root windows. Since the second |
| 421 // parameter is |display1|, the window should be shown on the secondary root. | 428 // parameter is |display1|, the window should be shown on the secondary root. |
| 422 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100), | 429 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100), |
| 423 display1); | 430 display1); |
| 424 EXPECT_EQ("500,10 1000x100", | 431 EXPECT_EQ("500,10 1000x100", |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); | 601 EXPECT_EQ(root_windows[1], w1->GetNativeView()->GetRootWindow()); |
| 595 | 602 |
| 596 // The widget should now move to the 1st root window without the property. | 603 // The widget should now move to the 1st root window without the property. |
| 597 w1->GetNativeView()->ClearProperty(internal::kStayInSameRootWindowKey); | 604 w1->GetNativeView()->ClearProperty(internal::kStayInSameRootWindowKey); |
| 598 w1->SetBounds(gfx::Rect(10, 10, 50, 50)); | 605 w1->SetBounds(gfx::Rect(10, 10, 50, 50)); |
| 599 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); | 606 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); |
| 600 } | 607 } |
| 601 | 608 |
| 602 } // namespace internal | 609 } // namespace internal |
| 603 } // namespace ash | 610 } // namespace ash |
| OLD | NEW |