| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 | 306 |
| 307 // Synthesized mouse event should not SetBacklightsForcedOff(false). | 307 // Synthesized mouse event should not SetBacklightsForcedOff(false). |
| 308 PressPowerButton(); | 308 PressPowerButton(); |
| 309 ReleasePowerButton(); | 309 ReleasePowerButton(); |
| 310 power_manager_client_->SendBrightnessChanged(0, false); | 310 power_manager_client_->SendBrightnessChanged(0, false); |
| 311 EXPECT_TRUE(GetBacklightsForcedOff()); | 311 EXPECT_TRUE(GetBacklightsForcedOff()); |
| 312 generator_->set_flags(ui::EF_IS_SYNTHESIZED); | 312 generator_->set_flags(ui::EF_IS_SYNTHESIZED); |
| 313 generator_->MoveMouseBy(1, 1); | 313 generator_->MoveMouseBy(1, 1); |
| 314 generator_->set_flags(ui::EF_NONE); | 314 generator_->set_flags(ui::EF_NONE); |
| 315 EXPECT_TRUE(GetBacklightsForcedOff()); | 315 EXPECT_TRUE(GetBacklightsForcedOff()); |
| 316 | |
| 317 // Stylus event should not SetBacklightsForcedOff(false). | |
| 318 EXPECT_TRUE(GetBacklightsForcedOff()); | |
| 319 generator_->EnterPenPointerMode(); | |
| 320 generator_->PressTouch(); | |
| 321 generator_->MoveTouch(gfx::Point(1, 1)); | |
| 322 generator_->ReleaseTouch(); | |
| 323 EXPECT_TRUE(GetBacklightsForcedOff()); | |
| 324 generator_->ExitPenPointerMode(); | |
| 325 } | 316 } |
| 326 | 317 |
| 327 // For convertible device working on tablet mode, keyboard/mouse event should | 318 // For convertible device working on tablet mode, keyboard/mouse event should |
| 328 // not SetBacklightsForcedOff(false) when screen is off. | 319 // not SetBacklightsForcedOff(false) when screen is off. |
| 329 TEST_F(TabletPowerButtonControllerTest, ConvertibleOnMaximizeMode) { | 320 TEST_F(TabletPowerButtonControllerTest, ConvertibleOnMaximizeMode) { |
| 330 EnableMaximizeMode(true); | 321 EnableMaximizeMode(true); |
| 331 | 322 |
| 332 PressPowerButton(); | 323 PressPowerButton(); |
| 333 ReleasePowerButton(); | 324 ReleasePowerButton(); |
| 334 power_manager_client_->SendBrightnessChanged(0, false); | 325 power_manager_client_->SendBrightnessChanged(0, false); |
| 335 EXPECT_TRUE(GetBacklightsForcedOff()); | 326 EXPECT_TRUE(GetBacklightsForcedOff()); |
| 336 generator_->PressKey(ui::VKEY_L, ui::EF_NONE); | 327 generator_->PressKey(ui::VKEY_L, ui::EF_NONE); |
| 337 EXPECT_TRUE(GetBacklightsForcedOff()); | 328 EXPECT_TRUE(GetBacklightsForcedOff()); |
| 338 | 329 |
| 339 generator_->MoveMouseBy(1, 1); | 330 generator_->MoveMouseBy(1, 1); |
| 340 EXPECT_TRUE(GetBacklightsForcedOff()); | 331 EXPECT_TRUE(GetBacklightsForcedOff()); |
| 341 | |
| 342 generator_->EnterPenPointerMode(); | |
| 343 generator_->MoveMouseBy(1, 1); | |
| 344 EXPECT_TRUE(GetBacklightsForcedOff()); | |
| 345 generator_->ExitPenPointerMode(); | |
| 346 } | 332 } |
| 347 | 333 |
| 348 // Tests that a single set of power button pressed-and-released operation should | 334 // Tests that a single set of power button pressed-and-released operation should |
| 349 // cause only one SetBacklightsForcedOff call. | 335 // cause only one SetBacklightsForcedOff call. |
| 350 TEST_F(TabletPowerButtonControllerTest, IgnorePowerOnKeyEvent) { | 336 TEST_F(TabletPowerButtonControllerTest, IgnorePowerOnKeyEvent) { |
| 351 ui::KeyEvent power_key_pressed(ui::ET_KEY_PRESSED, ui::VKEY_POWER, | 337 ui::KeyEvent power_key_pressed(ui::ET_KEY_PRESSED, ui::VKEY_POWER, |
| 352 ui::EF_NONE); | 338 ui::EF_NONE); |
| 353 ui::KeyEvent power_key_released(ui::ET_KEY_RELEASED, ui::VKEY_POWER, | 339 ui::KeyEvent power_key_released(ui::ET_KEY_RELEASED, ui::VKEY_POWER, |
| 354 ui::EF_NONE); | 340 ui::EF_NONE); |
| 355 | 341 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 tablet_controller_->OnMaximizeModeEnded(); | 434 tablet_controller_->OnMaximizeModeEnded(); |
| 449 EXPECT_FALSE(lock_state_test_api_->shutdown_timer_is_running()); | 435 EXPECT_FALSE(lock_state_test_api_->shutdown_timer_is_running()); |
| 450 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(4500)); | 436 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(4500)); |
| 451 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); | 437 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); |
| 452 EXPECT_FALSE(GetLockedState()); | 438 EXPECT_FALSE(GetLockedState()); |
| 453 EXPECT_FALSE(GetBacklightsForcedOff()); | 439 EXPECT_FALSE(GetBacklightsForcedOff()); |
| 454 } | 440 } |
| 455 | 441 |
| 456 } // namespace test | 442 } // namespace test |
| 457 } // namespace ash | 443 } // namespace ash |
| OLD | NEW |