Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/system/power/tablet_power_button_controller.h" | 5 #include "ash/system/power/tablet_power_button_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/public/cpp/config.h" | 10 #include "ash/public/cpp/config.h" |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 477 EXPECT_FALSE(GetBacklightsForcedOff()); | 477 EXPECT_FALSE(GetBacklightsForcedOff()); |
| 478 | 478 |
| 479 // Test that after another long duration, backlights should be forced off. | 479 // Test that after another long duration, backlights should be forced off. |
| 480 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(800)); | 480 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(800)); |
| 481 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks()); | 481 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks()); |
| 482 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); | 482 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); |
| 483 power_manager_client_->SendBrightnessChanged(0, false); | 483 power_manager_client_->SendBrightnessChanged(0, false); |
| 484 EXPECT_TRUE(GetBacklightsForcedOff()); | 484 EXPECT_TRUE(GetBacklightsForcedOff()); |
| 485 } | 485 } |
| 486 | 486 |
| 487 // Tests that lid closed/open events stop forcing off backlights. | |
| 488 TEST_F(TabletPowerButtonControllerTest, LidEventsStopForcingOff) { | |
| 489 // Pressing/releasing power button to set backlights forced off. | |
| 490 PressPowerButton(); | |
| 491 ReleasePowerButton(); | |
| 492 ASSERT_TRUE(GetBacklightsForcedOff()); | |
| 493 | |
| 494 // A lid closed event is received, we should stop forcing off backlights. | |
| 495 power_manager_client_->SetLidState( | |
| 496 chromeos::PowerManagerClient::LidState::CLOSED, tick_clock_->NowTicks()); | |
| 497 EXPECT_FALSE(GetBacklightsForcedOff()); | |
| 498 | |
| 499 // Pressing/releasing power button again to set backlights forced off. This is | |
| 500 // for testing purpose. In real life, powerd would not repond to this event | |
| 501 // with lid closed state. | |
| 502 PressPowerButton(); | |
| 503 ReleasePowerButton(); | |
| 504 ASSERT_TRUE(GetBacklightsForcedOff()); | |
| 505 | |
| 506 // A lid open event is received, we should get stopped forcing off backlights. | |
|
Daniel Erat
2017/04/13 05:10:03
nit: s/get stopped/stop/
Qiang(Joe) Xu
2017/04/13 17:08:47
Done.
| |
| 507 power_manager_client_->SetLidState( | |
| 508 chromeos::PowerManagerClient::LidState::OPEN, tick_clock_->NowTicks()); | |
| 509 EXPECT_FALSE(GetBacklightsForcedOff()); | |
| 510 } | |
| 511 | |
| 487 } // namespace test | 512 } // namespace test |
| 488 } // namespace ash | 513 } // namespace ash |
| OLD | NEW |