OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/wm/lock_state_controller.h" | 5 #include "ash/wm/lock_state_controller.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/session/session_state_delegate.h" | 8 #include "ash/session/session_state_delegate.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
12 #include "ash/test/test_lock_state_controller_delegate.h" | 12 #include "ash/test/test_lock_state_controller_delegate.h" |
| 13 #include "ash/test/test_screenshot_delegate.h" |
13 #include "ash/test/test_shell_delegate.h" | 14 #include "ash/test/test_shell_delegate.h" |
14 #include "ash/wm/power_button_controller.h" | 15 #include "ash/wm/power_button_controller.h" |
15 #include "ash/wm/session_state_animator.h" | 16 #include "ash/wm/session_state_animator.h" |
16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
17 #include "base/memory/scoped_ptr.h" | 18 #include "base/memory/scoped_ptr.h" |
18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
19 #include "ui/aura/env.h" | 20 #include "ui/aura/env.h" |
20 #include "ui/aura/test/event_generator.h" | 21 #include "ui/aura/test/event_generator.h" |
21 #include "ui/aura/test/test_window_delegate.h" | 22 #include "ui/aura/test/test_window_delegate.h" |
22 #include "ui/aura/window_event_dispatcher.h" | 23 #include "ui/aura/window_event_dispatcher.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 61 |
61 void HideBackground() { | 62 void HideBackground() { |
62 ui::ScopedLayerAnimationSettings settings( | 63 ui::ScopedLayerAnimationSettings settings( |
63 GetContainer(kShellWindowId_DesktopBackgroundContainer) | 64 GetContainer(kShellWindowId_DesktopBackgroundContainer) |
64 ->layer() | 65 ->layer() |
65 ->GetAnimator()); | 66 ->GetAnimator()); |
66 settings.SetTransitionDuration(base::TimeDelta()); | 67 settings.SetTransitionDuration(base::TimeDelta()); |
67 GetContainer(kShellWindowId_DesktopBackgroundContainer)->Hide(); | 68 GetContainer(kShellWindowId_DesktopBackgroundContainer)->Hide(); |
68 } | 69 } |
69 | 70 |
70 } // namespace | 71 } // namespace |
71 | 72 |
72 class LockStateControllerTest : public AshTestBase { | 73 class LockStateControllerTest : public AshTestBase { |
73 public: | 74 public: |
74 LockStateControllerTest() : controller_(NULL), delegate_(NULL) {} | 75 LockStateControllerTest() : controller_(NULL), delegate_(NULL) {} |
75 virtual ~LockStateControllerTest() {} | 76 virtual ~LockStateControllerTest() {} |
76 | 77 |
77 virtual void SetUp() OVERRIDE { | 78 virtual void SetUp() OVERRIDE { |
78 AshTestBase::SetUp(); | 79 AshTestBase::SetUp(); |
79 | 80 |
80 // We would control animations in a fine way: | 81 // We would control animations in a fine way: |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 Shell::GetPrimaryRootWindow()); | 118 Shell::GetPrimaryRootWindow()); |
118 generator.MoveMouseTo(10, 10); | 119 generator.MoveMouseTo(10, 10); |
119 } | 120 } |
120 | 121 |
121 int NumShutdownRequests() { | 122 int NumShutdownRequests() { |
122 return delegate_->num_shutdown_requests() + | 123 return delegate_->num_shutdown_requests() + |
123 shell_delegate_->num_exit_requests(); | 124 shell_delegate_->num_exit_requests(); |
124 } | 125 } |
125 | 126 |
126 void Advance(SessionStateAnimator::AnimationSpeed speed) { | 127 void Advance(SessionStateAnimator::AnimationSpeed speed) { |
127 // TODO (antrim) : restore | 128 // TODO(antrim) : restore |
128 // animator_helper_->Advance(SessionStateAnimator::GetDuration(speed)); | 129 // animator_helper_->Advance(SessionStateAnimator::GetDuration(speed)); |
129 } | 130 } |
130 | 131 |
131 void AdvancePartially(SessionStateAnimator::AnimationSpeed speed, | 132 void AdvancePartially(SessionStateAnimator::AnimationSpeed speed, |
132 float factor) { | 133 float factor) { |
133 // TODO (antrim) : restore | 134 // TODO(antrim) : restore |
134 // base::TimeDelta duration = SessionStateAnimator::GetDuration(speed); | 135 // base::TimeDelta duration = SessionStateAnimator::GetDuration(speed); |
135 // base::TimeDelta partial_duration = | 136 // base::TimeDelta partial_duration = |
136 // base::TimeDelta::FromInternalValue(duration.ToInternalValue() * factor); | 137 // base::TimeDelta::FromInternalValue(duration.ToInternalValue() * factor); |
137 // animator_helper_->Advance(partial_duration); | 138 // animator_helper_->Advance(partial_duration); |
138 } | 139 } |
139 | 140 |
140 void ExpectPreLockAnimationStarted() { | 141 void ExpectPreLockAnimationStarted() { |
141 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 142 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
142 EXPECT_TRUE( | 143 EXPECT_TRUE( |
143 animator_api_->ContainersAreAnimated( | 144 animator_api_->ContainersAreAnimated( |
144 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 145 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
145 SessionStateAnimator::ANIMATION_LIFT)); | 146 SessionStateAnimator::ANIMATION_LIFT)); |
146 EXPECT_TRUE( | 147 EXPECT_TRUE( |
147 animator_api_->ContainersAreAnimated( | 148 animator_api_->ContainersAreAnimated( |
148 SessionStateAnimator::LAUNCHER, | 149 SessionStateAnimator::LAUNCHER, |
149 SessionStateAnimator::ANIMATION_FADE_OUT)); | 150 SessionStateAnimator::ANIMATION_FADE_OUT)); |
150 EXPECT_TRUE( | 151 EXPECT_TRUE( |
151 animator_api_->ContainersAreAnimated( | 152 animator_api_->ContainersAreAnimated( |
152 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 153 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
153 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); | 154 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); |
154 EXPECT_TRUE(test_api_->is_animating_lock()); | 155 EXPECT_TRUE(test_api_->is_animating_lock()); |
155 } | 156 } |
156 | 157 |
157 void ExpectPreLockAnimationCancel() { | 158 void ExpectPreLockAnimationCancel() { |
158 EXPECT_TRUE( | 159 EXPECT_TRUE( |
159 animator_api_->ContainersAreAnimated( | 160 animator_api_->ContainersAreAnimated( |
160 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 161 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
161 SessionStateAnimator::ANIMATION_DROP)); | 162 SessionStateAnimator::ANIMATION_DROP)); |
162 EXPECT_TRUE( | 163 EXPECT_TRUE( |
163 animator_api_->ContainersAreAnimated( | 164 animator_api_->ContainersAreAnimated( |
164 SessionStateAnimator::LAUNCHER, | 165 SessionStateAnimator::LAUNCHER, |
165 SessionStateAnimator::ANIMATION_FADE_IN)); | 166 SessionStateAnimator::ANIMATION_FADE_IN)); |
166 } | 167 } |
167 | 168 |
168 void ExpectPreLockAnimationFinished() { | 169 void ExpectPreLockAnimationFinished() { |
169 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 170 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
170 EXPECT_TRUE( | 171 EXPECT_TRUE( |
171 animator_api_->ContainersAreAnimated( | 172 animator_api_->ContainersAreAnimated( |
172 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 173 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
173 SessionStateAnimator::ANIMATION_LIFT)); | 174 SessionStateAnimator::ANIMATION_LIFT)); |
174 EXPECT_TRUE( | 175 EXPECT_TRUE( |
175 animator_api_->ContainersAreAnimated( | 176 animator_api_->ContainersAreAnimated( |
176 SessionStateAnimator::LAUNCHER, | 177 SessionStateAnimator::LAUNCHER, |
177 SessionStateAnimator::ANIMATION_FADE_OUT)); | 178 SessionStateAnimator::ANIMATION_FADE_OUT)); |
178 EXPECT_TRUE( | 179 EXPECT_TRUE( |
179 animator_api_->ContainersAreAnimated( | 180 animator_api_->ContainersAreAnimated( |
180 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 181 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
181 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); | 182 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); |
182 } | 183 } |
183 | 184 |
184 void ExpectPostLockAnimationStarted() { | 185 void ExpectPostLockAnimationStarted() { |
185 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 186 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
186 EXPECT_TRUE( | 187 EXPECT_TRUE( |
187 animator_api_->ContainersAreAnimated( | 188 animator_api_->ContainersAreAnimated( |
188 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 189 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
189 SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN)); | 190 SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN)); |
190 } | 191 } |
191 | 192 |
192 void ExpectPastLockAnimationFinished() { | 193 void ExpectPastLockAnimationFinished() { |
193 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 194 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
194 EXPECT_TRUE( | 195 EXPECT_TRUE( |
195 animator_api_->ContainersAreAnimated( | 196 animator_api_->ContainersAreAnimated( |
196 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 197 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
197 SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN)); | 198 SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN)); |
198 } | 199 } |
199 | 200 |
200 void ExpectUnlockBeforeUIDestroyedAnimationStarted() { | 201 void ExpectUnlockBeforeUIDestroyedAnimationStarted() { |
201 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 202 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
202 EXPECT_TRUE( | 203 EXPECT_TRUE( |
203 animator_api_->ContainersAreAnimated( | 204 animator_api_->ContainersAreAnimated( |
204 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 205 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
205 SessionStateAnimator::ANIMATION_LIFT)); | 206 SessionStateAnimator::ANIMATION_LIFT)); |
206 } | 207 } |
207 | 208 |
208 void ExpectUnlockBeforeUIDestroyedAnimationFinished() { | 209 void ExpectUnlockBeforeUIDestroyedAnimationFinished() { |
209 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 210 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
210 EXPECT_TRUE( | 211 EXPECT_TRUE( |
211 animator_api_->ContainersAreAnimated( | 212 animator_api_->ContainersAreAnimated( |
212 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 213 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
213 SessionStateAnimator::ANIMATION_LIFT)); | 214 SessionStateAnimator::ANIMATION_LIFT)); |
214 } | 215 } |
215 | 216 |
216 void ExpectUnlockAfterUIDestroyedAnimationStarted() { | 217 void ExpectUnlockAfterUIDestroyedAnimationStarted() { |
217 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 218 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
218 EXPECT_TRUE( | 219 EXPECT_TRUE( |
219 animator_api_->ContainersAreAnimated( | 220 animator_api_->ContainersAreAnimated( |
220 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 221 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
221 SessionStateAnimator::ANIMATION_DROP)); | 222 SessionStateAnimator::ANIMATION_DROP)); |
222 EXPECT_TRUE( | 223 EXPECT_TRUE( |
223 animator_api_->ContainersAreAnimated( | 224 animator_api_->ContainersAreAnimated( |
224 SessionStateAnimator::LAUNCHER, | 225 SessionStateAnimator::LAUNCHER, |
225 SessionStateAnimator::ANIMATION_FADE_IN)); | 226 SessionStateAnimator::ANIMATION_FADE_IN)); |
226 } | 227 } |
227 | 228 |
228 void ExpectUnlockAfterUIDestroyedAnimationFinished() { | 229 void ExpectUnlockAfterUIDestroyedAnimationFinished() { |
229 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 230 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
230 EXPECT_TRUE( | 231 EXPECT_TRUE( |
231 animator_api_->ContainersAreAnimated( | 232 animator_api_->ContainersAreAnimated( |
232 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 233 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
233 SessionStateAnimator::ANIMATION_DROP)); | 234 SessionStateAnimator::ANIMATION_DROP)); |
234 EXPECT_TRUE( | 235 EXPECT_TRUE( |
235 animator_api_->ContainersAreAnimated( | 236 animator_api_->ContainersAreAnimated( |
236 SessionStateAnimator::LAUNCHER, | 237 SessionStateAnimator::LAUNCHER, |
237 SessionStateAnimator::ANIMATION_FADE_IN)); | 238 SessionStateAnimator::ANIMATION_FADE_IN)); |
238 } | 239 } |
239 | 240 |
240 void ExpectShutdownAnimationStarted() { | 241 void ExpectShutdownAnimationStarted() { |
241 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 242 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
242 EXPECT_TRUE( | 243 EXPECT_TRUE( |
243 animator_api_->RootWindowIsAnimated( | 244 animator_api_->RootWindowIsAnimated( |
244 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS)); | 245 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS)); |
245 } | 246 } |
246 | 247 |
247 void ExpectShutdownAnimationFinished() { | 248 void ExpectShutdownAnimationFinished() { |
248 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 249 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
249 EXPECT_TRUE( | 250 EXPECT_TRUE( |
250 animator_api_->RootWindowIsAnimated( | 251 animator_api_->RootWindowIsAnimated( |
251 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS)); | 252 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS)); |
252 } | 253 } |
253 | 254 |
254 void ExpectShutdownAnimationCancel() { | 255 void ExpectShutdownAnimationCancel() { |
255 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 256 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
256 EXPECT_TRUE( | 257 EXPECT_TRUE( |
257 animator_api_->RootWindowIsAnimated( | 258 animator_api_->RootWindowIsAnimated( |
258 SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS)); | 259 SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS)); |
259 } | 260 } |
260 | 261 |
261 void ExpectBackgroundIsShowing() { | 262 void ExpectBackgroundIsShowing() { |
262 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 263 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
263 EXPECT_TRUE( | 264 EXPECT_TRUE( |
264 animator_api_->ContainersAreAnimated( | 265 animator_api_->ContainersAreAnimated( |
265 SessionStateAnimator::DESKTOP_BACKGROUND, | 266 SessionStateAnimator::DESKTOP_BACKGROUND, |
266 SessionStateAnimator::ANIMATION_FADE_IN)); | 267 SessionStateAnimator::ANIMATION_FADE_IN)); |
267 } | 268 } |
268 | 269 |
269 void ExpectBackgroundIsHiding() { | 270 void ExpectBackgroundIsHiding() { |
270 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 271 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
271 EXPECT_TRUE( | 272 EXPECT_TRUE( |
272 animator_api_->ContainersAreAnimated( | 273 animator_api_->ContainersAreAnimated( |
273 SessionStateAnimator::DESKTOP_BACKGROUND, | 274 SessionStateAnimator::DESKTOP_BACKGROUND, |
274 SessionStateAnimator::ANIMATION_FADE_OUT)); | 275 SessionStateAnimator::ANIMATION_FADE_OUT)); |
275 } | 276 } |
276 | 277 |
277 void ExpectUnlockedState() { | 278 void ExpectUnlockedState() { |
278 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 279 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
279 EXPECT_FALSE(session_state_delegate_->IsScreenLocked()); | 280 EXPECT_FALSE(session_state_delegate_->IsScreenLocked()); |
280 | 281 |
281 aura::Window::Windows containers; | 282 aura::Window::Windows containers; |
282 | 283 |
283 SessionStateAnimator::GetContainers( | 284 SessionStateAnimator::GetContainers( |
284 SessionStateAnimator::LAUNCHER | | 285 SessionStateAnimator::LAUNCHER | |
285 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 286 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
286 &containers); | 287 &containers); |
287 for (aura::Window::Windows::const_iterator it = containers.begin(); | 288 for (aura::Window::Windows::const_iterator it = containers.begin(); |
288 it != containers.end(); ++it) { | 289 it != containers.end(); ++it) { |
289 aura::Window* window = *it; | 290 aura::Window* window = *it; |
290 ui::Layer* layer = window->layer(); | 291 ui::Layer* layer = window->layer(); |
291 EXPECT_EQ(1.0f, layer->opacity()); | 292 EXPECT_EQ(1.0f, layer->opacity()); |
292 EXPECT_EQ(0.0f, layer->layer_brightness()); | 293 EXPECT_EQ(0.0f, layer->layer_brightness()); |
293 EXPECT_EQ(0.0f, layer->layer_saturation()); | 294 EXPECT_EQ(0.0f, layer->layer_saturation()); |
294 EXPECT_EQ(gfx::Transform(), layer->transform()); | 295 EXPECT_EQ(gfx::Transform(), layer->transform()); |
295 } | 296 } |
296 } | 297 } |
297 | 298 |
298 void ExpectLockedState() { | 299 void ExpectLockedState() { |
299 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 300 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
300 EXPECT_TRUE(session_state_delegate_->IsScreenLocked()); | 301 EXPECT_TRUE(session_state_delegate_->IsScreenLocked()); |
301 | 302 |
302 aura::Window::Windows containers; | 303 aura::Window::Windows containers; |
303 | 304 |
304 SessionStateAnimator::GetContainers( | 305 SessionStateAnimator::GetContainers( |
305 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS | | 306 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS | |
306 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 307 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
307 &containers); | 308 &containers); |
308 for (aura::Window::Windows::const_iterator it = containers.begin(); | 309 for (aura::Window::Windows::const_iterator it = containers.begin(); |
309 it != containers.end(); ++it) { | 310 it != containers.end(); ++it) { |
310 aura::Window* window = *it; | 311 aura::Window* window = *it; |
311 ui::Layer* layer = window->layer(); | 312 ui::Layer* layer = window->layer(); |
312 EXPECT_EQ(1.0f, layer->opacity()); | 313 EXPECT_EQ(1.0f, layer->opacity()); |
313 EXPECT_EQ(0.0f, layer->layer_brightness()); | 314 EXPECT_EQ(0.0f, layer->layer_brightness()); |
314 EXPECT_EQ(0.0f, layer->layer_saturation()); | 315 EXPECT_EQ(0.0f, layer->layer_saturation()); |
315 EXPECT_EQ(gfx::Transform(), layer->transform()); | 316 EXPECT_EQ(gfx::Transform(), layer->transform()); |
316 } | 317 } |
317 } | 318 } |
318 | 319 |
319 void PressPowerButton() { | 320 void PressPowerButton() { |
320 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 321 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
321 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 322 // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
322 } | 323 } |
323 | 324 |
324 void ReleasePowerButton() { | 325 void ReleasePowerButton() { |
325 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); | 326 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); |
326 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 327 // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
327 } | 328 } |
328 | 329 |
329 void PressLockButton() { | 330 void PressLockButton() { |
330 controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); | 331 controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); |
331 } | 332 } |
332 | 333 |
333 void ReleaseLockButton() { | 334 void ReleaseLockButton() { |
334 controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); | 335 controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); |
335 } | 336 } |
336 | 337 |
| 338 void PressVolumeDown() { |
| 339 GetEventGenerator().PressKey(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); |
| 340 } |
| 341 |
| 342 void ReleaseVolumeDown() { |
| 343 GetEventGenerator().ReleaseKey(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); |
| 344 } |
| 345 |
337 void SystemLocks() { | 346 void SystemLocks() { |
338 lock_state_controller_->OnLockStateChanged(true); | 347 lock_state_controller_->OnLockStateChanged(true); |
339 session_state_delegate_->LockScreen(); | 348 session_state_delegate_->LockScreen(); |
340 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 349 // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
341 } | 350 } |
342 | 351 |
343 void SuccessfulAuthentication(bool* call_flag) { | 352 void SuccessfulAuthentication(bool* call_flag) { |
344 base::Closure closure = base::Bind(&CheckCalledCallback, call_flag); | 353 base::Closure closure = base::Bind(&CheckCalledCallback, call_flag); |
345 lock_state_controller_->OnLockScreenHide(closure); | 354 lock_state_controller_->OnLockScreenHide(closure); |
346 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 355 // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
347 } | 356 } |
348 | 357 |
349 void SystemUnlocks() { | 358 void SystemUnlocks() { |
350 lock_state_controller_->OnLockStateChanged(false); | 359 lock_state_controller_->OnLockStateChanged(false); |
351 session_state_delegate_->UnlockScreen(); | 360 session_state_delegate_->UnlockScreen(); |
352 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 361 // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
353 } | 362 } |
354 | 363 |
355 void Initialize(bool legacy_button, user::LoginStatus status) { | 364 void Initialize(bool legacy_button, user::LoginStatus status) { |
356 controller_->set_has_legacy_power_button_for_test(legacy_button); | 365 controller_->set_has_legacy_power_button_for_test(legacy_button); |
357 lock_state_controller_->OnLoginStateChanged(status); | 366 lock_state_controller_->OnLoginStateChanged(status); |
358 SetUserLoggedIn(status != user::LOGGED_IN_NONE); | 367 SetUserLoggedIn(status != user::LOGGED_IN_NONE); |
359 if (status == user::LOGGED_IN_GUEST) | 368 if (status == user::LOGGED_IN_GUEST) |
360 SetCanLockScreen(false); | 369 SetCanLockScreen(false); |
361 lock_state_controller_->OnLockStateChanged(false); | 370 lock_state_controller_->OnLockStateChanged(false); |
362 } | 371 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 EXPECT_FALSE(test_api_->is_lock_cancellable()); | 420 EXPECT_FALSE(test_api_->is_lock_cancellable()); |
412 | 421 |
413 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 422 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
414 | 423 |
415 ExpectPreLockAnimationFinished(); | 424 ExpectPreLockAnimationFinished(); |
416 EXPECT_EQ(1, delegate_->num_lock_requests()); | 425 EXPECT_EQ(1, delegate_->num_lock_requests()); |
417 | 426 |
418 // Notify that we locked successfully. | 427 // Notify that we locked successfully. |
419 lock_state_controller_->OnStartingLock(); | 428 lock_state_controller_->OnStartingLock(); |
420 // We had that animation already. | 429 // We had that animation already. |
421 //TODO (antrim) : restore | 430 // TODO(antrim) : restore |
422 // EXPECT_FALSE(animator_helper_->IsAnimating()); | 431 // EXPECT_FALSE(animator_helper_->IsAnimating()); |
423 | 432 |
424 SystemLocks(); | 433 SystemLocks(); |
425 | 434 |
426 ExpectPostLockAnimationStarted(); | 435 ExpectPostLockAnimationStarted(); |
427 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 436 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
428 ExpectPastLockAnimationFinished(); | 437 ExpectPastLockAnimationFinished(); |
429 | 438 |
430 // We shouldn't progress towards the shutdown state, however. | 439 // We shouldn't progress towards the shutdown state, however. |
431 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); | 440 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 EXPECT_EQ(0, delegate_->num_lock_requests()); | 535 EXPECT_EQ(0, delegate_->num_lock_requests()); |
527 | 536 |
528 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); | 537 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
529 ExpectPreLockAnimationFinished(); | 538 ExpectPreLockAnimationFinished(); |
530 | 539 |
531 EXPECT_EQ(1, delegate_->num_lock_requests()); | 540 EXPECT_EQ(1, delegate_->num_lock_requests()); |
532 | 541 |
533 // Notify that we locked successfully. | 542 // Notify that we locked successfully. |
534 lock_state_controller_->OnStartingLock(); | 543 lock_state_controller_->OnStartingLock(); |
535 // We had that animation already. | 544 // We had that animation already. |
536 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 545 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
537 | 546 |
538 SystemLocks(); | 547 SystemLocks(); |
539 | 548 |
540 ExpectPostLockAnimationStarted(); | 549 ExpectPostLockAnimationStarted(); |
541 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 550 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
542 ExpectPastLockAnimationFinished(); | 551 ExpectPastLockAnimationFinished(); |
543 | 552 |
544 // When we release the power button, the lock-to-shutdown timer should be | 553 // When we release the power button, the lock-to-shutdown timer should be |
545 // stopped. | 554 // stopped. |
546 ExpectLockedState(); | 555 ExpectLockedState(); |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1083 ExpectBackgroundIsHiding(); | 1092 ExpectBackgroundIsHiding(); |
1084 EXPECT_FALSE(IsBackgroundHidden()); | 1093 EXPECT_FALSE(IsBackgroundHidden()); |
1085 | 1094 |
1086 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 1095 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
1087 ExpectUnlockAfterUIDestroyedAnimationFinished(); | 1096 ExpectUnlockAfterUIDestroyedAnimationFinished(); |
1088 EXPECT_TRUE(IsBackgroundHidden()); | 1097 EXPECT_TRUE(IsBackgroundHidden()); |
1089 | 1098 |
1090 ExpectUnlockedState(); | 1099 ExpectUnlockedState(); |
1091 } | 1100 } |
1092 | 1101 |
| 1102 // Tests that a screenshot can be taken by holding volume down and |
| 1103 // pressing power. |
| 1104 TEST_F(LockStateControllerTest, Screenshot) { |
| 1105 Shell::GetInstance()->lock_state_controller()->SetDelegate( |
| 1106 new test::TestLockStateControllerDelegate); |
| 1107 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); |
| 1108 delegate->set_can_take_screenshot(true); |
| 1109 |
| 1110 // Pressing power alone does not take a screenshot. |
| 1111 PressPowerButton(); |
| 1112 ReleasePowerButton(); |
| 1113 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1114 |
| 1115 // Press & release volume then pressing power does not take a screenshot. |
| 1116 ASSERT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1117 PressVolumeDown(); |
| 1118 ReleaseVolumeDown(); |
| 1119 PressPowerButton(); |
| 1120 ReleasePowerButton(); |
| 1121 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1122 |
| 1123 // Pressing power and then volume does not take a screenshot. |
| 1124 ASSERT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1125 PressPowerButton(); |
| 1126 ReleasePowerButton(); |
| 1127 PressVolumeDown(); |
| 1128 ReleaseVolumeDown(); |
| 1129 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1130 |
| 1131 // Holding volume down and pressing power takes a screenshot. |
| 1132 ASSERT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1133 PressVolumeDown(); |
| 1134 PressPowerButton(); |
| 1135 ReleasePowerButton(); |
| 1136 ReleaseVolumeDown(); |
| 1137 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); |
| 1138 } |
| 1139 |
1093 } // namespace test | 1140 } // namespace test |
1094 } // namespace ash | 1141 } // namespace ash |
OLD | NEW |