Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Side by Side Diff: ash/extended_desktop_unittest.cc

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/drag_drop/drag_drop_tracker.cc ('k') | ash/first_run/first_run_helper_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
12 #include "ash/wm/aura/wm_window_aura.h" 12 #include "ash/wm/aura/wm_window_aura.h"
13 #include "ash/wm/common/root_window_finder.h" 13 #include "ash/wm/common/root_window_finder.h"
14 #include "ash/wm/window_properties.h" 14 #include "ash/wm/window_properties.h"
15 #include "ash/wm/window_util.h" 15 #include "ash/wm/window_util.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "ui/aura/client/capture_client.h" 18 #include "ui/aura/client/capture_client.h"
19 #include "ui/aura/client/focus_client.h" 19 #include "ui/aura/client/focus_client.h"
20 #include "ui/aura/test/test_windows.h" 20 #include "ui/aura/test/test_windows.h"
21 #include "ui/aura/test/window_test_api.h" 21 #include "ui/aura/test/window_test_api.h"
22 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
23 #include "ui/aura/window_event_dispatcher.h" 23 #include "ui/aura/window_event_dispatcher.h"
24 #include "ui/base/cursor/cursor.h" 24 #include "ui/base/cursor/cursor.h"
25 #include "ui/display/display.h"
25 #include "ui/display/manager/display_layout.h" 26 #include "ui/display/manager/display_layout.h"
27 #include "ui/display/screen.h"
26 #include "ui/events/event_handler.h" 28 #include "ui/events/event_handler.h"
27 #include "ui/events/test/event_generator.h" 29 #include "ui/events/test/event_generator.h"
28 #include "ui/gfx/display.h"
29 #include "ui/gfx/screen.h"
30 #include "ui/views/controls/textfield/textfield.h" 30 #include "ui/views/controls/textfield/textfield.h"
31 #include "ui/views/widget/widget.h" 31 #include "ui/views/widget/widget.h"
32 #include "ui/views/widget/widget_delegate.h" 32 #include "ui/views/widget/widget_delegate.h"
33 #include "ui/wm/public/activation_client.h" 33 #include "ui/wm/public/activation_client.h"
34 34
35 namespace ash { 35 namespace ash {
36 namespace { 36 namespace {
37 37
38 void SetSecondaryDisplayLayout(display::DisplayPlacement::Position position) { 38 void SetSecondaryDisplayLayout(display::DisplayPlacement::Position position) {
39 std::unique_ptr<display::DisplayLayout> layout = 39 std::unique_ptr<display::DisplayLayout> layout =
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 if (!SupportsMultipleDisplays()) 285 if (!SupportsMultipleDisplays())
286 return; 286 return;
287 287
288 UpdateDisplay("1000x600,600x400"); 288 UpdateDisplay("1000x600,600x400");
289 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 289 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
290 aura::test::WindowTestApi root_window0_test_api(root_windows[0]); 290 aura::test::WindowTestApi root_window0_test_api(root_windows[0]);
291 aura::test::WindowTestApi root_window1_test_api(root_windows[1]); 291 aura::test::WindowTestApi root_window1_test_api(root_windows[1]);
292 292
293 root_windows[0]->MoveCursorTo(gfx::Point(10, 10)); 293 root_windows[0]->MoveCursorTo(gfx::Point(10, 10));
294 EXPECT_EQ("10,10", 294 EXPECT_EQ("10,10",
295 gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); 295 display::Screen::GetScreen()->GetCursorScreenPoint().ToString());
296 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); 296 EXPECT_TRUE(root_window0_test_api.ContainsMouse());
297 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); 297 EXPECT_FALSE(root_window1_test_api.ContainsMouse());
298 root_windows[1]->MoveCursorTo(gfx::Point(10, 20)); 298 root_windows[1]->MoveCursorTo(gfx::Point(10, 20));
299 EXPECT_EQ("1010,20", 299 EXPECT_EQ("1010,20",
300 gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); 300 display::Screen::GetScreen()->GetCursorScreenPoint().ToString());
301 EXPECT_FALSE(root_window0_test_api.ContainsMouse()); 301 EXPECT_FALSE(root_window0_test_api.ContainsMouse());
302 EXPECT_TRUE(root_window1_test_api.ContainsMouse()); 302 EXPECT_TRUE(root_window1_test_api.ContainsMouse());
303 root_windows[0]->MoveCursorTo(gfx::Point(20, 10)); 303 root_windows[0]->MoveCursorTo(gfx::Point(20, 10));
304 EXPECT_EQ("20,10", 304 EXPECT_EQ("20,10",
305 gfx::Screen::GetScreen()->GetCursorScreenPoint().ToString()); 305 display::Screen::GetScreen()->GetCursorScreenPoint().ToString());
306 EXPECT_TRUE(root_window0_test_api.ContainsMouse()); 306 EXPECT_TRUE(root_window0_test_api.ContainsMouse());
307 EXPECT_FALSE(root_window1_test_api.ContainsMouse()); 307 EXPECT_FALSE(root_window1_test_api.ContainsMouse());
308 } 308 }
309 309
310 TEST_F(ExtendedDesktopTest, GetRootWindowAt) { 310 TEST_F(ExtendedDesktopTest, GetRootWindowAt) {
311 if (!SupportsMultipleDisplays()) 311 if (!SupportsMultipleDisplays())
312 return; 312 return;
313 313
314 UpdateDisplay("700x500,500x500"); 314 UpdateDisplay("700x500,500x500");
315 SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT); 315 SetSecondaryDisplayLayout(display::DisplayPlacement::LEFT);
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 EXPECT_EQ(root_windows[1], window->GetRootWindow()); 624 EXPECT_EQ(root_windows[1], window->GetRootWindow());
625 } 625 }
626 626
627 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) { 627 TEST_F(ExtendedDesktopTest, MoveWindowToDisplay) {
628 if (!SupportsMultipleDisplays()) 628 if (!SupportsMultipleDisplays())
629 return; 629 return;
630 630
631 UpdateDisplay("1000x1000,1000x1000"); 631 UpdateDisplay("1000x1000,1000x1000");
632 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 632 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
633 633
634 gfx::Display display0 = gfx::Screen::GetScreen()->GetDisplayMatching( 634 display::Display display0 = display::Screen::GetScreen()->GetDisplayMatching(
635 root_windows[0]->GetBoundsInScreen()); 635 root_windows[0]->GetBoundsInScreen());
636 gfx::Display display1 = gfx::Screen::GetScreen()->GetDisplayMatching( 636 display::Display display1 = display::Screen::GetScreen()->GetDisplayMatching(
637 root_windows[1]->GetBoundsInScreen()); 637 root_windows[1]->GetBoundsInScreen());
638 EXPECT_NE(display0.id(), display1.id()); 638 EXPECT_NE(display0.id(), display1.id());
639 639
640 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100)); 640 views::Widget* d1 = CreateTestWidget(gfx::Rect(10, 10, 1000, 100));
641 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow()); 641 EXPECT_EQ(root_windows[0], d1->GetNativeView()->GetRootWindow());
642 642
643 // Move the window where the window spans both root windows. Since the second 643 // Move the window where the window spans both root windows. Since the second
644 // parameter is |display1|, the window should be shown on the secondary root. 644 // parameter is |display1|, the window should be shown on the secondary root.
645 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100), 645 d1->GetNativeWindow()->SetBoundsInScreen(gfx::Rect(500, 10, 1000, 100),
646 display1); 646 display1);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow()); 712 EXPECT_EQ(root_windows[1], w1_t1->GetNativeView()->GetRootWindow());
713 EXPECT_EQ("10,50 50x50", 713 EXPECT_EQ("10,50 50x50",
714 w1_t1->GetWindowBoundsInScreen().ToString()); 714 w1_t1->GetWindowBoundsInScreen().ToString());
715 } 715 }
716 716
717 // Test if the Window::ConvertPointToTarget works across root windows. 717 // Test if the Window::ConvertPointToTarget works across root windows.
718 // TODO(oshima): Move multiple display suport and this test to aura. 718 // TODO(oshima): Move multiple display suport and this test to aura.
719 TEST_F(ExtendedDesktopTest, ConvertPoint) { 719 TEST_F(ExtendedDesktopTest, ConvertPoint) {
720 if (!SupportsMultipleDisplays()) 720 if (!SupportsMultipleDisplays())
721 return; 721 return;
722 gfx::Screen* screen = gfx::Screen::GetScreen(); 722 display::Screen* screen = display::Screen::GetScreen();
723 UpdateDisplay("1000x600,600x400"); 723 UpdateDisplay("1000x600,600x400");
724 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 724 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
725 gfx::Display display_1 = screen->GetDisplayNearestWindow(root_windows[0]); 725 display::Display display_1 = screen->GetDisplayNearestWindow(root_windows[0]);
726 EXPECT_EQ("0,0", display_1.bounds().origin().ToString()); 726 EXPECT_EQ("0,0", display_1.bounds().origin().ToString());
727 gfx::Display display_2 = screen->GetDisplayNearestWindow(root_windows[1]); 727 display::Display display_2 = screen->GetDisplayNearestWindow(root_windows[1]);
728 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString()); 728 EXPECT_EQ("1000,0", display_2.bounds().origin().ToString());
729 729
730 aura::Window* d1 = 730 aura::Window* d1 =
731 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView(); 731 CreateTestWidget(gfx::Rect(10, 10, 100, 100))->GetNativeView();
732 aura::Window* d2 = 732 aura::Window* d2 =
733 CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView(); 733 CreateTestWidget(gfx::Rect(1020, 20, 100, 100))->GetNativeView();
734 EXPECT_EQ(root_windows[0], d1->GetRootWindow()); 734 EXPECT_EQ(root_windows[0], d1->GetRootWindow());
735 EXPECT_EQ(root_windows[1], d2->GetRootWindow()); 735 EXPECT_EQ(root_windows[1], d2->GetRootWindow());
736 736
737 // Convert point in the Root2's window to the Root1's window Coord. 737 // Convert point in the Root2's window to the Root1's window Coord.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
850 } 850 }
851 851
852 TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) { 852 TEST_F(ExtendedDesktopTest, KeyEventsOnLockScreen) {
853 if (!SupportsMultipleDisplays()) 853 if (!SupportsMultipleDisplays())
854 return; 854 return;
855 855
856 UpdateDisplay("100x100,200x200"); 856 UpdateDisplay("100x100,200x200");
857 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 857 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
858 858
859 // Create normal windows on both displays. 859 // Create normal windows on both displays.
860 views::Widget* widget1 = 860 views::Widget* widget1 = CreateTestWidget(
861 CreateTestWidget(gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds()); 861 display::Screen::GetScreen()->GetPrimaryDisplay().bounds());
862 widget1->Show(); 862 widget1->Show();
863 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow()); 863 EXPECT_EQ(root_windows[0], widget1->GetNativeView()->GetRootWindow());
864 views::Widget* widget2 = CreateTestWidget( 864 views::Widget* widget2 = CreateTestWidget(
865 ScreenUtil::GetSecondaryDisplay().bounds()); 865 ScreenUtil::GetSecondaryDisplay().bounds());
866 widget2->Show(); 866 widget2->Show();
867 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow()); 867 EXPECT_EQ(root_windows[1], widget2->GetNativeView()->GetRootWindow());
868 868
869 // Create a LockScreen window. 869 // Create a LockScreen window.
870 views::Widget* lock_widget = 870 views::Widget* lock_widget = CreateTestWidget(
871 CreateTestWidget(gfx::Screen::GetScreen()->GetPrimaryDisplay().bounds()); 871 display::Screen::GetScreen()->GetPrimaryDisplay().bounds());
872 views::Textfield* textfield = new views::Textfield; 872 views::Textfield* textfield = new views::Textfield;
873 lock_widget->client_view()->AddChildView(textfield); 873 lock_widget->client_view()->AddChildView(textfield);
874 874
875 ash::Shell::GetContainer(Shell::GetPrimaryRootWindow(), 875 ash::Shell::GetContainer(Shell::GetPrimaryRootWindow(),
876 ash::kShellWindowId_LockScreenContainer) 876 ash::kShellWindowId_LockScreenContainer)
877 ->AddChild(lock_widget->GetNativeView()); 877 ->AddChild(lock_widget->GetNativeView());
878 lock_widget->Show(); 878 lock_widget->Show();
879 textfield->RequestFocus(); 879 textfield->RequestFocus();
880 880
881 aura::client::FocusClient* focus_client = 881 aura::client::FocusClient* focus_client =
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 generator.ReleaseLeftButton(); 947 generator.ReleaseLeftButton();
948 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset()); 948 EXPECT_EQ("-999,-999 -999,-999", event_handler.GetLocationsAndReset());
949 949
950 generator.MoveMouseTo(400, 150); 950 generator.MoveMouseTo(400, 150);
951 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset()); 951 EXPECT_EQ("100,150 100,150", event_handler.GetLocationsAndReset());
952 952
953 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler); 953 ash::Shell::GetInstance()->RemovePreTargetHandler(&event_handler);
954 } 954 }
955 955
956 } // namespace ash 956 } // namespace ash
OLDNEW
« no previous file with comments | « ash/drag_drop/drag_drop_tracker.cc ('k') | ash/first_run/first_run_helper_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698