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

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

Issue 10442017: Rename GetRootWindow() -> GetPrimaryRootWindow() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: git-try -b linux_chromeos,win_aura Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « ash/wm/power_button_controller.cc ('k') | ash/wm/root_window_event_filter_unittest.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/power_button_controller.h" 5 #include "ash/wm/power_button_controller.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); 107 EXPECT_FALSE(test_api_->shutdown_timer_is_running());
108 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); 108 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now());
109 109
110 // Hold the button again and check that we start shutting down. 110 // Hold the button again and check that we start shutting down.
111 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); 111 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
112 EXPECT_EQ(0, delegate_->num_shutdown_requests()); 112 EXPECT_EQ(0, delegate_->num_shutdown_requests());
113 EXPECT_TRUE( 113 EXPECT_TRUE(
114 test_api_->ContainerGroupIsAnimated( 114 test_api_->ContainerGroupIsAnimated(
115 PowerButtonController::ALL_CONTAINERS, 115 PowerButtonController::ALL_CONTAINERS,
116 PowerButtonController::ANIMATION_FAST_CLOSE)); 116 PowerButtonController::ANIMATION_FAST_CLOSE));
117 EXPECT_FALSE(Shell::GetRootWindow()->cursor_shown()); 117 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->cursor_shown());
118 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); 118 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
119 test_api_->trigger_real_shutdown_timeout(); 119 test_api_->trigger_real_shutdown_timeout();
120 EXPECT_EQ(1, delegate_->num_shutdown_requests()); 120 EXPECT_EQ(1, delegate_->num_shutdown_requests());
121 } 121 }
122 122
123 // Test that we start shutting down immediately if the power button is pressed 123 // Test that we start shutting down immediately if the power button is pressed
124 // while we're not logged in on an unofficial system. 124 // while we're not logged in on an unofficial system.
125 TEST_F(PowerButtonControllerTest, LegacyNotLoggedIn) { 125 TEST_F(PowerButtonControllerTest, LegacyNotLoggedIn) {
126 controller_->set_has_legacy_power_button_for_test(true); 126 controller_->set_has_legacy_power_button_for_test(true);
127 controller_->OnLoginStateChanged(user::LOGGED_IN_NONE); 127 controller_->OnLoginStateChanged(user::LOGGED_IN_NONE);
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 // When we hear that the process is exiting but we haven't had a chance to 474 // When we hear that the process is exiting but we haven't had a chance to
475 // display an animation, we should just blank the screen. 475 // display an animation, we should just blank the screen.
476 TEST_F(PowerButtonControllerTest, ShutdownWithoutButton) { 476 TEST_F(PowerButtonControllerTest, ShutdownWithoutButton) {
477 controller_->OnLoginStateChanged(user::LOGGED_IN_USER); 477 controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
478 controller_->OnAppTerminating(); 478 controller_->OnAppTerminating();
479 EXPECT_TRUE( 479 EXPECT_TRUE(
480 test_api_->ContainerGroupIsAnimated( 480 test_api_->ContainerGroupIsAnimated(
481 PowerButtonController::ALL_CONTAINERS, 481 PowerButtonController::ALL_CONTAINERS,
482 PowerButtonController::ANIMATION_HIDE)); 482 PowerButtonController::ANIMATION_HIDE));
483 EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); 483 EXPECT_TRUE(test_api_->BackgroundLayerIsVisible());
484 EXPECT_FALSE(Shell::GetRootWindow()->cursor_shown()); 484 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->cursor_shown());
485 } 485 }
486 486
487 // Test that we display the fast-close animation and shut down when we get an 487 // Test that we display the fast-close animation and shut down when we get an
488 // outside request to shut down (e.g. from the login or lock screen). 488 // outside request to shut down (e.g. from the login or lock screen).
489 TEST_F(PowerButtonControllerTest, RequestShutdownFromLoginScreen) { 489 TEST_F(PowerButtonControllerTest, RequestShutdownFromLoginScreen) {
490 controller_->OnLoginStateChanged(user::LOGGED_IN_NONE); 490 controller_->OnLoginStateChanged(user::LOGGED_IN_NONE);
491 controller_->RequestShutdown(); 491 controller_->RequestShutdown();
492 EXPECT_TRUE( 492 EXPECT_TRUE(
493 test_api_->ContainerGroupIsAnimated( 493 test_api_->ContainerGroupIsAnimated(
494 PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, 494 PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
495 PowerButtonController::ANIMATION_HIDE)); 495 PowerButtonController::ANIMATION_HIDE));
496 EXPECT_TRUE( 496 EXPECT_TRUE(
497 test_api_->ContainerGroupIsAnimated( 497 test_api_->ContainerGroupIsAnimated(
498 PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS, 498 PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS,
499 PowerButtonController::ANIMATION_FAST_CLOSE)); 499 PowerButtonController::ANIMATION_FAST_CLOSE));
500 EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); 500 EXPECT_TRUE(test_api_->BackgroundLayerIsVisible());
501 EXPECT_FALSE(Shell::GetRootWindow()->cursor_shown()); 501 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->cursor_shown());
502 502
503 EXPECT_EQ(0, delegate_->num_shutdown_requests()); 503 EXPECT_EQ(0, delegate_->num_shutdown_requests());
504 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); 504 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
505 test_api_->trigger_real_shutdown_timeout(); 505 test_api_->trigger_real_shutdown_timeout();
506 EXPECT_EQ(1, delegate_->num_shutdown_requests()); 506 EXPECT_EQ(1, delegate_->num_shutdown_requests());
507 } 507 }
508 508
509 TEST_F(PowerButtonControllerTest, RequestShutdownFromLockScreen) { 509 TEST_F(PowerButtonControllerTest, RequestShutdownFromLockScreen) {
510 controller_->OnLoginStateChanged(user::LOGGED_IN_USER); 510 controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
511 controller_->OnLockStateChanged(true); 511 controller_->OnLockStateChanged(true);
512 controller_->RequestShutdown(); 512 controller_->RequestShutdown();
513 EXPECT_TRUE( 513 EXPECT_TRUE(
514 test_api_->ContainerGroupIsAnimated( 514 test_api_->ContainerGroupIsAnimated(
515 PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, 515 PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS,
516 PowerButtonController::ANIMATION_HIDE)); 516 PowerButtonController::ANIMATION_HIDE));
517 EXPECT_TRUE( 517 EXPECT_TRUE(
518 test_api_->ContainerGroupIsAnimated( 518 test_api_->ContainerGroupIsAnimated(
519 PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS, 519 PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS,
520 PowerButtonController::ANIMATION_FAST_CLOSE)); 520 PowerButtonController::ANIMATION_FAST_CLOSE));
521 EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); 521 EXPECT_TRUE(test_api_->BackgroundLayerIsVisible());
522 EXPECT_FALSE(Shell::GetRootWindow()->cursor_shown()); 522 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->cursor_shown());
523 523
524 EXPECT_EQ(0, delegate_->num_shutdown_requests()); 524 EXPECT_EQ(0, delegate_->num_shutdown_requests());
525 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); 525 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
526 test_api_->trigger_real_shutdown_timeout(); 526 test_api_->trigger_real_shutdown_timeout();
527 EXPECT_EQ(1, delegate_->num_shutdown_requests()); 527 EXPECT_EQ(1, delegate_->num_shutdown_requests());
528 } 528 }
529 529
530 // Test that the background layer is resized in response to root window resizes. 530 // Test that the background layer is resized in response to root window resizes.
531 TEST_F(PowerButtonControllerTest, ResizeBackgroundLayer) { 531 TEST_F(PowerButtonControllerTest, ResizeBackgroundLayer) {
532 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); 532 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
533 EXPECT_EQ(Shell::GetRootWindow()->bounds().ToString(), 533 EXPECT_EQ(Shell::GetPrimaryRootWindow()->bounds().ToString(),
534 test_api_->GetBackgroundLayerBounds().ToString()); 534 test_api_->GetBackgroundLayerBounds().ToString());
535 535
536 const gfx::Size kNewSize(400, 300); 536 const gfx::Size kNewSize(400, 300);
537 Shell::GetRootWindow()->SetHostSize(kNewSize); 537 Shell::GetPrimaryRootWindow()->SetHostSize(kNewSize);
538 EXPECT_EQ(gfx::Rect(kNewSize).ToString(), 538 EXPECT_EQ(gfx::Rect(kNewSize).ToString(),
539 test_api_->GetBackgroundLayerBounds().ToString()); 539 test_api_->GetBackgroundLayerBounds().ToString());
540 } 540 }
541 541
542 // Test that we ignore power button presses when the screen is turned off. 542 // Test that we ignore power button presses when the screen is turned off.
543 TEST_F(PowerButtonControllerTest, IgnorePowerButtonIfScreenIsOff) { 543 TEST_F(PowerButtonControllerTest, IgnorePowerButtonIfScreenIsOff) {
544 controller_->OnLoginStateChanged(user::LOGGED_IN_USER); 544 controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
545 545
546 // When the screen brightness is at 0%, we shouldn't do anything in response 546 // When the screen brightness is at 0%, we shouldn't do anything in response
547 // to power button presses. 547 // to power button presses.
548 controller_->OnScreenBrightnessChanged(0.0); 548 controller_->OnScreenBrightnessChanged(0.0);
549 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); 549 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
550 EXPECT_FALSE(test_api_->lock_timer_is_running()); 550 EXPECT_FALSE(test_api_->lock_timer_is_running());
551 551
552 // After increasing the brightness to 10%, we should start the timer like 552 // After increasing the brightness to 10%, we should start the timer like
553 // usual. 553 // usual.
554 controller_->OnScreenBrightnessChanged(10.0); 554 controller_->OnScreenBrightnessChanged(10.0);
555 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); 555 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
556 EXPECT_TRUE(test_api_->lock_timer_is_running()); 556 EXPECT_TRUE(test_api_->lock_timer_is_running());
557 } 557 }
558 558
559 } // namespace test 559 } // namespace test
560 } // namespace ash 560 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/power_button_controller.cc ('k') | ash/wm/root_window_event_filter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698