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/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
6 | 6 |
7 #include "ash/accelerators/accelerator_controller.h" | 7 #include "ash/accelerators/accelerator_controller.h" |
8 #include "ash/accelerators/accelerator_table.h" | 8 #include "ash/accelerators/accelerator_table.h" |
9 #include "ash/focus_cycler.h" | 9 #include "ash/focus_cycler.h" |
10 #include "ash/public/cpp/config.h" | 10 #include "ash/public/cpp/config.h" |
11 #include "ash/public/cpp/shell_window_ids.h" | 11 #include "ash/public/cpp/shell_window_ids.h" |
12 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
13 #include "ash/session/session_controller.h" | 13 #include "ash/session/session_controller.h" |
14 #include "ash/shelf/shelf.h" | 14 #include "ash/shelf/shelf.h" |
15 #include "ash/shelf/shelf_constants.h" | 15 #include "ash/shelf/shelf_constants.h" |
16 #include "ash/shelf/shelf_layout_manager_observer.h" | 16 #include "ash/shelf/shelf_layout_manager_observer.h" |
17 #include "ash/shelf/shelf_view.h" | 17 #include "ash/shelf/shelf_view.h" |
18 #include "ash/shelf/shelf_widget.h" | 18 #include "ash/shelf/shelf_widget.h" |
19 #include "ash/shell.h" | 19 #include "ash/shell.h" |
20 #include "ash/shell_port.h" | 20 #include "ash/shell_port.h" |
21 #include "ash/system/status_area_widget.h" | 21 #include "ash/system/status_area_widget.h" |
22 #include "ash/system/tray/system_tray.h" | 22 #include "ash/system/tray/system_tray.h" |
23 #include "ash/system/tray/system_tray_item.h" | 23 #include "ash/system/tray/system_tray_item.h" |
24 #include "ash/test/ash_test_base.h" | 24 #include "ash/test/ash_test_base.h" |
25 #include "ash/test/test_app_list_view_presenter_impl.h" | 25 #include "ash/test/test_app_list_view_presenter_impl.h" |
26 #include "ash/test/test_system_tray_item.h" | 26 #include "ash/test/test_system_tray_item.h" |
27 #include "ash/wm/lock_state_controller.h" | 27 #include "ash/wm/lock_state_controller.h" |
28 #include "ash/wm/window_state.h" | 28 #include "ash/wm/window_state.h" |
29 #include "ash/wm/window_util.h" | 29 #include "ash/wm/window_util.h" |
30 #include "ash/wm_window.h" | |
31 #include "base/command_line.h" | 30 #include "base/command_line.h" |
32 #include "base/memory/ptr_util.h" | 31 #include "base/memory/ptr_util.h" |
33 #include "base/message_loop/message_loop.h" | 32 #include "base/message_loop/message_loop.h" |
34 #include "base/run_loop.h" | 33 #include "base/run_loop.h" |
35 #include "ui/aura/client/aura_constants.h" | 34 #include "ui/aura/client/aura_constants.h" |
36 #include "ui/aura/client/window_parenting_client.h" | 35 #include "ui/aura/client/window_parenting_client.h" |
37 #include "ui/aura/window.h" | 36 #include "ui/aura/window.h" |
38 #include "ui/aura/window_event_dispatcher.h" | 37 #include "ui/aura/window_event_dispatcher.h" |
39 #include "ui/base/ui_base_switches.h" | 38 #include "ui/base/ui_base_switches.h" |
40 #include "ui/compositor/layer.h" | 39 #include "ui/compositor/layer.h" |
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1090 // Create a window in each display and show them in maximized state. | 1089 // Create a window in each display and show them in maximized state. |
1091 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); | 1090 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); |
1092 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1091 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
1093 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1092 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
1094 window_1->Show(); | 1093 window_1->Show(); |
1095 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); | 1094 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); |
1096 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); | 1095 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); |
1097 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1096 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
1098 window_2->Show(); | 1097 window_2->Show(); |
1099 | 1098 |
1100 EXPECT_EQ(shelf_1->GetWindow()->GetRootWindow(), | 1099 EXPECT_EQ(shelf_1->GetWindow()->GetRootWindow(), window_1->GetRootWindow()); |
1101 WmWindow::Get(window_1)->GetRootWindow()); | 1100 EXPECT_EQ(shelf_2->GetWindow()->GetRootWindow(), window_2->GetRootWindow()); |
1102 EXPECT_EQ(shelf_2->GetWindow()->GetRootWindow(), | |
1103 WmWindow::Get(window_2)->GetRootWindow()); | |
1104 | 1101 |
1105 // Activate one window in one display. | 1102 // Activate one window in one display. |
1106 wm::ActivateWindow(window_1); | 1103 wm::ActivateWindow(window_1); |
1107 | 1104 |
1108 // The tested behavior relies on the app list presenter implementation. | 1105 // The tested behavior relies on the app list presenter implementation. |
1109 test::TestAppListViewPresenterImpl app_list_presenter_impl; | 1106 test::TestAppListViewPresenterImpl app_list_presenter_impl; |
1110 | 1107 |
1111 Shell::Get()->UpdateShelfVisibility(); | 1108 Shell::Get()->UpdateShelfVisibility(); |
1112 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); | 1109 EXPECT_FALSE(app_list_presenter_impl.GetTargetVisibility()); |
1113 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); | 1110 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 // Create a window in each display and show them in maximized state. | 1212 // Create a window in each display and show them in maximized state. |
1216 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); | 1213 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); |
1217 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1214 window_1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
1218 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1215 window_1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
1219 window_1->Show(); | 1216 window_1->Show(); |
1220 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); | 1217 aura::Window* window_2 = CreateTestWindowInParent(root_windows[1]); |
1221 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); | 1218 window_2->SetBounds(gfx::Rect(201, 0, 100, 100)); |
1222 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 1219 window_2->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
1223 window_2->Show(); | 1220 window_2->Show(); |
1224 | 1221 |
1225 EXPECT_EQ(shelf_1->GetWindow()->GetRootWindow(), | 1222 EXPECT_EQ(shelf_1->GetWindow()->GetRootWindow(), window_1->GetRootWindow()); |
1226 WmWindow::Get(window_1)->GetRootWindow()); | 1223 EXPECT_EQ(shelf_2->GetWindow()->GetRootWindow(), window_2->GetRootWindow()); |
1227 EXPECT_EQ(shelf_2->GetWindow()->GetRootWindow(), | |
1228 WmWindow::Get(window_2)->GetRootWindow()); | |
1229 EXPECT_TRUE(window_1->IsVisible()); | 1224 EXPECT_TRUE(window_1->IsVisible()); |
1230 EXPECT_TRUE(window_2->IsVisible()); | 1225 EXPECT_TRUE(window_2->IsVisible()); |
1231 | 1226 |
1232 // Enable system modal dialog, and make sure both shelves are still hidden. | 1227 // Enable system modal dialog, and make sure both shelves are still hidden. |
1233 ShellPort::Get()->SimulateModalWindowOpenForTesting(true); | 1228 ShellPort::Get()->SimulateModalWindowOpenForTesting(true); |
1234 EXPECT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); | 1229 EXPECT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); |
1235 EXPECT_FALSE(wm::CanActivateWindow(window_1)); | 1230 EXPECT_FALSE(wm::CanActivateWindow(window_1)); |
1236 EXPECT_FALSE(wm::CanActivateWindow(window_2)); | 1231 EXPECT_FALSE(wm::CanActivateWindow(window_2)); |
1237 Shell::Get()->UpdateShelfVisibility(); | 1232 Shell::Get()->UpdateShelfVisibility(); |
1238 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); | 1233 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 | 1303 |
1309 aura::Window* window1 = CreateTestWindow(); | 1304 aura::Window* window1 = CreateTestWindow(); |
1310 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); | 1305 window1->SetBounds(gfx::Rect(0, 0, 100, 100)); |
1311 window1->Show(); | 1306 window1->Show(); |
1312 | 1307 |
1313 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1308 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
1314 | 1309 |
1315 wm::PinWindow(window1, /* trusted */ false); | 1310 wm::PinWindow(window1, /* trusted */ false); |
1316 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); | 1311 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); |
1317 | 1312 |
1318 WmWindow::Get(window1)->GetWindowState()->Restore(); | 1313 wm::GetWindowState(window1)->Restore(); |
1319 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); | 1314 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); |
1320 } | 1315 } |
1321 | 1316 |
1322 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT). | 1317 // Tests SHELF_ALIGNMENT_(LEFT, RIGHT). |
1323 TEST_F(ShelfLayoutManagerTest, SetAlignment) { | 1318 TEST_F(ShelfLayoutManagerTest, SetAlignment) { |
1324 Shelf* shelf = GetPrimaryShelf(); | 1319 Shelf* shelf = GetPrimaryShelf(); |
1325 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); | 1320 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); |
1326 // Force an initial layout. | 1321 // Force an initial layout. |
1327 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); | 1322 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); |
1328 layout_manager->LayoutShelf(); | 1323 layout_manager->LayoutShelf(); |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1888 // Open keyboard in sticky mode. | 1883 // Open keyboard in sticky mode. |
1889 kb_controller->ShowKeyboard(true); | 1884 kb_controller->ShowKeyboard(true); |
1890 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); | 1885 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); |
1891 | 1886 |
1892 // Work area should be changed. | 1887 // Work area should be changed. |
1893 EXPECT_NE(orig_work_area, | 1888 EXPECT_NE(orig_work_area, |
1894 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1889 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
1895 } | 1890 } |
1896 | 1891 |
1897 } // namespace ash | 1892 } // namespace ash |
OLD | NEW |