| 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/common/shelf/shelf_layout_manager.h" | 5 #include "ash/common/shelf/shelf_layout_manager.h" |
| 6 | 6 |
| 7 #include "ash/common/accelerators/accelerator_controller.h" | 7 #include "ash/common/accelerators/accelerator_controller.h" |
| 8 #include "ash/common/accelerators/accelerator_table.h" | 8 #include "ash/common/accelerators/accelerator_table.h" |
| 9 #include "ash/common/focus_cycler.h" | 9 #include "ash/common/focus_cycler.h" |
| 10 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| (...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 752 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 753 generator.PressLeftButton(); | 753 generator.PressLeftButton(); |
| 754 generator.MoveMouseTo(1, display_bottom - 1); | 754 generator.MoveMouseTo(1, display_bottom - 1); |
| 755 UpdateAutoHideStateNow(); | 755 UpdateAutoHideStateNow(); |
| 756 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); | 756 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); |
| 757 } | 757 } |
| 758 | 758 |
| 759 // Test the behavior of the shelf when it is auto hidden and it is on the | 759 // Test the behavior of the shelf when it is auto hidden and it is on the |
| 760 // boundary between the primary and the secondary display. | 760 // boundary between the primary and the secondary display. |
| 761 TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) { | 761 TEST_F(ShelfLayoutManagerTest, AutoHideShelfOnScreenBoundary) { |
| 762 if (!SupportsMultipleDisplays()) | |
| 763 return; | |
| 764 | |
| 765 UpdateDisplay("800x600,800x600"); | 762 UpdateDisplay("800x600,800x600"); |
| 766 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 763 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 767 display::test::CreateDisplayLayout(display_manager(), | 764 display::test::CreateDisplayLayout(display_manager(), |
| 768 display::DisplayPlacement::RIGHT, 0)); | 765 display::DisplayPlacement::RIGHT, 0)); |
| 769 // Put the primary monitor's shelf on the display boundary. | 766 // Put the primary monitor's shelf on the display boundary. |
| 770 WmShelf* shelf = GetPrimaryShelf(); | 767 WmShelf* shelf = GetPrimaryShelf(); |
| 771 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 768 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 772 | 769 |
| 773 // Create a window because the shelf is always shown when no windows are | 770 // Create a window because the shelf is always shown when no windows are |
| 774 // visible. | 771 // visible. |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 app_list_presenter_impl.Dismiss(); | 991 app_list_presenter_impl.Dismiss(); |
| 995 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); | 992 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); |
| 996 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 993 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 997 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 994 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 998 } | 995 } |
| 999 | 996 |
| 1000 // Makes sure that when we have dual displays, with one or both shelves are set | 997 // Makes sure that when we have dual displays, with one or both shelves are set |
| 1001 // to AutoHide, viewing the AppList on one of them doesn't unhide the other | 998 // to AutoHide, viewing the AppList on one of them doesn't unhide the other |
| 1002 // hidden shelf. | 999 // hidden shelf. |
| 1003 TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) { | 1000 TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) { |
| 1004 if (!SupportsMultipleDisplays()) | |
| 1005 return; | |
| 1006 | |
| 1007 // Create two displays. | 1001 // Create two displays. |
| 1008 UpdateDisplay("0+0-200x200,+200+0-100x100"); | 1002 UpdateDisplay("0+0-200x200,+200+0-100x100"); |
| 1009 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1003 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1010 EXPECT_EQ(root_windows.size(), 2U); | 1004 EXPECT_EQ(root_windows.size(), 2U); |
| 1011 | 1005 |
| 1012 // Get the shelves in both displays and set them to be 'AutoHide'. | 1006 // Get the shelves in both displays and set them to be 'AutoHide'. |
| 1013 WmShelf* shelf_1 = GetRootWindowController(root_windows[0])->wm_shelf(); | 1007 WmShelf* shelf_1 = GetRootWindowController(root_windows[0])->wm_shelf(); |
| 1014 WmShelf* shelf_2 = GetRootWindowController(root_windows[1])->wm_shelf(); | 1008 WmShelf* shelf_2 = GetRootWindowController(root_windows[1])->wm_shelf(); |
| 1015 EXPECT_NE(shelf_1, shelf_2); | 1009 EXPECT_NE(shelf_1, shelf_2); |
| 1016 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(), | 1010 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(), |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1115 EXPECT_TRUE(wm_shell->IsSystemModalWindowOpen()); | 1109 EXPECT_TRUE(wm_shell->IsSystemModalWindowOpen()); |
| 1116 EXPECT_FALSE(wm::CanActivateWindow(window)); | 1110 EXPECT_FALSE(wm::CanActivateWindow(window)); |
| 1117 Shell::GetInstance()->UpdateShelfVisibility(); | 1111 Shell::GetInstance()->UpdateShelfVisibility(); |
| 1118 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 1112 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 1119 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); | 1113 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); |
| 1120 } | 1114 } |
| 1121 | 1115 |
| 1122 // Tests the correct behavior of the shelf when there is a system modal window | 1116 // Tests the correct behavior of the shelf when there is a system modal window |
| 1123 // open when we have dual display. | 1117 // open when we have dual display. |
| 1124 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { | 1118 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { |
| 1125 if (!SupportsMultipleDisplays()) | |
| 1126 return; | |
| 1127 | |
| 1128 // Create two displays. | 1119 // Create two displays. |
| 1129 UpdateDisplay("200x200,100x100"); | 1120 UpdateDisplay("200x200,100x100"); |
| 1130 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1121 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1131 EXPECT_EQ(2U, root_windows.size()); | 1122 EXPECT_EQ(2U, root_windows.size()); |
| 1132 | 1123 |
| 1133 // Get the shelves in both displays and set them to be 'AutoHide'. | 1124 // Get the shelves in both displays and set them to be 'AutoHide'. |
| 1134 WmShelf* shelf_1 = GetRootWindowController(root_windows[0])->wm_shelf(); | 1125 WmShelf* shelf_1 = GetRootWindowController(root_windows[0])->wm_shelf(); |
| 1135 WmShelf* shelf_2 = GetRootWindowController(root_windows[1])->wm_shelf(); | 1126 WmShelf* shelf_2 = GetRootWindowController(root_windows[1])->wm_shelf(); |
| 1136 EXPECT_NE(shelf_1, shelf_2); | 1127 EXPECT_NE(shelf_1, shelf_2); |
| 1137 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(), | 1128 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(), |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1192 wm::GetWindowState(window2)->Activate(); | 1183 wm::GetWindowState(window2)->Activate(); |
| 1193 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1184 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 1194 | 1185 |
| 1195 wm::GetWindowState(window1)->Activate(); | 1186 wm::GetWindowState(window1)->Activate(); |
| 1196 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); | 1187 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); |
| 1197 } | 1188 } |
| 1198 | 1189 |
| 1199 // Test the behavior of the shelf when a window on one display is fullscreen | 1190 // Test the behavior of the shelf when a window on one display is fullscreen |
| 1200 // but the other display has the active window. | 1191 // but the other display has the active window. |
| 1201 TEST_F(ShelfLayoutManagerTest, FullscreenWindowOnSecondDisplay) { | 1192 TEST_F(ShelfLayoutManagerTest, FullscreenWindowOnSecondDisplay) { |
| 1202 if (!SupportsMultipleDisplays()) | |
| 1203 return; | |
| 1204 | |
| 1205 UpdateDisplay("800x600,800x600"); | 1193 UpdateDisplay("800x600,800x600"); |
| 1206 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1194 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1207 Shell::RootWindowControllerList root_window_controllers = | 1195 Shell::RootWindowControllerList root_window_controllers = |
| 1208 Shell::GetAllRootWindowControllers(); | 1196 Shell::GetAllRootWindowControllers(); |
| 1209 | 1197 |
| 1210 // Create windows on either display. | 1198 // Create windows on either display. |
| 1211 aura::Window* window1 = CreateTestWindow(); | 1199 aura::Window* window1 = CreateTestWindow(); |
| 1212 window1->SetBoundsInScreen(gfx::Rect(0, 0, 100, 100), | 1200 window1->SetBoundsInScreen(gfx::Rect(0, 0, 100, 100), |
| 1213 display::Screen::GetScreen()->GetAllDisplays()[0]); | 1201 display::Screen::GetScreen()->GetAllDisplays()[0]); |
| 1214 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); | 1202 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 } | 1325 } |
| 1338 | 1326 |
| 1339 { | 1327 { |
| 1340 SCOPED_TRACE("RIGHT"); | 1328 SCOPED_TRACE("RIGHT"); |
| 1341 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 1329 shelf->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 1342 RunGestureDragTests(gfx::Vector2d(120, 0)); | 1330 RunGestureDragTests(gfx::Vector2d(120, 0)); |
| 1343 } | 1331 } |
| 1344 } | 1332 } |
| 1345 | 1333 |
| 1346 TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) { | 1334 TEST_F(ShelfLayoutManagerTest, WindowVisibilityDisablesAutoHide) { |
| 1347 if (!SupportsMultipleDisplays()) | |
| 1348 return; | |
| 1349 | |
| 1350 UpdateDisplay("800x600,800x600"); | 1335 UpdateDisplay("800x600,800x600"); |
| 1351 WmShelf* shelf = GetPrimaryShelf(); | 1336 WmShelf* shelf = GetPrimaryShelf(); |
| 1352 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 1337 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1353 layout_manager->LayoutShelf(); | 1338 layout_manager->LayoutShelf(); |
| 1354 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1339 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1355 | 1340 |
| 1356 // Create a visible window so auto-hide behavior is enforced | 1341 // Create a visible window so auto-hide behavior is enforced |
| 1357 views::Widget* dummy = CreateTestWidget(); | 1342 views::Widget* dummy = CreateTestWidget(); |
| 1358 | 1343 |
| 1359 // Window visible => auto hide behaves normally. | 1344 // Window visible => auto hide behaves normally. |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 | 1681 |
| 1697 GetShelfWidget()->Shutdown(); | 1682 GetShelfWidget()->Shutdown(); |
| 1698 | 1683 |
| 1699 // Deleting a focused maximized window will switch focus to |window2|. This | 1684 // Deleting a focused maximized window will switch focus to |window2|. This |
| 1700 // would normally cause the ShelfLayoutManager to update its state. However | 1685 // would normally cause the ShelfLayoutManager to update its state. However |
| 1701 // during shutdown we want to handle this without crashing. | 1686 // during shutdown we want to handle this without crashing. |
| 1702 delete window1; | 1687 delete window1; |
| 1703 } | 1688 } |
| 1704 | 1689 |
| 1705 TEST_F(ShelfLayoutManagerTest, ShelfLayoutInUnifiedDesktop) { | 1690 TEST_F(ShelfLayoutManagerTest, ShelfLayoutInUnifiedDesktop) { |
| 1706 if (!SupportsMultipleDisplays()) | |
| 1707 return; | |
| 1708 | |
| 1709 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); | 1691 Shell::GetInstance()->display_manager()->SetUnifiedDesktopEnabled(true); |
| 1710 UpdateDisplay("500x400, 500x400"); | 1692 UpdateDisplay("500x400, 500x400"); |
| 1711 | 1693 |
| 1712 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); | 1694 StatusAreaWidget* status_area_widget = GetShelfWidget()->status_area_widget(); |
| 1713 EXPECT_TRUE(status_area_widget->IsVisible()); | 1695 EXPECT_TRUE(status_area_widget->IsVisible()); |
| 1714 // Shelf should be in the first display's area. | 1696 // Shelf should be in the first display's area. |
| 1715 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); | 1697 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); |
| 1716 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); | 1698 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); |
| 1717 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); | 1699 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); |
| 1718 } | 1700 } |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1822 // Open keyboard in sticky mode. | 1804 // Open keyboard in sticky mode. |
| 1823 kb_controller->ShowKeyboard(true); | 1805 kb_controller->ShowKeyboard(true); |
| 1824 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); | 1806 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); |
| 1825 | 1807 |
| 1826 // Work area should be changed. | 1808 // Work area should be changed. |
| 1827 EXPECT_NE(orig_work_area, | 1809 EXPECT_NE(orig_work_area, |
| 1828 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1810 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 1829 } | 1811 } |
| 1830 | 1812 |
| 1831 } // namespace ash | 1813 } // namespace ash |
| OLD | NEW |