| 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/login_status.h" | 8 #include "ash/common/login_status.h" |
| 9 #include "ash/common/shelf/shelf_types.h" | 9 #include "ash/common/shelf/shelf_types.h" |
| 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // Ensures that creation doesn't cause any crashes and adds the image icon. | 80 // Ensures that creation doesn't cause any crashes and adds the image icon. |
| 81 TEST_F(OverviewButtonTrayTest, BasicConstruction) { | 81 TEST_F(OverviewButtonTrayTest, BasicConstruction) { |
| 82 EXPECT_TRUE(GetImageView(GetTray()) != NULL); | 82 EXPECT_TRUE(GetImageView(GetTray()) != NULL); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Test that maximize mode toggle changes visibility. | 85 // Test that maximize mode toggle changes visibility. |
| 86 // OverviewButtonTray should only be visible when MaximizeMode is enabled. | 86 // OverviewButtonTray should only be visible when MaximizeMode is enabled. |
| 87 // By default the system should not have MaximizeMode enabled. | 87 // By default the system should not have MaximizeMode enabled. |
| 88 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) { | 88 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) { |
| 89 ASSERT_FALSE(GetTray()->visible()); | 89 ASSERT_FALSE(GetTray()->visible()); |
| 90 Shell::GetInstance() | 90 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 91 ->maximize_mode_controller() | 91 true); |
| 92 ->EnableMaximizeModeWindowManager(true); | |
| 93 EXPECT_TRUE(GetTray()->visible()); | 92 EXPECT_TRUE(GetTray()->visible()); |
| 94 | 93 |
| 95 Shell::GetInstance() | 94 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 96 ->maximize_mode_controller() | 95 false); |
| 97 ->EnableMaximizeModeWindowManager(false); | |
| 98 EXPECT_FALSE(GetTray()->visible()); | 96 EXPECT_FALSE(GetTray()->visible()); |
| 99 } | 97 } |
| 100 | 98 |
| 101 // Tests that activating this control brings up window selection mode. | 99 // Tests that activating this control brings up window selection mode. |
| 102 TEST_F(OverviewButtonTrayTest, PerformAction) { | 100 TEST_F(OverviewButtonTrayTest, PerformAction) { |
| 103 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); | 101 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); |
| 104 | 102 |
| 105 // Overview Mode only works when there is a window | 103 // Overview Mode only works when there is a window |
| 106 std::unique_ptr<aura::Window> window( | 104 std::unique_ptr<aura::Window> window( |
| 107 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 105 CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // Tests that a second OverviewButtonTray has been created, and only shows | 140 // Tests that a second OverviewButtonTray has been created, and only shows |
| 143 // when MaximizeMode has been enabled, when we are using multiple displays. | 141 // when MaximizeMode has been enabled, when we are using multiple displays. |
| 144 // By default the DisplayManger is in extended mode. | 142 // By default the DisplayManger is in extended mode. |
| 145 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) { | 143 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) { |
| 146 if (!SupportsMultipleDisplays()) | 144 if (!SupportsMultipleDisplays()) |
| 147 return; | 145 return; |
| 148 | 146 |
| 149 UpdateDisplay("400x400,200x200"); | 147 UpdateDisplay("400x400,200x200"); |
| 150 EXPECT_FALSE(GetTray()->visible()); | 148 EXPECT_FALSE(GetTray()->visible()); |
| 151 EXPECT_FALSE(GetSecondaryTray()->visible()); | 149 EXPECT_FALSE(GetSecondaryTray()->visible()); |
| 152 Shell::GetInstance() | 150 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 153 ->maximize_mode_controller() | 151 true); |
| 154 ->EnableMaximizeModeWindowManager(true); | |
| 155 EXPECT_TRUE(GetTray()->visible()); | 152 EXPECT_TRUE(GetTray()->visible()); |
| 156 EXPECT_TRUE(GetSecondaryTray()->visible()); | 153 EXPECT_TRUE(GetSecondaryTray()->visible()); |
| 157 Shell::GetInstance() | 154 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 158 ->maximize_mode_controller() | 155 false); |
| 159 ->EnableMaximizeModeWindowManager(false); | |
| 160 } | 156 } |
| 161 | 157 |
| 162 // Tests if Maximize Mode is enabled before a secondary display is attached | 158 // Tests if Maximize Mode is enabled before a secondary display is attached |
| 163 // that the second OverviewButtonTray should be created in a visible state. | 159 // that the second OverviewButtonTray should be created in a visible state. |
| 164 TEST_F(OverviewButtonTrayTest, SecondaryTrayCreatedVisible) { | 160 TEST_F(OverviewButtonTrayTest, SecondaryTrayCreatedVisible) { |
| 165 if (!SupportsMultipleDisplays()) | 161 if (!SupportsMultipleDisplays()) |
| 166 return; | 162 return; |
| 167 | 163 |
| 168 Shell::GetInstance() | 164 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 169 ->maximize_mode_controller() | 165 true); |
| 170 ->EnableMaximizeModeWindowManager(true); | |
| 171 UpdateDisplay("400x400,200x200"); | 166 UpdateDisplay("400x400,200x200"); |
| 172 EXPECT_TRUE(GetSecondaryTray()->visible()); | 167 EXPECT_TRUE(GetSecondaryTray()->visible()); |
| 173 Shell::GetInstance() | 168 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 174 ->maximize_mode_controller() | 169 false); |
| 175 ->EnableMaximizeModeWindowManager(false); | |
| 176 } | 170 } |
| 177 | 171 |
| 178 // Tests that the tray loses visibility when a user logs out, and that it | 172 // Tests that the tray loses visibility when a user logs out, and that it |
| 179 // regains visibility when a user logs back in. | 173 // regains visibility when a user logs back in. |
| 180 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) { | 174 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) { |
| 181 Shell::GetInstance() | 175 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 182 ->maximize_mode_controller() | 176 true); |
| 183 ->EnableMaximizeModeWindowManager(true); | |
| 184 SetUserLoggedIn(false); | 177 SetUserLoggedIn(false); |
| 185 Shell::GetInstance()->UpdateAfterLoginStatusChange( | 178 Shell::GetInstance()->UpdateAfterLoginStatusChange( |
| 186 LoginStatus::NOT_LOGGED_IN); | 179 LoginStatus::NOT_LOGGED_IN); |
| 187 EXPECT_FALSE(GetTray()->visible()); | 180 EXPECT_FALSE(GetTray()->visible()); |
| 188 SetUserLoggedIn(true); | 181 SetUserLoggedIn(true); |
| 189 SetSessionStarted(true); | 182 SetSessionStarted(true); |
| 190 Shell::GetInstance()->UpdateAfterLoginStatusChange(LoginStatus::USER); | 183 Shell::GetInstance()->UpdateAfterLoginStatusChange(LoginStatus::USER); |
| 191 EXPECT_TRUE(GetTray()->visible()); | 184 EXPECT_TRUE(GetTray()->visible()); |
| 192 SetUserAddingScreenRunning(true); | 185 SetUserAddingScreenRunning(true); |
| 193 NotifySessionStateChanged(); | 186 NotifySessionStateChanged(); |
| 194 EXPECT_FALSE(GetTray()->visible()); | 187 EXPECT_FALSE(GetTray()->visible()); |
| 195 SetUserAddingScreenRunning(false); | 188 SetUserAddingScreenRunning(false); |
| 196 NotifySessionStateChanged(); | 189 NotifySessionStateChanged(); |
| 197 EXPECT_TRUE(GetTray()->visible()); | 190 EXPECT_TRUE(GetTray()->visible()); |
| 198 Shell::GetInstance() | 191 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 199 ->maximize_mode_controller() | 192 false); |
| 200 ->EnableMaximizeModeWindowManager(false); | |
| 201 } | 193 } |
| 202 | 194 |
| 203 // 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 |
| 204 // dismissal of overview mode clears the active state. | 196 // dismissal of overview mode clears the active state. |
| 205 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { | 197 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { |
| 206 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); | 198 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); |
| 207 ASSERT_FALSE(GetTray()->draw_background_as_active()); | 199 ASSERT_FALSE(GetTray()->draw_background_as_active()); |
| 208 | 200 |
| 209 // Overview Mode only works when there is a window | 201 // Overview Mode only works when there is a window |
| 210 std::unique_ptr<aura::Window> window( | 202 std::unique_ptr<aura::Window> window( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 222 | 214 |
| 223 // 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 |
| 224 // OverviewButton is still hidden. | 216 // OverviewButton is still hidden. |
| 225 #if defined(OS_WIN) && !defined(USE_ASH) | 217 #if defined(OS_WIN) && !defined(USE_ASH) |
| 226 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 218 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
| 227 #define MAYBE_HideAnimationAlwaysCompletes DISABLED_HideAnimationAlwaysCompletes | 219 #define MAYBE_HideAnimationAlwaysCompletes DISABLED_HideAnimationAlwaysCompletes |
| 228 #else | 220 #else |
| 229 #define MAYBE_HideAnimationAlwaysCompletes HideAnimationAlwaysCompletes | 221 #define MAYBE_HideAnimationAlwaysCompletes HideAnimationAlwaysCompletes |
| 230 #endif | 222 #endif |
| 231 TEST_F(OverviewButtonTrayTest, MAYBE_HideAnimationAlwaysCompletes) { | 223 TEST_F(OverviewButtonTrayTest, MAYBE_HideAnimationAlwaysCompletes) { |
| 232 Shell::GetInstance() | 224 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 233 ->maximize_mode_controller() | 225 true); |
| 234 ->EnableMaximizeModeWindowManager(true); | |
| 235 | 226 |
| 236 // Long duration for hide animation, to allow it to be interrupted. | 227 // Long duration for hide animation, to allow it to be interrupted. |
| 237 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration( | 228 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration( |
| 238 new ui::ScopedAnimationDurationScaleMode( | 229 new ui::ScopedAnimationDurationScaleMode( |
| 239 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); | 230 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); |
| 240 GetTray()->SetVisible(false); | 231 GetTray()->SetVisible(false); |
| 241 | 232 |
| 242 // ScreenRotationAnimator copies the current layers, and deletes them upon | 233 // ScreenRotationAnimator copies the current layers, and deletes them upon |
| 243 // completion. Allow its animation to complete first. | 234 // completion. Allow its animation to complete first. |
| 244 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> rotate_duration( | 235 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> rotate_duration( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 259 // TODO(jonross): When CreateTestWindow*() have been unified, use the | 250 // TODO(jonross): When CreateTestWindow*() have been unified, use the |
| 260 // appropriate method to replace this setup. (crbug.com/483503) | 251 // appropriate method to replace this setup. (crbug.com/483503) |
| 261 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); | 252 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); |
| 262 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); | 253 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
| 263 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 254 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 264 window->Init(ui::LAYER_TEXTURED); | 255 window->Init(ui::LAYER_TEXTURED); |
| 265 window->Show(); | 256 window->Show(); |
| 266 ParentWindowInPrimaryRootWindow(window.get()); | 257 ParentWindowInPrimaryRootWindow(window.get()); |
| 267 | 258 |
| 268 ASSERT_TRUE(WmShell::Get()->IsSystemModalWindowOpen()); | 259 ASSERT_TRUE(WmShell::Get()->IsSystemModalWindowOpen()); |
| 269 Shell::GetInstance() | 260 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 270 ->maximize_mode_controller() | 261 true); |
| 271 ->EnableMaximizeModeWindowManager(true); | |
| 272 EXPECT_TRUE(GetTray()->visible()); | 262 EXPECT_TRUE(GetTray()->visible()); |
| 273 Shell::GetInstance() | 263 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 274 ->maximize_mode_controller() | 264 false); |
| 275 ->EnableMaximizeModeWindowManager(false); | |
| 276 EXPECT_FALSE(GetTray()->visible()); | 265 EXPECT_FALSE(GetTray()->visible()); |
| 277 } | 266 } |
| 278 | 267 |
| 279 } // namespace ash | 268 } // namespace ash |
| OLD | NEW |