Commit 68704c3a authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Move test method from PowerManagerClient to FakePowerManagerClient

Bug: 644348
Change-Id: I420883c7ce6e61783fd56fd94e044f5e59291b31
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1526485Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Reviewed-by: default avatarSteven Bennetts <stevenjb@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#641706}
parent a14701de
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
#include "ash/wm/lock_state_controller_test_api.h" #include "ash/wm/lock_state_controller_test_api.h"
#include "ash/wm/test_session_state_animator.h" #include "ash/wm/test_session_state_animator.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "chromeos/dbus/dbus_thread_manager.h" #include "chromeos/dbus/power/fake_power_manager_client.h"
#include "chromeos/dbus/power/power_manager_client.h"
#include "chromeos/dbus/power_manager/suspend.pb.h" #include "chromeos/dbus/power_manager/suspend.pb.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h" #include "ui/aura/window_tree_host.h"
...@@ -33,7 +32,6 @@ class PowerEventObserverTest : public AshTestBase { ...@@ -33,7 +32,6 @@ class PowerEventObserverTest : public AshTestBase {
// AshTestBase: // AshTestBase:
void SetUp() override { void SetUp() override {
chromeos::DBusThreadManager::Initialize();
AshTestBase::SetUp(); AshTestBase::SetUp();
observer_.reset(new PowerEventObserver()); observer_.reset(new PowerEventObserver());
} }
...@@ -41,7 +39,6 @@ class PowerEventObserverTest : public AshTestBase { ...@@ -41,7 +39,6 @@ class PowerEventObserverTest : public AshTestBase {
void TearDown() override { void TearDown() override {
observer_.reset(); observer_.reset();
AshTestBase::TearDown(); AshTestBase::TearDown();
chromeos::DBusThreadManager::Shutdown();
} }
protected: protected:
...@@ -70,15 +67,16 @@ class PowerEventObserverTest : public AshTestBase { ...@@ -70,15 +67,16 @@ class PowerEventObserverTest : public AshTestBase {
}; };
TEST_F(PowerEventObserverTest, LockBeforeSuspend) { TEST_F(PowerEventObserverTest, LockBeforeSuspend) {
chromeos::PowerManagerClient* client = chromeos::PowerManagerClient::Get(); chromeos::FakePowerManagerClient* client =
ASSERT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); chromeos::FakePowerManagerClient::Get();
ASSERT_EQ(0, client->num_pending_suspend_readiness_callbacks());
// Check that the observer requests a suspend-readiness callback when it hears // Check that the observer requests a suspend-readiness callback when it hears
// that the system is about to suspend. // that the system is about to suspend.
SetCanLockScreen(true); SetCanLockScreen(true);
SetShouldLockScreenAutomatically(true); SetShouldLockScreenAutomatically(true);
observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER); observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
// It should run the callback when it hears that the screen is locked and the // It should run the callback when it hears that the screen is locked and the
// lock screen animations have completed. // lock screen animations have completed.
...@@ -96,21 +94,21 @@ TEST_F(PowerEventObserverTest, LockBeforeSuspend) { ...@@ -96,21 +94,21 @@ TEST_F(PowerEventObserverTest, LockBeforeSuspend) {
// CompositingDidCommit are ignored. // CompositingDidCommit are ignored.
test_api.CompositingStarted(compositor); test_api.CompositingStarted(compositor);
test_api.CompositingEnded(compositor); test_api.CompositingEnded(compositor);
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(1, GetNumVisibleCompositors()); EXPECT_EQ(1, GetNumVisibleCompositors());
// Suspend should remain delayed after first compositing cycle ends. // Suspend should remain delayed after first compositing cycle ends.
test_api.CompositeFrame(compositor); test_api.CompositeFrame(compositor);
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(1, GetNumVisibleCompositors()); EXPECT_EQ(1, GetNumVisibleCompositors());
test_api.CompositingDidCommit(compositor); test_api.CompositingDidCommit(compositor);
test_api.CompositingStarted(compositor); test_api.CompositingStarted(compositor);
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(1, GetNumVisibleCompositors()); EXPECT_EQ(1, GetNumVisibleCompositors());
test_api.CompositingEnded(compositor); test_api.CompositingEnded(compositor);
EXPECT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(0, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(0, GetNumVisibleCompositors()); EXPECT_EQ(0, GetNumVisibleCompositors());
// If the system is already locked, no callback should be requested. // If the system is already locked, no callback should be requested.
...@@ -128,7 +126,7 @@ TEST_F(PowerEventObserverTest, LockBeforeSuspend) { ...@@ -128,7 +126,7 @@ TEST_F(PowerEventObserverTest, LockBeforeSuspend) {
test_api.CompositeFrame(compositor); test_api.CompositeFrame(compositor);
observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER); observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(0, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(0, GetNumVisibleCompositors()); EXPECT_EQ(0, GetNumVisibleCompositors());
// It also shouldn't request a callback if it isn't instructed to lock the // It also shouldn't request a callback if it isn't instructed to lock the
...@@ -138,7 +136,7 @@ TEST_F(PowerEventObserverTest, LockBeforeSuspend) { ...@@ -138,7 +136,7 @@ TEST_F(PowerEventObserverTest, LockBeforeSuspend) {
SetShouldLockScreenAutomatically(false); SetShouldLockScreenAutomatically(false);
EXPECT_EQ(1, GetNumVisibleCompositors()); EXPECT_EQ(1, GetNumVisibleCompositors());
observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER); observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(0, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(0, GetNumVisibleCompositors()); EXPECT_EQ(0, GetNumVisibleCompositors());
} }
...@@ -202,9 +200,10 @@ TEST_F(PowerEventObserverTest, DelayResuspendForLockAnimations) { ...@@ -202,9 +200,10 @@ TEST_F(PowerEventObserverTest, DelayResuspendForLockAnimations) {
SetCanLockScreen(true); SetCanLockScreen(true);
SetShouldLockScreenAutomatically(true); SetShouldLockScreenAutomatically(true);
chromeos::PowerManagerClient* client = chromeos::PowerManagerClient::Get(); chromeos::FakePowerManagerClient* client =
chromeos::FakePowerManagerClient::Get();
observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER); observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
BlockUserSession(BLOCKED_BY_LOCK_SCREEN); BlockUserSession(BLOCKED_BY_LOCK_SCREEN);
observer_->SuspendDone(base::TimeDelta()); observer_->SuspendDone(base::TimeDelta());
...@@ -214,15 +213,15 @@ TEST_F(PowerEventObserverTest, DelayResuspendForLockAnimations) { ...@@ -214,15 +213,15 @@ TEST_F(PowerEventObserverTest, DelayResuspendForLockAnimations) {
// observer has not run the callback that it got from the first suspend // observer has not run the callback that it got from the first suspend
// request. The real PowerManagerClient would reset its internal counter in // request. The real PowerManagerClient would reset its internal counter in
// this situation but the stub client is not that smart. // this situation but the stub client is not that smart.
EXPECT_EQ(2, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(2, client->num_pending_suspend_readiness_callbacks());
observer_->OnLockAnimationsComplete(); observer_->OnLockAnimationsComplete();
EXPECT_EQ(2, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(2, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(1, GetNumVisibleCompositors()); EXPECT_EQ(1, GetNumVisibleCompositors());
ASSERT_TRUE(PowerEventObserverTestApi(observer_.get()) ASSERT_TRUE(PowerEventObserverTestApi(observer_.get())
.SimulateCompositorsReadyForSuspend()); .SimulateCompositorsReadyForSuspend());
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(0, GetNumVisibleCompositors()); EXPECT_EQ(0, GetNumVisibleCompositors());
} }
...@@ -234,9 +233,10 @@ TEST_F(PowerEventObserverTest, DelaySuspendForCompositing_MultiDisplay) { ...@@ -234,9 +233,10 @@ TEST_F(PowerEventObserverTest, DelaySuspendForCompositing_MultiDisplay) {
UpdateDisplay("100x100,200x200"); UpdateDisplay("100x100,200x200");
chromeos::PowerManagerClient* client = chromeos::PowerManagerClient::Get(); chromeos::FakePowerManagerClient* client =
chromeos::FakePowerManagerClient::Get();
observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER); observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
aura::Window::Windows windows = Shell::GetAllRootWindows(); aura::Window::Windows windows = Shell::GetAllRootWindows();
ASSERT_EQ(2u, windows.size()); ASSERT_EQ(2u, windows.size());
...@@ -244,7 +244,7 @@ TEST_F(PowerEventObserverTest, DelaySuspendForCompositing_MultiDisplay) { ...@@ -244,7 +244,7 @@ TEST_F(PowerEventObserverTest, DelaySuspendForCompositing_MultiDisplay) {
ui::Compositor* primary_compositor = windows[0]->GetHost()->compositor(); ui::Compositor* primary_compositor = windows[0]->GetHost()->compositor();
ui::Compositor* secondary_compositor = windows[1]->GetHost()->compositor(); ui::Compositor* secondary_compositor = windows[1]->GetHost()->compositor();
ASSERT_EQ(2, GetNumVisibleCompositors()); ASSERT_EQ(2, GetNumVisibleCompositors());
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
PowerEventObserverTestApi test_api(observer_.get()); PowerEventObserverTestApi test_api(observer_.get());
...@@ -256,7 +256,7 @@ TEST_F(PowerEventObserverTest, DelaySuspendForCompositing_MultiDisplay) { ...@@ -256,7 +256,7 @@ TEST_F(PowerEventObserverTest, DelaySuspendForCompositing_MultiDisplay) {
test_api.CompositingStarted(secondary_compositor); test_api.CompositingStarted(secondary_compositor);
test_api.CompositingEnded(secondary_compositor); test_api.CompositingEnded(secondary_compositor);
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(2, GetNumVisibleCompositors()); EXPECT_EQ(2, GetNumVisibleCompositors());
test_api.CompositeFrame(primary_compositor); test_api.CompositeFrame(primary_compositor);
...@@ -267,11 +267,11 @@ TEST_F(PowerEventObserverTest, DelaySuspendForCompositing_MultiDisplay) { ...@@ -267,11 +267,11 @@ TEST_F(PowerEventObserverTest, DelaySuspendForCompositing_MultiDisplay) {
// Even though compositing for one display is done, changes to compositor // Even though compositing for one display is done, changes to compositor
// visibility, and suspend readines state should be delayed until compositing // visibility, and suspend readines state should be delayed until compositing
// for the other display finishes. // for the other display finishes.
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(2, GetNumVisibleCompositors()); EXPECT_EQ(2, GetNumVisibleCompositors());
test_api.CompositeFrame(secondary_compositor); test_api.CompositeFrame(secondary_compositor);
EXPECT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(0, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(0, GetNumVisibleCompositors()); EXPECT_EQ(0, GetNumVisibleCompositors());
} }
...@@ -282,16 +282,17 @@ TEST_F(PowerEventObserverTest, ...@@ -282,16 +282,17 @@ TEST_F(PowerEventObserverTest,
UpdateDisplay("100x100,200x200"); UpdateDisplay("100x100,200x200");
chromeos::PowerManagerClient* client = chromeos::PowerManagerClient::Get(); chromeos::FakePowerManagerClient* client =
chromeos::FakePowerManagerClient::Get();
observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER); observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
aura::Window::Windows windows = Shell::GetAllRootWindows(); aura::Window::Windows windows = Shell::GetAllRootWindows();
ASSERT_EQ(2u, windows.size()); ASSERT_EQ(2u, windows.size());
ui::Compositor* primary_compositor = windows[0]->GetHost()->compositor(); ui::Compositor* primary_compositor = windows[0]->GetHost()->compositor();
ASSERT_EQ(2, GetNumVisibleCompositors()); ASSERT_EQ(2, GetNumVisibleCompositors());
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
observer_->OnLockAnimationsComplete(); observer_->OnLockAnimationsComplete();
PowerEventObserverTestApi test_api(observer_.get()); PowerEventObserverTestApi test_api(observer_.get());
...@@ -302,7 +303,7 @@ TEST_F(PowerEventObserverTest, ...@@ -302,7 +303,7 @@ TEST_F(PowerEventObserverTest,
// Even though compositing for one display is done, changes to compositor // Even though compositing for one display is done, changes to compositor
// visibility, and suspend readines state should be delayed until compositing // visibility, and suspend readines state should be delayed until compositing
// for the other display finishes. // for the other display finishes.
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(2, GetNumVisibleCompositors()); EXPECT_EQ(2, GetNumVisibleCompositors());
// Remove the second display, and verify the remaining compositor is hidden // Remove the second display, and verify the remaining compositor is hidden
...@@ -310,7 +311,7 @@ TEST_F(PowerEventObserverTest, ...@@ -310,7 +311,7 @@ TEST_F(PowerEventObserverTest,
UpdateDisplay("100x100"); UpdateDisplay("100x100");
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(0, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(0, GetNumVisibleCompositors()); EXPECT_EQ(0, GetNumVisibleCompositors());
} }
...@@ -318,17 +319,18 @@ TEST_F(PowerEventObserverTest, CompositorNotVisibleAtLockAnimationsComplete) { ...@@ -318,17 +319,18 @@ TEST_F(PowerEventObserverTest, CompositorNotVisibleAtLockAnimationsComplete) {
SetCanLockScreen(true); SetCanLockScreen(true);
SetShouldLockScreenAutomatically(true); SetShouldLockScreenAutomatically(true);
chromeos::PowerManagerClient* client = chromeos::PowerManagerClient::Get(); chromeos::FakePowerManagerClient* client =
chromeos::FakePowerManagerClient::Get();
observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER); observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
Shell::GetPrimaryRootWindow()->GetHost()->compositor()->SetVisible(false); Shell::GetPrimaryRootWindow()->GetHost()->compositor()->SetVisible(false);
observer_->OnLockAnimationsComplete(); observer_->OnLockAnimationsComplete();
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(0, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(0, GetNumVisibleCompositors()); EXPECT_EQ(0, GetNumVisibleCompositors());
} }
...@@ -384,8 +386,9 @@ TEST_F(PowerEventObserverTest, ImmediateLockAnimations) { ...@@ -384,8 +386,9 @@ TEST_F(PowerEventObserverTest, ImmediateLockAnimations) {
// another wallpaper after the screen is locked). // another wallpaper after the screen is locked).
TEST_F(PowerEventObserverTest, TEST_F(PowerEventObserverTest,
DisplaysNotReadyForSuspendUntilWallpaperAnimationEnds) { DisplaysNotReadyForSuspendUntilWallpaperAnimationEnds) {
chromeos::PowerManagerClient* client = chromeos::PowerManagerClient::Get(); chromeos::FakePowerManagerClient* client =
ASSERT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); chromeos::FakePowerManagerClient::Get();
ASSERT_EQ(0, client->num_pending_suspend_readiness_callbacks());
SetCanLockScreen(true); SetCanLockScreen(true);
SetShouldLockScreenAutomatically(true); SetShouldLockScreenAutomatically(true);
...@@ -423,19 +426,20 @@ TEST_F(PowerEventObserverTest, ...@@ -423,19 +426,20 @@ TEST_F(PowerEventObserverTest,
// and displays get suspended. // and displays get suspended.
test_api.CompositeFrame(compositor); test_api.CompositeFrame(compositor);
observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER); observer_->SuspendImminent(power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(1, GetNumVisibleCompositors()); EXPECT_EQ(1, GetNumVisibleCompositors());
test_api.CompositeFrame(compositor); test_api.CompositeFrame(compositor);
EXPECT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(0, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(0, GetNumVisibleCompositors()); EXPECT_EQ(0, GetNumVisibleCompositors());
} }
// Tests that animated wallpaper changes will be finished immediately when // Tests that animated wallpaper changes will be finished immediately when
// suspend starts (if the screen was locked when suspend started). // suspend starts (if the screen was locked when suspend started).
TEST_F(PowerEventObserverTest, EndWallpaperAnimationOnSuspendWhileLocked) { TEST_F(PowerEventObserverTest, EndWallpaperAnimationOnSuspendWhileLocked) {
chromeos::PowerManagerClient* client = chromeos::PowerManagerClient::Get(); chromeos::FakePowerManagerClient* client =
ASSERT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); chromeos::FakePowerManagerClient::Get();
ASSERT_EQ(0, client->num_pending_suspend_readiness_callbacks());
SetCanLockScreen(true); SetCanLockScreen(true);
SetShouldLockScreenAutomatically(true); SetShouldLockScreenAutomatically(true);
...@@ -464,19 +468,20 @@ TEST_F(PowerEventObserverTest, EndWallpaperAnimationOnSuspendWhileLocked) { ...@@ -464,19 +468,20 @@ TEST_F(PowerEventObserverTest, EndWallpaperAnimationOnSuspendWhileLocked) {
// Expect that two compositing cycles are completed before suspend continues, // Expect that two compositing cycles are completed before suspend continues,
// and displays get suspended. // and displays get suspended.
test_api.CompositeFrame(compositor); test_api.CompositeFrame(compositor);
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(1, GetNumVisibleCompositors()); EXPECT_EQ(1, GetNumVisibleCompositors());
test_api.CompositeFrame(compositor); test_api.CompositeFrame(compositor);
EXPECT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(0, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(0, GetNumVisibleCompositors()); EXPECT_EQ(0, GetNumVisibleCompositors());
} }
// Tests that animated wallpaper changes will be finished immediately when // Tests that animated wallpaper changes will be finished immediately when
// suspend starts (if the screen lock started before suspend). // suspend starts (if the screen lock started before suspend).
TEST_F(PowerEventObserverTest, EndWallpaperAnimationOnSuspendWhileLocking) { TEST_F(PowerEventObserverTest, EndWallpaperAnimationOnSuspendWhileLocking) {
chromeos::PowerManagerClient* client = chromeos::PowerManagerClient::Get(); chromeos::FakePowerManagerClient* client =
ASSERT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); chromeos::FakePowerManagerClient::Get();
ASSERT_EQ(0, client->num_pending_suspend_readiness_callbacks());
SetCanLockScreen(true); SetCanLockScreen(true);
SetShouldLockScreenAutomatically(true); SetShouldLockScreenAutomatically(true);
...@@ -506,19 +511,20 @@ TEST_F(PowerEventObserverTest, EndWallpaperAnimationOnSuspendWhileLocking) { ...@@ -506,19 +511,20 @@ TEST_F(PowerEventObserverTest, EndWallpaperAnimationOnSuspendWhileLocking) {
// Expect that two compositing cycles are completed before suspend continues, // Expect that two compositing cycles are completed before suspend continues,
// and displays get suspended. // and displays get suspended.
test_api.CompositeFrame(compositor); test_api.CompositeFrame(compositor);
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(1, GetNumVisibleCompositors()); EXPECT_EQ(1, GetNumVisibleCompositors());
test_api.CompositeFrame(compositor); test_api.CompositeFrame(compositor);
EXPECT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(0, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(0, GetNumVisibleCompositors()); EXPECT_EQ(0, GetNumVisibleCompositors());
} }
// Tests that animated wallpaper changes will be finished immediately when // Tests that animated wallpaper changes will be finished immediately when
// suspend starts and causes a screen lock. // suspend starts and causes a screen lock.
TEST_F(PowerEventObserverTest, EndWallpaperAnimationAfterLockDueToSuspend) { TEST_F(PowerEventObserverTest, EndWallpaperAnimationAfterLockDueToSuspend) {
chromeos::PowerManagerClient* client = chromeos::PowerManagerClient::Get(); chromeos::FakePowerManagerClient* client =
ASSERT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); chromeos::FakePowerManagerClient::Get();
ASSERT_EQ(0, client->num_pending_suspend_readiness_callbacks());
SetCanLockScreen(true); SetCanLockScreen(true);
SetShouldLockScreenAutomatically(true); SetShouldLockScreenAutomatically(true);
...@@ -544,19 +550,20 @@ TEST_F(PowerEventObserverTest, EndWallpaperAnimationAfterLockDueToSuspend) { ...@@ -544,19 +550,20 @@ TEST_F(PowerEventObserverTest, EndWallpaperAnimationAfterLockDueToSuspend) {
// Expect that two compositing cycles are completed before suspend continues, // Expect that two compositing cycles are completed before suspend continues,
// and displays get suspended. // and displays get suspended.
test_api.CompositeFrame(compositor); test_api.CompositeFrame(compositor);
EXPECT_EQ(1, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(1, GetNumVisibleCompositors()); EXPECT_EQ(1, GetNumVisibleCompositors());
test_api.CompositeFrame(compositor); test_api.CompositeFrame(compositor);
EXPECT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(0, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(0, GetNumVisibleCompositors()); EXPECT_EQ(0, GetNumVisibleCompositors());
} }
// Tests that removing a display while power event observer is waiting for the // Tests that removing a display while power event observer is waiting for the
// wallpaper animation does not cause suspend to hang. // wallpaper animation does not cause suspend to hang.
TEST_F(PowerEventObserverTest, DisplayRemovedDuringWallpaperAnimation) { TEST_F(PowerEventObserverTest, DisplayRemovedDuringWallpaperAnimation) {
chromeos::PowerManagerClient* client = chromeos::PowerManagerClient::Get(); chromeos::FakePowerManagerClient* client =
ASSERT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); chromeos::FakePowerManagerClient::Get();
ASSERT_EQ(0, client->num_pending_suspend_readiness_callbacks());
SetCanLockScreen(true); SetCanLockScreen(true);
SetShouldLockScreenAutomatically(true); SetShouldLockScreenAutomatically(true);
...@@ -589,7 +596,7 @@ TEST_F(PowerEventObserverTest, DisplayRemovedDuringWallpaperAnimation) { ...@@ -589,7 +596,7 @@ TEST_F(PowerEventObserverTest, DisplayRemovedDuringWallpaperAnimation) {
// and displays get suspended. // and displays get suspended.
test_api.CompositeFrame(compositor); test_api.CompositeFrame(compositor);
test_api.CompositeFrame(compositor); test_api.CompositeFrame(compositor);
EXPECT_EQ(0, client->GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(0, client->num_pending_suspend_readiness_callbacks());
EXPECT_EQ(0, GetNumVisibleCompositors()); EXPECT_EQ(0, GetNumVisibleCompositors());
} }
......
...@@ -142,22 +142,22 @@ TEST_F(ExtensionEventObserverTest, BasicSuspendAndDarkSuspend) { ...@@ -142,22 +142,22 @@ TEST_F(ExtensionEventObserverTest, BasicSuspendAndDarkSuspend) {
power_manager::SuspendImminent_Reason_OTHER); power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ( EXPECT_EQ(
1, 1,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback()); EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback());
EXPECT_EQ( EXPECT_EQ(
0, 0,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
FakePowerManagerClient::Get()->SendDarkSuspendImminent(); FakePowerManagerClient::Get()->SendDarkSuspendImminent();
EXPECT_EQ( EXPECT_EQ(
1, 1,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback()); EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback());
EXPECT_EQ( EXPECT_EQ(
0, 0,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
} }
// Tests that the ExtensionEventObserver properly handles a canceled suspend // Tests that the ExtensionEventObserver properly handles a canceled suspend
...@@ -167,7 +167,7 @@ TEST_F(ExtensionEventObserverTest, CanceledSuspend) { ...@@ -167,7 +167,7 @@ TEST_F(ExtensionEventObserverTest, CanceledSuspend) {
power_manager::SuspendImminent_Reason_OTHER); power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ( EXPECT_EQ(
1, 1,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
FakePowerManagerClient::Get()->SendSuspendDone(); FakePowerManagerClient::Get()->SendSuspendDone();
EXPECT_FALSE(test_api_->MaybeRunSuspendReadinessCallback()); EXPECT_FALSE(test_api_->MaybeRunSuspendReadinessCallback());
...@@ -193,12 +193,12 @@ TEST_F(ExtensionEventObserverTest, PushMessagesDelaySuspend) { ...@@ -193,12 +193,12 @@ TEST_F(ExtensionEventObserverTest, PushMessagesDelaySuspend) {
EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback()); EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback());
EXPECT_EQ( EXPECT_EQ(
1, 1,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
extension_event_observer_->OnBackgroundEventAcked(host, kSuspendPushId); extension_event_observer_->OnBackgroundEventAcked(host, kSuspendPushId);
EXPECT_EQ( EXPECT_EQ(
0, 0,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
// Now test receiving the suspend attempt before the push message. // Now test receiving the suspend attempt before the push message.
const int kDarkSuspendPushId = 56674; const int kDarkSuspendPushId = 56674;
...@@ -209,12 +209,12 @@ TEST_F(ExtensionEventObserverTest, PushMessagesDelaySuspend) { ...@@ -209,12 +209,12 @@ TEST_F(ExtensionEventObserverTest, PushMessagesDelaySuspend) {
EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback()); EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback());
EXPECT_EQ( EXPECT_EQ(
1, 1,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
extension_event_observer_->OnBackgroundEventAcked(host, kDarkSuspendPushId); extension_event_observer_->OnBackgroundEventAcked(host, kDarkSuspendPushId);
EXPECT_EQ( EXPECT_EQ(
0, 0,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
// Test that non-push messages do not delay the suspend. // Test that non-push messages do not delay the suspend.
const int kNonPushId = 5687; const int kNonPushId = 5687;
...@@ -225,7 +225,7 @@ TEST_F(ExtensionEventObserverTest, PushMessagesDelaySuspend) { ...@@ -225,7 +225,7 @@ TEST_F(ExtensionEventObserverTest, PushMessagesDelaySuspend) {
EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback()); EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback());
EXPECT_EQ( EXPECT_EQ(
0, 0,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
} }
// Tests that messages sent for apps that don't use GCM are ignored. // Tests that messages sent for apps that don't use GCM are ignored.
...@@ -241,7 +241,7 @@ TEST_F(ExtensionEventObserverTest, IgnoresNonGCMApps) { ...@@ -241,7 +241,7 @@ TEST_F(ExtensionEventObserverTest, IgnoresNonGCMApps) {
EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback()); EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback());
EXPECT_EQ( EXPECT_EQ(
0, 0,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
} }
// Tests that network requests started by an app while it is processing a push // Tests that network requests started by an app while it is processing a push
...@@ -263,7 +263,7 @@ TEST_F(ExtensionEventObserverTest, NetworkRequestsMayDelaySuspend) { ...@@ -263,7 +263,7 @@ TEST_F(ExtensionEventObserverTest, NetworkRequestsMayDelaySuspend) {
EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback()); EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback());
EXPECT_EQ( EXPECT_EQ(
0, 0,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
// Test that network requests started while a push message is pending delay // Test that network requests started while a push message is pending delay
// the suspend even after the push message has been acked. // the suspend even after the push message has been acked.
...@@ -276,18 +276,18 @@ TEST_F(ExtensionEventObserverTest, NetworkRequestsMayDelaySuspend) { ...@@ -276,18 +276,18 @@ TEST_F(ExtensionEventObserverTest, NetworkRequestsMayDelaySuspend) {
EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback()); EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback());
EXPECT_EQ( EXPECT_EQ(
1, 1,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
extension_event_observer_->OnNetworkRequestStarted(host, kNetworkRequestId); extension_event_observer_->OnNetworkRequestStarted(host, kNetworkRequestId);
extension_event_observer_->OnBackgroundEventAcked(host, kPushMessageId); extension_event_observer_->OnBackgroundEventAcked(host, kPushMessageId);
EXPECT_EQ( EXPECT_EQ(
1, 1,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
extension_event_observer_->OnNetworkRequestDone(host, kNetworkRequestId); extension_event_observer_->OnNetworkRequestDone(host, kNetworkRequestId);
EXPECT_EQ( EXPECT_EQ(
0, 0,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
} }
// Tests that any outstanding push messages or network requests for an // Tests that any outstanding push messages or network requests for an
...@@ -320,7 +320,7 @@ TEST_F(ExtensionEventObserverTest, DeletedExtensionHostDoesNotBlockSuspend) { ...@@ -320,7 +320,7 @@ TEST_F(ExtensionEventObserverTest, DeletedExtensionHostDoesNotBlockSuspend) {
EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback()); EXPECT_TRUE(test_api_->MaybeRunSuspendReadinessCallback());
EXPECT_EQ( EXPECT_EQ(
0, 0,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
} }
// Tests that the ExtensionEventObserver does not delay suspend attempts when it // Tests that the ExtensionEventObserver does not delay suspend attempts when it
...@@ -341,20 +341,20 @@ TEST_F(ExtensionEventObserverTest, DoesNotDelaySuspendWhenDisabled) { ...@@ -341,20 +341,20 @@ TEST_F(ExtensionEventObserverTest, DoesNotDelaySuspendWhenDisabled) {
power_manager::SuspendImminent_Reason_OTHER); power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ( EXPECT_EQ(
1, 1,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
extension_event_observer_->SetShouldDelaySuspend(false); extension_event_observer_->SetShouldDelaySuspend(false);
EXPECT_FALSE(test_api_->MaybeRunSuspendReadinessCallback()); EXPECT_FALSE(test_api_->MaybeRunSuspendReadinessCallback());
EXPECT_EQ( EXPECT_EQ(
0, 0,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
// Test that the ExtensionEventObserver does not delay suspend attempts when // Test that the ExtensionEventObserver does not delay suspend attempts when
// it is disabled. // it is disabled.
FakePowerManagerClient::Get()->SendDarkSuspendImminent(); FakePowerManagerClient::Get()->SendDarkSuspendImminent();
EXPECT_EQ( EXPECT_EQ(
0, 0,
FakePowerManagerClient::Get()->GetNumPendingSuspendReadinessCallbacks()); FakePowerManagerClient::Get()->num_pending_suspend_readiness_callbacks());
} }
} // namespace chromeos } // namespace chromeos
...@@ -255,10 +255,6 @@ base::Closure FakePowerManagerClient::GetSuspendReadinessCallback( ...@@ -255,10 +255,6 @@ base::Closure FakePowerManagerClient::GetSuspendReadinessCallback(
base::Unretained(this)); base::Unretained(this));
} }
int FakePowerManagerClient::GetNumPendingSuspendReadinessCallbacks() {
return num_pending_suspend_readiness_callbacks_;
}
void FakePowerManagerClient::CreateArcTimers( void FakePowerManagerClient::CreateArcTimers(
const std::string& tag, const std::string& tag,
std::vector<std::pair<clockid_t, base::ScopedFD>> arc_timer_requests, std::vector<std::pair<clockid_t, base::ScopedFD>> arc_timer_requests,
......
...@@ -48,6 +48,9 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) FakePowerManagerClient ...@@ -48,6 +48,9 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) FakePowerManagerClient
int num_wake_notification_calls() const { int num_wake_notification_calls() const {
return num_wake_notification_calls_; return num_wake_notification_calls_;
} }
int num_pending_suspend_readiness_callbacks() const {
return num_pending_suspend_readiness_callbacks_;
}
double screen_brightness_percent() const { double screen_brightness_percent() const {
return screen_brightness_percent_.value(); return screen_brightness_percent_.value();
} }
...@@ -109,7 +112,6 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) FakePowerManagerClient ...@@ -109,7 +112,6 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) FakePowerManagerClient
override; override;
base::Closure GetSuspendReadinessCallback( base::Closure GetSuspendReadinessCallback(
const base::Location& from_where) override; const base::Location& from_where) override;
int GetNumPendingSuspendReadinessCallbacks() override;
void CreateArcTimers( void CreateArcTimers(
const std::string& tag, const std::string& tag,
std::vector<std::pair<clockid_t, base::ScopedFD>> arc_timer_requests, std::vector<std::pair<clockid_t, base::ScopedFD>> arc_timer_requests,
......
...@@ -463,10 +463,6 @@ class PowerManagerClientImpl : public PowerManagerClient { ...@@ -463,10 +463,6 @@ class PowerManagerClientImpl : public PowerManagerClient {
suspending_from_dark_resume_, callback_id); suspending_from_dark_resume_, callback_id);
} }
int GetNumPendingSuspendReadinessCallbacks() override {
return pending_suspend_readiness_callbacks_.size();
}
void CreateArcTimers( void CreateArcTimers(
const std::string& tag, const std::string& tag,
std::vector<std::pair<clockid_t, base::ScopedFD>> arc_timer_requests, std::vector<std::pair<clockid_t, base::ScopedFD>> arc_timer_requests,
...@@ -1054,7 +1050,7 @@ class PowerManagerClientImpl : public PowerManagerClient { ...@@ -1054,7 +1050,7 @@ class PowerManagerClientImpl : public PowerManagerClient {
if (notifying_observers_about_suspend_imminent_) if (notifying_observers_about_suspend_imminent_)
return; return;
if (GetNumPendingSuspendReadinessCallbacks() > 0) if (!pending_suspend_readiness_callbacks_.empty())
return; return;
std::string method_name; std::string method_name;
......
...@@ -279,10 +279,6 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) PowerManagerClient { ...@@ -279,10 +279,6 @@ class COMPONENT_EXPORT(CHROMEOS_DBUS) PowerManagerClient {
virtual base::Closure GetSuspendReadinessCallback( virtual base::Closure GetSuspendReadinessCallback(
const base::Location& from_where) = 0; const base::Location& from_where) = 0;
// Returns the number of callbacks returned by GetSuspendReadinessCallback()
// for the current suspend attempt but not yet called. Used by tests.
virtual int GetNumPendingSuspendReadinessCallbacks() = 0;
// Creates timers corresponding to clocks present in |arc_timer_requests|. // Creates timers corresponding to clocks present in |arc_timer_requests|.
// ScopedFDs are used to indicate timer expiration as described in // ScopedFDs are used to indicate timer expiration as described in
// |StartArcTimer|. Aysnchronously runs |callback| with the created timers' // |StartArcTimer|. Aysnchronously runs |callback| with the created timers'
......
...@@ -91,7 +91,7 @@ TEST_F(SuspendUnmountManagerTest, Basic) { ...@@ -91,7 +91,7 @@ TEST_F(SuspendUnmountManagerTest, Basic) {
fake_power_client_.SendSuspendImminent( fake_power_client_.SendSuspendImminent(
power_manager::SuspendImminent_Reason_OTHER); power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ(1, fake_power_client_.GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, fake_power_client_.num_pending_suspend_readiness_callbacks());
EXPECT_EQ(2u, disk_mount_manager_.unmounting_mount_paths().size()); EXPECT_EQ(2u, disk_mount_manager_.unmounting_mount_paths().size());
EXPECT_EQ(1, std::count(disk_mount_manager_.unmounting_mount_paths().begin(), EXPECT_EQ(1, std::count(disk_mount_manager_.unmounting_mount_paths().begin(),
disk_mount_manager_.unmounting_mount_paths().end(), disk_mount_manager_.unmounting_mount_paths().end(),
...@@ -103,7 +103,7 @@ TEST_F(SuspendUnmountManagerTest, Basic) { ...@@ -103,7 +103,7 @@ TEST_F(SuspendUnmountManagerTest, Basic) {
disk_mount_manager_.unmounting_mount_paths().end(), disk_mount_manager_.unmounting_mount_paths().end(),
kDummyMountPathUnknown)); kDummyMountPathUnknown));
disk_mount_manager_.NotifyUnmountDeviceComplete(MOUNT_ERROR_NONE); disk_mount_manager_.NotifyUnmountDeviceComplete(MOUNT_ERROR_NONE);
EXPECT_EQ(0, fake_power_client_.GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(0, fake_power_client_.num_pending_suspend_readiness_callbacks());
} }
TEST_F(SuspendUnmountManagerTest, CancelAndSuspendAgain) { TEST_F(SuspendUnmountManagerTest, CancelAndSuspendAgain) {
...@@ -119,7 +119,7 @@ TEST_F(SuspendUnmountManagerTest, CancelAndSuspendAgain) { ...@@ -119,7 +119,7 @@ TEST_F(SuspendUnmountManagerTest, CancelAndSuspendAgain) {
disk_mount_manager_.SetupDefaultReplies(); disk_mount_manager_.SetupDefaultReplies();
fake_power_client_.SendSuspendImminent( fake_power_client_.SendSuspendImminent(
power_manager::SuspendImminent_Reason_OTHER); power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ(1, fake_power_client_.GetNumPendingSuspendReadinessCallbacks()); EXPECT_EQ(1, fake_power_client_.num_pending_suspend_readiness_callbacks());
ASSERT_EQ(1u, disk_mount_manager_.unmounting_mount_paths().size()); ASSERT_EQ(1u, disk_mount_manager_.unmounting_mount_paths().size());
EXPECT_EQ(kDummyMountPath, EXPECT_EQ(kDummyMountPath,
disk_mount_manager_.unmounting_mount_paths().front()); disk_mount_manager_.unmounting_mount_paths().front());
......
...@@ -96,7 +96,8 @@ TEST_F(DarkResumeControllerTest, CheckSuspendAfterDarkResumeNoWakeLocksHeld) { ...@@ -96,7 +96,8 @@ TEST_F(DarkResumeControllerTest, CheckSuspendAfterDarkResumeNoWakeLocksHeld) {
run_loop.RunUntilIdle(); run_loop.RunUntilIdle();
EXPECT_TRUE(dark_resume_controller_->IsDarkResumeStateClearedForTesting()); EXPECT_TRUE(dark_resume_controller_->IsDarkResumeStateClearedForTesting());
EXPECT_EQ( EXPECT_EQ(
0, fake_power_manager_client()->GetNumPendingSuspendReadinessCallbacks()); 0,
fake_power_manager_client()->num_pending_suspend_readiness_callbacks());
// Trigger a dark resume event, acquire and release a wake lock and move time // Trigger a dark resume event, acquire and release a wake lock and move time
// forward to trigger a wake lock check. The device should re-suspend in this // forward to trigger a wake lock check. The device should re-suspend in this
...@@ -110,7 +111,8 @@ TEST_F(DarkResumeControllerTest, CheckSuspendAfterDarkResumeNoWakeLocksHeld) { ...@@ -110,7 +111,8 @@ TEST_F(DarkResumeControllerTest, CheckSuspendAfterDarkResumeNoWakeLocksHeld) {
run_loop2.RunUntilIdle(); run_loop2.RunUntilIdle();
EXPECT_TRUE(dark_resume_controller_->IsDarkResumeStateClearedForTesting()); EXPECT_TRUE(dark_resume_controller_->IsDarkResumeStateClearedForTesting());
EXPECT_EQ( EXPECT_EQ(
0, fake_power_manager_client()->GetNumPendingSuspendReadinessCallbacks()); 0,
fake_power_manager_client()->num_pending_suspend_readiness_callbacks());
} }
TEST_F(DarkResumeControllerTest, CheckSuspendAfterDarkResumeWakeLocksHeld) { TEST_F(DarkResumeControllerTest, CheckSuspendAfterDarkResumeWakeLocksHeld) {
...@@ -136,7 +138,8 @@ TEST_F(DarkResumeControllerTest, CheckSuspendAfterDarkResumeWakeLocksHeld) { ...@@ -136,7 +138,8 @@ TEST_F(DarkResumeControllerTest, CheckSuspendAfterDarkResumeWakeLocksHeld) {
run_loop2.RunUntilIdle(); run_loop2.RunUntilIdle();
EXPECT_TRUE(dark_resume_controller_->IsDarkResumeStateClearedForTesting()); EXPECT_TRUE(dark_resume_controller_->IsDarkResumeStateClearedForTesting());
EXPECT_EQ( EXPECT_EQ(
0, fake_power_manager_client()->GetNumPendingSuspendReadinessCallbacks()); 0,
fake_power_manager_client()->num_pending_suspend_readiness_callbacks());
} }
TEST_F(DarkResumeControllerTest, CheckSuspendAfterDarkResumeHardTimeout) { TEST_F(DarkResumeControllerTest, CheckSuspendAfterDarkResumeHardTimeout) {
...@@ -162,7 +165,8 @@ TEST_F(DarkResumeControllerTest, CheckSuspendAfterDarkResumeHardTimeout) { ...@@ -162,7 +165,8 @@ TEST_F(DarkResumeControllerTest, CheckSuspendAfterDarkResumeHardTimeout) {
run_loop2.RunUntilIdle(); run_loop2.RunUntilIdle();
EXPECT_TRUE(dark_resume_controller_->IsDarkResumeStateClearedForTesting()); EXPECT_TRUE(dark_resume_controller_->IsDarkResumeStateClearedForTesting());
EXPECT_EQ( EXPECT_EQ(
0, fake_power_manager_client()->GetNumPendingSuspendReadinessCallbacks()); 0,
fake_power_manager_client()->num_pending_suspend_readiness_callbacks());
} }
TEST_F(DarkResumeControllerTest, CheckStateResetAfterSuspendDone) { TEST_F(DarkResumeControllerTest, CheckStateResetAfterSuspendDone) {
......
...@@ -128,12 +128,12 @@ TEST_F(ArcPowerBridgeTest, SuspendAndResume) { ...@@ -128,12 +128,12 @@ TEST_F(ArcPowerBridgeTest, SuspendAndResume) {
EXPECT_EQ(1, power_instance_->num_suspend()); EXPECT_EQ(1, power_instance_->num_suspend());
EXPECT_EQ(0, power_instance_->num_resume()); EXPECT_EQ(0, power_instance_->num_resume());
EXPECT_EQ(1, EXPECT_EQ(1,
power_manager_client()->GetNumPendingSuspendReadinessCallbacks()); power_manager_client()->num_pending_suspend_readiness_callbacks());
// Simulate Android acknowledging that it's ready for the system to suspend. // Simulate Android acknowledging that it's ready for the system to suspend.
power_instance_->GetSuspendCallback().Run(); power_instance_->GetSuspendCallback().Run();
EXPECT_EQ(0, EXPECT_EQ(0,
power_manager_client()->GetNumPendingSuspendReadinessCallbacks()); power_manager_client()->num_pending_suspend_readiness_callbacks());
power_manager_client()->SendSuspendDone(); power_manager_client()->SendSuspendDone();
EXPECT_EQ(1, power_instance_->num_suspend()); EXPECT_EQ(1, power_instance_->num_suspend());
...@@ -144,7 +144,7 @@ TEST_F(ArcPowerBridgeTest, SuspendAndResume) { ...@@ -144,7 +144,7 @@ TEST_F(ArcPowerBridgeTest, SuspendAndResume) {
power_manager_client()->SendSuspendImminent( power_manager_client()->SendSuspendImminent(
power_manager::SuspendImminent_Reason_OTHER); power_manager::SuspendImminent_Reason_OTHER);
EXPECT_EQ(0, EXPECT_EQ(0,
power_manager_client()->GetNumPendingSuspendReadinessCallbacks()); power_manager_client()->num_pending_suspend_readiness_callbacks());
power_manager_client()->SendSuspendDone(); power_manager_client()->SendSuspendDone();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment