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" |
15 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | |
14 #include "ash/wm/power_button_controller.h" | 16 #include "ash/wm/power_button_controller.h" |
15 #include "ash/wm/session_state_animator.h" | 17 #include "ash/wm/session_state_animator.h" |
16 #include "base/command_line.h" | 18 #include "base/command_line.h" |
17 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
18 #include "base/time/time.h" | 20 #include "base/time/time.h" |
19 #include "ui/aura/env.h" | 21 #include "ui/aura/env.h" |
20 #include "ui/aura/test/test_window_delegate.h" | 22 #include "ui/aura/test/test_window_delegate.h" |
21 #include "ui/aura/window_event_dispatcher.h" | 23 #include "ui/aura/window_event_dispatcher.h" |
22 #include "ui/compositor/layer_animator.h" | 24 #include "ui/compositor/layer_animator.h" |
23 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 25 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 | 62 |
61 void HideBackground() { | 63 void HideBackground() { |
62 ui::ScopedLayerAnimationSettings settings( | 64 ui::ScopedLayerAnimationSettings settings( |
63 GetContainer(kShellWindowId_DesktopBackgroundContainer) | 65 GetContainer(kShellWindowId_DesktopBackgroundContainer) |
64 ->layer() | 66 ->layer() |
65 ->GetAnimator()); | 67 ->GetAnimator()); |
66 settings.SetTransitionDuration(base::TimeDelta()); | 68 settings.SetTransitionDuration(base::TimeDelta()); |
67 GetContainer(kShellWindowId_DesktopBackgroundContainer)->Hide(); | 69 GetContainer(kShellWindowId_DesktopBackgroundContainer)->Hide(); |
68 } | 70 } |
69 | 71 |
70 } // namespace | 72 } // namespace |
71 | 73 |
72 class LockStateControllerTest : public AshTestBase { | 74 class LockStateControllerTest : public AshTestBase { |
73 public: | 75 public: |
74 LockStateControllerTest() : controller_(NULL), delegate_(NULL) {} | 76 LockStateControllerTest() : controller_(NULL), delegate_(NULL) {} |
75 virtual ~LockStateControllerTest() {} | 77 virtual ~LockStateControllerTest() {} |
76 | 78 |
77 virtual void SetUp() OVERRIDE { | 79 virtual void SetUp() OVERRIDE { |
78 AshTestBase::SetUp(); | 80 AshTestBase::SetUp(); |
79 | 81 |
80 // We would control animations in a fine way: | 82 // We would control animations in a fine way: |
81 animation_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( | 83 animation_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( |
82 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION)); | 84 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION)); |
83 // TODO(antrim) : restore | 85 // TODO(antrim) : restore |
84 // animator_helper_ = ui::test::CreateLayerAnimatorHelperForTest(); | 86 // animator_helper_ = ui::test::CreateLayerAnimatorHelperForTest(); |
85 | 87 |
86 // Temporary disable animations so that observer is always called, and | 88 // Temporary disable animations so that observer is always called, and |
87 // no leaks happen during tests. | 89 // no leaks happen during tests. |
88 animation_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( | 90 // animation_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( |
89 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); | 91 // ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); |
flackr
2014/09/03 12:48:28
nit: Delete code if we no longer want it, though I
bruthig
2014/09/08 15:33:20
Done.
| |
90 // TODO(antrim): once there is a way to mock time and run animations, make | 92 // TODO(antrim): once there is a way to mock time and run animations, make |
91 // sure that animations are finished even in simple tests. | 93 // sure that animations are finished even in simple tests. |
92 | 94 |
93 delegate_ = new TestLockStateControllerDelegate; | 95 delegate_ = new TestLockStateControllerDelegate; |
94 controller_ = Shell::GetInstance()->power_button_controller(); | 96 controller_ = Shell::GetInstance()->power_button_controller(); |
95 lock_state_controller_ = static_cast<LockStateController*>( | 97 lock_state_controller_ = static_cast<LockStateController*>( |
96 Shell::GetInstance()->lock_state_controller()); | 98 Shell::GetInstance()->lock_state_controller()); |
97 lock_state_controller_->SetDelegate(delegate_); // transfers ownership | 99 lock_state_controller_->SetDelegate(delegate_); // transfers ownership |
98 test_api_.reset(new LockStateController::TestApi(lock_state_controller_)); | 100 test_api_.reset(new LockStateController::TestApi(lock_state_controller_)); |
99 animator_api_.reset( | 101 animator_api_.reset( |
(...skipping 16 matching lines...) Expand all Loading... | |
116 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); | 118 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
117 generator.MoveMouseTo(10, 10); | 119 generator.MoveMouseTo(10, 10); |
118 } | 120 } |
119 | 121 |
120 int NumShutdownRequests() { | 122 int NumShutdownRequests() { |
121 return delegate_->num_shutdown_requests() + | 123 return delegate_->num_shutdown_requests() + |
122 shell_delegate_->num_exit_requests(); | 124 shell_delegate_->num_exit_requests(); |
123 } | 125 } |
124 | 126 |
125 void Advance(SessionStateAnimator::AnimationSpeed speed) { | 127 void Advance(SessionStateAnimator::AnimationSpeed speed) { |
126 // TODO (antrim) : restore | 128 // TODO(antrim) : restore |
127 // animator_helper_->Advance(SessionStateAnimator::GetDuration(speed)); | 129 // animator_helper_->Advance(SessionStateAnimator::GetDuration(speed)); |
128 } | 130 } |
129 | 131 |
130 void AdvancePartially(SessionStateAnimator::AnimationSpeed speed, | 132 void AdvancePartially(SessionStateAnimator::AnimationSpeed speed, |
131 float factor) { | 133 float factor) { |
132 // TODO (antrim) : restore | 134 // TODO(antrim) : restore |
133 // base::TimeDelta duration = SessionStateAnimator::GetDuration(speed); | 135 // base::TimeDelta duration = SessionStateAnimator::GetDuration(speed); |
134 // base::TimeDelta partial_duration = | 136 // base::TimeDelta partial_duration = |
135 // base::TimeDelta::FromInternalValue(duration.ToInternalValue() * factor); | 137 // base::TimeDelta::FromInternalValue(duration.ToInternalValue() * factor); |
136 // animator_helper_->Advance(partial_duration); | 138 // animator_helper_->Advance(partial_duration); |
137 } | 139 } |
138 | 140 |
139 void ExpectPreLockAnimationStarted() { | 141 void ExpectPreLockAnimationStarted() { |
140 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 142 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
141 EXPECT_TRUE( | 143 EXPECT_TRUE( |
142 animator_api_->ContainersAreAnimated( | 144 animator_api_->ContainersAreAnimated( |
143 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 145 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
144 SessionStateAnimator::ANIMATION_LIFT)); | 146 SessionStateAnimator::ANIMATION_LIFT)); |
145 EXPECT_TRUE( | 147 EXPECT_TRUE( |
146 animator_api_->ContainersAreAnimated( | 148 animator_api_->ContainersAreAnimated( |
147 SessionStateAnimator::LAUNCHER, | 149 SessionStateAnimator::LAUNCHER, |
148 SessionStateAnimator::ANIMATION_FADE_OUT)); | 150 SessionStateAnimator::ANIMATION_FADE_OUT)); |
149 EXPECT_TRUE( | 151 EXPECT_TRUE( |
150 animator_api_->ContainersAreAnimated( | 152 animator_api_->ContainersAreAnimated( |
151 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 153 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
152 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); | 154 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); |
153 EXPECT_TRUE(test_api_->is_animating_lock()); | 155 EXPECT_TRUE(test_api_->is_animating_lock()); |
154 } | 156 } |
155 | 157 |
156 void ExpectPreLockAnimationCancel() { | 158 void ExpectPreLockAnimationCancel() { |
157 EXPECT_TRUE( | 159 EXPECT_TRUE( |
158 animator_api_->ContainersAreAnimated( | 160 animator_api_->ContainersAreAnimated( |
159 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 161 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
160 SessionStateAnimator::ANIMATION_DROP)); | 162 SessionStateAnimator::ANIMATION_DROP)); |
161 EXPECT_TRUE( | 163 EXPECT_TRUE( |
162 animator_api_->ContainersAreAnimated( | 164 animator_api_->ContainersAreAnimated( |
163 SessionStateAnimator::LAUNCHER, | 165 SessionStateAnimator::LAUNCHER, |
164 SessionStateAnimator::ANIMATION_FADE_IN)); | 166 SessionStateAnimator::ANIMATION_FADE_IN)); |
165 } | 167 } |
166 | 168 |
167 void ExpectPreLockAnimationFinished() { | 169 void ExpectPreLockAnimationFinished() { |
168 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 170 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
169 EXPECT_TRUE( | 171 EXPECT_TRUE( |
170 animator_api_->ContainersAreAnimated( | 172 animator_api_->ContainersAreAnimated( |
171 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 173 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
172 SessionStateAnimator::ANIMATION_LIFT)); | 174 SessionStateAnimator::ANIMATION_LIFT)); |
173 EXPECT_TRUE( | 175 EXPECT_TRUE( |
174 animator_api_->ContainersAreAnimated( | 176 animator_api_->ContainersAreAnimated( |
175 SessionStateAnimator::LAUNCHER, | 177 SessionStateAnimator::LAUNCHER, |
176 SessionStateAnimator::ANIMATION_FADE_OUT)); | 178 SessionStateAnimator::ANIMATION_FADE_OUT)); |
177 EXPECT_TRUE( | 179 EXPECT_TRUE( |
178 animator_api_->ContainersAreAnimated( | 180 animator_api_->ContainersAreAnimated( |
179 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 181 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
180 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); | 182 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); |
181 } | 183 } |
182 | 184 |
183 void ExpectPostLockAnimationStarted() { | 185 void ExpectPostLockAnimationStarted() { |
184 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 186 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
185 EXPECT_TRUE( | 187 EXPECT_TRUE( |
186 animator_api_->ContainersAreAnimated( | 188 animator_api_->ContainersAreAnimated( |
187 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 189 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
188 SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN)); | 190 SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN)); |
189 } | 191 } |
190 | 192 |
191 void ExpectPastLockAnimationFinished() { | 193 void ExpectPastLockAnimationFinished() { |
192 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 194 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
193 EXPECT_TRUE( | 195 EXPECT_TRUE( |
194 animator_api_->ContainersAreAnimated( | 196 animator_api_->ContainersAreAnimated( |
195 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 197 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
196 SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN)); | 198 SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN)); |
197 } | 199 } |
198 | 200 |
199 void ExpectUnlockBeforeUIDestroyedAnimationStarted() { | 201 void ExpectUnlockBeforeUIDestroyedAnimationStarted() { |
200 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 202 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
201 EXPECT_TRUE( | 203 EXPECT_TRUE( |
202 animator_api_->ContainersAreAnimated( | 204 animator_api_->ContainersAreAnimated( |
203 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 205 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
204 SessionStateAnimator::ANIMATION_LIFT)); | 206 SessionStateAnimator::ANIMATION_LIFT)); |
205 } | 207 } |
206 | 208 |
207 void ExpectUnlockBeforeUIDestroyedAnimationFinished() { | 209 void ExpectUnlockBeforeUIDestroyedAnimationFinished() { |
208 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 210 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
209 EXPECT_TRUE( | 211 EXPECT_TRUE( |
210 animator_api_->ContainersAreAnimated( | 212 animator_api_->ContainersAreAnimated( |
211 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 213 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
212 SessionStateAnimator::ANIMATION_LIFT)); | 214 SessionStateAnimator::ANIMATION_LIFT)); |
213 } | 215 } |
214 | 216 |
215 void ExpectUnlockAfterUIDestroyedAnimationStarted() { | 217 void ExpectUnlockAfterUIDestroyedAnimationStarted() { |
216 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 218 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
217 EXPECT_TRUE( | 219 EXPECT_TRUE( |
218 animator_api_->ContainersAreAnimated( | 220 animator_api_->ContainersAreAnimated( |
219 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 221 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
220 SessionStateAnimator::ANIMATION_DROP)); | 222 SessionStateAnimator::ANIMATION_DROP)); |
221 EXPECT_TRUE( | 223 EXPECT_TRUE( |
222 animator_api_->ContainersAreAnimated( | 224 animator_api_->ContainersAreAnimated( |
223 SessionStateAnimator::LAUNCHER, | 225 SessionStateAnimator::LAUNCHER, |
224 SessionStateAnimator::ANIMATION_FADE_IN)); | 226 SessionStateAnimator::ANIMATION_FADE_IN)); |
225 } | 227 } |
226 | 228 |
227 void ExpectUnlockAfterUIDestroyedAnimationFinished() { | 229 void ExpectUnlockAfterUIDestroyedAnimationFinished() { |
228 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 230 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
229 EXPECT_TRUE( | 231 EXPECT_TRUE( |
230 animator_api_->ContainersAreAnimated( | 232 animator_api_->ContainersAreAnimated( |
231 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 233 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
232 SessionStateAnimator::ANIMATION_DROP)); | 234 SessionStateAnimator::ANIMATION_DROP)); |
233 EXPECT_TRUE( | 235 EXPECT_TRUE( |
234 animator_api_->ContainersAreAnimated( | 236 animator_api_->ContainersAreAnimated( |
235 SessionStateAnimator::LAUNCHER, | 237 SessionStateAnimator::LAUNCHER, |
236 SessionStateAnimator::ANIMATION_FADE_IN)); | 238 SessionStateAnimator::ANIMATION_FADE_IN)); |
237 } | 239 } |
238 | 240 |
239 void ExpectShutdownAnimationStarted() { | 241 void ExpectShutdownAnimationStarted() { |
240 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 242 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
241 EXPECT_TRUE( | 243 EXPECT_TRUE( |
242 animator_api_->RootWindowIsAnimated( | 244 animator_api_->RootWindowIsAnimated( |
243 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS)); | 245 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS)); |
244 } | 246 } |
245 | 247 |
246 void ExpectShutdownAnimationFinished() { | 248 void ExpectShutdownAnimationFinished() { |
247 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 249 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
248 EXPECT_TRUE( | 250 EXPECT_TRUE( |
249 animator_api_->RootWindowIsAnimated( | 251 animator_api_->RootWindowIsAnimated( |
250 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS)); | 252 SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS)); |
251 } | 253 } |
252 | 254 |
253 void ExpectShutdownAnimationCancel() { | 255 void ExpectShutdownAnimationCancel() { |
254 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 256 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
255 EXPECT_TRUE( | 257 EXPECT_TRUE( |
256 animator_api_->RootWindowIsAnimated( | 258 animator_api_->RootWindowIsAnimated( |
257 SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS)); | 259 SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS)); |
258 } | 260 } |
259 | 261 |
260 void ExpectBackgroundIsShowing() { | 262 void ExpectBackgroundIsShowing() { |
261 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 263 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
262 EXPECT_TRUE( | 264 EXPECT_TRUE( |
263 animator_api_->ContainersAreAnimated( | 265 animator_api_->ContainersAreAnimated( |
264 SessionStateAnimator::DESKTOP_BACKGROUND, | 266 SessionStateAnimator::DESKTOP_BACKGROUND, |
265 SessionStateAnimator::ANIMATION_FADE_IN)); | 267 SessionStateAnimator::ANIMATION_FADE_IN)); |
266 } | 268 } |
267 | 269 |
268 void ExpectBackgroundIsHiding() { | 270 void ExpectBackgroundIsHiding() { |
269 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 271 // TODO(antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
270 EXPECT_TRUE( | 272 EXPECT_TRUE( |
271 animator_api_->ContainersAreAnimated( | 273 animator_api_->ContainersAreAnimated( |
272 SessionStateAnimator::DESKTOP_BACKGROUND, | 274 SessionStateAnimator::DESKTOP_BACKGROUND, |
273 SessionStateAnimator::ANIMATION_FADE_OUT)); | 275 SessionStateAnimator::ANIMATION_FADE_OUT)); |
274 } | 276 } |
275 | 277 |
276 void ExpectUnlockedState() { | 278 void ExpectUnlockedState() { |
277 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 279 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
278 EXPECT_FALSE(session_state_delegate_->IsScreenLocked()); | 280 EXPECT_FALSE(session_state_delegate_->IsScreenLocked()); |
279 | 281 |
280 aura::Window::Windows containers; | 282 aura::Window::Windows containers; |
281 | 283 |
282 SessionStateAnimator::GetContainers( | 284 SessionStateAnimator::GetContainers( |
283 SessionStateAnimator::LAUNCHER | | 285 SessionStateAnimator::LAUNCHER | |
284 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 286 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
285 &containers); | 287 &containers); |
286 for (aura::Window::Windows::const_iterator it = containers.begin(); | 288 for (aura::Window::Windows::const_iterator it = containers.begin(); |
287 it != containers.end(); ++it) { | 289 it != containers.end(); ++it) { |
288 aura::Window* window = *it; | 290 aura::Window* window = *it; |
289 ui::Layer* layer = window->layer(); | 291 ui::Layer* layer = window->layer(); |
290 EXPECT_EQ(1.0f, layer->opacity()); | 292 EXPECT_EQ(1.0f, layer->opacity()); |
291 EXPECT_EQ(0.0f, layer->layer_brightness()); | 293 EXPECT_EQ(0.0f, layer->layer_brightness()); |
292 EXPECT_EQ(0.0f, layer->layer_saturation()); | 294 EXPECT_EQ(0.0f, layer->layer_saturation()); |
293 EXPECT_EQ(gfx::Transform(), layer->transform()); | 295 EXPECT_EQ(gfx::Transform(), layer->transform()); |
294 } | 296 } |
295 } | 297 } |
296 | 298 |
297 void ExpectLockedState() { | 299 void ExpectLockedState() { |
298 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 300 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
299 EXPECT_TRUE(session_state_delegate_->IsScreenLocked()); | 301 EXPECT_TRUE(session_state_delegate_->IsScreenLocked()); |
300 | 302 |
301 aura::Window::Windows containers; | 303 aura::Window::Windows containers; |
302 | 304 |
303 SessionStateAnimator::GetContainers( | 305 SessionStateAnimator::GetContainers( |
304 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS | | 306 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS | |
305 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 307 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
306 &containers); | 308 &containers); |
307 for (aura::Window::Windows::const_iterator it = containers.begin(); | 309 for (aura::Window::Windows::const_iterator it = containers.begin(); |
308 it != containers.end(); ++it) { | 310 it != containers.end(); ++it) { |
309 aura::Window* window = *it; | 311 aura::Window* window = *it; |
310 ui::Layer* layer = window->layer(); | 312 ui::Layer* layer = window->layer(); |
311 EXPECT_EQ(1.0f, layer->opacity()); | 313 EXPECT_EQ(1.0f, layer->opacity()); |
312 EXPECT_EQ(0.0f, layer->layer_brightness()); | 314 EXPECT_EQ(0.0f, layer->layer_brightness()); |
313 EXPECT_EQ(0.0f, layer->layer_saturation()); | 315 EXPECT_EQ(0.0f, layer->layer_saturation()); |
314 EXPECT_EQ(gfx::Transform(), layer->transform()); | 316 EXPECT_EQ(gfx::Transform(), layer->transform()); |
315 } | 317 } |
316 } | 318 } |
317 | 319 |
318 void PressPowerButton() { | 320 void PressPowerButton() { |
319 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 321 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
320 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 322 // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
321 } | 323 } |
322 | 324 |
323 void ReleasePowerButton() { | 325 void ReleasePowerButton() { |
324 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); | 326 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); |
325 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 327 // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
326 } | 328 } |
327 | 329 |
328 void PressLockButton() { | 330 void PressLockButton() { |
329 controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); | 331 controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); |
330 } | 332 } |
331 | 333 |
332 void ReleaseLockButton() { | 334 void ReleaseLockButton() { |
333 controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); | 335 controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); |
334 } | 336 } |
335 | 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 | |
336 void SystemLocks() { | 346 void SystemLocks() { |
337 lock_state_controller_->OnLockStateChanged(true); | 347 lock_state_controller_->OnLockStateChanged(true); |
338 session_state_delegate_->LockScreen(); | 348 session_state_delegate_->LockScreen(); |
339 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 349 // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
340 } | 350 } |
341 | 351 |
342 void SuccessfulAuthentication(bool* call_flag) { | 352 void SuccessfulAuthentication(bool* call_flag) { |
343 base::Closure closure = base::Bind(&CheckCalledCallback, call_flag); | 353 base::Closure closure = base::Bind(&CheckCalledCallback, call_flag); |
344 lock_state_controller_->OnLockScreenHide(closure); | 354 lock_state_controller_->OnLockScreenHide(closure); |
345 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 355 // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
346 } | 356 } |
347 | 357 |
348 void SystemUnlocks() { | 358 void SystemUnlocks() { |
349 lock_state_controller_->OnLockStateChanged(false); | 359 lock_state_controller_->OnLockStateChanged(false); |
350 session_state_delegate_->UnlockScreen(); | 360 session_state_delegate_->UnlockScreen(); |
351 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 361 // TODO(antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
362 } | |
363 | |
364 void EnableMaximizeMode(bool enable) { | |
365 Shell::GetInstance()->maximize_mode_controller()-> | |
366 EnableMaximizeModeWindowManager(enable); | |
352 } | 367 } |
353 | 368 |
354 void Initialize(bool legacy_button, user::LoginStatus status) { | 369 void Initialize(bool legacy_button, user::LoginStatus status) { |
355 controller_->set_has_legacy_power_button_for_test(legacy_button); | 370 controller_->set_has_legacy_power_button_for_test(legacy_button); |
356 lock_state_controller_->OnLoginStateChanged(status); | 371 lock_state_controller_->OnLoginStateChanged(status); |
357 SetUserLoggedIn(status != user::LOGGED_IN_NONE); | 372 SetUserLoggedIn(status != user::LOGGED_IN_NONE); |
358 if (status == user::LOGGED_IN_GUEST) | 373 if (status == user::LOGGED_IN_GUEST) |
359 SetCanLockScreen(false); | 374 SetCanLockScreen(false); |
360 lock_state_controller_->OnLockStateChanged(false); | 375 lock_state_controller_->OnLockStateChanged(false); |
361 } | 376 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
410 EXPECT_FALSE(test_api_->is_lock_cancellable()); | 425 EXPECT_FALSE(test_api_->is_lock_cancellable()); |
411 | 426 |
412 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 427 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
413 | 428 |
414 ExpectPreLockAnimationFinished(); | 429 ExpectPreLockAnimationFinished(); |
415 EXPECT_EQ(1, delegate_->num_lock_requests()); | 430 EXPECT_EQ(1, delegate_->num_lock_requests()); |
416 | 431 |
417 // Notify that we locked successfully. | 432 // Notify that we locked successfully. |
418 lock_state_controller_->OnStartingLock(); | 433 lock_state_controller_->OnStartingLock(); |
419 // We had that animation already. | 434 // We had that animation already. |
420 //TODO (antrim) : restore | 435 // TODO(antrim) : restore |
421 // EXPECT_FALSE(animator_helper_->IsAnimating()); | 436 // EXPECT_FALSE(animator_helper_->IsAnimating()); |
422 | 437 |
423 SystemLocks(); | 438 SystemLocks(); |
424 | 439 |
425 ExpectPostLockAnimationStarted(); | 440 ExpectPostLockAnimationStarted(); |
426 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 441 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
427 ExpectPastLockAnimationFinished(); | 442 ExpectPastLockAnimationFinished(); |
428 | 443 |
429 // We shouldn't progress towards the shutdown state, however. | 444 // We shouldn't progress towards the shutdown state, however. |
430 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); | 445 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
525 EXPECT_EQ(0, delegate_->num_lock_requests()); | 540 EXPECT_EQ(0, delegate_->num_lock_requests()); |
526 | 541 |
527 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); | 542 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
528 ExpectPreLockAnimationFinished(); | 543 ExpectPreLockAnimationFinished(); |
529 | 544 |
530 EXPECT_EQ(1, delegate_->num_lock_requests()); | 545 EXPECT_EQ(1, delegate_->num_lock_requests()); |
531 | 546 |
532 // Notify that we locked successfully. | 547 // Notify that we locked successfully. |
533 lock_state_controller_->OnStartingLock(); | 548 lock_state_controller_->OnStartingLock(); |
534 // We had that animation already. | 549 // We had that animation already. |
535 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 550 // TODO(antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
536 | 551 |
537 SystemLocks(); | 552 SystemLocks(); |
538 | 553 |
539 ExpectPostLockAnimationStarted(); | 554 ExpectPostLockAnimationStarted(); |
540 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 555 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
541 ExpectPastLockAnimationFinished(); | 556 ExpectPastLockAnimationFinished(); |
542 | 557 |
543 // When we release the power button, the lock-to-shutdown timer should be | 558 // When we release the power button, the lock-to-shutdown timer should be |
544 // stopped. | 559 // stopped. |
545 ExpectLockedState(); | 560 ExpectLockedState(); |
(...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1082 ExpectBackgroundIsHiding(); | 1097 ExpectBackgroundIsHiding(); |
1083 EXPECT_FALSE(IsBackgroundHidden()); | 1098 EXPECT_FALSE(IsBackgroundHidden()); |
1084 | 1099 |
1085 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 1100 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
1086 ExpectUnlockAfterUIDestroyedAnimationFinished(); | 1101 ExpectUnlockAfterUIDestroyedAnimationFinished(); |
1087 EXPECT_TRUE(IsBackgroundHidden()); | 1102 EXPECT_TRUE(IsBackgroundHidden()); |
1088 | 1103 |
1089 ExpectUnlockedState(); | 1104 ExpectUnlockedState(); |
1090 } | 1105 } |
1091 | 1106 |
1107 // Tests that a screenshot can be taken by holding volume down and | |
1108 // pressing power. | |
1109 TEST_F(LockStateControllerTest, Screenshot) { | |
1110 Shell::GetInstance()->lock_state_controller()->SetDelegate( | |
1111 new test::TestLockStateControllerDelegate); | |
1112 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); | |
1113 delegate->set_can_take_screenshot(true); | |
1114 | |
1115 // Pressing power alone does not take a screenshot. | |
1116 PressPowerButton(); | |
1117 ReleasePowerButton(); | |
1118 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); | |
1119 | |
1120 // Press & release volume then pressing power does not take a screenshot. | |
1121 ASSERT_EQ(0, delegate->handle_take_screenshot_count()); | |
1122 PressVolumeDown(); | |
1123 ReleaseVolumeDown(); | |
1124 PressPowerButton(); | |
1125 ReleasePowerButton(); | |
1126 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); | |
1127 | |
1128 // Pressing power and then volume does not take a screenshot. | |
1129 ASSERT_EQ(0, delegate->handle_take_screenshot_count()); | |
1130 PressPowerButton(); | |
1131 ReleasePowerButton(); | |
1132 PressVolumeDown(); | |
1133 ReleaseVolumeDown(); | |
1134 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); | |
1135 | |
1136 // Holding volume down and pressing power takes a screenshot. | |
1137 ASSERT_EQ(0, delegate->handle_take_screenshot_count()); | |
1138 PressVolumeDown(); | |
1139 PressPowerButton(); | |
1140 ReleasePowerButton(); | |
1141 ReleaseVolumeDown(); | |
1142 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); | |
1143 } | |
1144 | |
1145 // Tests that a lock action is cancellable when quick lock is turned on and | |
1146 // maximize mode is not active. | |
1147 TEST_F(LockStateControllerTest, QuickLockWhileNotInMaximizeMode) { | |
1148 Initialize(false, user::LOGGED_IN_USER); | |
1149 controller_->set_enable_quick_lock_for_test(true); | |
1150 | |
1151 PressPowerButton(); | |
1152 | |
1153 EXPECT_TRUE(test_api_->is_animating_lock()); | |
1154 EXPECT_TRUE(lock_state_controller_->CanCancelLockAnimation()); | |
1155 | |
1156 ReleasePowerButton(); | |
1157 } | |
1158 | |
1159 // Tests that a lock action is not cancellable when quick lock is turned on and | |
1160 // maximize mode is active. | |
1161 TEST_F(LockStateControllerTest, QuickLockWhileInMaximizeMode) { | |
1162 Initialize(false, user::LOGGED_IN_USER); | |
1163 controller_->set_enable_quick_lock_for_test(true); | |
1164 EnableMaximizeMode(true); | |
1165 | |
1166 PressPowerButton(); | |
1167 | |
1168 EXPECT_TRUE(test_api_->is_animating_lock()); | |
1169 EXPECT_FALSE(lock_state_controller_->CanCancelLockAnimation()); | |
1170 | |
1171 ReleasePowerButton(); | |
1172 } | |
1173 | |
1092 } // namespace test | 1174 } // namespace test |
1093 } // namespace ash | 1175 } // namespace ash |
OLD | NEW |