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

Unified Diff: base/system_monitor/system_monitor_unittest.cc

Issue 9363008: Add Media device notification to SystemMonitor and Mac impl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 8 years, 10 months 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_mac.mm ('k') | no next file » | 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 1d5d6af86467c834b1f40172e0ef73c3e76262b3..69253439e7e341208729a6d839b2d2b41791db97 100644
--- a/base/system_monitor/system_monitor_unittest.cc
+++ b/base/system_monitor/system_monitor_unittest.cc
@@ -92,8 +92,7 @@ TEST(SystemMonitor, PowerNotifications) {
class DevicesChangedTest : public SystemMonitor::DevicesChangedObserver {
tpayne 2012/02/15 00:56:30 As mentioned on chat, this would be better using g
vandebo (ex-Chrome) 2012/02/15 22:28:25 Done.
public:
- DevicesChangedTest()
- : changes_(0) {
+ DevicesChangedTest() : changes_(0), media_attaches_(0), media_detaches_(0) {
}
// DevicesChangedObserver callbacks.
@@ -101,11 +100,25 @@ class DevicesChangedTest : public SystemMonitor::DevicesChangedObserver {
changes_++;
}
+ virtual void OnMediaDeviceAttached(const SystemMonitor::DeviceIdType& id,
+ const std::string& name,
+ const FilePath& path) OVERRIDE {
+ media_attaches_++;
+ }
+ virtual void OnMediaDeviceDetached(
+ const SystemMonitor::DeviceIdType& name) OVERRIDE {
+ media_detaches_++;
+ }
+
// Test status counts.
int changes() const { return changes_; }
+ int media_attaches() const { return media_attaches_; }
+ int media_detaches() const { return media_detaches_; }
private:
int changes_; // Count of OnDevicesChanged notifications.
+ int media_attaches_; // Count of OnMediaDeviceAttached notifications.
+ int media_detaches_; // Count of OnMediaDeviceDetached notifications.
DISALLOW_COPY_AND_ASSIGN(DevicesChangedTest);
};
@@ -128,11 +141,29 @@ TEST(SystemMonitor, DeviceChangeNotifications) {
system_monitor.ProcessDevicesChanged();
loop.RunAllPending();
EXPECT_EQ(1, test[0].changes());
+ EXPECT_EQ(0, test[0].media_attaches());
+ EXPECT_EQ(0, test[0].media_detaches());
system_monitor.ProcessDevicesChanged();
system_monitor.ProcessDevicesChanged();
loop.RunAllPending();
EXPECT_EQ(3, test[0].changes());
+ EXPECT_EQ(0, test[0].media_attaches());
+ EXPECT_EQ(0, test[0].media_detaches());
+
+ system_monitor.ProcessMediaDeviceAttached(
+ 1, "media device", FilePath(FILE_PATH_LITERAL("path")));
+ loop.RunAllPending();
+ EXPECT_EQ(3, test[0].changes());
+ EXPECT_EQ(1, test[0].media_attaches());
+ EXPECT_EQ(0, test[0].media_detaches());
+
+ system_monitor.ProcessMediaDeviceDetached(1);
+ system_monitor.ProcessMediaDeviceDetached(2);
+ loop.RunAllPending();
+ EXPECT_EQ(3, test[0].changes());
+ EXPECT_EQ(1, test[0].media_attaches());
+ EXPECT_EQ(2, test[0].media_detaches());
}
} // namespace base
« no previous file with comments | « base/system_monitor/system_monitor_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698