| 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/common/ash_switches.h" | 7 #include "ash/common/ash_switches.h" |
| 8 #include "ash/common/shelf/shelf_types.h" | 8 #include "ash/common/shelf/shelf_types.h" |
| 9 #include "ash/common/wm/overview/window_selector_controller.h" | 9 #include "ash/common/wm/overview/window_selector_controller.h" |
| 10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 EnableMaximizeModeWindowManager(true); | 91 EnableMaximizeModeWindowManager(true); |
| 92 EXPECT_TRUE(GetTray()->visible()); | 92 EXPECT_TRUE(GetTray()->visible()); |
| 93 | 93 |
| 94 Shell::GetInstance()->maximize_mode_controller()-> | 94 Shell::GetInstance()->maximize_mode_controller()-> |
| 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(WmShell::Get()->window_selector_controller()->IsSelecting()); |
| 102 IsSelecting()); | |
| 103 | 102 |
| 104 // Overview Mode only works when there is a window | 103 // Overview Mode only works when there is a window |
| 105 std::unique_ptr<aura::Window> window( | 104 std::unique_ptr<aura::Window> window( |
| 106 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 105 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| 107 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), | 106 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), |
| 108 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 107 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 109 GetTray()->PerformAction(tap); | 108 GetTray()->PerformAction(tap); |
| 110 EXPECT_TRUE(Shell::GetInstance()->window_selector_controller()-> | 109 EXPECT_TRUE(WmShell::Get()->window_selector_controller()->IsSelecting()); |
| 111 IsSelecting()); | |
| 112 } | 110 } |
| 113 | 111 |
| 114 // Tests that tapping on the control will record the user action Tray_Overview. | 112 // Tests that tapping on the control will record the user action Tray_Overview. |
| 115 TEST_F(OverviewButtonTrayTest, TrayOverviewUserAction) { | 113 TEST_F(OverviewButtonTrayTest, TrayOverviewUserAction) { |
| 116 ASSERT_FALSE( | 114 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); |
| 117 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | |
| 118 | 115 |
| 119 // Tapping on the control when there are no windows (and thus the user cannot | 116 // Tapping on the control when there are no windows (and thus the user cannot |
| 120 // enter overview mode) should still record the action. | 117 // enter overview mode) should still record the action. |
| 121 base::UserActionTester user_action_tester; | 118 base::UserActionTester user_action_tester; |
| 122 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), | 119 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), |
| 123 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 120 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 124 GetTray()->PerformAction(tap); | 121 GetTray()->PerformAction(tap); |
| 125 ASSERT_FALSE( | 122 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); |
| 126 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | |
| 127 EXPECT_EQ(1, user_action_tester.GetActionCount(kTrayOverview)); | 123 EXPECT_EQ(1, user_action_tester.GetActionCount(kTrayOverview)); |
| 128 | 124 |
| 129 // With one window present, tapping on the control to enter overview mode | 125 // With one window present, tapping on the control to enter overview mode |
| 130 // should record the user action. | 126 // should record the user action. |
| 131 std::unique_ptr<aura::Window> window( | 127 std::unique_ptr<aura::Window> window( |
| 132 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 128 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| 133 GetTray()->PerformAction(tap); | 129 GetTray()->PerformAction(tap); |
| 134 ASSERT_TRUE( | 130 ASSERT_TRUE(WmShell::Get()->window_selector_controller()->IsSelecting()); |
| 135 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | |
| 136 EXPECT_EQ(2, user_action_tester.GetActionCount(kTrayOverview)); | 131 EXPECT_EQ(2, user_action_tester.GetActionCount(kTrayOverview)); |
| 137 | 132 |
| 138 // Tapping on the control to exit overview mode should record the | 133 // Tapping on the control to exit overview mode should record the |
| 139 // user action. | 134 // user action. |
| 140 GetTray()->PerformAction(tap); | 135 GetTray()->PerformAction(tap); |
| 141 ASSERT_FALSE( | 136 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); |
| 142 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | |
| 143 EXPECT_EQ(3, user_action_tester.GetActionCount(kTrayOverview)); | 137 EXPECT_EQ(3, user_action_tester.GetActionCount(kTrayOverview)); |
| 144 } | 138 } |
| 145 | 139 |
| 146 // Tests that a second OverviewButtonTray has been created, and only shows | 140 // Tests that a second OverviewButtonTray has been created, and only shows |
| 147 // when MaximizeMode has been enabled, when we are using multiple displays. | 141 // when MaximizeMode has been enabled, when we are using multiple displays. |
| 148 // By default the DisplayManger is in extended mode. | 142 // By default the DisplayManger is in extended mode. |
| 149 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) { | 143 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) { |
| 150 if (!SupportsMultipleDisplays()) | 144 if (!SupportsMultipleDisplays()) |
| 151 return; | 145 return; |
| 152 | 146 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 SetUserAddingScreenRunning(false); | 188 SetUserAddingScreenRunning(false); |
| 195 NotifySessionStateChanged(); | 189 NotifySessionStateChanged(); |
| 196 EXPECT_TRUE(GetTray()->visible()); | 190 EXPECT_TRUE(GetTray()->visible()); |
| 197 Shell::GetInstance()->maximize_mode_controller()-> | 191 Shell::GetInstance()->maximize_mode_controller()-> |
| 198 EnableMaximizeModeWindowManager(false); | 192 EnableMaximizeModeWindowManager(false); |
| 199 } | 193 } |
| 200 | 194 |
| 201 // Tests that the tray only renders as active while selection is ongoing. Any | 195 // Tests that the tray only renders as active while selection is ongoing. Any |
| 202 // dismissal of overview mode clears the active state. | 196 // dismissal of overview mode clears the active state. |
| 203 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { | 197 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { |
| 204 ASSERT_FALSE( | 198 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); |
| 205 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | |
| 206 ASSERT_FALSE(GetTray()->draw_background_as_active()); | 199 ASSERT_FALSE(GetTray()->draw_background_as_active()); |
| 207 | 200 |
| 208 // Overview Mode only works when there is a window | 201 // Overview Mode only works when there is a window |
| 209 std::unique_ptr<aura::Window> window( | 202 std::unique_ptr<aura::Window> window( |
| 210 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 203 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| 211 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), | 204 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), |
| 212 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 205 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 213 GetTray()->PerformAction(tap); | 206 GetTray()->PerformAction(tap); |
| 214 EXPECT_TRUE( | 207 EXPECT_TRUE(WmShell::Get()->window_selector_controller()->IsSelecting()); |
| 215 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | |
| 216 EXPECT_TRUE(GetTray()->draw_background_as_active()); | 208 EXPECT_TRUE(GetTray()->draw_background_as_active()); |
| 217 | 209 |
| 218 Shell::GetInstance()->window_selector_controller()->OnSelectionEnded(); | 210 WmShell::Get()->window_selector_controller()->OnSelectionEnded(); |
| 219 EXPECT_FALSE( | 211 EXPECT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); |
| 220 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | |
| 221 EXPECT_FALSE(GetTray()->draw_background_as_active()); | 212 EXPECT_FALSE(GetTray()->draw_background_as_active()); |
| 222 } | 213 } |
| 223 | 214 |
| 224 // Test that when a hide animation is aborted via deletion, that the | 215 // Test that when a hide animation is aborted via deletion, that the |
| 225 // OverviewButton is still hidden. | 216 // OverviewButton is still hidden. |
| 226 #if defined(OS_WIN) && !defined(USE_ASH) | 217 #if defined(OS_WIN) && !defined(USE_ASH) |
| 227 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 218 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
| 228 #define MAYBE_HideAnimationAlwaysCompletes DISABLED_HideAnimationAlwaysCompletes | 219 #define MAYBE_HideAnimationAlwaysCompletes DISABLED_HideAnimationAlwaysCompletes |
| 229 #else | 220 #else |
| 230 #define MAYBE_HideAnimationAlwaysCompletes HideAnimationAlwaysCompletes | 221 #define MAYBE_HideAnimationAlwaysCompletes HideAnimationAlwaysCompletes |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 ->maximize_mode_controller() | 262 ->maximize_mode_controller() |
| 272 ->EnableMaximizeModeWindowManager(true); | 263 ->EnableMaximizeModeWindowManager(true); |
| 273 EXPECT_TRUE(GetTray()->visible()); | 264 EXPECT_TRUE(GetTray()->visible()); |
| 274 Shell::GetInstance() | 265 Shell::GetInstance() |
| 275 ->maximize_mode_controller() | 266 ->maximize_mode_controller() |
| 276 ->EnableMaximizeModeWindowManager(false); | 267 ->EnableMaximizeModeWindowManager(false); |
| 277 EXPECT_FALSE(GetTray()->visible()); | 268 EXPECT_FALSE(GetTray()->visible()); |
| 278 } | 269 } |
| 279 | 270 |
| 280 } // namespace ash | 271 } // namespace ash |
| OLD | NEW |