| 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/common/system/overview/overview_button_tray.h" | 5 #include "ash/common/system/overview/overview_button_tray.h" |
| 6 | 6 |
| 7 #include "ash/common/login_status.h" | 7 #include "ash/common/login_status.h" |
| 8 #include "ash/common/session/session_controller.h" | 8 #include "ash/common/session/session_controller.h" |
| 9 #include "ash/common/system/status_area_widget.h" | 9 #include "ash/common/system/status_area_widget.h" |
| 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 true); | 91 true); |
| 92 EXPECT_TRUE(GetTray()->visible()); | 92 EXPECT_TRUE(GetTray()->visible()); |
| 93 | 93 |
| 94 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 94 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 95 false); | 95 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(WmShell::Get()->window_selector_controller()->IsSelecting()); | 101 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); |
| 102 | 102 |
| 103 // Overview Mode only works when there is a window | 103 // Overview Mode only works when there is a window |
| 104 std::unique_ptr<aura::Window> window( | 104 std::unique_ptr<aura::Window> window( |
| 105 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 105 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| 106 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), | 106 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), |
| 107 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 107 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 108 GetTray()->PerformAction(tap); | 108 GetTray()->PerformAction(tap); |
| 109 EXPECT_TRUE(WmShell::Get()->window_selector_controller()->IsSelecting()); | 109 EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting()); |
| 110 } | 110 } |
| 111 | 111 |
| 112 // 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. |
| 113 TEST_F(OverviewButtonTrayTest, TrayOverviewUserAction) { | 113 TEST_F(OverviewButtonTrayTest, TrayOverviewUserAction) { |
| 114 // TODO: investigate failure in mash, http://crbug.com/698129. | 114 // TODO: investigate failure in mash, http://crbug.com/698129. |
| 115 if (WmShell::Get()->IsRunningInMash()) | 115 if (WmShell::Get()->IsRunningInMash()) |
| 116 return; | 116 return; |
| 117 | 117 |
| 118 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); | 118 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); |
| 119 | 119 |
| 120 // Tapping on the control when there are no windows (and thus the user cannot | 120 // Tapping on the control when there are no windows (and thus the user cannot |
| 121 // enter overview mode) should still record the action. | 121 // enter overview mode) should still record the action. |
| 122 base::UserActionTester user_action_tester; | 122 base::UserActionTester user_action_tester; |
| 123 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), | 123 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), |
| 124 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 124 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 125 GetTray()->PerformAction(tap); | 125 GetTray()->PerformAction(tap); |
| 126 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); | 126 ASSERT_FALSE(Shell::Get()->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 std::unique_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(WmShell::Get()->window_selector_controller()->IsSelecting()); | 134 ASSERT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting()); |
| 135 EXPECT_EQ(2, user_action_tester.GetActionCount(kTrayOverview)); | 135 EXPECT_EQ(2, user_action_tester.GetActionCount(kTrayOverview)); |
| 136 | 136 |
| 137 // Tapping on the control to exit overview mode should record the | 137 // Tapping on the control to exit overview mode should record the |
| 138 // user action. | 138 // user action. |
| 139 GetTray()->PerformAction(tap); | 139 GetTray()->PerformAction(tap); |
| 140 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); | 140 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); |
| 141 EXPECT_EQ(3, user_action_tester.GetActionCount(kTrayOverview)); | 141 EXPECT_EQ(3, user_action_tester.GetActionCount(kTrayOverview)); |
| 142 } | 142 } |
| 143 | 143 |
| 144 // Tests that a second OverviewButtonTray has been created, and only shows | 144 // Tests that a second OverviewButtonTray has been created, and only shows |
| 145 // when MaximizeMode has been enabled, when we are using multiple displays. | 145 // when MaximizeMode has been enabled, when we are using multiple displays. |
| 146 // By default the DisplayManger is in extended mode. | 146 // By default the DisplayManger is in extended mode. |
| 147 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) { | 147 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) { |
| 148 UpdateDisplay("400x400,200x200"); | 148 UpdateDisplay("400x400,200x200"); |
| 149 EXPECT_FALSE(GetTray()->visible()); | 149 EXPECT_FALSE(GetTray()->visible()); |
| 150 EXPECT_FALSE(GetSecondaryTray()->visible()); | 150 EXPECT_FALSE(GetSecondaryTray()->visible()); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 SetUserAddingScreenRunning(false); | 185 SetUserAddingScreenRunning(false); |
| 186 NotifySessionStateChanged(); | 186 NotifySessionStateChanged(); |
| 187 EXPECT_TRUE(GetTray()->visible()); | 187 EXPECT_TRUE(GetTray()->visible()); |
| 188 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 188 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 189 false); | 189 false); |
| 190 } | 190 } |
| 191 | 191 |
| 192 // Tests that the tray only renders as active while selection is ongoing. Any | 192 // Tests that the tray only renders as active while selection is ongoing. Any |
| 193 // dismissal of overview mode clears the active state. | 193 // dismissal of overview mode clears the active state. |
| 194 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { | 194 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { |
| 195 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); | 195 ASSERT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); |
| 196 ASSERT_FALSE(GetTray()->is_active()); | 196 ASSERT_FALSE(GetTray()->is_active()); |
| 197 | 197 |
| 198 // Overview Mode only works when there is a window | 198 // Overview Mode only works when there is a window |
| 199 std::unique_ptr<aura::Window> window( | 199 std::unique_ptr<aura::Window> window( |
| 200 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 200 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| 201 | 201 |
| 202 EXPECT_TRUE(WmShell::Get()->window_selector_controller()->ToggleOverview()); | 202 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview()); |
| 203 EXPECT_TRUE(WmShell::Get()->window_selector_controller()->IsSelecting()); | 203 EXPECT_TRUE(Shell::Get()->window_selector_controller()->IsSelecting()); |
| 204 EXPECT_TRUE(GetTray()->is_active()); | 204 EXPECT_TRUE(GetTray()->is_active()); |
| 205 | 205 |
| 206 EXPECT_TRUE(WmShell::Get()->window_selector_controller()->ToggleOverview()); | 206 EXPECT_TRUE(Shell::Get()->window_selector_controller()->ToggleOverview()); |
| 207 EXPECT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); | 207 EXPECT_FALSE(Shell::Get()->window_selector_controller()->IsSelecting()); |
| 208 EXPECT_FALSE(GetTray()->is_active()); | 208 EXPECT_FALSE(GetTray()->is_active()); |
| 209 } | 209 } |
| 210 | 210 |
| 211 // Test that when a hide animation is aborted via deletion, that the | 211 // Test that when a hide animation is aborted via deletion, that the |
| 212 // OverviewButton is still hidden. | 212 // OverviewButton is still hidden. |
| 213 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletes) { | 213 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletes) { |
| 214 // TODO: disabled as ScreenRotationAnimator does not work in mash, | 214 // TODO: disabled as ScreenRotationAnimator does not work in mash, |
| 215 // http://crbug.com/696754. | 215 // http://crbug.com/696754. |
| 216 if (WmShell::Get()->IsRunningInMash()) | 216 if (WmShell::Get()->IsRunningInMash()) |
| 217 return; | 217 return; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 ASSERT_TRUE(WmShell::Get()->IsSystemModalWindowOpen()); | 254 ASSERT_TRUE(WmShell::Get()->IsSystemModalWindowOpen()); |
| 255 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 255 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 256 true); | 256 true); |
| 257 EXPECT_TRUE(GetTray()->visible()); | 257 EXPECT_TRUE(GetTray()->visible()); |
| 258 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 258 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 259 false); | 259 false); |
| 260 EXPECT_FALSE(GetTray()->visible()); | 260 EXPECT_FALSE(GetTray()->visible()); |
| 261 } | 261 } |
| 262 | 262 |
| 263 } // namespace ash | 263 } // namespace ash |
| OLD | NEW |