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

Side by Side Diff: ash/system/chromeos/power/tablet_power_button_controller_unittest.cc

Issue 2664683002: ash: Drop the immediately following power button released induced forcing off request (Closed)
Patch Set: better comments Created 3 years, 10 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
OLDNEW
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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 test_api_->TriggerShutdownTimeout(); 432 test_api_->TriggerShutdownTimeout();
433 EXPECT_TRUE(lock_state_test_api_->shutdown_timer_is_running()); 433 EXPECT_TRUE(lock_state_test_api_->shutdown_timer_is_running());
434 tablet_controller_->OnMaximizeModeEnded(); 434 tablet_controller_->OnMaximizeModeEnded();
435 EXPECT_FALSE(lock_state_test_api_->shutdown_timer_is_running()); 435 EXPECT_FALSE(lock_state_test_api_->shutdown_timer_is_running());
436 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(4500)); 436 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(4500));
437 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks()); 437 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks());
438 EXPECT_FALSE(GetLockedState()); 438 EXPECT_FALSE(GetLockedState());
439 EXPECT_FALSE(GetBacklightsForcedOff()); 439 EXPECT_FALSE(GetBacklightsForcedOff());
440 } 440 }
441 441
442 // Tests that the very adjacent power button released for forcing off needs to
Daniel Erat 2017/01/30 17:55:00 // Tests that repeated power button releases are i
Qiang(Joe) Xu 2017/01/30 19:35:44 Done.
443 // be dropped (crbug.com/675291).
444 TEST_F(TabletPowerButtonControllerTest, DropVeryAdjacentForcingOff) {
445 // Advance a long duration from initialized last resume time in
446 // |tablet_controller_| to avoid cross interference.
447 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(2000));
448
449 // Set backlights forced off for starting point.
450 PressPowerButton();
451 ReleasePowerButton();
452 power_manager_client_->SendBrightnessChanged(0, false);
453 EXPECT_TRUE(GetBacklightsForcedOff());
454
455 // Test that a pressing-releasing operation after a short duration, backlights
456 // forced off is stopped since we don't drop request for power button pressed.
457 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
458 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks());
459 power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false);
460 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks());
461 EXPECT_FALSE(GetBacklightsForcedOff());
462
463 // Test that after another short duration, backlights will not be forced off
464 // since this very adjacent forcing off request needs to be dropped.
Daniel Erat 2017/01/30 17:55:00 hmm. "adjacent" usually refers more to physical di
Qiang(Joe) Xu 2017/01/30 19:35:44 done by changed to "immediately following"
465 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
466 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks());
467 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks());
468 EXPECT_FALSE(GetBacklightsForcedOff());
469
470 // Test that after another long duration, backlights should be forced off.
471 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(800));
472 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks());
473 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks());
474 power_manager_client_->SendBrightnessChanged(0, false);
475 EXPECT_TRUE(GetBacklightsForcedOff());
476 }
477
442 } // namespace test 478 } // namespace test
443 } // namespace ash 479 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698