diff options
author | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-03 18:00:29 +0000 |
---|---|---|
committer | mbelshe@google.com <mbelshe@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-03 18:00:29 +0000 |
commit | 1252dad25c795900b09d11dfa57601d348067d04 (patch) | |
tree | 969974d9f36f97d38d1c3dcf0ec5c05bf98ffe49 /base/system_monitor_unittest.cc | |
parent | 99d897c73c3ca446cb257b6099eee0ef9f47d781 (diff) | |
download | chromium_src-1252dad25c795900b09d11dfa57601d348067d04.zip chromium_src-1252dad25c795900b09d11dfa57601d348067d04.tar.gz chromium_src-1252dad25c795900b09d11dfa57601d348067d04.tar.bz2 |
Fix unit test for system monitor.
Not sure how I missed this!
Review URL: http://codereview.chromium.org/9250
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4457 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/system_monitor_unittest.cc')
-rw-r--r-- | base/system_monitor_unittest.cc | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/base/system_monitor_unittest.cc b/base/system_monitor_unittest.cc index b3deccc..786a94d 100644 --- a/base/system_monitor_unittest.cc +++ b/base/system_monitor_unittest.cc @@ -33,6 +33,12 @@ class PowerTest : public base::SystemMonitor::PowerObserver { 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 @@ TEST(SystemMonitor, PowerNotifications) { // 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);
}
|