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

Side by Side Diff: ash/root_window_controller_unittest.cc

Issue 2653593004: chromeos: Remove AshTestBase::SupportsMultipleDisplays (Closed)
Patch Set: Created 3 years, 11 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/mus/top_level_window_factory_unittest.cc ('k') | ash/screen_util_unittest.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/root_window_controller.h" 5 #include "ash/root_window_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/common/material_design/material_design_controller.h" 9 #include "ash/common/material_design/material_design_controller.h"
10 #include "ash/common/session/session_controller.h" 10 #include "ash/common/session/session_controller.h"
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 }; 137 };
138 138
139 INSTANTIATE_TEST_CASE_P( 139 INSTANTIATE_TEST_CASE_P(
140 /* prefix intentionally left blank due to only one parameterization */, 140 /* prefix intentionally left blank due to only one parameterization */,
141 RootWindowControllerTest, 141 RootWindowControllerTest,
142 testing::Values(MaterialDesignController::NON_MATERIAL, 142 testing::Values(MaterialDesignController::NON_MATERIAL,
143 MaterialDesignController::MATERIAL_NORMAL, 143 MaterialDesignController::MATERIAL_NORMAL,
144 MaterialDesignController::MATERIAL_EXPERIMENTAL)); 144 MaterialDesignController::MATERIAL_EXPERIMENTAL));
145 145
146 TEST_P(RootWindowControllerTest, MoveWindows_Basic) { 146 TEST_P(RootWindowControllerTest, MoveWindows_Basic) {
147 if (!SupportsMultipleDisplays())
148 return;
149 const int height_offset = GetMdMaximizedWindowHeightOffset(); 147 const int height_offset = GetMdMaximizedWindowHeightOffset();
150 148
151 // Windows origin should be doubled when moved to the 1st display. 149 // Windows origin should be doubled when moved to the 1st display.
152 UpdateDisplay("600x600,300x300"); 150 UpdateDisplay("600x600,300x300");
153 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 151 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
154 152
155 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100)); 153 views::Widget* normal = CreateTestWidget(gfx::Rect(650, 10, 100, 100));
156 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow()); 154 EXPECT_EQ(root_windows[1], normal->GetNativeView()->GetRootWindow());
157 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString()); 155 EXPECT_EQ("650,10 100x100", normal->GetWindowBoundsInScreen().ToString());
158 EXPECT_EQ("50,10 100x100", 156 EXPECT_EQ("50,10 100x100",
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 unparented_control->GetNativeView()->GetRootWindow()); 259 unparented_control->GetNativeView()->GetRootWindow());
262 EXPECT_EQ(kShellWindowId_UnparentedControlContainer, 260 EXPECT_EQ(kShellWindowId_UnparentedControlContainer,
263 unparented_control->GetNativeView()->parent()->id()); 261 unparented_control->GetNativeView()->parent()->id());
264 262
265 // Test if the panel has moved. 263 // Test if the panel has moved.
266 EXPECT_EQ(root_windows[0], panel->GetRootWindow()); 264 EXPECT_EQ(root_windows[0], panel->GetRootWindow());
267 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id()); 265 EXPECT_EQ(kShellWindowId_PanelContainer, panel->parent()->id());
268 } 266 }
269 267
270 TEST_P(RootWindowControllerTest, MoveWindows_Modal) { 268 TEST_P(RootWindowControllerTest, MoveWindows_Modal) {
271 if (!SupportsMultipleDisplays())
272 return;
273
274 UpdateDisplay("500x500,500x500"); 269 UpdateDisplay("500x500,500x500");
275 270
276 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 271 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
277 // Emulate virtual screen coordinate system. 272 // Emulate virtual screen coordinate system.
278 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500)); 273 root_windows[0]->SetBounds(gfx::Rect(0, 0, 500, 500));
279 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500)); 274 root_windows[1]->SetBounds(gfx::Rect(500, 0, 500, 500));
280 275
281 views::Widget* normal = CreateTestWidget(gfx::Rect(300, 10, 100, 100)); 276 views::Widget* normal = CreateTestWidget(gfx::Rect(300, 10, 100, 100));
282 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow()); 277 EXPECT_EQ(root_windows[0], normal->GetNativeView()->GetRootWindow());
283 EXPECT_TRUE(wm::IsActiveWindow(normal->GetNativeView())); 278 EXPECT_TRUE(wm::IsActiveWindow(normal->GetNativeView()));
(...skipping 10 matching lines...) Expand all
294 289
295 UpdateDisplay("500x500"); 290 UpdateDisplay("500x500");
296 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow()); 291 EXPECT_EQ(root_windows[0], modal->GetNativeView()->GetRootWindow());
297 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); 292 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView()));
298 generator_1st.ClickLeftButton(); 293 generator_1st.ClickLeftButton();
299 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView())); 294 EXPECT_TRUE(wm::IsActiveWindow(modal->GetNativeView()));
300 } 295 }
301 296
302 // Make sure lock related windows moves. 297 // Make sure lock related windows moves.
303 TEST_P(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) { 298 TEST_P(RootWindowControllerTest, MoveWindows_LockWindowsInUnified) {
304 if (!SupportsMultipleDisplays())
305 return;
306 display_manager()->SetUnifiedDesktopEnabled(true); 299 display_manager()->SetUnifiedDesktopEnabled(true);
307 300
308 UpdateDisplay("500x500"); 301 UpdateDisplay("500x500");
309 const int kLockScreenWindowId = 1000; 302 const int kLockScreenWindowId = 1000;
310 const int kLockWallpaperWindowId = 1001; 303 const int kLockWallpaperWindowId = 1001;
311 304
312 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); 305 RootWindowController* controller = Shell::GetPrimaryRootWindowController();
313 306
314 aura::Window* lock_container = 307 aura::Window* lock_container =
315 controller->GetContainer(kShellWindowId_LockScreenContainer); 308 controller->GetContainer(kShellWindowId_LockScreenContainer);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 521
529 // Only w2 remains, if minimized GetWindowForFullscreenMode should return 522 // Only w2 remains, if minimized GetWindowForFullscreenMode should return
530 // NULL. 523 // NULL.
531 w2->Activate(); 524 w2->Activate();
532 EXPECT_EQ(w2->GetNativeWindow(), controller->GetWindowForFullscreenMode()); 525 EXPECT_EQ(w2->GetNativeWindow(), controller->GetWindowForFullscreenMode());
533 w2->Minimize(); 526 w2->Minimize();
534 EXPECT_EQ(NULL, controller->GetWindowForFullscreenMode()); 527 EXPECT_EQ(NULL, controller->GetWindowForFullscreenMode());
535 } 528 }
536 529
537 TEST_P(RootWindowControllerTest, MultipleDisplaysGetWindowForFullscreenMode) { 530 TEST_P(RootWindowControllerTest, MultipleDisplaysGetWindowForFullscreenMode) {
538 if (!SupportsMultipleDisplays())
539 return;
540
541 UpdateDisplay("600x600,600x600"); 531 UpdateDisplay("600x600,600x600");
542 Shell::RootWindowControllerList controllers = 532 Shell::RootWindowControllerList controllers =
543 Shell::GetInstance()->GetAllRootWindowControllers(); 533 Shell::GetInstance()->GetAllRootWindowControllers();
544 534
545 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); 535 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100));
546 w1->Maximize(); 536 w1->Maximize();
547 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); 537 Widget* w2 = CreateTestWidget(gfx::Rect(0, 0, 100, 100));
548 w2->SetFullscreen(true); 538 w2->SetFullscreen(true);
549 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100)); 539 Widget* w3 = CreateTestWidget(gfx::Rect(600, 0, 100, 100));
550 540
(...skipping 17 matching lines...) Expand all
568 // when a window on the other display is activated. 558 // when a window on the other display is activated.
569 w3->Activate(); 559 w3->Activate();
570 EXPECT_EQ(w2->GetNativeWindow(), 560 EXPECT_EQ(w2->GetNativeWindow(),
571 controllers[0]->GetWindowForFullscreenMode()); 561 controllers[0]->GetWindowForFullscreenMode());
572 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode()); 562 EXPECT_EQ(NULL, controllers[1]->GetWindowForFullscreenMode());
573 } 563 }
574 564
575 // Test that GetRootWindowController() works with multiple displays and 565 // Test that GetRootWindowController() works with multiple displays and
576 // child widgets. 566 // child widgets.
577 TEST_P(RootWindowControllerTest, GetRootWindowController) { 567 TEST_P(RootWindowControllerTest, GetRootWindowController) {
578 if (!SupportsMultipleDisplays())
579 return;
580 UpdateDisplay("600x600,600x600"); 568 UpdateDisplay("600x600,600x600");
581 Shell::RootWindowControllerList controllers = 569 Shell::RootWindowControllerList controllers =
582 Shell::GetInstance()->GetAllRootWindowControllers(); 570 Shell::GetInstance()->GetAllRootWindowControllers();
583 ASSERT_EQ(2u, controllers.size()); 571 ASSERT_EQ(2u, controllers.size());
584 572
585 // Test null. 573 // Test null.
586 EXPECT_FALSE(GetRootWindowController(nullptr)); 574 EXPECT_FALSE(GetRootWindowController(nullptr));
587 575
588 // Test a widget on the first display. 576 // Test a widget on the first display.
589 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100)); 577 Widget* w1 = CreateTestWidget(gfx::Rect(0, 0, 100, 100));
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 } 729 }
742 730
743 private: 731 private:
744 DISALLOW_COPY_AND_ASSIGN(TargetHitTestEventHandler); 732 DISALLOW_COPY_AND_ASSIGN(TargetHitTestEventHandler);
745 }; 733 };
746 734
747 // Test for http://crbug.com/297858. Virtual keyboard container should only show 735 // Test for http://crbug.com/297858. Virtual keyboard container should only show
748 // on primary root window if no window has touch capability. 736 // on primary root window if no window has touch capability.
749 TEST_F(VirtualKeyboardRootWindowControllerTest, 737 TEST_F(VirtualKeyboardRootWindowControllerTest,
750 VirtualKeyboardOnPrimaryRootWindowDefault) { 738 VirtualKeyboardOnPrimaryRootWindowDefault) {
751 if (!SupportsMultipleDisplays())
752 return;
753
754 UpdateDisplay("500x500,500x500"); 739 UpdateDisplay("500x500,500x500");
755 740
756 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 741 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
757 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); 742 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow();
758 aura::Window* secondary_root_window = root_windows[0] == primary_root_window 743 aura::Window* secondary_root_window = root_windows[0] == primary_root_window
759 ? root_windows[1] 744 ? root_windows[1]
760 : root_windows[0]; 745 : root_windows[0];
761 746
762 ASSERT_TRUE(Shell::GetContainer(primary_root_window, 747 ASSERT_TRUE(Shell::GetContainer(primary_root_window,
763 kShellWindowId_VirtualKeyboardContainer)); 748 kShellWindowId_VirtualKeyboardContainer));
764 ASSERT_FALSE(Shell::GetContainer(secondary_root_window, 749 ASSERT_FALSE(Shell::GetContainer(secondary_root_window,
765 kShellWindowId_VirtualKeyboardContainer)); 750 kShellWindowId_VirtualKeyboardContainer));
766 } 751 }
767 752
768 // Test for http://crbug.com/303429. Virtual keyboard container should show on 753 // Test for http://crbug.com/303429. Virtual keyboard container should show on
769 // a display which has touch capability. 754 // a display which has touch capability.
770 TEST_F(VirtualKeyboardRootWindowControllerTest, 755 TEST_F(VirtualKeyboardRootWindowControllerTest,
771 VirtualKeyboardOnTouchableDisplayOnly) { 756 VirtualKeyboardOnTouchableDisplayOnly) {
772 if (!SupportsMultipleDisplays())
773 return;
774
775 UpdateDisplay("500x500,500x500"); 757 UpdateDisplay("500x500,500x500");
776 display::Display secondary_display = 758 display::Display secondary_display =
777 Shell::GetInstance()->display_manager()->GetSecondaryDisplay(); 759 Shell::GetInstance()->display_manager()->GetSecondaryDisplay();
778 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) 760 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager())
779 .SetTouchSupport(secondary_display.id(), 761 .SetTouchSupport(secondary_display.id(),
780 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); 762 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE);
781 763
782 // The primary display doesn't have touch capability and the secondary display 764 // The primary display doesn't have touch capability and the secondary display
783 // does. 765 // does.
784 ASSERT_NE(display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE, 766 ASSERT_NE(display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE,
(...skipping 30 matching lines...) Expand all
815 keyboard::KeyboardController::GetInstance()->ShowKeyboard(false); 797 keyboard::KeyboardController::GetInstance()->ShowKeyboard(false);
816 EXPECT_FALSE(Shell::GetContainer(primary_root_window, 798 EXPECT_FALSE(Shell::GetContainer(primary_root_window,
817 kShellWindowId_VirtualKeyboardContainer)); 799 kShellWindowId_VirtualKeyboardContainer));
818 EXPECT_TRUE(Shell::GetContainer(secondary_root_window, 800 EXPECT_TRUE(Shell::GetContainer(secondary_root_window,
819 kShellWindowId_VirtualKeyboardContainer)); 801 kShellWindowId_VirtualKeyboardContainer));
820 } 802 }
821 803
822 // Test for http://crbug.com/303429. If both of displays have touch capability, 804 // Test for http://crbug.com/303429. If both of displays have touch capability,
823 // virtual keyboard follows the input focus. 805 // virtual keyboard follows the input focus.
824 TEST_F(VirtualKeyboardRootWindowControllerTest, FollowInputFocus) { 806 TEST_F(VirtualKeyboardRootWindowControllerTest, FollowInputFocus) {
825 if (!SupportsMultipleDisplays())
826 return;
827
828 UpdateDisplay("500x500,500x500"); 807 UpdateDisplay("500x500,500x500");
829 const int64_t primary_display_id = 808 const int64_t primary_display_id =
830 display::Screen::GetScreen()->GetPrimaryDisplay().id(); 809 display::Screen::GetScreen()->GetPrimaryDisplay().id();
831 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) 810 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager())
832 .SetTouchSupport(primary_display_id, 811 .SetTouchSupport(primary_display_id,
833 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE); 812 display::Display::TouchSupport::TOUCH_SUPPORT_AVAILABLE);
834 const int64_t secondary_display_id = 813 const int64_t secondary_display_id =
835 Shell::GetInstance()->display_manager()->GetSecondaryDisplay().id(); 814 Shell::GetInstance()->display_manager()->GetSecondaryDisplay().id();
836 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager()) 815 display::test::DisplayManagerTestApi(Shell::GetInstance()->display_manager())
837 .SetTouchSupport(secondary_display_id, 816 .SetTouchSupport(secondary_display_id,
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 EXPECT_TRUE(Shell::GetContainer(primary_root_window, 865 EXPECT_TRUE(Shell::GetContainer(primary_root_window,
887 kShellWindowId_VirtualKeyboardContainer)); 866 kShellWindowId_VirtualKeyboardContainer));
888 EXPECT_FALSE(Shell::GetContainer(secondary_root_window, 867 EXPECT_FALSE(Shell::GetContainer(secondary_root_window,
889 kShellWindowId_VirtualKeyboardContainer)); 868 kShellWindowId_VirtualKeyboardContainer));
890 } 869 }
891 870
892 // Test for http://crbug.com/303429. Even if both of display don't have touch 871 // Test for http://crbug.com/303429. Even if both of display don't have touch
893 // capability, the virtual keyboard shows up on the specified display. 872 // capability, the virtual keyboard shows up on the specified display.
894 TEST_F(VirtualKeyboardRootWindowControllerTest, 873 TEST_F(VirtualKeyboardRootWindowControllerTest,
895 VirtualKeyboardShowOnSpecifiedDisplay) { 874 VirtualKeyboardShowOnSpecifiedDisplay) {
896 if (!SupportsMultipleDisplays())
897 return;
898
899 UpdateDisplay("500x500,500x500"); 875 UpdateDisplay("500x500,500x500");
900 display::Display secondary_display = 876 display::Display secondary_display =
901 Shell::GetInstance()->display_manager()->GetSecondaryDisplay(); 877 Shell::GetInstance()->display_manager()->GetSecondaryDisplay();
902 878
903 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 879 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
904 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow(); 880 aura::Window* primary_root_window = Shell::GetPrimaryRootWindow();
905 aura::Window* secondary_root_window = root_windows[0] == primary_root_window 881 aura::Window* secondary_root_window = root_windows[0] == primary_root_window
906 ? root_windows[1] 882 ? root_windows[1]
907 : root_windows[0]; 883 : root_windows[0];
908 884
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 ui->EnsureCaretInWorkArea(); 1056 ui->EnsureCaretInWorkArea();
1081 ASSERT_EQ(root_window->bounds().width(), 1057 ASSERT_EQ(root_window->bounds().width(),
1082 text_input_client.caret_exclude_rect().width()); 1058 text_input_client.caret_exclude_rect().width());
1083 ASSERT_EQ(keyboard_height, text_input_client.caret_exclude_rect().height()); 1059 ASSERT_EQ(keyboard_height, text_input_client.caret_exclude_rect().height());
1084 1060
1085 input_method->SetFocusedTextInputClient(NULL); 1061 input_method->SetFocusedTextInputClient(NULL);
1086 } 1062 }
1087 1063
1088 TEST_F(VirtualKeyboardRootWindowControllerTest, 1064 TEST_F(VirtualKeyboardRootWindowControllerTest,
1089 EnsureCaretInWorkAreaWithMultipleDisplays) { 1065 EnsureCaretInWorkAreaWithMultipleDisplays) {
1090 if (!SupportsMultipleDisplays())
1091 return;
1092
1093 UpdateDisplay("500x500,600x600"); 1066 UpdateDisplay("500x500,600x600");
1094 const int64_t primary_display_id = 1067 const int64_t primary_display_id =
1095 display::Screen::GetScreen()->GetPrimaryDisplay().id(); 1068 display::Screen::GetScreen()->GetPrimaryDisplay().id();
1096 const int64_t secondary_display_id = 1069 const int64_t secondary_display_id =
1097 Shell::GetInstance()->display_manager()->GetSecondaryDisplay().id(); 1070 Shell::GetInstance()->display_manager()->GetSecondaryDisplay().id();
1098 ASSERT_NE(primary_display_id, secondary_display_id); 1071 ASSERT_NE(primary_display_id, secondary_display_id);
1099 1072
1100 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1073 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1101 ASSERT_EQ(static_cast<size_t>(2), root_windows.size()); 1074 ASSERT_EQ(static_cast<size_t>(2), root_windows.size());
1102 aura::Window* primary_root_window = root_windows[0]; 1075 aura::Window* primary_root_window = root_windows[0];
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds( 1215 keyboard_controller->ui()->GetKeyboardWindow()->SetBounds(
1243 gfx::Rect(0, 400, 800, 200)); 1216 gfx::Rect(0, 400, 800, 200));
1244 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString()); 1217 EXPECT_EQ("0,400 800x200", keyboard_container->bounds().ToString());
1245 1218
1246 UpdateDisplay("600x800"); 1219 UpdateDisplay("600x800");
1247 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString()); 1220 EXPECT_EQ("0,600 600x200", keyboard_container->bounds().ToString());
1248 } 1221 }
1249 1222
1250 } // namespace test 1223 } // namespace test
1251 } // namespace ash 1224 } // namespace ash
OLDNEW
« no previous file with comments | « ash/mus/top_level_window_factory_unittest.cc ('k') | ash/screen_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698