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

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

Issue 2845123003: Add more tests to test OverviewButtonTray. (Closed)
Patch Set: Fix nits in patch 2. Created 3 years, 6 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/rotator/screen_rotation_animator.h"
12 #include "ash/session/session_controller.h" 13 #include "ash/session/session_controller.h"
13 #include "ash/shell.h" 14 #include "ash/shell.h"
14 #include "ash/shell_port.h" 15 #include "ash/shell_port.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 "ash/wm/window_util.h" 22 #include "ash/wm/window_util.h"
22 #include "base/command_line.h" 23 #include "base/command_line.h"
23 #include "base/test/user_action_tester.h" 24 #include "base/test/user_action_tester.h"
24 #include "base/time/time.h" 25 #include "base/time/time.h"
25 #include "ui/aura/client/aura_constants.h" 26 #include "ui/aura/client/aura_constants.h"
26 #include "ui/aura/window.h" 27 #include "ui/aura/window.h"
27 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 28 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
28 #include "ui/display/display_switches.h" 29 #include "ui/display/display_switches.h"
29 #include "ui/display/manager/display_manager.h" 30 #include "ui/display/manager/display_manager.h"
30 #include "ui/events/event.h" 31 #include "ui/events/event.h"
31 #include "ui/events/event_constants.h" 32 #include "ui/events/event_constants.h"
32 #include "ui/events/gestures/gesture_types.h" 33 #include "ui/events/gestures/gesture_types.h"
33 #include "ui/views/controls/image_view.h" 34 #include "ui/views/controls/image_view.h"
35 #include "ui/wm/core/window_util.h"
34 36
35 namespace ash { 37 namespace ash {
36 38
37 namespace { 39 namespace {
38 40
39 const char kTrayOverview[] = "Tray_Overview"; 41 const char kTrayOverview[] = "Tray_Overview";
40 42
41 OverviewButtonTray* GetTray() { 43 OverviewButtonTray* GetTray() {
42 return StatusAreaWidgetTestHelper::GetStatusAreaWidget() 44 return StatusAreaWidgetTestHelper::GetStatusAreaWidget()
43 ->overview_button_tray(); 45 ->overview_button_tray();
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 251
250 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview()); 252 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview());
251 EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting()); 253 EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting());
252 EXPECT_TRUE(GetTray()->is_active()); 254 EXPECT_TRUE(GetTray()->is_active());
253 255
254 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview()); 256 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview());
255 EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); 257 EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting());
256 EXPECT_FALSE(GetTray()->is_active()); 258 EXPECT_FALSE(GetTray()->is_active());
257 } 259 }
258 260
259 // Test that when a hide animation is aborted via deletion, that the 261 // Test that a hide animation can complete.
262 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletes) {
263 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
264 true);
265 EXPECT_TRUE(GetTray()->visible());
266 GetTray()->SetVisible(false);
267 EXPECT_FALSE(GetTray()->visible());
268 }
269
270 // Test that when a hide animation is aborted via deletion, the
260 // OverviewButton is still hidden. 271 // OverviewButton is still hidden.
261 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletes) { 272 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletesOnDelete) {
262 // TODO: disabled as ScreenRotationAnimator does not work in mash, 273 // TODO(wutao): disabled as GetRootWindowForDisplayId does not work in mash,
263 // http://crbug.com/696754. 274 // http://crbug.com/706589.
264 if (Shell::GetAshConfig() == Config::MASH) 275 if (Shell::GetAshConfig() == Config::MASH)
265 return; 276 return;
266 277
267 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 278 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
268 true); 279 true);
269 280
270 // Long duration for hide animation, to allow it to be interrupted. 281 // Long duration for hide animation, to allow it to be interrupted.
271 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration( 282 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration(
272 new ui::ScopedAnimationDurationScaleMode( 283 new ui::ScopedAnimationDurationScaleMode(
273 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); 284 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
274 GetTray()->SetVisible(false); 285 GetTray()->SetVisible(false);
275 286
276 // ScreenRotationAnimator copies the current layers, and deletes them upon 287 aura::Window* root_window =
277 // completion. Allow its animation to complete first. 288 Shell::Get()->window_tree_host_manager()->GetRootWindowForDisplayId(
278 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> rotate_duration( 289 display::Screen::GetScreen()->GetPrimaryDisplay().id());
279 new ui::ScopedAnimationDurationScaleMode( 290 // Colone and delete the old layer tree.
280 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); 291 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner =
281 ash::ScreenRotationAnimator(display::Display::InternalDisplayId()) 292 ::wm::RecreateLayers(root_window);
282 .Rotate(display::Display::ROTATE_270, 293 old_layer_tree_owner.reset();
283 display::Display::ROTATION_SOURCE_ACTIVE);
284 294
285 RunAllPendingInMessageLoop();
286 EXPECT_FALSE(GetTray()->visible()); 295 EXPECT_FALSE(GetTray()->visible());
287 } 296 }
288 297
289 // Tests that the overview button becomes visible when the user enters 298 // Tests that the overview button becomes visible when the user enters
290 // maximize mode with a system modal window open, and that it hides once 299 // maximize mode with a system modal window open, and that it hides once
291 // the user exits maximize mode. 300 // the user exits maximize mode.
292 TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) { 301 TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) {
293 // TODO(jonross): When CreateTestWindow*() have been unified, use the 302 // TODO(jonross): When CreateTestWindow*() have been unified, use the
294 // appropriate method to replace this setup. (crbug.com/483503) 303 // appropriate method to replace this setup. (crbug.com/483503)
295 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); 304 std::unique_ptr<aura::Window> window(new aura::Window(nullptr));
296 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); 305 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
297 window->SetType(aura::client::WINDOW_TYPE_NORMAL); 306 window->SetType(aura::client::WINDOW_TYPE_NORMAL);
298 window->Init(ui::LAYER_TEXTURED); 307 window->Init(ui::LAYER_TEXTURED);
299 window->Show(); 308 window->Show();
300 ParentWindowInPrimaryRootWindow(window.get()); 309 ParentWindowInPrimaryRootWindow(window.get());
301 310
302 ASSERT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); 311 ASSERT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen());
303 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 312 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
304 true); 313 true);
305 EXPECT_TRUE(GetTray()->visible()); 314 EXPECT_TRUE(GetTray()->visible());
306 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 315 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
307 false); 316 false);
308 EXPECT_FALSE(GetTray()->visible()); 317 EXPECT_FALSE(GetTray()->visible());
309 } 318 }
310 319
311 } // namespace ash 320 } // namespace ash
OLDNEW
« no previous file with comments | « ash/rotator/screen_rotation_animator_unittest.cc ('k') | testing/buildbot/filters/ash_unittests_mash.filter » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698