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

Unified Diff: base/system_monitor_unittest.cc

Issue 4288: Make the SystemMonitor observer list thread safe.... (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 | « base/system_monitor.cc ('k') | base/system_monitor_win.cc » ('j') | 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 4449)
+++ base/system_monitor_unittest.cc (working copy)
@@ -32,35 +32,37 @@
};
TEST(SystemMonitor, PowerNotifications) {
+ const int kObservers = 5;
base::SystemMonitor* monitor = base::SystemMonitor::Get();
- PowerTest test;
- monitor->AddObserver(&test);
+ PowerTest test[kObservers];
+ for (int index = 0; index < kObservers; ++index)
+ monitor->AddObserver(&test[index]);
// Send a bunch of power changes. Since the battery power hasn't
// actually changed, we shouldn't get notifications.
for (int index = 0; index < 5; index++) {
- monitor->ProcessPowerMessage(base::SystemMonitor::PowerStateEvent);
- EXPECT_EQ(test.power_state_changes(), 0);
+ monitor->ProcessPowerMessage(base::SystemMonitor::POWER_STATE_EVENT);
+ EXPECT_EQ(test[0].power_state_changes(), 0);
}
// Sending resume when not suspended should have no effect.
- monitor->ProcessPowerMessage(base::SystemMonitor::ResumeEvent);
- EXPECT_EQ(test.resumes(), 0);
+ monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
+ EXPECT_EQ(test[0].resumes(), 0);
// Pretend we suspended.
- monitor->ProcessPowerMessage(base::SystemMonitor::SuspendEvent);
- EXPECT_EQ(test.suspends(), 1);
+ monitor->ProcessPowerMessage(base::SystemMonitor::SUSPEND_EVENT);
+ EXPECT_EQ(test[0].suspends(), 1);
// Send a second suspend notification. This should be suppressed.
- monitor->ProcessPowerMessage(base::SystemMonitor::SuspendEvent);
- EXPECT_EQ(test.suspends(), 1);
+ monitor->ProcessPowerMessage(base::SystemMonitor::SUSPEND_EVENT);
+ EXPECT_EQ(test[0].suspends(), 1);
// Pretend we were awakened.
- monitor->ProcessPowerMessage(base::SystemMonitor::ResumeEvent);
- EXPECT_EQ(test.resumes(), 1);
+ monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
+ EXPECT_EQ(test[0].resumes(), 1);
// Send a duplicate resume notification. This should be suppressed.
- monitor->ProcessPowerMessage(base::SystemMonitor::ResumeEvent);
- EXPECT_EQ(test.resumes(), 1);
+ monitor->ProcessPowerMessage(base::SystemMonitor::RESUME_EVENT);
+ EXPECT_EQ(test[0].resumes(), 1);
}
« no previous file with comments | « base/system_monitor.cc ('k') | base/system_monitor_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698