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/screen_ash.h" | 7 #include "ash/screen_ash.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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type()); | 187 EXPECT_EQ(ui::kCursorCopy, root_windows[1]->last_cursor().native_type()); |
188 } | 188 } |
189 | 189 |
190 TEST_F(ExtendedDesktopTest, TestCursorLocation) { | 190 TEST_F(ExtendedDesktopTest, TestCursorLocation) { |
191 UpdateDisplay("0+0-1000x600,1001+0-600x400"); | 191 UpdateDisplay("0+0-1000x600,1001+0-600x400"); |
192 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 192 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
193 aura::Window::TestApi root_window0_test_api(root_windows[0]); | 193 aura::Window::TestApi root_window0_test_api(root_windows[0]); |
194 aura::Window::TestApi root_window1_test_api(root_windows[1]); | 194 aura::Window::TestApi root_window1_test_api(root_windows[1]); |
195 | 195 |
196 root_windows[0]->MoveCursorTo(gfx::Point(10, 10)); | 196 root_windows[0]->MoveCursorTo(gfx::Point(10, 10)); |
197 EXPECT_EQ("10,10", gfx::Screen::GetCursorScreenPoint().ToString()); | 197 EXPECT_EQ("10,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); |
198 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); | 198 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); |
199 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); | 199 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); |
200 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); | 200 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); |
201 EXPECT_EQ("1010,20", gfx::Screen::GetCursorScreenPoint().ToString()); | 201 EXPECT_EQ("1010,20", Shell::GetScreen()->GetCursorScreenPoint().ToString()); |
202 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); | 202 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); |
203 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); | 203 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); |
204 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); | 204 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); |
205 EXPECT_EQ("20,10", gfx::Screen::GetCursorScreenPoint().ToString()); | 205 EXPECT_EQ("20,10", Shell::GetScreen()->GetCursorScreenPoint().ToString()); |
206 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); | 206 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); |
207 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); | 207 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); |
208 } | 208 } |
209 | 209 |
210 TEST_F(ExtendedDesktopTest, CycleWindows) { | 210 TEST_F(ExtendedDesktopTest, CycleWindows) { |
211 UpdateDisplay("700x500,500x500"); | 211 UpdateDisplay("700x500,500x500"); |
212 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 212 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
213 | 213 |
214 WindowCycleController* controller = | 214 WindowCycleController* controller = |
215 Shell::GetInstance()->window_cycle_controller(); | 215 Shell::GetInstance()->window_cycle_controller(); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 // Setting outside of root windows will be moved to primary root window. | 405 // Setting outside of root windows will be moved to primary root window. |
406 // TODO(oshima): This one probably should pick the closest root window. | 406 // TODO(oshima): This one probably should pick the closest root window. |
407 d1->SetBounds(gfx::Rect(200, 10, 100, 100)); | 407 d1->SetBounds(gfx::Rect(200, 10, 100, 100)); |
408 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); | 408 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
409 } | 409 } |
410 | 410 |
411 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) { | 411 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) { |
412 UpdateDisplay("1000x1000,1000x1000"); | 412 UpdateDisplay("1000x1000,1000x1000"); |
413 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 413 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
414 | 414 |
415 gfx::Display display0 = | 415 gfx::Display display0 = Shell::GetScreen()->GetDisplayMatching( |
416 gfx::Screen::GetDisplayMatching(root_windows[0]->GetBoundsInScreen()); | 416 root_windows[0]->GetBoundsInScreen()); |
417 gfx::Display display1 = | 417 gfx::Display display1 = Shell::GetScreen()->GetDisplayMatching( |
418 gfx::Screen::GetDisplayMatching(root_windows[1]->GetBoundsInScreen()); | 418 root_windows[1]->GetBoundsInScreen()); |
419 EXPECT_NE(display0.id(), display1.id()); | 419 EXPECT_NE(display0.id(), display1.id()); |
420 | 420 |
421 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); | 421 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); |
422 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); | 422 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); |
423 | 423 |
424 // Move the window where the window spans both root windows. Since the second | 424 // Move the window where the window spans both root windows. Since the second |
425 // parameter is |display1|, the window should be shown on the secondary root. | 425 // parameter is |display1|, the window should be shown on the secondary root. |
426 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100), | 426 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100), |
427 display1); | 427 display1); |
428 EXPECT_EQ("500,10 1000x100", | 428 EXPECT_EQ("500,10 1000x100", |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
602 w1->SetBounds(gfx::Rect(10, 10, 50, 50)); | 602 w1->SetBounds(gfx::Rect(10, 10, 50, 50)); |
603 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); | 603 EXPECT_EQ(root_windows[0], w1->GetNativeView()->GetRootWindow()); |
604 } | 604 } |
605 | 605 |
606 TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) { | 606 TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) { |
607 UpdateDisplay("100x100,200x200"); | 607 UpdateDisplay("100x100,200x200"); |
608 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 608 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
609 | 609 |
610 // Create normal windows on both displays. | 610 // Create normal windows on both displays. |
611 views::Widget* widget1 = CreateTestWidget( | 611 views::Widget* widget1 = CreateTestWidget( |
612 gfx::Screen::GetPrimaryDisplay().bounds()); | 612 Shell::GetScreen()->GetPrimaryDisplay().bounds()); |
613 widget1->Show(); | 613 widget1->Show(); |
614 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow()); | 614 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow()); |
615 views::Widget* widget2 = CreateTestWidget( | 615 views::Widget* widget2 = CreateTestWidget( |
616 ScreenAsh::GetSecondaryDisplay().bounds()); | 616 ScreenAsh::GetSecondaryDisplay().bounds()); |
617 widget2->Show(); | 617 widget2->Show(); |
618 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow()); | 618 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow()); |
619 | 619 |
620 // Create a LockScreen window. | 620 // Create a LockScreen window. |
621 views::Widget* lock_widget = CreateTestWidget( | 621 views::Widget* lock_widget = CreateTestWidget( |
622 gfx::Screen::GetPrimaryDisplay().bounds()); | 622 Shell::GetScreen()->GetPrimaryDisplay().bounds()); |
623 views::Textfield* textfield = new views::Textfield; | 623 views::Textfield* textfield = new views::Textfield; |
624 lock_widget->SetContentsView(textfield); | 624 lock_widget->SetContentsView(textfield); |
625 | 625 |
626 ash::Shell::GetContainer( | 626 ash::Shell::GetContainer( |
627 Shell::GetPrimaryRootWindow(), | 627 Shell::GetPrimaryRootWindow(), |
628 ash::internal::kShellWindowId_LockScreenContainer)-> | 628 ash::internal::kShellWindowId_LockScreenContainer)-> |
629 AddChild(lock_widget->GetNativeView()); | 629 AddChild(lock_widget->GetNativeView()); |
630 lock_widget->Show(); | 630 lock_widget->Show(); |
631 textfield->RequestFocus(); | 631 textfield->RequestFocus(); |
632 | 632 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 | 664 |
665 aura::test::EventGenerator generator22(root_windows[1]); | 665 aura::test::EventGenerator generator22(root_windows[1]); |
666 generator22.PressKey(ui::VKEY_E, 0); | 666 generator22.PressKey(ui::VKEY_E, 0); |
667 generator22.ReleaseKey(ui::VKEY_E, 0); | 667 generator22.ReleaseKey(ui::VKEY_E, 0); |
668 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow()); | 668 EXPECT_EQ(lock_widget->GetNativeView(), focus_manager->GetFocusedWindow()); |
669 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text())); | 669 EXPECT_EQ("abcde", UTF16ToASCII(textfield->text())); |
670 } | 670 } |
671 | 671 |
672 } // namespace internal | 672 } // namespace internal |
673 } // namespace ash | 673 } // namespace ash |
OLD | NEW |