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

Side by Side Diff: ash/wm/session_state_controller_impl2_unittest.cc

Issue 14295008: Add ash SessionStateDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 7 years, 8 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
« no previous file with comments | « ash/wm/power_button_controller_unittest.cc ('k') | ash/wm/stacking_controller.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/session_state_controller_impl2.h" 5 #include "ash/wm/session_state_controller_impl2.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.h"
8 #include "ash/session_state_delegate.h"
8 #include "ash/shell.h" 9 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h" 10 #include "ash/shell_window_ids.h"
10 #include "ash/test/ash_test_base.h" 11 #include "ash/test/ash_test_base.h"
11 #include "ash/test/test_shell_delegate.h" 12 #include "ash/test/test_shell_delegate.h"
12 #include "ash/wm/power_button_controller.h" 13 #include "ash/wm/power_button_controller.h"
13 #include "ash/wm/session_state_animator.h" 14 #include "ash/wm/session_state_animator.h"
14 #include "ash/wm/session_state_controller.h" 15 #include "ash/wm/session_state_controller.h"
15 #include "base/command_line.h" 16 #include "base/command_line.h"
16 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
17 #include "base/time.h" 18 #include "base/time.h"
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 state_controller_ = static_cast<SessionStateControllerImpl2*>( 131 state_controller_ = static_cast<SessionStateControllerImpl2*>(
131 Shell::GetInstance()->session_state_controller()); 132 Shell::GetInstance()->session_state_controller());
132 state_controller_->SetDelegate(delegate_); // transfers ownership 133 state_controller_->SetDelegate(delegate_); // transfers ownership
133 test_api_.reset( 134 test_api_.reset(
134 new SessionStateControllerImpl2::TestApi(state_controller_)); 135 new SessionStateControllerImpl2::TestApi(state_controller_));
135 animator_api_.reset( 136 animator_api_.reset(
136 new SessionStateAnimator::TestApi(state_controller_-> 137 new SessionStateAnimator::TestApi(state_controller_->
137 animator_.get())); 138 animator_.get()));
138 shell_delegate_ = reinterpret_cast<TestShellDelegate*>( 139 shell_delegate_ = reinterpret_cast<TestShellDelegate*>(
139 ash::Shell::GetInstance()->delegate()); 140 ash::Shell::GetInstance()->delegate());
141 state_delegate_ = Shell::GetInstance()->session_state_delegate();
140 } 142 }
141 143
142 virtual void TearDown() { 144 virtual void TearDown() {
143 // TODO(antrim) : restore 145 // TODO(antrim) : restore
144 // animator_helper_->AdvanceUntilDone(); 146 // animator_helper_->AdvanceUntilDone();
145 AshTestBase::TearDown(); 147 AshTestBase::TearDown();
146 } 148 }
147 149
148 protected: 150 protected:
149 void GenerateMouseMoveEvent() { 151 void GenerateMouseMoveEvent() {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 void ExpectBackgroundIsHiding() { 305 void ExpectBackgroundIsHiding() {
304 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); 306 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating());
305 EXPECT_TRUE( 307 EXPECT_TRUE(
306 animator_api_->ContainersAreAnimated( 308 animator_api_->ContainersAreAnimated(
307 SessionStateAnimator::DESKTOP_BACKGROUND, 309 SessionStateAnimator::DESKTOP_BACKGROUND,
308 SessionStateAnimator::ANIMATION_FADE_OUT)); 310 SessionStateAnimator::ANIMATION_FADE_OUT));
309 } 311 }
310 312
311 void ExpectUnlockedState() { 313 void ExpectUnlockedState() {
312 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); 314 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
313 EXPECT_FALSE(shell_delegate_->IsScreenLocked()); 315 EXPECT_FALSE(state_delegate_->IsScreenLocked());
314 316
315 aura::Window::Windows containers; 317 aura::Window::Windows containers;
316 318
317 SessionStateAnimator::GetContainers( 319 SessionStateAnimator::GetContainers(
318 SessionStateAnimator::LAUNCHER | 320 SessionStateAnimator::LAUNCHER |
319 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, 321 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS,
320 &containers); 322 &containers);
321 for (aura::Window::Windows::const_iterator it = containers.begin(); 323 for (aura::Window::Windows::const_iterator it = containers.begin();
322 it != containers.end(); ++it) { 324 it != containers.end(); ++it) {
323 aura::Window* window = *it; 325 aura::Window* window = *it;
324 ui::Layer* layer = window->layer(); 326 ui::Layer* layer = window->layer();
325 EXPECT_EQ(1.0f, layer->opacity()); 327 EXPECT_EQ(1.0f, layer->opacity());
326 EXPECT_EQ(0.0f, layer->layer_brightness()); 328 EXPECT_EQ(0.0f, layer->layer_brightness());
327 EXPECT_EQ(0.0f, layer->layer_saturation()); 329 EXPECT_EQ(0.0f, layer->layer_saturation());
328 EXPECT_EQ(gfx::Transform(), layer->transform()); 330 EXPECT_EQ(gfx::Transform(), layer->transform());
329 } 331 }
330 } 332 }
331 333
332 void ExpectLockedState() { 334 void ExpectLockedState() {
333 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); 335 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating());
334 EXPECT_TRUE(shell_delegate_->IsScreenLocked()); 336 EXPECT_TRUE(state_delegate_->IsScreenLocked());
335 337
336 aura::Window::Windows containers; 338 aura::Window::Windows containers;
337 339
338 SessionStateAnimator::GetContainers( 340 SessionStateAnimator::GetContainers(
339 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS | 341 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS |
340 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, 342 SessionStateAnimator::LOCK_SCREEN_CONTAINERS,
341 &containers); 343 &containers);
342 for (aura::Window::Windows::const_iterator it = containers.begin(); 344 for (aura::Window::Windows::const_iterator it = containers.begin();
343 it != containers.end(); ++it) { 345 it != containers.end(); ++it) {
344 aura::Window* window = *it; 346 aura::Window* window = *it;
(...skipping 18 matching lines...) Expand all
363 void PressLockButton() { 365 void PressLockButton() {
364 controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); 366 controller_->OnLockButtonEvent(true, base::TimeTicks::Now());
365 } 367 }
366 368
367 void ReleaseLockButton() { 369 void ReleaseLockButton() {
368 controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); 370 controller_->OnLockButtonEvent(false, base::TimeTicks::Now());
369 } 371 }
370 372
371 void SystemLocks() { 373 void SystemLocks() {
372 state_controller_->OnLockStateChanged(true); 374 state_controller_->OnLockStateChanged(true);
373 shell_delegate_->LockScreen(); 375 state_delegate_->LockScreen();
374 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); 376 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta());
375 } 377 }
376 378
377 void SuccessfulAuthentication(bool* call_flag) { 379 void SuccessfulAuthentication(bool* call_flag) {
378 base::Closure closure = base::Bind(&CheckCalledCallback, call_flag); 380 base::Closure closure = base::Bind(&CheckCalledCallback, call_flag);
379 state_controller_->OnLockScreenHide(closure); 381 state_controller_->OnLockScreenHide(closure);
380 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); 382 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta());
381 } 383 }
382 384
383 void SystemUnlocks() { 385 void SystemUnlocks() {
384 state_controller_->OnLockStateChanged(false); 386 state_controller_->OnLockStateChanged(false);
385 shell_delegate_->UnlockScreen(); 387 state_delegate_->UnlockScreen();
386 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); 388 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta());
387 } 389 }
388 390
389 void Initialize(bool legacy_button, user::LoginStatus status) { 391 void Initialize(bool legacy_button, user::LoginStatus status) {
390 controller_->set_has_legacy_power_button_for_test(legacy_button); 392 controller_->set_has_legacy_power_button_for_test(legacy_button);
391 state_controller_->OnLoginStateChanged(status); 393 state_controller_->OnLoginStateChanged(status);
392 SetUserLoggedIn(status != user::LOGGED_IN_NONE); 394 SetUserLoggedIn(status != user::LOGGED_IN_NONE);
393 if (status == user::LOGGED_IN_GUEST) 395 if (status == user::LOGGED_IN_GUEST)
394 SetCanLockScreen(false); 396 SetCanLockScreen(false);
395 state_controller_->OnLockStateChanged(false); 397 state_controller_->OnLockStateChanged(false);
396 } 398 }
397 399
398 PowerButtonController* controller_; // not owned 400 PowerButtonController* controller_; // not owned
399 SessionStateControllerImpl2* state_controller_; // not owned 401 SessionStateControllerImpl2* state_controller_; // not owned
400 TestSessionStateControllerDelegate* delegate_; // not owned 402 TestSessionStateControllerDelegate* delegate_; // not owned
401 TestShellDelegate* shell_delegate_; // not owned 403 TestShellDelegate* shell_delegate_; // not owned
404 SessionStateDelegate* state_delegate_; // not owned
402 405
403 scoped_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration_mode_; 406 scoped_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration_mode_;
404 scoped_ptr<SessionStateControllerImpl2::TestApi> test_api_; 407 scoped_ptr<SessionStateControllerImpl2::TestApi> test_api_;
405 scoped_ptr<SessionStateAnimator::TestApi> animator_api_; 408 scoped_ptr<SessionStateAnimator::TestApi> animator_api_;
406 // TODO(antrim) : restore 409 // TODO(antrim) : restore
407 // scoped_ptr<ui::test::AnimationContainerTestHelper> animator_helper_; 410 // scoped_ptr<ui::test::AnimationContainerTestHelper> animator_helper_;
408 411
409 private: 412 private:
410 DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl2Test); 413 DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl2Test);
411 }; 414 };
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 1063
1061 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); 1064 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS);
1062 ExpectUnlockAfterUIDestroyedAnimationFinished(); 1065 ExpectUnlockAfterUIDestroyedAnimationFinished();
1063 EXPECT_TRUE(IsBackgroundHidden()); 1066 EXPECT_TRUE(IsBackgroundHidden());
1064 1067
1065 ExpectUnlockedState(); 1068 ExpectUnlockedState();
1066 } 1069 }
1067 1070
1068 } // namespace test 1071 } // namespace test
1069 } // namespace ash 1072 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/power_button_controller_unittest.cc ('k') | ash/wm/stacking_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698