OLD | NEW |
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 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::GetRootWindow()->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::GetRootWindow()->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. |
| 543 TEST_F(PowerButtonControllerTest, IgnorePowerButtonIfScreenIsOff) { |
| 544 controller_->OnLoginStateChanged(user::LOGGED_IN_USER); |
| 545 |
| 546 // When the screen brightness is at 0%, we shouldn't do anything in response |
| 547 // to power button presses. |
| 548 controller_->OnScreenBrightnessChanged(0.0); |
| 549 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
| 550 EXPECT_FALSE(test_api_->lock_timer_is_running()); |
| 551 |
| 552 // After increasing the brightness to 10%, we should start the timer like |
| 553 // usual. |
| 554 controller_->OnScreenBrightnessChanged(10.0); |
| 555 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
| 556 EXPECT_TRUE(test_api_->lock_timer_is_running()); |
| 557 } |
| 558 |
542 } // namespace test | 559 } // namespace test |
543 } // namespace ash | 560 } // namespace ash |
OLD | NEW |