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/chromeos/power/tablet_power_button_controller.h" | 5 #include "ash/system/chromeos/power/tablet_power_button_controller.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/common/ash_switches.h" | 9 #include "ash/common/ash_switches.h" |
| 10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 // Tests tapping power button when device is suspended without backlights forced | 221 // Tests tapping power button when device is suspended without backlights forced |
| 222 // off. | 222 // off. |
| 223 TEST_F(TabletPowerButtonControllerTest, | 223 TEST_F(TabletPowerButtonControllerTest, |
| 224 TappingPowerButtonWhenSuspendedWithoutBacklightsForcedOff) { | 224 TappingPowerButtonWhenSuspendedWithoutBacklightsForcedOff) { |
| 225 power_manager_client_->SendSuspendImminent(); | 225 power_manager_client_->SendSuspendImminent(); |
| 226 power_manager_client_->SendBrightnessChanged(0, false); | 226 power_manager_client_->SendBrightnessChanged(0, false); |
| 227 // There is a power button pressed here, but PowerButtonEvent is sent later. | 227 // There is a power button pressed here, but PowerButtonEvent is sent later. |
| 228 power_manager_client_->SendSuspendDone(); | 228 power_manager_client_->SendSuspendDone(); |
| 229 power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false); | 229 power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false); |
| 230 | 230 |
| 231 // Send the power button event after a short delay and check that it is | 231 // Send the power button event after a short delay and check that backlights |
| 232 // ignored. | 232 // are not forced off. |
| 233 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(500)); | 233 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(500)); |
| 234 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks()); | 234 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks()); |
| 235 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); | 235 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); |
| 236 EXPECT_FALSE(GetBacklightsForcedOff()); | 236 EXPECT_FALSE(GetBacklightsForcedOff()); |
| 237 | 237 |
| 238 // Send the power button event after a longer delay and check that it is not | 238 // Send the power button event after a longer delay and check that backlights |
| 239 // ignored. | 239 // are forced off. |
| 240 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(1600)); | 240 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(1600)); |
| 241 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks()); | 241 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks()); |
| 242 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); | 242 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); |
| 243 power_manager_client_->SendBrightnessChanged(0, false); | 243 power_manager_client_->SendBrightnessChanged(0, false); |
| 244 EXPECT_TRUE(GetBacklightsForcedOff()); | 244 EXPECT_TRUE(GetBacklightsForcedOff()); |
| 245 } | 245 } |
| 246 | 246 |
| 247 // Tests tapping power button when device is suspended with backlights forced | 247 // Tests tapping power button when device is suspended with backlights forced |
| 248 // off. | 248 // off. |
| 249 TEST_F(TabletPowerButtonControllerTest, | 249 TEST_F(TabletPowerButtonControllerTest, |
| 250 TappingPowerButtonWhenSuspendedWithBacklightsForcedOff) { | 250 TappingPowerButtonWhenSuspendedWithBacklightsForcedOff) { |
| 251 PressPowerButton(); | 251 PressPowerButton(); |
| 252 ReleasePowerButton(); | 252 ReleasePowerButton(); |
| 253 power_manager_client_->SendBrightnessChanged(0, false); | 253 power_manager_client_->SendBrightnessChanged(0, false); |
| 254 EXPECT_TRUE(GetBacklightsForcedOff()); | 254 EXPECT_TRUE(GetBacklightsForcedOff()); |
| 255 power_manager_client_->SendSuspendImminent(); | 255 power_manager_client_->SendSuspendImminent(); |
| 256 // There is a power button pressed here, but PowerButtonEvent is sent later. | 256 // There is a power button pressed here, but PowerButtonEvent is sent later. |
| 257 // Because of backlights forced off, resuming system will not restore | 257 // Because of backlights forced off, resuming system will not restore |
| 258 // brightness. | 258 // brightness. |
| 259 power_manager_client_->SendSuspendDone(); | 259 power_manager_client_->SendSuspendDone(); |
| 260 | 260 |
| 261 // Send the power button event after a short delay and check that it is | 261 // Send the power button event after a short delay and check that backlights |
| 262 // ignored. But if backlights are forced off, stop forcing off. | 262 // are not forced off. |
| 263 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(500)); | 263 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(500)); |
| 264 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks()); | 264 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks()); |
| 265 power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false); | 265 power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false); |
| 266 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); | 266 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); |
| 267 EXPECT_FALSE(GetBacklightsForcedOff()); | 267 EXPECT_FALSE(GetBacklightsForcedOff()); |
| 268 | 268 |
| 269 // Send the power button event after a longer delay and check that it is not | 269 // Send the power button event after a longer delay and check that backlights |
| 270 // ignored. | 270 // are forced off. |
|
Daniel Erat
2016/12/05 17:26:00
it looks like you're only updating comments. can y
Qiang(Joe) Xu
2016/12/05 19:33:59
Done.
| |
| 271 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(1600)); | 271 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(1600)); |
| 272 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks()); | 272 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks()); |
| 273 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); | 273 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); |
| 274 power_manager_client_->SendBrightnessChanged(0, false); | 274 power_manager_client_->SendBrightnessChanged(0, false); |
| 275 EXPECT_TRUE(GetBacklightsForcedOff()); | 275 EXPECT_TRUE(GetBacklightsForcedOff()); |
| 276 } | 276 } |
| 277 | 277 |
| 278 // For convertible device working on laptop mode, tests keyboard/mouse event | 278 // For convertible device working on laptop mode, tests keyboard/mouse event |
| 279 // when screen is off. | 279 // when screen is off. |
| 280 TEST_F(TabletPowerButtonControllerTest, ConvertibleOnLaptopMode) { | 280 TEST_F(TabletPowerButtonControllerTest, ConvertibleOnLaptopMode) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 power_manager_client_->SendBrightnessChanged(0, false); | 393 power_manager_client_->SendBrightnessChanged(0, false); |
| 394 EXPECT_TRUE(GetBacklightsForcedOff()); | 394 EXPECT_TRUE(GetBacklightsForcedOff()); |
| 395 EXPECT_FALSE(shell_delegate_->IsTouchscreenEnabledInPrefs(true)); | 395 EXPECT_FALSE(shell_delegate_->IsTouchscreenEnabledInPrefs(true)); |
| 396 generator_->MoveMouseBy(1, 1); | 396 generator_->MoveMouseBy(1, 1); |
| 397 power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false); | 397 power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false); |
| 398 EXPECT_TRUE(shell_delegate_->IsTouchscreenEnabledInPrefs(true)); | 398 EXPECT_TRUE(shell_delegate_->IsTouchscreenEnabledInPrefs(true)); |
| 399 } | 399 } |
| 400 | 400 |
| 401 } // namespace test | 401 } // namespace test |
| 402 } // namespace ash | 402 } // namespace ash |
| OLD | NEW |