| OLD | NEW |
| 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 "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 Loading... |
| 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 via deletion, the |
| 213 // OverviewButton is still hidden. | 224 // OverviewButton is still hidden. |
| 214 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletes) { | 225 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletesOnDelete) { |
| 215 // TODO: disabled as ScreenRotationAnimator does not work in mash, | 226 // TODO(wutao): disabled as GetRootWindowForDisplayId does not work in mash, |
| 216 // http://crbug.com/696754. | 227 // http://crbug.com/706589. |
| 217 if (Shell::GetAshConfig() == Config::MASH) | 228 if (Shell::GetAshConfig() == Config::MASH) |
| 218 return; | 229 return; |
| 219 | 230 |
| 220 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 231 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 221 true); | 232 true); |
| 222 | 233 |
| 223 // Long duration for hide animation, to allow it to be interrupted. | 234 // Long duration for hide animation, to allow it to be interrupted. |
| 224 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration( | 235 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration( |
| 225 new ui::ScopedAnimationDurationScaleMode( | 236 new ui::ScopedAnimationDurationScaleMode( |
| 226 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); | 237 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); |
| 227 GetTray()->SetVisible(false); | 238 GetTray()->SetVisible(false); |
| 228 | 239 |
| 229 // ScreenRotationAnimator copies the current layers, and deletes them upon | 240 aura::Window* root_window = |
| 230 // completion. Allow its animation to complete first. | 241 Shell::Get()->window_tree_host_manager()->GetRootWindowForDisplayId( |
| 231 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> rotate_duration( | 242 display::Screen::GetScreen()->GetPrimaryDisplay().id()); |
| 232 new ui::ScopedAnimationDurationScaleMode( | 243 // Colone and delete the old layer tree. |
| 233 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); | 244 std::unique_ptr<ui::LayerTreeOwner> old_layer_tree_owner = |
| 234 ash::ScreenRotationAnimator(display::Display::InternalDisplayId()) | 245 ::wm::RecreateLayers(root_window); |
| 235 .Rotate(display::Display::ROTATE_270, | 246 old_layer_tree_owner.reset(); |
| 236 display::Display::ROTATION_SOURCE_ACTIVE); | |
| 237 | 247 |
| 238 RunAllPendingInMessageLoop(); | |
| 239 EXPECT_FALSE(GetTray()->visible()); | 248 EXPECT_FALSE(GetTray()->visible()); |
| 240 } | 249 } |
| 241 | 250 |
| 242 // Tests that the overview button becomes visible when the user enters | 251 // 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 | 252 // maximize mode with a system modal window open, and that it hides once |
| 244 // the user exits maximize mode. | 253 // the user exits maximize mode. |
| 245 TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) { | 254 TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) { |
| 246 // TODO(jonross): When CreateTestWindow*() have been unified, use the | 255 // TODO(jonross): When CreateTestWindow*() have been unified, use the |
| 247 // appropriate method to replace this setup. (crbug.com/483503) | 256 // appropriate method to replace this setup. (crbug.com/483503) |
| 248 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); | 257 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); |
| 249 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); | 258 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
| 250 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 259 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 251 window->Init(ui::LAYER_TEXTURED); | 260 window->Init(ui::LAYER_TEXTURED); |
| 252 window->Show(); | 261 window->Show(); |
| 253 ParentWindowInPrimaryRootWindow(window.get()); | 262 ParentWindowInPrimaryRootWindow(window.get()); |
| 254 | 263 |
| 255 ASSERT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); | 264 ASSERT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); |
| 256 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 265 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 257 true); | 266 true); |
| 258 EXPECT_TRUE(GetTray()->visible()); | 267 EXPECT_TRUE(GetTray()->visible()); |
| 259 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 268 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 260 false); | 269 false); |
| 261 EXPECT_FALSE(GetTray()->visible()); | 270 EXPECT_FALSE(GetTray()->visible()); |
| 262 } | 271 } |
| 263 | 272 |
| 264 } // namespace ash | 273 } // namespace ash |
| OLD | NEW |