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

Unified Diff: base/system_monitor/system_monitor_unittest.cc

Issue 8523021: Send WM_DEVICECHANGE message through SystemMonitor (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 9 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/system_monitor.cc ('k') | content/browser/browser_main_loop.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/system_monitor/system_monitor_unittest.cc
diff --git a/base/system_monitor/system_monitor_unittest.cc b/base/system_monitor/system_monitor_unittest.cc
index f4a4e73fae2113b8e5a131502a1bf9ed54eead46..1d5d6af86467c834b1f40172e0ef73c3e76262b3 100644
--- a/base/system_monitor/system_monitor_unittest.cc
+++ b/base/system_monitor/system_monitor_unittest.cc
@@ -55,7 +55,7 @@ TEST(SystemMonitor, PowerNotifications) {
SystemMonitor system_monitor;
PowerTest test[kObservers];
for (int index = 0; index < kObservers; ++index)
- system_monitor.AddObserver(&test[index]);
+ system_monitor.AddPowerObserver(&test[index]);
// Send a bunch of power changes. Since the battery power hasn't
// actually changed, we shouldn't get notifications.
@@ -90,4 +90,49 @@ TEST(SystemMonitor, PowerNotifications) {
EXPECT_EQ(test[0].resumes(), 1);
}
+class DevicesChangedTest : public SystemMonitor::DevicesChangedObserver {
+ public:
+ DevicesChangedTest()
+ : changes_(0) {
+ }
+
+ // DevicesChangedObserver callbacks.
+ virtual void OnDevicesChanged() OVERRIDE {
+ changes_++;
+ }
+
+ // Test status counts.
+ int changes() const { return changes_; }
+
+ private:
+ int changes_; // Count of OnDevicesChanged notifications.
+
+ DISALLOW_COPY_AND_ASSIGN(DevicesChangedTest);
+};
+
+TEST(SystemMonitor, DeviceChangeNotifications) {
+ const int kObservers = 5;
+
+ // Initialize a message loop for this to run on.
+ MessageLoop loop;
+
+#if defined(OS_MACOSX)
+ SystemMonitor::AllocateSystemIOPorts();
+#endif
+
+ SystemMonitor system_monitor;
+ DevicesChangedTest test[kObservers];
+ for (int index = 0; index < kObservers; ++index)
+ system_monitor.AddDevicesChangedObserver(&test[index]);
+
+ system_monitor.ProcessDevicesChanged();
+ loop.RunAllPending();
+ EXPECT_EQ(1, test[0].changes());
+
+ system_monitor.ProcessDevicesChanged();
+ system_monitor.ProcessDevicesChanged();
+ loop.RunAllPending();
+ EXPECT_EQ(3, test[0].changes());
+}
+
} // namespace base
« no previous file with comments | « base/system_monitor/system_monitor.cc ('k') | content/browser/browser_main_loop.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698