| 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 {
|
| 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
|
|
|