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" |
23 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 25 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
24 #include "ui/events/event.h" | 26 #include "ui/events/event.h" |
25 #include "ui/events/event_constants.h" | 27 #include "ui/events/event_constants.h" |
26 #include "ui/events/gestures/gesture_types.h" | 28 #include "ui/events/gestures/gesture_types.h" |
27 #include "ui/views/controls/image_view.h" | 29 #include "ui/views/controls/image_view.h" |
(...skipping 16 matching lines...) Expand all Loading... |
44 | 46 |
45 } // namespace | 47 } // namespace |
46 | 48 |
47 class OverviewButtonTrayTest : public test::AshTestBase { | 49 class OverviewButtonTrayTest : public test::AshTestBase { |
48 public: | 50 public: |
49 OverviewButtonTrayTest() {} | 51 OverviewButtonTrayTest() {} |
50 ~OverviewButtonTrayTest() override {} | 52 ~OverviewButtonTrayTest() override {} |
51 | 53 |
52 void SetUp() override; | 54 void SetUp() override; |
53 | 55 |
| 56 void UpdateSessionsState(); |
| 57 |
54 protected: | 58 protected: |
55 views::ImageView* GetImageView(OverviewButtonTray* tray) { | 59 views::ImageView* GetImageView(OverviewButtonTray* tray) { |
56 return tray->icon_; | 60 return tray->icon_; |
57 } | 61 } |
58 | 62 |
59 private: | 63 private: |
60 DISALLOW_COPY_AND_ASSIGN(OverviewButtonTrayTest); | 64 DISALLOW_COPY_AND_ASSIGN(OverviewButtonTrayTest); |
61 }; | 65 }; |
62 | 66 |
63 void OverviewButtonTrayTest::SetUp() { | 67 void OverviewButtonTrayTest::SetUp() { |
64 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 68 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
65 switches::kAshUseFirstDisplayAsInternal); | 69 switches::kAshUseFirstDisplayAsInternal); |
66 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 70 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
67 switches::kAshEnableScreenRotationAnimation); | 71 switches::kAshEnableScreenRotationAnimation); |
68 AshTestBase::SetUp(); | 72 AshTestBase::SetUp(); |
69 } | 73 } |
70 | 74 |
| 75 void OverviewButtonTrayTest::UpdateSessionsState() { |
| 76 GetTray()->SessionStateChanged( |
| 77 ash_test_helper()->GetTestSessionStateDelegate()->GetSessionState()); |
| 78 } |
| 79 |
71 // 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. |
72 TEST_F(OverviewButtonTrayTest, BasicConstruction) { | 81 TEST_F(OverviewButtonTrayTest, BasicConstruction) { |
73 EXPECT_TRUE(GetImageView(GetTray()) != NULL); | 82 EXPECT_TRUE(GetImageView(GetTray()) != NULL); |
74 } | 83 } |
75 | 84 |
76 // Test that maximize mode toggle changes visibility. | 85 // Test that maximize mode toggle changes visibility. |
77 // OverviewButtonTray should only be visible when MaximizeMode is enabled. | 86 // OverviewButtonTray should only be visible when MaximizeMode is enabled. |
78 // By default the system should not have MaximizeMode enabled. | 87 // By default the system should not have MaximizeMode enabled. |
79 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) { | 88 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) { |
80 ASSERT_FALSE(GetTray()->visible()); | 89 ASSERT_FALSE(GetTray()->visible()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) { | 180 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) { |
172 Shell::GetInstance()->maximize_mode_controller()-> | 181 Shell::GetInstance()->maximize_mode_controller()-> |
173 EnableMaximizeModeWindowManager(true); | 182 EnableMaximizeModeWindowManager(true); |
174 SetUserLoggedIn(false); | 183 SetUserLoggedIn(false); |
175 Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_NONE); | 184 Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_NONE); |
176 EXPECT_FALSE(GetTray()->visible()); | 185 EXPECT_FALSE(GetTray()->visible()); |
177 SetUserLoggedIn(true); | 186 SetUserLoggedIn(true); |
178 SetSessionStarted(true); | 187 SetSessionStarted(true); |
179 Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_USER); | 188 Shell::GetInstance()->UpdateAfterLoginStatusChange(user::LOGGED_IN_USER); |
180 EXPECT_TRUE(GetTray()->visible()); | 189 EXPECT_TRUE(GetTray()->visible()); |
| 190 SetUserAddingScreenRunning(true); |
| 191 UpdateSessionsState(); |
| 192 EXPECT_FALSE(GetTray()->visible()); |
| 193 SetUserAddingScreenRunning(false); |
| 194 UpdateSessionsState(); |
| 195 EXPECT_TRUE(GetTray()->visible()); |
181 Shell::GetInstance()->maximize_mode_controller()-> | 196 Shell::GetInstance()->maximize_mode_controller()-> |
182 EnableMaximizeModeWindowManager(false); | 197 EnableMaximizeModeWindowManager(false); |
183 } | 198 } |
184 | 199 |
185 // 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 |
186 // dismissal of overview mode clears the active state. | 201 // dismissal of overview mode clears the active state. |
187 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { | 202 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { |
188 ASSERT_FALSE( | 203 ASSERT_FALSE( |
189 Shell::GetInstance()->window_selector_controller()->IsSelecting()); | 204 Shell::GetInstance()->window_selector_controller()->IsSelecting()); |
190 ASSERT_FALSE(GetTray()->draw_background_as_active()); | 205 ASSERT_FALSE(GetTray()->draw_background_as_active()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 new ui::ScopedAnimationDurationScaleMode( | 239 new ui::ScopedAnimationDurationScaleMode( |
225 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); | 240 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); |
226 ash::ScreenRotationAnimator(gfx::Display::InternalDisplayId()) | 241 ash::ScreenRotationAnimator(gfx::Display::InternalDisplayId()) |
227 .Rotate(gfx::Display::ROTATE_270, gfx::Display::ROTATION_SOURCE_ACTIVE); | 242 .Rotate(gfx::Display::ROTATE_270, gfx::Display::ROTATION_SOURCE_ACTIVE); |
228 | 243 |
229 RunAllPendingInMessageLoop(); | 244 RunAllPendingInMessageLoop(); |
230 EXPECT_FALSE(GetTray()->visible()); | 245 EXPECT_FALSE(GetTray()->visible()); |
231 } | 246 } |
232 | 247 |
233 } // namespace ash | 248 } // namespace ash |
OLD | NEW |