| 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/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/rotator/screen_rotation_animator.h" | 10 #include "ash/rotator/screen_rotation_animator.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 EnableMaximizeModeWindowManager(false); | 95 EnableMaximizeModeWindowManager(false); |
| 96 EXPECT_FALSE(GetTray()->visible()); | 96 EXPECT_FALSE(GetTray()->visible()); |
| 97 } | 97 } |
| 98 | 98 |
| 99 // Tests that activating this control brings up window selection mode. | 99 // Tests that activating this control brings up window selection mode. |
| 100 TEST_F(OverviewButtonTrayTest, PerformAction) { | 100 TEST_F(OverviewButtonTrayTest, PerformAction) { |
| 101 ASSERT_FALSE(Shell::GetInstance()->window_selector_controller()-> | 101 ASSERT_FALSE(Shell::GetInstance()->window_selector_controller()-> |
| 102 IsSelecting()); | 102 IsSelecting()); |
| 103 | 103 |
| 104 // Overview Mode only works when there is a window | 104 // Overview Mode only works when there is a window |
| 105 scoped_ptr<aura::Window> window( | 105 std::unique_ptr<aura::Window> window( |
| 106 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 106 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| 107 ui::GestureEvent tap( | 107 ui::GestureEvent tap( |
| 108 0, 0, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 108 0, 0, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 109 GetTray()->PerformAction(tap); | 109 GetTray()->PerformAction(tap); |
| 110 EXPECT_TRUE(Shell::GetInstance()->window_selector_controller()-> | 110 EXPECT_TRUE(Shell::GetInstance()->window_selector_controller()-> |
| 111 IsSelecting()); | 111 IsSelecting()); |
| 112 } | 112 } |
| 113 | 113 |
| 114 // Tests that tapping on the control will record the user action Tray_Overview. | 114 // Tests that tapping on the control will record the user action Tray_Overview. |
| 115 TEST_F(OverviewButtonTrayTest, TrayOverviewUserAction) { | 115 TEST_F(OverviewButtonTrayTest, TrayOverviewUserAction) { |
| 116 ASSERT_FALSE( | 116 ASSERT_FALSE( |
| 117 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | 117 Shell::GetInstance()->window_selector_controller()->IsSelecting()); |
| 118 | 118 |
| 119 // Tapping on the control when there are no windows (and thus the user cannot | 119 // Tapping on the control when there are no windows (and thus the user cannot |
| 120 // enter overview mode) should still record the action. | 120 // enter overview mode) should still record the action. |
| 121 base::UserActionTester user_action_tester; | 121 base::UserActionTester user_action_tester; |
| 122 ui::GestureEvent tap(0, 0, 0, base::TimeDelta(), | 122 ui::GestureEvent tap(0, 0, 0, base::TimeDelta(), |
| 123 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 123 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 124 GetTray()->PerformAction(tap); | 124 GetTray()->PerformAction(tap); |
| 125 ASSERT_FALSE( | 125 ASSERT_FALSE( |
| 126 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | 126 Shell::GetInstance()->window_selector_controller()->IsSelecting()); |
| 127 EXPECT_EQ(1, user_action_tester.GetActionCount(kTrayOverview)); | 127 EXPECT_EQ(1, user_action_tester.GetActionCount(kTrayOverview)); |
| 128 | 128 |
| 129 // With one window present, tapping on the control to enter overview mode | 129 // With one window present, tapping on the control to enter overview mode |
| 130 // should record the user action. | 130 // should record the user action. |
| 131 scoped_ptr<aura::Window> window( | 131 std::unique_ptr<aura::Window> window( |
| 132 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 132 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| 133 GetTray()->PerformAction(tap); | 133 GetTray()->PerformAction(tap); |
| 134 ASSERT_TRUE( | 134 ASSERT_TRUE( |
| 135 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | 135 Shell::GetInstance()->window_selector_controller()->IsSelecting()); |
| 136 EXPECT_EQ(2, user_action_tester.GetActionCount(kTrayOverview)); | 136 EXPECT_EQ(2, user_action_tester.GetActionCount(kTrayOverview)); |
| 137 | 137 |
| 138 // Tapping on the control to exit overview mode should record the | 138 // Tapping on the control to exit overview mode should record the |
| 139 // user action. | 139 // user action. |
| 140 GetTray()->PerformAction(tap); | 140 GetTray()->PerformAction(tap); |
| 141 ASSERT_FALSE( | 141 ASSERT_FALSE( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 } | 198 } |
| 199 | 199 |
| 200 // Tests that the tray only renders as active while selection is ongoing. Any | 200 // Tests that the tray only renders as active while selection is ongoing. Any |
| 201 // dismissal of overview mode clears the active state. | 201 // dismissal of overview mode clears the active state. |
| 202 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { | 202 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { |
| 203 ASSERT_FALSE( | 203 ASSERT_FALSE( |
| 204 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | 204 Shell::GetInstance()->window_selector_controller()->IsSelecting()); |
| 205 ASSERT_FALSE(GetTray()->draw_background_as_active()); | 205 ASSERT_FALSE(GetTray()->draw_background_as_active()); |
| 206 | 206 |
| 207 // Overview Mode only works when there is a window | 207 // Overview Mode only works when there is a window |
| 208 scoped_ptr<aura::Window> window( | 208 std::unique_ptr<aura::Window> window( |
| 209 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 209 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| 210 ui::GestureEvent tap( | 210 ui::GestureEvent tap( |
| 211 0, 0, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 211 0, 0, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 212 GetTray()->PerformAction(tap); | 212 GetTray()->PerformAction(tap); |
| 213 EXPECT_TRUE( | 213 EXPECT_TRUE( |
| 214 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | 214 Shell::GetInstance()->window_selector_controller()->IsSelecting()); |
| 215 EXPECT_TRUE(GetTray()->draw_background_as_active()); | 215 EXPECT_TRUE(GetTray()->draw_background_as_active()); |
| 216 | 216 |
| 217 Shell::GetInstance()->window_selector_controller()->OnSelectionEnded(); | 217 Shell::GetInstance()->window_selector_controller()->OnSelectionEnded(); |
| 218 EXPECT_FALSE( | 218 EXPECT_FALSE( |
| 219 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | 219 Shell::GetInstance()->window_selector_controller()->IsSelecting()); |
| 220 EXPECT_FALSE(GetTray()->draw_background_as_active()); | 220 EXPECT_FALSE(GetTray()->draw_background_as_active()); |
| 221 } | 221 } |
| 222 | 222 |
| 223 // Test that when a hide animation is aborted via deletion, that the | 223 // Test that when a hide animation is aborted via deletion, that the |
| 224 // OverviewButton is still hidden. | 224 // OverviewButton is still hidden. |
| 225 #if defined(OS_WIN) && !defined(USE_ASH) | 225 #if defined(OS_WIN) && !defined(USE_ASH) |
| 226 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 226 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
| 227 #define MAYBE_HideAnimationAlwaysCompletes DISABLED_HideAnimationAlwaysCompletes | 227 #define MAYBE_HideAnimationAlwaysCompletes DISABLED_HideAnimationAlwaysCompletes |
| 228 #else | 228 #else |
| 229 #define MAYBE_HideAnimationAlwaysCompletes HideAnimationAlwaysCompletes | 229 #define MAYBE_HideAnimationAlwaysCompletes HideAnimationAlwaysCompletes |
| 230 #endif | 230 #endif |
| 231 TEST_F(OverviewButtonTrayTest, MAYBE_HideAnimationAlwaysCompletes) { | 231 TEST_F(OverviewButtonTrayTest, MAYBE_HideAnimationAlwaysCompletes) { |
| 232 Shell::GetInstance() | 232 Shell::GetInstance() |
| 233 ->maximize_mode_controller() | 233 ->maximize_mode_controller() |
| 234 ->EnableMaximizeModeWindowManager(true); | 234 ->EnableMaximizeModeWindowManager(true); |
| 235 | 235 |
| 236 // Long duration for hide animation, to allow it to be interrupted. | 236 // Long duration for hide animation, to allow it to be interrupted. |
| 237 scoped_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration( | 237 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration( |
| 238 new ui::ScopedAnimationDurationScaleMode( | 238 new ui::ScopedAnimationDurationScaleMode( |
| 239 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); | 239 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); |
| 240 GetTray()->SetVisible(false); | 240 GetTray()->SetVisible(false); |
| 241 | 241 |
| 242 // ScreenRotationAnimator copies the current layers, and deletes them upon | 242 // ScreenRotationAnimator copies the current layers, and deletes them upon |
| 243 // completion. Allow its animation to complete first. | 243 // completion. Allow its animation to complete first. |
| 244 scoped_ptr<ui::ScopedAnimationDurationScaleMode> rotate_duration( | 244 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> rotate_duration( |
| 245 new ui::ScopedAnimationDurationScaleMode( | 245 new ui::ScopedAnimationDurationScaleMode( |
| 246 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); | 246 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); |
| 247 ash::ScreenRotationAnimator(gfx::Display::InternalDisplayId()) | 247 ash::ScreenRotationAnimator(gfx::Display::InternalDisplayId()) |
| 248 .Rotate(gfx::Display::ROTATE_270, gfx::Display::ROTATION_SOURCE_ACTIVE); | 248 .Rotate(gfx::Display::ROTATE_270, gfx::Display::ROTATION_SOURCE_ACTIVE); |
| 249 | 249 |
| 250 RunAllPendingInMessageLoop(); | 250 RunAllPendingInMessageLoop(); |
| 251 EXPECT_FALSE(GetTray()->visible()); | 251 EXPECT_FALSE(GetTray()->visible()); |
| 252 } | 252 } |
| 253 | 253 |
| 254 // Tests that the overview button becomes visible when the user enters | 254 // Tests that the overview button becomes visible when the user enters |
| 255 // maximize mode with a system modal window open, and that it hides once | 255 // maximize mode with a system modal window open, and that it hides once |
| 256 // the user exits maximize mode. | 256 // the user exits maximize mode. |
| 257 TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) { | 257 TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) { |
| 258 // TODO(jonross): When CreateTestWindow*() have been unified, use the | 258 // TODO(jonross): When CreateTestWindow*() have been unified, use the |
| 259 // appropriate method to replace this setup. (crbug.com/483503) | 259 // appropriate method to replace this setup. (crbug.com/483503) |
| 260 scoped_ptr<aura::Window> window(new aura::Window(nullptr)); | 260 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); |
| 261 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); | 261 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
| 262 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 262 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 263 window->Init(ui::LAYER_TEXTURED); | 263 window->Init(ui::LAYER_TEXTURED); |
| 264 window->Show(); | 264 window->Show(); |
| 265 ParentWindowInPrimaryRootWindow(window.get()); | 265 ParentWindowInPrimaryRootWindow(window.get()); |
| 266 | 266 |
| 267 ASSERT_TRUE(Shell::GetInstance()->IsSystemModalWindowOpen()); | 267 ASSERT_TRUE(Shell::GetInstance()->IsSystemModalWindowOpen()); |
| 268 Shell::GetInstance() | 268 Shell::GetInstance() |
| 269 ->maximize_mode_controller() | 269 ->maximize_mode_controller() |
| 270 ->EnableMaximizeModeWindowManager(true); | 270 ->EnableMaximizeModeWindowManager(true); |
| 271 EXPECT_TRUE(GetTray()->visible()); | 271 EXPECT_TRUE(GetTray()->visible()); |
| 272 Shell::GetInstance() | 272 Shell::GetInstance() |
| 273 ->maximize_mode_controller() | 273 ->maximize_mode_controller() |
| 274 ->EnableMaximizeModeWindowManager(false); | 274 ->EnableMaximizeModeWindowManager(false); |
| 275 EXPECT_FALSE(GetTray()->visible()); | 275 EXPECT_FALSE(GetTray()->visible()); |
| 276 } | 276 } |
| 277 | 277 |
| 278 } // namespace ash | 278 } // namespace ash |
| OLD | NEW |