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

Side by Side Diff: ash/shelf/shelf_layout_manager_unittest.cc

Issue 2911393002: Nix GetRootWindowController, use RootWindowController::ForWindow. (Closed)
Patch Set: Sync and rebase AGAIN Created 3 years, 6 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/shelf/shelf.cc ('k') | ash/shelf/shelf_widget_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/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"
13 #include "ash/session/session_controller.h" 12 #include "ash/session/session_controller.h"
14 #include "ash/shelf/shelf.h" 13 #include "ash/shelf/shelf.h"
15 #include "ash/shelf/shelf_constants.h" 14 #include "ash/shelf/shelf_constants.h"
16 #include "ash/shelf/shelf_layout_manager_observer.h" 15 #include "ash/shelf/shelf_layout_manager_observer.h"
17 #include "ash/shelf/shelf_view.h" 16 #include "ash/shelf/shelf_view.h"
18 #include "ash/shelf/shelf_widget.h" 17 #include "ash/shelf/shelf_widget.h"
19 #include "ash/shell.h" 18 #include "ash/shell.h"
20 #include "ash/shell_port.h" 19 #include "ash/shell_port.h"
21 #include "ash/system/status_area_widget.h" 20 #include "ash/system/status_area_widget.h"
22 #include "ash/system/tray/system_tray.h" 21 #include "ash/system/tray/system_tray.h"
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 // Makes sure that when we have dual displays, with one or both shelves are set 1068 // Makes sure that when we have dual displays, with one or both shelves are set
1070 // to AutoHide, viewing the AppList on one of them doesn't unhide the other 1069 // to AutoHide, viewing the AppList on one of them doesn't unhide the other
1071 // hidden shelf. 1070 // hidden shelf.
1072 TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) { 1071 TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) {
1073 // Create two displays. 1072 // Create two displays.
1074 UpdateDisplay("0+0-200x200,+200+0-100x100"); 1073 UpdateDisplay("0+0-200x200,+200+0-100x100");
1075 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1074 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1076 EXPECT_EQ(root_windows.size(), 2U); 1075 EXPECT_EQ(root_windows.size(), 2U);
1077 1076
1078 // Get the shelves in both displays and set them to be 'AutoHide'. 1077 // Get the shelves in both displays and set them to be 'AutoHide'.
1079 Shelf* shelf_1 = GetRootWindowController(root_windows[0])->shelf(); 1078 Shelf* shelf_1 = Shelf::ForWindow(root_windows[0]);
1080 Shelf* shelf_2 = GetRootWindowController(root_windows[1])->shelf(); 1079 Shelf* shelf_2 = Shelf::ForWindow(root_windows[1]);
1081 EXPECT_NE(shelf_1, shelf_2); 1080 EXPECT_NE(shelf_1, shelf_2);
1082 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(), 1081 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(),
1083 shelf_2->GetWindow()->GetRootWindow()); 1082 shelf_2->GetWindow()->GetRootWindow());
1084 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1083 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1085 shelf_1->shelf_layout_manager()->LayoutShelf(); 1084 shelf_1->shelf_layout_manager()->LayoutShelf();
1086 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1085 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1087 shelf_2->shelf_layout_manager()->LayoutShelf(); 1086 shelf_2->shelf_layout_manager()->LayoutShelf();
1088 1087
1089 // Create a window in each display and show them in maximized state. 1088 // Create a window in each display and show them in maximized state.
1090 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); 1089 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 1191
1193 // Tests the correct behavior of the shelf when there is a system modal window 1192 // Tests the correct behavior of the shelf when there is a system modal window
1194 // open when we have dual display. 1193 // open when we have dual display.
1195 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) { 1194 TEST_F(ShelfLayoutManagerTest, ShelfWithSystemModalWindowDualDisplay) {
1196 // Create two displays. 1195 // Create two displays.
1197 UpdateDisplay("200x200,100x100"); 1196 UpdateDisplay("200x200,100x100");
1198 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1197 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1199 EXPECT_EQ(2U, root_windows.size()); 1198 EXPECT_EQ(2U, root_windows.size());
1200 1199
1201 // Get the shelves in both displays and set them to be 'AutoHide'. 1200 // Get the shelves in both displays and set them to be 'AutoHide'.
1202 Shelf* shelf_1 = GetRootWindowController(root_windows[0])->shelf(); 1201 Shelf* shelf_1 = Shelf::ForWindow(root_windows[0]);
1203 Shelf* shelf_2 = GetRootWindowController(root_windows[1])->shelf(); 1202 Shelf* shelf_2 = Shelf::ForWindow(root_windows[1]);
1204 EXPECT_NE(shelf_1, shelf_2); 1203 EXPECT_NE(shelf_1, shelf_2);
1205 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(), 1204 EXPECT_NE(shelf_1->GetWindow()->GetRootWindow(),
1206 shelf_2->GetWindow()->GetRootWindow()); 1205 shelf_2->GetWindow()->GetRootWindow());
1207 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1206 shelf_1->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1208 shelf_1->shelf_layout_manager()->LayoutShelf(); 1207 shelf_1->shelf_layout_manager()->LayoutShelf();
1209 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1208 shelf_2->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1210 shelf_2->shelf_layout_manager()->LayoutShelf(); 1209 shelf_2->shelf_layout_manager()->LayoutShelf();
1211 1210
1212 // Create a window in each display and show them in maximized state. 1211 // Create a window in each display and show them in maximized state.
1213 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]); 1212 aura::Window* window_1 = CreateTestWindowInParent(root_windows[0]);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1259 1258
1260 wm::GetWindowState(window1)->Activate(); 1259 wm::GetWindowState(window1)->Activate();
1261 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 1260 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
1262 } 1261 }
1263 1262
1264 // Test the behavior of the shelf when a window on one display is fullscreen 1263 // Test the behavior of the shelf when a window on one display is fullscreen
1265 // but the other display has the active window. 1264 // but the other display has the active window.
1266 TEST_F(ShelfLayoutManagerTest, FullscreenWindowOnSecondDisplay) { 1265 TEST_F(ShelfLayoutManagerTest, FullscreenWindowOnSecondDisplay) {
1267 UpdateDisplay("800x600,800x600"); 1266 UpdateDisplay("800x600,800x600");
1268 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1267 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1269 Shell::RootWindowControllerList root_window_controllers =
1270 Shell::GetAllRootWindowControllers();
1271 1268
1272 // Create windows on either display. 1269 // Create windows on either display.
1273 aura::Window* window1 = CreateTestWindow(); 1270 aura::Window* window1 = CreateTestWindow();
1274 window1->SetBoundsInScreen(gfx::Rect(0, 0, 100, 100), 1271 window1->SetBoundsInScreen(gfx::Rect(0, 0, 100, 100),
1275 display::Screen::GetScreen()->GetAllDisplays()[0]); 1272 display::Screen::GetScreen()->GetAllDisplays()[0]);
1276 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 1273 window1->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
1277 window1->Show(); 1274 window1->Show();
1278 1275
1279 aura::Window* window2 = CreateTestWindow(); 1276 aura::Window* window2 = CreateTestWindow();
1280 window2->SetBoundsInScreen(gfx::Rect(800, 0, 100, 100), 1277 window2->SetBoundsInScreen(gfx::Rect(800, 0, 100, 100),
1281 display::Screen::GetScreen()->GetAllDisplays()[1]); 1278 display::Screen::GetScreen()->GetAllDisplays()[1]);
1282 window2->Show(); 1279 window2->Show();
1283 1280
1284 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); 1281 EXPECT_EQ(root_windows[0], window1->GetRootWindow());
1285 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); 1282 EXPECT_EQ(root_windows[1], window2->GetRootWindow());
1286 1283
1287 wm::GetWindowState(window2)->Activate(); 1284 wm::GetWindowState(window2)->Activate();
1288 EXPECT_EQ( 1285 EXPECT_EQ(
1289 SHELF_HIDDEN, 1286 SHELF_HIDDEN,
1290 root_window_controllers[0]->GetShelfLayoutManager()->visibility_state()); 1287 Shelf::ForWindow(window1)->shelf_layout_manager()->visibility_state());
1291 EXPECT_EQ( 1288 EXPECT_EQ(
1292 SHELF_VISIBLE, 1289 SHELF_VISIBLE,
1293 root_window_controllers[1]->GetShelfLayoutManager()->visibility_state()); 1290 Shelf::ForWindow(window2)->shelf_layout_manager()->visibility_state());
1294 } 1291 }
1295 1292
1296 // Test for Pinned mode. 1293 // Test for Pinned mode.
1297 TEST_F(ShelfLayoutManagerTest, PinnedWindowHidesShelf) { 1294 TEST_F(ShelfLayoutManagerTest, PinnedWindowHidesShelf) {
1298 // TODO: investigate failure in mash, http://crbug.com/695686. 1295 // TODO: investigate failure in mash, http://crbug.com/695686.
1299 if (Shell::GetAshConfig() == Config::MASH) 1296 if (Shell::GetAshConfig() == Config::MASH)
1300 return; 1297 return;
1301 1298
1302 Shelf* shelf = GetPrimaryShelf(); 1299 Shelf* shelf = GetPrimaryShelf();
1303 1300
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 // Open keyboard in sticky mode. 1880 // Open keyboard in sticky mode.
1884 kb_controller->ShowKeyboard(true); 1881 kb_controller->ShowKeyboard(true);
1885 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); 1882 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds());
1886 1883
1887 // Work area should be changed. 1884 // Work area should be changed.
1888 EXPECT_NE(orig_work_area, 1885 EXPECT_NE(orig_work_area,
1889 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 1886 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
1890 } 1887 }
1891 1888
1892 } // namespace ash 1889 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf.cc ('k') | ash/shelf/shelf_widget_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698