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

Unified Diff: base/system_monitor_unittest.cc

Issue 9250: Fix unit test for system monitor. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/system_monitor_unittest.cc
===================================================================
--- base/system_monitor_unittest.cc (revision 4452)
+++ base/system_monitor_unittest.cc (working copy)
@@ -33,6 +33,12 @@
TEST(SystemMonitor, PowerNotifications) {
const int kObservers = 5;
+
+ // Initialize a message loop for this to run on.
+ MessageLoop loop;
+ // Initialize time() since it registers as a SystemMonitor observer.
+ base::Time now = base::Time::Now();
+
base::SystemMonitor* monitor = base::SystemMonitor::Get();
PowerTest test[kObservers];
for (int index = 0; index < kObservers; ++index)
@@ -47,22 +53,27 @@
// Sending resume when not suspended should have no effect.
monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
+ loop.RunAllPending();
EXPECT_EQ(test[0].resumes(), 0);
// Pretend we suspended.
monitor->ProcessPowerMessage(base::SystemMonitor::SUSPEND_EVENT);
+ loop.RunAllPending();
EXPECT_EQ(test[0].suspends(), 1);
// Send a second suspend notification. This should be suppressed.
monitor->ProcessPowerMessage(base::SystemMonitor::SUSPEND_EVENT);
+ loop.RunAllPending();
EXPECT_EQ(test[0].suspends(), 1);
// Pretend we were awakened.
monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
+ loop.RunAllPending();
EXPECT_EQ(test[0].resumes(), 1);
// Send a duplicate resume notification. This should be suppressed.
monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
+ loop.RunAllPending();
EXPECT_EQ(test[0].resumes(), 1);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698