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

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

Issue 2169533002: mash: Migrate shelf app list button to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 5 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_layout_manager.cc ('k') | ash/shelf/shelf_tooltip_manager_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/aura/wm_window_aura.h" 9 #include "ash/aura/wm_window_aura.h"
10 #include "ash/common/ash_switches.h" 10 #include "ash/common/ash_switches.h"
(...skipping 1302 matching lines...) Expand 10 before | Expand all | Expand 10 after
1313 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); 1313 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
1314 1314
1315 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD); 1315 GetShelfWidget()->GetFocusCycler()->RotateFocus(FocusCycler::FORWARD);
1316 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 1316 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
1317 } 1317 }
1318 1318
1319 // Makes sure shelf will be visible when app list opens as shelf is in 1319 // Makes sure shelf will be visible when app list opens as shelf is in
1320 // SHELF_VISIBLE state,and toggling app list won't change shelf 1320 // SHELF_VISIBLE state,and toggling app list won't change shelf
1321 // visibility state. 1321 // visibility state.
1322 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { 1322 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) {
1323 Shell* shell = Shell::GetInstance(); 1323 WmShell* shell = WmShell::Get();
1324 Shelf* shelf = GetShelf(); 1324 Shelf* shelf = GetShelf();
1325 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1325 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1326 layout_manager->LayoutShelf(); 1326 layout_manager->LayoutShelf();
1327 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1327 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1328 1328
1329 // Create a normal unmaximized windowm shelf should be visible. 1329 // Create a normal unmaximized windowm shelf should be visible.
1330 aura::Window* window = CreateTestWindow(); 1330 aura::Window* window = CreateTestWindow();
1331 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1331 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1332 window->Show(); 1332 window->Show();
1333 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1333 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1334 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1334 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1335 1335
1336 // Show app list and the shelf stays visible. 1336 // Show app list and the shelf stays visible.
1337 shell->ShowAppList(nullptr); 1337 shell->ShowAppList();
1338 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 1338 EXPECT_TRUE(shell->GetAppListTargetVisibility());
1339 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1339 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1340 1340
1341 // Hide app list and the shelf stays visible. 1341 // Hide app list and the shelf stays visible.
1342 shell->DismissAppList(); 1342 shell->DismissAppList();
1343 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1343 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1344 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1344 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1345 } 1345 }
1346 1346
1347 // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state 1347 // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state
1348 // when app list opens as shelf is in SHELF_AUTO_HIDE state, and 1348 // when app list opens as shelf is in SHELF_AUTO_HIDE state, and
1349 // toggling app list won't change shelf visibility state. 1349 // toggling app list won't change shelf visibility state.
1350 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { 1350 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
1351 Shell* shell = Shell::GetInstance(); 1351 WmShell* shell = WmShell::Get();
1352 Shelf* shelf = GetShelf(); 1352 Shelf* shelf = GetShelf();
1353 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1353 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1354 layout_manager->LayoutShelf(); 1354 layout_manager->LayoutShelf();
1355 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1355 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1356 1356
1357 // Create a window and show it in maximized state. 1357 // Create a window and show it in maximized state.
1358 aura::Window* window = CreateTestWindow(); 1358 aura::Window* window = CreateTestWindow();
1359 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1359 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1360 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); 1360 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1361 window->Show(); 1361 window->Show();
1362 wm::ActivateWindow(window); 1362 wm::ActivateWindow(window);
1363 1363
1364 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1364 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1365 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1365 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1366 1366
1367 // Show app list. 1367 // Show app list.
1368 shell->ShowAppList(nullptr); 1368 shell->ShowAppList();
1369 // The shelf's auto hide state won't be changed until the timer fires, so 1369 // The shelf's auto hide state won't be changed until the timer fires, so
1370 // calling shell->UpdateShelfVisibility() is kind of manually helping it to 1370 // force it to update now.
1371 // update the state. 1371 layout_manager->UpdateVisibilityState();
1372 shell->UpdateShelfVisibility();
1373 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 1372 EXPECT_TRUE(shell->GetAppListTargetVisibility());
1374 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1373 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1375 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 1374 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
1376 1375
1377 // Hide app list. 1376 // Hide app list.
1378 shell->DismissAppList(); 1377 shell->DismissAppList();
1379 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1378 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1380 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1379 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1381 } 1380 }
1382 1381
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1424 EXPECT_EQ(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(), 1423 EXPECT_EQ(shelf_1->shelf_widget()->GetNativeWindow()->GetRootWindow(),
1425 window_1->GetRootWindow()); 1424 window_1->GetRootWindow());
1426 EXPECT_EQ(shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow(), 1425 EXPECT_EQ(shelf_2->shelf_widget()->GetNativeWindow()->GetRootWindow(),
1427 window_2->GetRootWindow()); 1426 window_2->GetRootWindow());
1428 1427
1429 // Activate one window in one display and manually trigger the update of shelf 1428 // Activate one window in one display and manually trigger the update of shelf
1430 // visibility. 1429 // visibility.
1431 wm::ActivateWindow(window_1); 1430 wm::ActivateWindow(window_1);
1432 shell->UpdateShelfVisibility(); 1431 shell->UpdateShelfVisibility();
1433 1432
1434 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1433 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility());
1435 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); 1434 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState());
1436 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); 1435 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState());
1437 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); 1436 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState());
1438 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); 1437 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState());
1439 1438
1440 // Show app list. 1439 // Show app list.
1441 shell->ShowAppList(nullptr); 1440 WmShell::Get()->ShowAppList();
1442 shell->UpdateShelfVisibility(); 1441 shell->UpdateShelfVisibility();
1443 1442
1444 // Only the shelf in the active display should be shown, the other is hidden. 1443 // Only the shelf in the active display should be shown, the other is hidden.
1445 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 1444 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility());
1446 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); 1445 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState());
1447 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_1->GetAutoHideState()); 1446 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf_1->GetAutoHideState());
1448 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); 1447 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState());
1449 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); 1448 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState());
1450 1449
1451 // Hide app list, both shelves should be hidden. 1450 // Hide app list, both shelves should be hidden.
1452 shell->DismissAppList(); 1451 WmShell::Get()->DismissAppList();
1453 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1452 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility());
1454 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState()); 1453 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_1->GetVisibilityState());
1455 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState()); 1454 EXPECT_EQ(SHELF_AUTO_HIDE, shelf_2->GetVisibilityState());
1456 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState()); 1455 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_1->GetAutoHideState());
1457 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState()); 1456 EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf_2->GetAutoHideState());
1458 } 1457 }
1459 1458
1460 // Makes sure the shelf will be hidden when we have a fullscreen window, and it 1459 // Makes sure the shelf will be hidden when we have a fullscreen window, and it
1461 // will unhide when we open the app list. 1460 // will unhide when we open the app list.
1462 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) { 1461 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfHiddenState) {
1463 Shell* shell = Shell::GetInstance(); 1462 WmShell* shell = WmShell::Get();
1464 Shelf* shelf = GetShelf(); 1463 Shelf* shelf = GetShelf();
1465 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1464 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1466 // For shelf to be visible, app list is not open in initial state. 1465 // For shelf to be visible, app list is not open in initial state.
1467 layout_manager->LayoutShelf(); 1466 layout_manager->LayoutShelf();
1468 1467
1469 // Create a window and make it full screen. 1468 // Create a window and make it full screen.
1470 aura::Window* window = CreateTestWindow(); 1469 aura::Window* window = CreateTestWindow();
1471 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1470 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1472 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 1471 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
1473 window->Show(); 1472 window->Show();
1474 wm::ActivateWindow(window); 1473 wm::ActivateWindow(window);
1475 1474
1476 // App list and shelf is not shown. 1475 // App list and shelf is not shown.
1477 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1476 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1478 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 1477 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
1479 1478
1480 // Show app list. 1479 // Show app list.
1481 shell->ShowAppList(nullptr); 1480 shell->ShowAppList();
1482 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 1481 EXPECT_TRUE(shell->GetAppListTargetVisibility());
1483 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1482 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1484 1483
1485 // Hide app list. 1484 // Hide app list.
1486 shell->DismissAppList(); 1485 shell->DismissAppList();
1487 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1486 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1488 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 1487 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
1489 } 1488 }
1490 1489
1491 // Tests the correct behavior of the shelf when there is a system modal window 1490 // Tests the correct behavior of the shelf when there is a system modal window
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
2282 ->shelf_widget() 2281 ->shelf_widget()
2283 ->status_area_widget(); 2282 ->status_area_widget();
2284 EXPECT_TRUE(status_area_widget->IsVisible()); 2283 EXPECT_TRUE(status_area_widget->IsVisible());
2285 // Shelf should be in the first display's area. 2284 // Shelf should be in the first display's area.
2286 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen()); 2285 gfx::Rect status_area_bounds(status_area_widget->GetWindowBoundsInScreen());
2287 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds)); 2286 EXPECT_TRUE(gfx::Rect(0, 0, 500, 400).Contains(status_area_bounds));
2288 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right()); 2287 EXPECT_EQ(gfx::Point(500, 400), status_area_bounds.bottom_right());
2289 } 2288 }
2290 2289
2291 } // namespace ash 2290 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_layout_manager.cc ('k') | ash/shelf/shelf_tooltip_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698