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

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: comments from ps2 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
« no previous file with comments | « ash/system/chromeos/power/tablet_power_button_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 repeated power button releases are ignored (crbug.com/675291).
443 TEST_F(TabletPowerButtonControllerTest, IgnoreRepeatedPowerButtonReleases) {
444 // Advance a long duration from initialized last resume time in
445 // |tablet_controller_| to avoid cross interference.
446 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(2000));
447
448 // Set backlights forced off for starting point.
449 PressPowerButton();
450 ReleasePowerButton();
451 power_manager_client_->SendBrightnessChanged(0, false);
452 EXPECT_TRUE(GetBacklightsForcedOff());
453
454 // Test that a pressing-releasing operation after a short duration, backlights
455 // forced off is stopped since we don't drop request for power button pressed.
456 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
457 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks());
458 power_manager_client_->SendBrightnessChanged(kNonZeroBrightness, false);
459 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks());
460 EXPECT_FALSE(GetBacklightsForcedOff());
461
462 // Test that after another short duration, backlights will not be forced off
463 // since this immediately following forcing off request needs to be dropped.
464 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(200));
465 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks());
466 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks());
467 EXPECT_FALSE(GetBacklightsForcedOff());
468
469 // Test that after another long duration, backlights should be forced off.
470 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(800));
471 power_manager_client_->SendPowerButtonEvent(true, tick_clock_->NowTicks());
472 power_manager_client_->SendPowerButtonEvent(false, tick_clock_->NowTicks());
473 power_manager_client_->SendBrightnessChanged(0, false);
474 EXPECT_TRUE(GetBacklightsForcedOff());
475 }
476
442 } // namespace test 477 } // namespace test
443 } // namespace ash 478 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/power/tablet_power_button_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698