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" |
11 #include "ash/shelf/shelf_types.h" | 11 #include "ash/shelf/shelf_types.h" |
12 #include "ash/shelf/shelf_widget.h" | 12 #include "ash/shelf/shelf_widget.h" |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/system/status_area_widget.h" | 14 #include "ash/system/status_area_widget.h" |
15 #include "ash/system/user/login_status.h" | 15 #include "ash/system/user/login_status.h" |
16 #include "ash/test/ash_test_base.h" | 16 #include "ash/test/ash_test_base.h" |
| 17 #include "ash/test/ash_test_helper.h" |
17 #include "ash/test/status_area_widget_test_helper.h" | 18 #include "ash/test/status_area_widget_test_helper.h" |
| 19 #include "ash/test/test_session_state_delegate.h" |
18 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 20 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
19 #include "ash/wm/overview/window_selector_controller.h" | 21 #include "ash/wm/overview/window_selector_controller.h" |
20 #include "base/command_line.h" | 22 #include "base/command_line.h" |
21 #include "base/test/user_action_tester.h" | 23 #include "base/test/user_action_tester.h" |
22 #include "base/time/time.h" | 24 #include "base/time/time.h" |
| 25 #include "ui/aura/client/aura_constants.h" |
| 26 #include "ui/aura/window.h" |
23 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 27 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
24 #include "ui/events/event.h" | 28 #include "ui/events/event.h" |
25 #include "ui/events/event_constants.h" | 29 #include "ui/events/event_constants.h" |
26 #include "ui/events/gestures/gesture_types.h" | 30 #include "ui/events/gestures/gesture_types.h" |
27 #include "ui/views/controls/image_view.h" | 31 #include "ui/views/controls/image_view.h" |
28 | 32 |
29 namespace ash { | 33 namespace ash { |
30 | 34 |
31 namespace { | 35 namespace { |
32 | 36 |
(...skipping 11 matching lines...) Expand all Loading... |
44 | 48 |
45 } // namespace | 49 } // namespace |
46 | 50 |
47 class OverviewButtonTrayTest : public test::AshTestBase { | 51 class OverviewButtonTrayTest : public test::AshTestBase { |
48 public: | 52 public: |
49 OverviewButtonTrayTest() {} | 53 OverviewButtonTrayTest() {} |
50 ~OverviewButtonTrayTest() override {} | 54 ~OverviewButtonTrayTest() override {} |
51 | 55 |
52 void SetUp() override; | 56 void SetUp() override; |
53 | 57 |
| 58 void NotifySessionStateChanged(); |
| 59 |
54 protected: | 60 protected: |
55 views::ImageView* GetImageView(OverviewButtonTray* tray) { | 61 views::ImageView* GetImageView(OverviewButtonTray* tray) { |
56 return tray->icon_; | 62 return tray->icon_; |
57 } | 63 } |
58 | 64 |
59 private: | 65 private: |
60 DISALLOW_COPY_AND_ASSIGN(OverviewButtonTrayTest); | 66 DISALLOW_COPY_AND_ASSIGN(OverviewButtonTrayTest); |
61 }; | 67 }; |
62 | 68 |
63 void OverviewButtonTrayTest::SetUp() { | 69 void OverviewButtonTrayTest::SetUp() { |
64 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 70 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
65 switches::kAshUseFirstDisplayAsInternal); | 71 switches::kAshUseFirstDisplayAsInternal); |
66 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 72 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
67 switches::kAshEnableScreenRotationAnimation); | 73 switches::kAshEnableScreenRotationAnimation); |
68 AshTestBase::SetUp(); | 74 AshTestBase::SetUp(); |
69 } | 75 } |
70 | 76 |
| 77 void OverviewButtonTrayTest::NotifySessionStateChanged() { |
| 78 GetTray()->SessionStateChanged( |
| 79 ash_test_helper()->GetTestSessionStateDelegate()->GetSessionState()); |
| 80 } |
| 81 |
71 // Ensures that creation doesn't cause any crashes and adds the image icon. | 82 // Ensures that creation doesn't cause any crashes and adds the image icon. |
72 TEST_F(OverviewButtonTrayTest, BasicConstruction) { | 83 TEST_F(OverviewButtonTrayTest, BasicConstruction) { |
73 EXPECT_TRUE(GetImageView(GetTray()) != NULL); | 84 EXPECT_TRUE(GetImageView(GetTray()) != NULL); |
74 } | 85 } |
75 | 86 |
76 // Test that maximize mode toggle changes visibility. | 87 // Test that maximize mode toggle changes visibility. |
77 // OverviewButtonTray should only be visible when MaximizeMode is enabled. | 88 // OverviewButtonTray should only be visible when MaximizeMode is enabled. |
78 // By default the system should not have MaximizeMode enabled. | 89 // By default the system should not have MaximizeMode enabled. |
79 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) { | 90 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) { |
80 ASSERT_FALSE(GetTray()->visible()); | 91 ASSERT_FALSE(GetTray()->visible()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) { | 182 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) { |
172 Shell::GetInstance()->maximize_mode_controller()-> | 183 Shell::GetInstance()->maximize_mode_controller()-> |
173 EnableMaximizeModeWindowManager(true); | 184 EnableMaximizeModeWindowManager(true); |
174 SetUserLoggedIn(false); | 185 SetUserLoggedIn(false); |
175 Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_NONE); | 186 Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_NONE); |
176 EXPECT_FALSE(GetTray()->visible()); | 187 EXPECT_FALSE(GetTray()->visible()); |
177 SetUserLoggedIn(true); | 188 SetUserLoggedIn(true); |
178 SetSessionStarted(true); | 189 SetSessionStarted(true); |
179 Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_USER); | 190 Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_USER); |
180 EXPECT_TRUE(GetTray()->visible()); | 191 EXPECT_TRUE(GetTray()->visible()); |
| 192 SetUserAddingScreenRunning(true); |
| 193 NotifySessionStateChanged(); |
| 194 EXPECT_FALSE(GetTray()->visible()); |
| 195 SetUserAddingScreenRunning(false); |
| 196 NotifySessionStateChanged(); |
| 197 EXPECT_TRUE(GetTray()->visible()); |
181 Shell::GetInstance()->maximize_mode_controller()-> | 198 Shell::GetInstance()->maximize_mode_controller()-> |
182 EnableMaximizeModeWindowManager(false); | 199 EnableMaximizeModeWindowManager(false); |
183 } | 200 } |
184 | 201 |
185 // Tests that the tray only renders as active while selection is ongoing. Any | 202 // Tests that the tray only renders as active while selection is ongoing. Any |
186 // dismissal of overview mode clears the active state. | 203 // dismissal of overview mode clears the active state. |
187 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { | 204 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { |
188 ASSERT_FALSE( | 205 ASSERT_FALSE( |
189 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | 206 Shell::GetInstance()->window_selector_controller()->IsSelecting()); |
190 ASSERT_FALSE(GetTray()->draw_background_as_active()); | 207 ASSERT_FALSE(GetTray()->draw_background_as_active()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 scoped_ptr<ui::ScopedAnimationDurationScaleMode> rotate_duration( | 240 scoped_ptr<ui::ScopedAnimationDurationScaleMode> rotate_duration( |
224 new ui::ScopedAnimationDurationScaleMode( | 241 new ui::ScopedAnimationDurationScaleMode( |
225 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); | 242 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); |
226 ash::ScreenRotationAnimator(gfx::Display::InternalDisplayId()) | 243 ash::ScreenRotationAnimator(gfx::Display::InternalDisplayId()) |
227 .Rotate(gfx::Display::ROTATE_270, gfx::Display::ROTATION_SOURCE_ACTIVE); | 244 .Rotate(gfx::Display::ROTATE_270, gfx::Display::ROTATION_SOURCE_ACTIVE); |
228 | 245 |
229 RunAllPendingInMessageLoop(); | 246 RunAllPendingInMessageLoop(); |
230 EXPECT_FALSE(GetTray()->visible()); | 247 EXPECT_FALSE(GetTray()->visible()); |
231 } | 248 } |
232 | 249 |
| 250 // Tests that the overview button becomes visible when the user enters |
| 251 // maximize mode with a system modal window open, and that it hides once |
| 252 // the user exits maximize mode. |
| 253 TEST_F(OverviewButtonTrayTest, VisibilityChangesForSystemModalWindow) { |
| 254 // TODO(jonross): When CreateTestWindow*() have been unified, use the |
| 255 // appropriate method to replace this setup. (crbug.com/483503) |
| 256 scoped_ptr<aura::Window> window(new aura::Window(nullptr)); |
| 257 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); |
| 258 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
| 259 window->Init(ui::LAYER_TEXTURED); |
| 260 window->Show(); |
| 261 ParentWindowInPrimaryRootWindow(window.get()); |
| 262 |
| 263 ASSERT_TRUE(Shell::GetInstance()->IsSystemModalWindowOpen()); |
| 264 Shell::GetInstance() |
| 265 ->maximize_mode_controller() |
| 266 ->EnableMaximizeModeWindowManager(true); |
| 267 EXPECT_TRUE(GetTray()->visible()); |
| 268 Shell::GetInstance() |
| 269 ->maximize_mode_controller() |
| 270 ->EnableMaximizeModeWindowManager(false); |
| 271 EXPECT_FALSE(GetTray()->visible()); |
| 272 } |
| 273 |
233 } // namespace ash | 274 } // namespace ash |
OLD | NEW |