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

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

Issue 460933002: Split Shell::ToggleAppList() into ShowAppList and DismissAppList. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/display/display_manager.h" 10 #include "ash/display/display_manager.h"
(...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after
1271 shelf->LayoutShelf(); 1271 shelf->LayoutShelf();
1272 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1272 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1273 1273
1274 // Create a normal unmaximized windowm shelf should be visible. 1274 // Create a normal unmaximized windowm shelf should be visible.
1275 aura::Window* window = CreateTestWindow(); 1275 aura::Window* window = CreateTestWindow();
1276 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1276 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1277 window->Show(); 1277 window->Show();
1278 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1278 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1279 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 1279 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
1280 1280
1281 // Toggle app list to show, and the shelf stays visible. 1281 // Toggle app list to show, and the shelf stays visible.
Matt Giuca 2014/08/14 04:17:07 // Show app list, ...
calamity 2014/08/14 05:00:59 Done.
1282 shell->ToggleAppList(NULL); 1282 shell->ShowAppList(NULL);
1283 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 1283 EXPECT_TRUE(shell->GetAppListTargetVisibility());
1284 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 1284 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
1285 1285
1286 // Toggle app list to hide, and the shelf stays visible. 1286 // Toggle app list to hide, and the shelf stays visible.
Matt Giuca 2014/08/14 04:17:07 // Hide app list, ... (and continue throughout th
calamity 2014/08/14 05:00:59 Done.
1287 shell->ToggleAppList(NULL); 1287 shell->DismissAppList();
1288 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1288 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1289 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); 1289 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state());
1290 } 1290 }
1291 1291
1292 // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state 1292 // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state
1293 // when app list opens as shelf is in SHELF_AUTO_HIDE state, and 1293 // when app list opens as shelf is in SHELF_AUTO_HIDE state, and
1294 // toggling app list won't change shelf visibility state. 1294 // toggling app list won't change shelf visibility state.
1295 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { 1295 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
1296 Shell* shell = Shell::GetInstance(); 1296 Shell* shell = Shell::GetInstance();
1297 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 1297 ShelfLayoutManager* shelf = GetShelfLayoutManager();
1298 shelf->LayoutShelf(); 1298 shelf->LayoutShelf();
1299 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1299 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1300 1300
1301 // Create a window and show it in maximized state. 1301 // Create a window and show it in maximized state.
1302 aura::Window* window = CreateTestWindow(); 1302 aura::Window* window = CreateTestWindow();
1303 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1303 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1304 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1304 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1305 window->Show(); 1305 window->Show();
1306 wm::ActivateWindow(window); 1306 wm::ActivateWindow(window);
1307 1307
1308 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1308 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1309 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 1309 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
1310 1310
1311 // Toggle app list to show. 1311 // Toggle app list to show.
1312 shell->ToggleAppList(NULL); 1312 shell->ShowAppList(NULL);
1313 // The shelf's auto hide state won't be changed until the timer fires, so 1313 // The shelf's auto hide state won't be changed until the timer fires, so
1314 // calling shell->UpdateShelfVisibility() is kind of manually helping it to 1314 // calling shell->UpdateShelfVisibility() is kind of manually helping it to
1315 // update the state. 1315 // update the state.
1316 shell->UpdateShelfVisibility(); 1316 shell->UpdateShelfVisibility();
1317 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 1317 EXPECT_TRUE(shell->GetAppListTargetVisibility());
1318 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 1318 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
1319 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state()); 1319 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->auto_hide_state());
1320 1320
1321 // Toggle app list to hide. 1321 // Toggle app list to hide.
1322 shell->ToggleAppList(NULL); 1322 shell->DismissAppList();
1323 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1323 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1324 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 1324 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state());
1325 } 1325 }
1326 1326
1327 // Makes sure shelf will be hidden when app list opens as shelf is in HIDDEN 1327 // Makes sure shelf will be hidden when app list opens as shelf is in HIDDEN
1328 // state, and toggling app list won't change shelf visibility state. 1328 // state, and toggling app list won't change shelf visibility state.
1329 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) { 1329 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) {
1330 Shell* shell = Shell::GetInstance(); 1330 Shell* shell = Shell::GetInstance();
1331 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 1331 ShelfLayoutManager* shelf = GetShelfLayoutManager();
1332 // For shelf to be visible, app list is not open in initial state. 1332 // For shelf to be visible, app list is not open in initial state.
1333 shelf->LayoutShelf(); 1333 shelf->LayoutShelf();
1334 1334
1335 // Create a window and make it full screen. 1335 // Create a window and make it full screen.
1336 aura::Window* window = CreateTestWindow(); 1336 aura::Window* window = CreateTestWindow();
1337 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1337 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1338 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 1338 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
1339 window->Show(); 1339 window->Show();
1340 wm::ActivateWindow(window); 1340 wm::ActivateWindow(window);
1341 1341
1342 // App list and shelf is not shown. 1342 // App list and shelf is not shown.
1343 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1343 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1344 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); 1344 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
1345 1345
1346 // Toggle app list to show. 1346 // Toggle app list to show.
1347 shell->ToggleAppList(NULL); 1347 shell->ShowAppList(NULL);
1348 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 1348 EXPECT_TRUE(shell->GetAppListTargetVisibility());
1349 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); 1349 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
1350 1350
1351 // Toggle app list to hide. 1351 // Toggle app list to hide.
1352 shell->ToggleAppList(NULL); 1352 shell->DismissAppList();
1353 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1353 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1354 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); 1354 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state());
1355 } 1355 }
1356 1356
1357 // Tests that the shelf is only hidden for a fullscreen window at the front and 1357 // Tests that the shelf is only hidden for a fullscreen window at the front and
1358 // toggles visibility when another window is activated. 1358 // toggles visibility when another window is activated.
1359 TEST_F(ShelfLayoutManagerTest, FullscreenWindowInFrontHidesShelf) { 1359 TEST_F(ShelfLayoutManagerTest, FullscreenWindowInFrontHidesShelf) {
1360 ShelfLayoutManager* shelf = GetShelfLayoutManager(); 1360 ShelfLayoutManager* shelf = GetShelfLayoutManager();
1361 1361
1362 // Create a window and make it full screen. 1362 // Create a window and make it full screen.
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN); 2015 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_ALWAYS_HIDDEN);
2016 gfx::Rect hide_target_bounds = status_window->GetTargetBounds(); 2016 gfx::Rect hide_target_bounds = status_window->GetTargetBounds();
2017 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y()); 2017 EXPECT_GT(hide_target_bounds.y(), initial_bounds.y());
2018 2018
2019 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 2019 shelf_manager->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
2020 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds(); 2020 gfx::Rect reshow_target_bounds = status_window->GetTargetBounds();
2021 EXPECT_EQ(initial_bounds, reshow_target_bounds); 2021 EXPECT_EQ(initial_bounds, reshow_target_bounds);
2022 } 2022 }
2023 2023
2024 } // namespace ash 2024 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698