| 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/aura/wm_window_aura.h" | |
| 8 #include "ash/common/accelerators/accelerator_controller.h" | 7 #include "ash/common/accelerators/accelerator_controller.h" |
| 9 #include "ash/common/accelerators/accelerator_table.h" | 8 #include "ash/common/accelerators/accelerator_table.h" |
| 10 #include "ash/common/focus_cycler.h" | 9 #include "ash/common/focus_cycler.h" |
| 11 #include "ash/common/material_design/material_design_controller.h" | 10 #include "ash/common/material_design/material_design_controller.h" |
| 12 #include "ash/common/session/session_state_delegate.h" | 11 #include "ash/common/session/session_state_delegate.h" |
| 13 #include "ash/common/shelf/shelf_constants.h" | 12 #include "ash/common/shelf/shelf_constants.h" |
| 14 #include "ash/common/shelf/shelf_layout_manager_observer.h" | 13 #include "ash/common/shelf/shelf_layout_manager_observer.h" |
| 15 #include "ash/common/shelf/shelf_view.h" | 14 #include "ash/common/shelf/shelf_view.h" |
| 16 #include "ash/common/shelf/shelf_widget.h" | 15 #include "ash/common/shelf/shelf_widget.h" |
| 17 #include "ash/common/shelf/wm_shelf.h" | 16 #include "ash/common/shelf/wm_shelf.h" |
| 18 #include "ash/common/system/status_area_widget.h" | 17 #include "ash/common/system/status_area_widget.h" |
| 19 #include "ash/common/system/tray/system_tray.h" | 18 #include "ash/common/system/tray/system_tray.h" |
| 20 #include "ash/common/system/tray/system_tray_item.h" | 19 #include "ash/common/system/tray/system_tray_item.h" |
| 21 #include "ash/common/wm/window_state.h" | 20 #include "ash/common/wm/window_state.h" |
| 22 #include "ash/common/wm_shell.h" | 21 #include "ash/common/wm_shell.h" |
| 22 #include "ash/common/wm_window.h" |
| 23 #include "ash/public/cpp/shell_window_ids.h" | 23 #include "ash/public/cpp/shell_window_ids.h" |
| 24 #include "ash/root_window_controller.h" | 24 #include "ash/root_window_controller.h" |
| 25 #include "ash/shell.h" | 25 #include "ash/shell.h" |
| 26 #include "ash/test/ash_test_base.h" | 26 #include "ash/test/ash_test_base.h" |
| 27 #include "ash/test/test_app_list_view_presenter_impl.h" | 27 #include "ash/test/test_app_list_view_presenter_impl.h" |
| 28 #include "ash/test/test_system_tray_item.h" | 28 #include "ash/test/test_system_tray_item.h" |
| 29 #include "ash/wm/window_state_aura.h" | 29 #include "ash/wm/window_state_aura.h" |
| 30 #include "ash/wm/window_util.h" | 30 #include "ash/wm/window_util.h" |
| 31 #include "base/command_line.h" | 31 #include "base/command_line.h" |
| 32 #include "base/run_loop.h" | 32 #include "base/run_loop.h" |
| (...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); | 1023 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); |
| 1024 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1024 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1025 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1025 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1026 window_1->Show(); | 1026 window_1->Show(); |
| 1027 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); | 1027 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); |
| 1028 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); | 1028 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); |
| 1029 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1029 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1030 window_2->Show(); | 1030 window_2->Show(); |
| 1031 | 1031 |
| 1032 EXPECT_EQ(shelf_1->GetWindow()->GetRootWindow(), | 1032 EXPECT_EQ(shelf_1->GetWindow()->GetRootWindow(), |
| 1033 WmWindowAura::Get(window_1)->GetRootWindow()); | 1033 WmWindow::Get(window_1)->GetRootWindow()); |
| 1034 EXPECT_EQ(shelf_2->GetWindow()->GetRootWindow(), | 1034 EXPECT_EQ(shelf_2->GetWindow()->GetRootWindow(), |
| 1035 WmWindowAura::Get(window_2)->GetRootWindow()); | 1035 WmWindow::Get(window_2)->GetRootWindow()); |
| 1036 | 1036 |
| 1037 // Activate one window in one display. | 1037 // Activate one window in one display. |
| 1038 wm::ActivateWindow(window_1); | 1038 wm::ActivateWindow(window_1); |
| 1039 | 1039 |
| 1040 // The tested behavior relies on the app list presenter implementation. | 1040 // The tested behavior relies on the app list presenter implementation. |
| 1041 test::TestAppListViewPresenterImpl app_list_presenter_impl; | 1041 test::TestAppListViewPresenterImpl app_list_presenter_impl; |
| 1042 | 1042 |
| 1043 Shell::GetInstance()->UpdateShelfVisibility(); | 1043 Shell::GetInstance()->UpdateShelfVisibility(); |
| 1044 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); | 1044 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); |
| 1045 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); | 1045 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); | 1144 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); |
| 1145 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1145 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1146 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1146 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1147 window_1->Show(); | 1147 window_1->Show(); |
| 1148 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); | 1148 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); |
| 1149 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); | 1149 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); |
| 1150 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1150 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
| 1151 window_2->Show(); | 1151 window_2->Show(); |
| 1152 | 1152 |
| 1153 EXPECT_EQ(shelf_1->GetWindow()->GetRootWindow(), | 1153 EXPECT_EQ(shelf_1->GetWindow()->GetRootWindow(), |
| 1154 WmWindowAura::Get(window_1)->GetRootWindow()); | 1154 WmWindow::Get(window_1)->GetRootWindow()); |
| 1155 EXPECT_EQ(shelf_2->GetWindow()->GetRootWindow(), | 1155 EXPECT_EQ(shelf_2->GetWindow()->GetRootWindow(), |
| 1156 WmWindowAura::Get(window_2)->GetRootWindow()); | 1156 WmWindow::Get(window_2)->GetRootWindow()); |
| 1157 EXPECT_TRUE(window_1->IsVisible()); | 1157 EXPECT_TRUE(window_1->IsVisible()); |
| 1158 EXPECT_TRUE(window_2->IsVisible()); | 1158 EXPECT_TRUE(window_2->IsVisible()); |
| 1159 | 1159 |
| 1160 // Enable system modal dialog, and make sure both shelves are still hidden. | 1160 // Enable system modal dialog, and make sure both shelves are still hidden. |
| 1161 WmShell* wm_shell = WmShell::Get(); | 1161 WmShell* wm_shell = WmShell::Get(); |
| 1162 wm_shell->SimulateModalWindowOpenForTesting(true); | 1162 wm_shell->SimulateModalWindowOpenForTesting(true); |
| 1163 EXPECT_TRUE(wm_shell->IsSystemModalWindowOpen()); | 1163 EXPECT_TRUE(wm_shell->IsSystemModalWindowOpen()); |
| 1164 EXPECT_FALSE(wm::CanActivateWindow(window_1)); | 1164 EXPECT_FALSE(wm::CanActivateWindow(window_1)); |
| 1165 EXPECT_FALSE(wm::CanActivateWindow(window_2)); | 1165 EXPECT_FALSE(wm::CanActivateWindow(window_2)); |
| 1166 Shell::GetInstance()->UpdateShelfVisibility(); | 1166 Shell::GetInstance()->UpdateShelfVisibility(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 | 1236 |
| 1237 aura::Window* window1 = CreateTestWindow(); | 1237 aura::Window* window1 = CreateTestWindow(); |
| 1238 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1238 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
| 1239 window1->Show(); | 1239 window1->Show(); |
| 1240 | 1240 |
| 1241 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1241 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 1242 | 1242 |
| 1243 wm::PinWindow(window1, /* trusted */ false); | 1243 wm::PinWindow(window1, /* trusted */ false); |
| 1244 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); | 1244 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); |
| 1245 | 1245 |
| 1246 WmWindowAura::Get(window1)->GetWindowState()->Restore(); | 1246 WmWindow::Get(window1)->GetWindowState()->Restore(); |
| 1247 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1247 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT). | 1250 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT). |
| 1251 TEST_F(ShelfLayoutManagerTest, SetAlignment) { | 1251 TEST_F(ShelfLayoutManagerTest, SetAlignment) { |
| 1252 WmShelf* shelf = GetPrimaryShelf(); | 1252 WmShelf* shelf = GetPrimaryShelf(); |
| 1253 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 1253 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
| 1254 // Force an initial layout. | 1254 // Force an initial layout. |
| 1255 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1255 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
| 1256 layout_manager->LayoutShelf(); | 1256 layout_manager->LayoutShelf(); |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1821 // Open keyboard in sticky mode. | 1821 // Open keyboard in sticky mode. |
| 1822 kb_controller->ShowKeyboard(true); | 1822 kb_controller->ShowKeyboard(true); |
| 1823 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); | 1823 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); |
| 1824 | 1824 |
| 1825 // Work area should be changed. | 1825 // Work area should be changed. |
| 1826 EXPECT_NE(orig_work_area, | 1826 EXPECT_NE(orig_work_area, |
| 1827 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1827 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 1828 } | 1828 } |
| 1829 | 1829 |
| 1830 } // namespace ash | 1830 } // namespace ash |
| OLD | NEW |