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" |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 TEST_F(ExtendedDesktopTest, TestCursorLocation) { | 282 TEST_F(ExtendedDesktopTest, TestCursorLocation) { |
283 if (!SupportsMultipleDisplays()) | 283 if (!SupportsMultipleDisplays()) |
284 return; | 284 return; |
285 | 285 |
286 UpdateDisplay("1000x600,600x400"); | 286 UpdateDisplay("1000x600,600x400"); |
287 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 287 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
288 aura::test::WindowTestApi root_window0_test_api(root_windows[0]); | 288 aura::test::WindowTestApi root_window0_test_api(root_windows[0]); |
289 aura::test::WindowTestApi root_window1_test_api(root_windows[1]); | 289 aura::test::WindowTestApi root_window1_test_api(root_windows[1]); |
290 | 290 |
291 root_windows[0]->MoveCursorTo(gfx::Point(10, 10)); | 291 root_windows[0]->MoveCursorTo(gfx::Point(10, 10)); |
292 EXPECT_EQ("10,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); | 292 EXPECT_EQ("10,10", |
| 293 gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); |
293 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); | 294 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); |
294 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); | 295 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); |
295 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); | 296 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); |
296 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString()); | 297 EXPECT_EQ("1010,20", |
| 298 gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); |
297 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); | 299 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); |
298 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); | 300 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); |
299 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); | 301 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); |
300 EXPECT_EQ("20,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); | 302 EXPECT_EQ("20,10", |
| 303 gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); |
301 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); | 304 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); |
302 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); | 305 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); |
303 } | 306 } |
304 | 307 |
305 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { | 308 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { |
306 if (!SupportsMultipleDisplays()) | 309 if (!SupportsMultipleDisplays()) |
307 return; | 310 return; |
308 | 311 |
309 UpdateDisplay("700x500,500x500"); | 312 UpdateDisplay("700x500,500x500"); |
310 SetSecondaryDisplayLayout(DisplayLayout::LEFT); | 313 SetSecondaryDisplayLayout(DisplayLayout::LEFT); |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 605 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
603 } | 606 } |
604 | 607 |
605 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) { | 608 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) { |
606 if (!SupportsMultipleDisplays()) | 609 if (!SupportsMultipleDisplays()) |
607 return; | 610 return; |
608 | 611 |
609 UpdateDisplay("1000x1000,1000x1000"); | 612 UpdateDisplay("1000x1000,1000x1000"); |
610 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 613 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
611 | 614 |
612 gfx::Display display0 = Shell::GetScreen()->GetDisplayMatching( | 615 gfx::Display display0 = gfx::Screen::GetScreen()->GetDisplayMatching( |
613 root_windows[0]->GetBoundsInScreen()); | 616 root_windows[0]->GetBoundsInScreen()); |
614 gfx::Display display1 = Shell::GetScreen()->GetDisplayMatching( | 617 gfx::Display display1 = gfx::Screen::GetScreen()->GetDisplayMatching( |
615 root_windows[1]->GetBoundsInScreen()); | 618 root_windows[1]->GetBoundsInScreen()); |
616 EXPECT_NE(display0.id(), display1.id()); | 619 EXPECT_NE(display0.id(), display1.id()); |
617 | 620 |
618 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); | 621 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); |
619 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); | 622 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
620 | 623 |
621 // Move the window where the window spans both root windows. Since the second | 624 // Move the window where the window spans both root windows. Since the second |
622 // parameter is |display1|, the window should be shown on the secondary root. | 625 // parameter is |display1|, the window should be shown on the secondary root. |
623 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100), | 626 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100), |
624 display1); | 627 display1); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); | 693 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); |
691 EXPECT_EQ("10,50 50x50", | 694 EXPECT_EQ("10,50 50x50", |
692 w1_t1->GetWindowBoundsInScreen().ToString()); | 695 w1_t1->GetWindowBoundsInScreen().ToString()); |
693 } | 696 } |
694 | 697 |
695 // Test if the Window::ConvertPointToTarget works across root windows. | 698 // Test if the Window::ConvertPointToTarget works across root windows. |
696 // TODO(oshima): Move multiple display suport and this test to aura. | 699 // TODO(oshima): Move multiple display suport and this test to aura. |
697 TEST_F(ExtendedDesktopTest, ConvertPoint) { | 700 TEST_F(ExtendedDesktopTest, ConvertPoint) { |
698 if (!SupportsMultipleDisplays()) | 701 if (!SupportsMultipleDisplays()) |
699 return; | 702 return; |
700 gfx::Screen* screen = Shell::GetScreen(); | 703 gfx::Screen* screen = gfx::Screen::GetScreen(); |
701 UpdateDisplay("1000x600,600x400"); | 704 UpdateDisplay("1000x600,600x400"); |
702 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 705 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
703 gfx::Display display_1 = screen->GetDisplayNearestWindow(root_windows[0]); | 706 gfx::Display display_1 = screen->GetDisplayNearestWindow(root_windows[0]); |
704 EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); | 707 EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); |
705 gfx::Display display_2 = screen->GetDisplayNearestWindow(root_windows[1]); | 708 gfx::Display display_2 = screen->GetDisplayNearestWindow(root_windows[1]); |
706 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString()); | 709 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString()); |
707 | 710 |
708 aura::Window* d1 = | 711 aura::Window* d1 = |
709 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView(); | 712 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView(); |
710 aura::Window* d2 = | 713 aura::Window* d2 = |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 } | 831 } |
829 | 832 |
830 TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) { | 833 TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) { |
831 if (!SupportsMultipleDisplays()) | 834 if (!SupportsMultipleDisplays()) |
832 return; | 835 return; |
833 | 836 |
834 UpdateDisplay("100x100,200x200"); | 837 UpdateDisplay("100x100,200x200"); |
835 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 838 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
836 | 839 |
837 // Create normal windows on both displays. | 840 // Create normal windows on both displays. |
838 views::Widget* widget1 = CreateTestWidget( | 841 views::Widget* widget1 = |
839 Shell::GetScreen()->GetPrimaryDisplay().bounds()); | 842 CreateTestWidget(gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds()); |
840 widget1->Show(); | 843 widget1->Show(); |
841 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow()); | 844 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow()); |
842 views::Widget* widget2 = CreateTestWidget( | 845 views::Widget* widget2 = CreateTestWidget( |
843 ScreenUtil::GetSecondaryDisplay().bounds()); | 846 ScreenUtil::GetSecondaryDisplay().bounds()); |
844 widget2->Show(); | 847 widget2->Show(); |
845 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow()); | 848 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow()); |
846 | 849 |
847 // Create a LockScreen window. | 850 // Create a LockScreen window. |
848 views::Widget* lock_widget = CreateTestWidget( | 851 views::Widget* lock_widget = |
849 Shell::GetScreen()->GetPrimaryDisplay().bounds()); | 852 CreateTestWidget(gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds()); |
850 views::Textfield* textfield = new views::Textfield; | 853 views::Textfield* textfield = new views::Textfield; |
851 lock_widget->client_view()->AddChildView(textfield); | 854 lock_widget->client_view()->AddChildView(textfield); |
852 | 855 |
853 ash::Shell::GetContainer(Shell::GetPrimaryRootWindow(), | 856 ash::Shell::GetContainer(Shell::GetPrimaryRootWindow(), |
854 ash::kShellWindowId_LockScreenContainer) | 857 ash::kShellWindowId_LockScreenContainer) |
855 ->AddChild(lock_widget->GetNativeView()); | 858 ->AddChild(lock_widget->GetNativeView()); |
856 lock_widget->Show(); | 859 lock_widget->Show(); |
857 textfield->RequestFocus(); | 860 textfield->RequestFocus(); |
858 | 861 |
859 aura::client::FocusClient* focus_client = | 862 aura::client::FocusClient* focus_client = |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
925 generator.ReleaseLeftButton(); | 928 generator.ReleaseLeftButton(); |
926 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); | 929 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); |
927 | 930 |
928 generator.MoveMouseTo(400, 150); | 931 generator.MoveMouseTo(400, 150); |
929 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); | 932 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); |
930 | 933 |
931 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); | 934 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); |
932 } | 935 } |
933 | 936 |
934 } // namespace ash | 937 } // namespace ash |
OLD | NEW |