Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1179)

Side by Side Diff: ash/system/overview/overview_button_tray_unittest.cc

Issue 2766543002: Move even more from WmShell to Shell (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "ash/common/wm/overview/window_selector_controller.h" 11 #include "ash/common/wm/overview/window_selector_controller.h"
12 #include "ash/common/wm_shell.h" 12 #include "ash/common/wm_shell.h"
13 #include "ash/public/cpp/shelf_types.h" 13 #include "ash/public/cpp/shelf_types.h"
14 #include "ash/root_window_controller.h" 14 #include "ash/root_window_controller.h"
15 #include "ash/rotator/screen_rotation_animator.h" 15 #include "ash/rotator/screen_rotation_animator.h"
16 #include "ash/shell.h"
16 #include "ash/test/ash_test_base.h" 17 #include "ash/test/ash_test_base.h"
17 #include "ash/test/ash_test_helper.h" 18 #include "ash/test/ash_test_helper.h"
18 #include "ash/test/status_area_widget_test_helper.h" 19 #include "ash/test/status_area_widget_test_helper.h"
19 #include "base/command_line.h" 20 #include "base/command_line.h"
20 #include "base/test/user_action_tester.h" 21 #include "base/test/user_action_tester.h"
21 #include "base/time/time.h" 22 #include "base/time/time.h"
22 #include "ui/aura/client/aura_constants.h" 23 #include "ui/aura/client/aura_constants.h"
23 #include "ui/aura/window.h" 24 #include "ui/aura/window.h"
24 #include "ui/compositor/scoped_animation_duration_scale_mode.h" 25 #include "ui/compositor/scoped_animation_duration_scale_mode.h"
25 #include "ui/display/display_switches.h" 26 #include "ui/display/display_switches.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // 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.
80 TEST_F(OverviewButtonTrayTest, BasicConstruction) { 81 TEST_F(OverviewButtonTrayTest, BasicConstruction) {
81 EXPECT_TRUE(GetImageView(GetTray()) != NULL); 82 EXPECT_TRUE(GetImageView(GetTray()) != NULL);
82 } 83 }
83 84
84 // Test that maximize mode toggle changes visibility. 85 // Test that maximize mode toggle changes visibility.
85 // OverviewButtonTray should only be visible when MaximizeMode is enabled. 86 // OverviewButtonTray should only be visible when MaximizeMode is enabled.
86 // By default the system should not have MaximizeMode enabled. 87 // By default the system should not have MaximizeMode enabled.
87 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) { 88 TEST_F(OverviewButtonTrayTest, MaximizeModeObserverOnMaximizeModeToggled) {
88 ASSERT_FALSE(GetTray()->visible()); 89 ASSERT_FALSE(GetTray()->visible());
89 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 90 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
90 true); 91 true);
91 EXPECT_TRUE(GetTray()->visible()); 92 EXPECT_TRUE(GetTray()->visible());
92 93
93 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 94 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
94 false); 95 false);
95 EXPECT_FALSE(GetTray()->visible()); 96 EXPECT_FALSE(GetTray()->visible());
96 } 97 }
97 98
98 // Tests that activating this control brings up window selection mode. 99 // Tests that activating this control brings up window selection mode.
99 TEST_F(OverviewButtonTrayTest, PerformAction) { 100 TEST_F(OverviewButtonTrayTest, PerformAction) {
100 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); 101 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting());
101 102
102 // Overview Mode only works when there is a window 103 // Overview Mode only works when there is a window
103 std::unique_ptr<aura::Window> window( 104 std::unique_ptr<aura::Window> window(
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 EXPECT_EQ(3, user_action_tester.GetActionCount(kTrayOverview)); 141 EXPECT_EQ(3, user_action_tester.GetActionCount(kTrayOverview));
141 } 142 }
142 143
143 // Tests that a second OverviewButtonTray has been created, and only shows 144 // Tests that a second OverviewButtonTray has been created, and only shows
144 // when MaximizeMode has been enabled, when we are using multiple displays. 145 // when MaximizeMode has been enabled, when we are using multiple displays.
145 // By default the DisplayManger is in extended mode. 146 // By default the DisplayManger is in extended mode.
146 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) { 147 TEST_F(OverviewButtonTrayTest, DisplaysOnBothDisplays) {
147 UpdateDisplay("400x400,200x200"); 148 UpdateDisplay("400x400,200x200");
148 EXPECT_FALSE(GetTray()->visible()); 149 EXPECT_FALSE(GetTray()->visible());
149 EXPECT_FALSE(GetSecondaryTray()->visible()); 150 EXPECT_FALSE(GetSecondaryTray()->visible());
150 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 151 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
151 true); 152 true);
152 EXPECT_TRUE(GetTray()->visible()); 153 EXPECT_TRUE(GetTray()->visible());
153 EXPECT_TRUE(GetSecondaryTray()->visible()); 154 EXPECT_TRUE(GetSecondaryTray()->visible());
154 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 155 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
155 false); 156 false);
156 } 157 }
157 158
158 // Tests if Maximize Mode is enabled before a secondary display is attached 159 // Tests if Maximize Mode is enabled before a secondary display is attached
159 // that the second OverviewButtonTray should be created in a visible state. 160 // that the second OverviewButtonTray should be created in a visible state.
160 TEST_F(OverviewButtonTrayTest, SecondaryTrayCreatedVisible) { 161 TEST_F(OverviewButtonTrayTest, SecondaryTrayCreatedVisible) {
161 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 162 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
162 true); 163 true);
163 UpdateDisplay("400x400,200x200"); 164 UpdateDisplay("400x400,200x200");
164 EXPECT_TRUE(GetSecondaryTray()->visible()); 165 EXPECT_TRUE(GetSecondaryTray()->visible());
165 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 166 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
166 false); 167 false);
167 } 168 }
168 169
169 // Tests that the tray loses visibility when a user logs out, and that it 170 // Tests that the tray loses visibility when a user logs out, and that it
170 // regains visibility when a user logs back in. 171 // regains visibility when a user logs back in.
171 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) { 172 TEST_F(OverviewButtonTrayTest, VisibilityChangesForLoginStatus) {
172 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 173 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
173 true); 174 true);
174 SetUserLoggedIn(false); 175 SetUserLoggedIn(false);
175 WmShell::Get()->UpdateAfterLoginStatusChange(LoginStatus::NOT_LOGGED_IN); 176 WmShell::Get()->UpdateAfterLoginStatusChange(LoginStatus::NOT_LOGGED_IN);
176 EXPECT_FALSE(GetTray()->visible()); 177 EXPECT_FALSE(GetTray()->visible());
177 SetUserLoggedIn(true); 178 SetUserLoggedIn(true);
178 SetSessionStarted(true); 179 SetSessionStarted(true);
179 WmShell::Get()->UpdateAfterLoginStatusChange(LoginStatus::USER); 180 WmShell::Get()->UpdateAfterLoginStatusChange(LoginStatus::USER);
180 EXPECT_TRUE(GetTray()->visible()); 181 EXPECT_TRUE(GetTray()->visible());
181 SetUserAddingScreenRunning(true); 182 SetUserAddingScreenRunning(true);
182 NotifySessionStateChanged(); 183 NotifySessionStateChanged();
183 EXPECT_FALSE(GetTray()->visible()); 184 EXPECT_FALSE(GetTray()->visible());
184 SetUserAddingScreenRunning(false); 185 SetUserAddingScreenRunning(false);
185 NotifySessionStateChanged(); 186 NotifySessionStateChanged();
186 EXPECT_TRUE(GetTray()->visible()); 187 EXPECT_TRUE(GetTray()->visible());
187 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 188 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
188 false); 189 false);
189 } 190 }
190 191
191 // 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
192 // dismissal of overview mode clears the active state. 193 // dismissal of overview mode clears the active state.
193 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) { 194 TEST_F(OverviewButtonTrayTest, ActiveStateOnlyDuringOverviewMode) {
194 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting()); 195 ASSERT_FALSE(WmShell::Get()->window_selector_controller()->IsSelecting());
195 ASSERT_FALSE(GetTray()->is_active()); 196 ASSERT_FALSE(GetTray()->is_active());
196 197
197 // Overview Mode only works when there is a window 198 // Overview Mode only works when there is a window
(...skipping 10 matching lines...) Expand all
208 } 209 }
209 210
210 // 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
211 // OverviewButton is still hidden. 212 // OverviewButton is still hidden.
212 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletes) { 213 TEST_F(OverviewButtonTrayTest, HideAnimationAlwaysCompletes) {
213 // TODO: disabled as ScreenRotationAnimator does not work in mash, 214 // TODO: disabled as ScreenRotationAnimator does not work in mash,
214 // http://crbug.com/696754. 215 // http://crbug.com/696754.
215 if (WmShell::Get()->IsRunningInMash()) 216 if (WmShell::Get()->IsRunningInMash())
216 return; 217 return;
217 218
218 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 219 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
219 true); 220 true);
220 221
221 // Long duration for hide animation, to allow it to be interrupted. 222 // Long duration for hide animation, to allow it to be interrupted.
222 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration( 223 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> hide_duration(
223 new ui::ScopedAnimationDurationScaleMode( 224 new ui::ScopedAnimationDurationScaleMode(
224 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); 225 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
225 GetTray()->SetVisible(false); 226 GetTray()->SetVisible(false);
226 227
227 // ScreenRotationAnimator copies the current layers, and deletes them upon 228 // ScreenRotationAnimator copies the current layers, and deletes them upon
228 // completion. Allow its animation to complete first. 229 // completion. Allow its animation to complete first.
(...skipping 15 matching lines...) Expand all
244 // TODO(jonross): When CreateTestWindow*() have been unified, use the 245 // TODO(jonross): When CreateTestWindow*() have been unified, use the
245 // appropriate method to replace this setup. (crbug.com/483503) 246 // appropriate method to replace this setup. (crbug.com/483503)
246 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); 247 std::unique_ptr<aura::Window> window(new aura::Window(nullptr));
247 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM); 248 window->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_SYSTEM);
248 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 249 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
249 window->Init(ui::LAYER_TEXTURED); 250 window->Init(ui::LAYER_TEXTURED);
250 window->Show(); 251 window->Show();
251 ParentWindowInPrimaryRootWindow(window.get()); 252 ParentWindowInPrimaryRootWindow(window.get());
252 253
253 ASSERT_TRUE(WmShell::Get()->IsSystemModalWindowOpen()); 254 ASSERT_TRUE(WmShell::Get()->IsSystemModalWindowOpen());
254 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 255 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
255 true); 256 true);
256 EXPECT_TRUE(GetTray()->visible()); 257 EXPECT_TRUE(GetTray()->visible());
257 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 258 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
258 false); 259 false);
259 EXPECT_FALSE(GetTray()->visible()); 260 EXPECT_FALSE(GetTray()->visible());
260 } 261 }
261 262
262 } // namespace ash 263 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc ('k') | ash/virtual_keyboard_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698