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

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

Issue 2837773003: Flip the flag to enable smooth screen rotation by default. (Closed)
Patch Set: Created 3 years, 8 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/display/window_tree_host_manager.h"
7 #include "ash/login_status.h" 8 #include "ash/login_status.h"
8 #include "ash/public/cpp/config.h" 9 #include "ash/public/cpp/config.h"
9 #include "ash/public/cpp/shelf_types.h" 10 #include "ash/public/cpp/shelf_types.h"
10 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.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/overview/test/overview_button_tray_test_api.h"
15 #include "ash/system/status_area_widget.h" 16 #include "ash/system/status_area_widget.h"
16 #include "ash/test/ash_test_base.h" 17 #include "ash/test/ash_test_base.h"
17 #include "ash/test/ash_test_helper.h" 18 #include "ash/test/ash_test_helper.h"
18 #include "ash/test/status_area_widget_test_helper.h" 19 #include "ash/test/status_area_widget_test_helper.h"
19 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 20 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
20 #include "ash/wm/overview/window_selector_controller.h" 21 #include "ash/wm/overview/window_selector_controller.h"
21 #include "base/command_line.h" 22 #include "base/command_line.h"
22 #include "base/test/user_action_tester.h" 23 #include "base/test/user_action_tester.h"
23 #include "base/time/time.h" 24 #include "base/time/time.h"
24 #include "ui/aura/client/aura_constants.h" 25 #include "ui/aura/client/aura_constants.h"
25 #include "ui/aura/window.h" 26 #include "ui/aura/window.h"
26 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 27 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
27 #include "ui/display/display_switches.h" 28 #include "ui/display/display_switches.h"
28 #include "ui/display/manager/display_manager.h" 29 #include "ui/display/manager/display_manager.h"
29 #include "ui/events/event.h" 30 #include "ui/events/event.h"
30 #include "ui/events/event_constants.h" 31 #include "ui/events/event_constants.h"
31 #include "ui/events/gestures/gesture_types.h" 32 #include "ui/events/gestures/gesture_types.h"
32 #include "ui/views/controls/image_view.h" 33 #include "ui/views/controls/image_view.h"
34 #include "ui/wm/core/window_util.h"
33 35
34 namespace ash { 36 namespace ash {
35 37
36 namespace { 38 namespace {
37 39
38 const char kTrayOverview[] = "Tray_Overview"; 40 const char kTrayOverview[] = "Tray_Overview";
39 41
40 OverviewButtonTray* GetTray() { 42 OverviewButtonTray* GetTray() {
41 return StatusAreaWidgetTestHelper::GetStatusAreaWidget() 43 return StatusAreaWidgetTestHelper::GetStatusAreaWidget()
42 ->overview_button_tray(); 44 ->overview_button_tray();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 204
203 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview()); 205 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview());
204 EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting()); 206 EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting());
205 EXPECT_TRUE(GetTray()->is_active()); 207 EXPECT_TRUE(GetTray()->is_active());
206 208
207 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview()); 209 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview());
208 EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); 210 EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
209 EXPECT_FALSE(GetTray()->is_active()); 211 EXPECT_FALSE(GetTray()->is_active());
210 } 212 }
211 213
212 // Test that when a hide animation is aborted via deletion, that the 214 // Test that a hide animation can complete.
215 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletes) {
216 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
217 true);
218 EXPECT_TRUE(GetTray()->visible());
219 GetTray()->SetVisible(false);
220 EXPECT_FALSE(GetTray()->visible());
221 }
222
223 // Test that when a hide animation is aborted, the OverviewButton is still
224 // hidden.
225 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletesOnAbort) {
226 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
227 true);
228
229 // Long duration for hide animation, to allow it to be interrupted.
230 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration(
231 new ui::ScopedAnimationDurationScaleMode(
232 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
233 GetTray()->SetVisible(false);
234
235 // Abort the animation.
236 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> rotate_duration(
237 new ui::ScopedAnimationDurationScaleMode(
238 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
239 test::OverviewButtonTrayTestApi(GetTray()).AbortAllAnimations();
240
241 RunAllPendingInMessageLoop();
242 EXPECT_FALSE(GetTray()->visible());
243 }
244
245 // Test that when a hide animation is aborted via deletion, the
213 // OverviewButton is still hidden. 246 // OverviewButton is still hidden.
214 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletes) { 247 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletesOnDelete) {
215 // TODO: disabled as ScreenRotationAnimator does not work in mash, 248 // TODO(wutao): disabled as GetRootWindowForDisplayId does not work in mash,
216 // http://crbug.com/696754. 249 // http://crbug.com/706589.
217 if (Shell::GetAshConfig() == Config::MASH) 250 if (Shell::GetAshConfig() == Config::MASH)
218 return; 251 return;
219 252
220 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 253 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
221 true); 254 true);
222 255
223 // Long duration for hide animation, to allow it to be interrupted. 256 // Long duration for hide animation, to allow it to be interrupted.
224 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration( 257 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration(
225 new ui::ScopedAnimationDurationScaleMode( 258 new ui::ScopedAnimationDurationScaleMode(
226 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); 259 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
227 GetTray()->SetVisible(false); 260 GetTray()->SetVisible(false);
228 261
229 // ScreenRotationAnimator copies the current layers, and deletes them upon 262 // Clone old layers and delete them. This will abort the animation.
230 // completion. Allow its animation to complete first.
231 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> rotate_duration( 263 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> rotate_duration(
232 new ui::ScopedAnimationDurationScaleMode( 264 new ui::ScopedAnimationDurationScaleMode(
233 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); 265 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION));
234 ash::ScreenRotationAnimator(display::Display::InternalDisplayId()) 266 aura::Window* root_window =
235 .Rotate(display::Display::ROTATE_270, 267 Shell::Get()->window_tree_host_manager()->GetRootWindowForDisplayId(
236 display::Display::ROTATION_SOURCE_ACTIVE); 268 display::Screen::GetScreen()->GetPrimaryDisplay().id());
269 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner =
270 ::wm::RecreateLayers(root_window);
271 old_layer_tree_owner.reset();
237 272
238 RunAllPendingInMessageLoop(); 273 RunAllPendingInMessageLoop();
239 EXPECT_FALSE(GetTray()->visible()); 274 EXPECT_FALSE(GetTray()->visible());
240 } 275 }
241 276
242 // Tests that the overview button becomes visible when the user enters 277 // Tests that the overview button becomes visible when the user enters
243 // maximize mode with a system modal window open, and that it hides once 278 // maximize mode with a system modal window open, and that it hides once
244 // the user exits maximize mode. 279 // the user exits maximize mode.
245 TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) { 280 TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) {
246 // TODO(jonross): When CreateTestWindow*() have been unified, use the 281 // TODO(jonross): When CreateTestWindow*() have been unified, use the
247 // appropriate method to replace this setup. (crbug.com/483503) 282 // appropriate method to replace this setup. (crbug.com/483503)
248 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); 283 std::unique_ptr<aura::Window> window(new aura::Window(nullptr));
249 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); 284 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
250 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 285 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
251 window->Init(ui::LAYER_TEXTURED); 286 window->Init(ui::LAYER_TEXTURED);
252 window->Show(); 287 window->Show();
253 ParentWindowInPrimaryRootWindow(window.get()); 288 ParentWindowInPrimaryRootWindow(window.get());
254 289
255 ASSERT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); 290 ASSERT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen());
256 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 291 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
257 true); 292 true);
258 EXPECT_TRUE(GetTray()->visible()); 293 EXPECT_TRUE(GetTray()->visible());
259 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 294 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
260 false); 295 false);
261 EXPECT_FALSE(GetTray()->visible()); 296 EXPECT_FALSE(GetTray()->visible());
262 } 297 }
263 298
264 } // namespace ash 299 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698