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

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

Issue 2534953006: Fix shelf auto-hide calculation for app-list visibility. (Closed)
Patch Set: Cleanup. Created 4 years 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
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/common/shelf/shelf_layout_manager.h" 5 #include "ash/common/shelf/shelf_layout_manager.h"
6 6
7 #include "ash/aura/wm_shelf_aura.h" 7 #include "ash/aura/wm_shelf_aura.h"
8 #include "ash/aura/wm_window_aura.h" 8 #include "ash/aura/wm_window_aura.h"
9 #include "ash/common/accelerators/accelerator_controller.h" 9 #include "ash/common/accelerators/accelerator_controller.h"
10 #include "ash/common/accelerators/accelerator_table.h" 10 #include "ash/common/accelerators/accelerator_table.h"
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 // Makes sure shelf will be visible when app list opens as shelf is in 1125 // Makes sure shelf will be visible when app list opens as shelf is in
1126 // SHELF_VISIBLE state,and toggling app list won't change shelf 1126 // SHELF_VISIBLE state,and toggling app list won't change shelf
1127 // visibility state. 1127 // visibility state.
1128 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) { 1128 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfVisibleState) {
1129 WmShell* shell = WmShell::Get(); 1129 WmShell* shell = WmShell::Get();
1130 WmShelf* shelf = GetPrimaryShelf(); 1130 WmShelf* shelf = GetPrimaryShelf();
1131 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1131 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1132 layout_manager->LayoutShelf(); 1132 layout_manager->LayoutShelf();
1133 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER); 1133 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_NEVER);
1134 1134
1135 // Create a normal unmaximized windowm shelf should be visible. 1135 // Create a normal unmaximized window, shelf should be visible.
1136 aura::Window* window = CreateTestWindow(); 1136 aura::Window* window = CreateTestWindow();
1137 window->SetBounds(gfx::Rect(0, 0, 100, 100)); 1137 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1138 window->Show(); 1138 window->Show();
1139 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1139 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1140 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1140 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1141 1141
1142 // Show app list and the shelf stays visible. 1142 // Show app list and the shelf stays visible.
1143 shell->ShowAppList(); 1143 shell->ShowAppList();
1144 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 1144 EXPECT_TRUE(shell->GetAppListTargetVisibility());
1145 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1145 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1146 1146
1147 // Hide app list and the shelf stays visible. 1147 // Hide app list and the shelf stays visible.
1148 shell->DismissAppList(); 1148 shell->DismissAppList();
1149 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1149 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1150 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState()); 1150 EXPECT_EQ(SHELF_VISIBLE, shelf->GetVisibilityState());
1151 } 1151 }
1152 1152
1153 // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state 1153 // Makes sure shelf will be shown with SHELF_AUTO_HIDE_SHOWN state
1154 // when app list opens as shelf is in SHELF_AUTO_HIDE state, and 1154 // when app list opens as shelf is in SHELF_AUTO_HIDE state, and
1155 // toggling app list won't change shelf visibility state. 1155 // toggling app list won't change shelf visibility state.
1156 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) { 1156 TEST_F(ShelfLayoutManagerTest, OpenAppListWithShelfAutoHideState) {
1157 WmShell* shell = WmShell::Get(); 1157 WmShell* shell = WmShell::Get();
1158 WmShelf* shelf = GetPrimaryShelf(); 1158 WmShelf* shelf = GetPrimaryShelf();
1159 ShelfLayoutManager* layout_manager = GetShelfLayoutManager(); 1159 ShelfLayoutManager* layout_manager = GetShelfLayoutManager();
1160 layout_manager->LayoutShelf(); 1160 layout_manager->LayoutShelf();
1161 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1161 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1162 1162
1163 // Create a window and show it in maximized state.
1164 aura::Window* window = CreateTestWindow();
1165 window->SetBounds(gfx::Rect(0, 0, 100, 100));
1166 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED);
1167 window->Show();
1168 wm::ActivateWindow(window);
1169
1170 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1163 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1171 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1164 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1165 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
James Cook 2016/11/30 23:27:19 Thanks for checking this case.
1172 1166
1173 // Show app list. 1167 // Show app list.
1174 shell->ShowAppList(); 1168 shell->ShowAppList();
1175 // The shelf's auto hide state won't be changed until the timer fires, so 1169 // The shelf's auto hide state won't be changed until the timer fires, so
1176 // force it to update now. 1170 // force it to update now.
1177 layout_manager->UpdateVisibilityState(); 1171 layout_manager->UpdateVisibilityState();
1178 EXPECT_TRUE(shell->GetAppListTargetVisibility()); 1172 EXPECT_TRUE(shell->GetAppListTargetVisibility());
1179 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1173 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1180 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState()); 1174 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
1181 1175
1182 // Hide app list. 1176 // Hide app list.
1183 shell->DismissAppList(); 1177 shell->DismissAppList();
1184 EXPECT_FALSE(shell->GetAppListTargetVisibility()); 1178 EXPECT_FALSE(shell->GetAppListTargetVisibility());
1185 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1179 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1180 EXPECT_EQ(SHELF_AUTO_HIDE_SHOWN, shelf->GetAutoHideState());
1186 } 1181 }
1187 1182
1188 // Makes sure that when we have dual displays, with one or both shelves are set 1183 // Makes sure that when we have dual displays, with one or both shelves are set
1189 // to AutoHide, viewing the AppList on one of them doesn't unhide the other 1184 // to AutoHide, viewing the AppList on one of them doesn't unhide the other
1190 // hidden shelf. 1185 // hidden shelf.
1191 TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) { 1186 TEST_F(ShelfLayoutManagerTest, DualDisplayOpenAppListWithShelfAutoHideState) {
1192 if (!SupportsMultipleDisplays()) 1187 if (!SupportsMultipleDisplays())
1193 return; 1188 return;
1194 1189
1195 // Create two displays. 1190 // Create two displays.
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after
2060 // Open keyboard in sticky mode. 2055 // Open keyboard in sticky mode.
2061 kb_controller->ShowKeyboard(true); 2056 kb_controller->ShowKeyboard(true);
2062 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds()); 2057 layout_manager->OnKeyboardBoundsChanging(keyboard_bounds());
2063 2058
2064 // Work area should be changed. 2059 // Work area should be changed.
2065 EXPECT_NE(orig_work_area, 2060 EXPECT_NE(orig_work_area,
2066 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 2061 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
2067 } 2062 }
2068 2063
2069 } // namespace ash 2064 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698