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

Side by Side Diff: ash/system/overview/overview_button_tray_unittest.cc

Issue 2909763002: Revert of Rename MaximizeMode to TabletMode (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/system/overview/overview_button_tray.h" 5 #include "ash/system/overview/overview_button_tray.h"
6 6
7 #include "ash/login_status.h" 7 #include "ash/login_status.h"
8 #include "ash/public/cpp/config.h" 8 #include "ash/public/cpp/config.h"
9 #include "ash/public/cpp/shelf_types.h" 9 #include "ash/public/cpp/shelf_types.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
11 #include "ash/rotator/screen_rotation_animator.h" 11 #include "ash/rotator/screen_rotation_animator.h"
12 #include "ash/session/session_controller.h" 12 #include "ash/session/session_controller.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/shell_port.h" 14 #include "ash/shell_port.h"
15 #include "ash/system/status_area_widget.h" 15 #include "ash/system/status_area_widget.h"
16 #include "ash/test/ash_test_base.h" 16 #include "ash/test/ash_test_base.h"
17 #include "ash/test/ash_test_helper.h" 17 #include "ash/test/ash_test_helper.h"
18 #include "ash/test/status_area_widget_test_helper.h" 18 #include "ash/test/status_area_widget_test_helper.h"
19 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
19 #include "ash/wm/overview/window_selector_controller.h" 20 #include "ash/wm/overview/window_selector_controller.h"
20 #include "ash/wm/tablet_mode/tablet_mode_controller.h"
21 #include "ash/wm/window_util.h" 21 #include "ash/wm/window_util.h"
22 #include "base/command_line.h" 22 #include "base/command_line.h"
23 #include "base/test/user_action_tester.h" 23 #include "base/test/user_action_tester.h"
24 #include "base/time/time.h" 24 #include "base/time/time.h"
25 #include "ui/aura/client/aura_constants.h" 25 #include "ui/aura/client/aura_constants.h"
26 #include "ui/aura/window.h" 26 #include "ui/aura/window.h"
27 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 27 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
28 #include "ui/display/display_switches.h" 28 #include "ui/display/display_switches.h"
29 #include "ui/display/manager/display_manager.h" 29 #include "ui/display/manager/display_manager.h"
30 #include "ui/events/event.h" 30 #include "ui/events/event.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 void OverviewButtonTrayTest::NotifySessionStateChanged() { 91 void OverviewButtonTrayTest::NotifySessionStateChanged() {
92 GetTray()->OnSessionStateChanged( 92 GetTray()->OnSessionStateChanged(
93 Shell::Get()->session_controller()->GetSessionState()); 93 Shell::Get()->session_controller()->GetSessionState());
94 } 94 }
95 95
96 // Ensures that creation doesn't cause any crashes and adds the image icon. 96 // Ensures that creation doesn't cause any crashes and adds the image icon.
97 TEST_F(OverviewButtonTrayTest, BasicConstruction) { 97 TEST_F(OverviewButtonTrayTest, BasicConstruction) {
98 EXPECT_TRUE(GetImageView(GetTray()) != NULL); 98 EXPECT_TRUE(GetImageView(GetTray()) != NULL);
99 } 99 }
100 100
101 // Test that tablet mode toggle changes visibility. 101 // Test that maximize mode toggle changes visibility.
102 // OverviewButtonTray should only be visible when TabletMode is enabled. 102 // OverviewButtonTray should only be visible when MaximizeMode is enabled.
103 // By default the system should not have TabletMode enabled. 103 // By default the system should not have MaximizeMode enabled.
104 TEST_F(OverviewButtonTrayTest, TabletModeObserverOnTabletModeToggled) { 104 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) {
105 ASSERT_FALSE(GetTray()->visible()); 105 ASSERT_FALSE(GetTray()->visible());
106 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); 106 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
107 true);
107 EXPECT_TRUE(GetTray()->visible()); 108 EXPECT_TRUE(GetTray()->visible());
108 109
109 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false); 110 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
111 false);
110 EXPECT_FALSE(GetTray()->visible()); 112 EXPECT_FALSE(GetTray()->visible());
111 } 113 }
112 114
113 // Tests that activating this control brings up window selection mode. 115 // Tests that activating this control brings up window selection mode.
114 TEST_F(OverviewButtonTrayTest, PerformAction) { 116 TEST_F(OverviewButtonTrayTest, PerformAction) {
115 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); 117 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
116 118
117 // Overview Mode only works when there is a window 119 // Overview Mode only works when there is a window
118 std::unique_ptr<aura::Window> window( 120 std::unique_ptr<aura::Window> window(
119 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 121 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 EXPECT_EQ(2, user_action_tester.GetActionCount(kTrayOverview)); 183 EXPECT_EQ(2, user_action_tester.GetActionCount(kTrayOverview));
182 184
183 // Tapping on the control to exit overview mode should record the 185 // Tapping on the control to exit overview mode should record the
184 // user action. 186 // user action.
185 GetTray()->PerformAction(tap); 187 GetTray()->PerformAction(tap);
186 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); 188 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
187 EXPECT_EQ(3, user_action_tester.GetActionCount(kTrayOverview)); 189 EXPECT_EQ(3, user_action_tester.GetActionCount(kTrayOverview));
188 } 190 }
189 191
190 // Tests that a second OverviewButtonTray has been created, and only shows 192 // Tests that a second OverviewButtonTray has been created, and only shows
191 // when TabletMode has been enabled, when we are using multiple displays. 193 // when MaximizeMode has been enabled, when we are using multiple displays.
192 // By default the DisplayManger is in extended mode. 194 // By default the DisplayManger is in extended mode.
193 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) { 195 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) {
194 UpdateDisplay("400x400,200x200"); 196 UpdateDisplay("400x400,200x200");
195 EXPECT_FALSE(GetTray()->visible()); 197 EXPECT_FALSE(GetTray()->visible());
196 EXPECT_FALSE(GetSecondaryTray()->visible()); 198 EXPECT_FALSE(GetSecondaryTray()->visible());
197 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); 199 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
200 true);
198 EXPECT_TRUE(GetTray()->visible()); 201 EXPECT_TRUE(GetTray()->visible());
199 EXPECT_TRUE(GetSecondaryTray()->visible()); 202 EXPECT_TRUE(GetSecondaryTray()->visible());
200 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false); 203 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
204 false);
201 } 205 }
202 206
203 // Tests if Maximize Mode is enabled before a secondary display is attached 207 // Tests if Maximize Mode is enabled before a secondary display is attached
204 // that the second OverviewButtonTray should be created in a visible state. 208 // that the second OverviewButtonTray should be created in a visible state.
205 TEST_F(OverviewButtonTrayTest, SecondaryTrayCreatedVisible) { 209 TEST_F(OverviewButtonTrayTest, SecondaryTrayCreatedVisible) {
206 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); 210 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
211 true);
207 UpdateDisplay("400x400,200x200"); 212 UpdateDisplay("400x400,200x200");
208 EXPECT_TRUE(GetSecondaryTray()->visible()); 213 EXPECT_TRUE(GetSecondaryTray()->visible());
209 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false); 214 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
215 false);
210 } 216 }
211 217
212 // Tests that the tray loses visibility when a user logs out, and that it 218 // Tests that the tray loses visibility when a user logs out, and that it
213 // regains visibility when a user logs back in. 219 // regains visibility when a user logs back in.
214 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) { 220 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) {
215 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); 221 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
222 true);
216 SetUserLoggedIn(false); 223 SetUserLoggedIn(false);
217 Shell::Get()->UpdateAfterLoginStatusChange(LoginStatus::NOT_LOGGED_IN); 224 Shell::Get()->UpdateAfterLoginStatusChange(LoginStatus::NOT_LOGGED_IN);
218 EXPECT_FALSE(GetTray()->visible()); 225 EXPECT_FALSE(GetTray()->visible());
219 SetUserLoggedIn(true); 226 SetUserLoggedIn(true);
220 SetSessionStarted(true); 227 SetSessionStarted(true);
221 Shell::Get()->UpdateAfterLoginStatusChange(LoginStatus::USER); 228 Shell::Get()->UpdateAfterLoginStatusChange(LoginStatus::USER);
222 EXPECT_TRUE(GetTray()->visible()); 229 EXPECT_TRUE(GetTray()->visible());
223 SetUserAddingScreenRunning(true); 230 SetUserAddingScreenRunning(true);
224 NotifySessionStateChanged(); 231 NotifySessionStateChanged();
225 EXPECT_FALSE(GetTray()->visible()); 232 EXPECT_FALSE(GetTray()->visible());
226 SetUserAddingScreenRunning(false); 233 SetUserAddingScreenRunning(false);
227 NotifySessionStateChanged(); 234 NotifySessionStateChanged();
228 EXPECT_TRUE(GetTray()->visible()); 235 EXPECT_TRUE(GetTray()->visible());
229 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false); 236 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
237 false);
230 } 238 }
231 239
232 // Tests that the tray only renders as active while selection is ongoing. Any 240 // Tests that the tray only renders as active while selection is ongoing. Any
233 // dismissal of overview mode clears the active state. 241 // dismissal of overview mode clears the active state.
234 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { 242 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) {
235 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); 243 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
236 ASSERT_FALSE(GetTray()->is_active()); 244 ASSERT_FALSE(GetTray()->is_active());
237 245
238 // Overview Mode only works when there is a window 246 // Overview Mode only works when there is a window
239 std::unique_ptr<aura::Window> window( 247 std::unique_ptr<aura::Window> window(
240 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); 248 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20)));
241 249
242 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview()); 250 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview());
243 EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting()); 251 EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting());
244 EXPECT_TRUE(GetTray()->is_active()); 252 EXPECT_TRUE(GetTray()->is_active());
245 253
246 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview()); 254 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview());
247 EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); 255 EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
248 EXPECT_FALSE(GetTray()->is_active()); 256 EXPECT_FALSE(GetTray()->is_active());
249 } 257 }
250 258
251 // Test that when a hide animation is aborted via deletion, that the 259 // Test that when a hide animation is aborted via deletion, that the
252 // OverviewButton is still hidden. 260 // OverviewButton is still hidden.
253 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletes) { 261 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletes) {
254 // TODO: disabled as ScreenRotationAnimator does not work in mash, 262 // TODO: disabled as ScreenRotationAnimator does not work in mash,
255 // http://crbug.com/696754. 263 // http://crbug.com/696754.
256 if (Shell::GetAshConfig() == Config::MASH) 264 if (Shell::GetAshConfig() == Config::MASH)
257 return; 265 return;
258 266
259 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); 267 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
268 true);
260 269
261 // Long duration for hide animation, to allow it to be interrupted. 270 // Long duration for hide animation, to allow it to be interrupted.
262 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration( 271 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration(
263 new ui::ScopedAnimationDurationScaleMode( 272 new ui::ScopedAnimationDurationScaleMode(
264 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); 273 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
265 GetTray()->SetVisible(false); 274 GetTray()->SetVisible(false);
266 275
267 // ScreenRotationAnimator copies the current layers, and deletes them upon 276 // ScreenRotationAnimator copies the current layers, and deletes them upon
268 // completion. Allow its animation to complete first. 277 // completion. Allow its animation to complete first.
269 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> rotate_duration( 278 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> rotate_duration(
270 new ui::ScopedAnimationDurationScaleMode( 279 new ui::ScopedAnimationDurationScaleMode(
271 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); 280 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
272 ash::ScreenRotationAnimator(display::Display::InternalDisplayId()) 281 ash::ScreenRotationAnimator(display::Display::InternalDisplayId())
273 .Rotate(display::Display::ROTATE_270, 282 .Rotate(display::Display::ROTATE_270,
274 display::Display::ROTATION_SOURCE_ACTIVE); 283 display::Display::ROTATION_SOURCE_ACTIVE);
275 284
276 RunAllPendingInMessageLoop(); 285 RunAllPendingInMessageLoop();
277 EXPECT_FALSE(GetTray()->visible()); 286 EXPECT_FALSE(GetTray()->visible());
278 } 287 }
279 288
280 // Tests that the overview button becomes visible when the user enters 289 // Tests that the overview button becomes visible when the user enters
281 // tablet mode with a system modal window open, and that it hides once 290 // maximize mode with a system modal window open, and that it hides once
282 // the user exits tablet mode. 291 // the user exits maximize mode.
283 TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) { 292 TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) {
284 // TODO(jonross): When CreateTestWindow*() have been unified, use the 293 // TODO(jonross): When CreateTestWindow*() have been unified, use the
285 // appropriate method to replace this setup. (crbug.com/483503) 294 // appropriate method to replace this setup. (crbug.com/483503)
286 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); 295 std::unique_ptr<aura::Window> window(new aura::Window(nullptr));
287 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); 296 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
288 window->SetType(aura::client::WINDOW_TYPE_NORMAL); 297 window->SetType(aura::client::WINDOW_TYPE_NORMAL);
289 window->Init(ui::LAYER_TEXTURED); 298 window->Init(ui::LAYER_TEXTURED);
290 window->Show(); 299 window->Show();
291 ParentWindowInPrimaryRootWindow(window.get()); 300 ParentWindowInPrimaryRootWindow(window.get());
292 301
293 ASSERT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); 302 ASSERT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen());
294 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); 303 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
304 true);
295 EXPECT_TRUE(GetTray()->visible()); 305 EXPECT_TRUE(GetTray()->visible());
296 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false); 306 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
307 false);
297 EXPECT_FALSE(GetTray()->visible()); 308 EXPECT_FALSE(GetTray()->visible());
298 } 309 }
299 310
300 } // namespace ash 311 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/overview/overview_button_tray.cc ('k') | ash/system/power/tablet_power_button_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698