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

Side by Side Diff: base/system_monitor/system_monitor_unittest.cc

Issue 10836004: add device type as an argument in OnDevicesChanged. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix indent Created 8 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/system_monitor/system_monitor.cc ('k') | base/test/mock_devices_changed_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/system_monitor/system_monitor.h" 5 #include "base/system_monitor/system_monitor.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/test/mock_devices_changed_observer.h" 9 #include "base/test/mock_devices_changed_observer.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 const int kObservers = 5; 111 const int kObservers = 5;
112 const string16 kDeviceName = ASCIIToUTF16("media device"); 112 const string16 kDeviceName = ASCIIToUTF16("media device");
113 const std::string kDeviceId1 = "1"; 113 const std::string kDeviceId1 = "1";
114 const std::string kDeviceId2 = "2"; 114 const std::string kDeviceId2 = "2";
115 115
116 testing::Sequence mock_sequencer[kObservers]; 116 testing::Sequence mock_sequencer[kObservers];
117 MockDevicesChangedObserver observers[kObservers]; 117 MockDevicesChangedObserver observers[kObservers];
118 for (int index = 0; index < kObservers; ++index) { 118 for (int index = 0; index < kObservers; ++index) {
119 system_monitor_->AddDevicesChangedObserver(&observers[index]); 119 system_monitor_->AddDevicesChangedObserver(&observers[index]);
120 120
121 EXPECT_CALL(observers[index], OnDevicesChanged()) 121 EXPECT_CALL(observers[index],
122 OnDevicesChanged(base::SystemMonitor::DEVTYPE_UNKNOWN))
122 .Times(3) 123 .Times(3)
123 .InSequence(mock_sequencer[index]); 124 .InSequence(mock_sequencer[index]);
124 EXPECT_CALL(observers[index], 125 EXPECT_CALL(observers[index],
125 OnMediaDeviceAttached(kDeviceId1, 126 OnMediaDeviceAttached(kDeviceId1,
126 kDeviceName, 127 kDeviceName,
127 base::SystemMonitor::TYPE_PATH, 128 base::SystemMonitor::TYPE_PATH,
128 testing::_)) 129 testing::_))
129 .InSequence(mock_sequencer[index]); 130 .InSequence(mock_sequencer[index]);
130 EXPECT_CALL(observers[index], OnMediaDeviceDetached(kDeviceId1)) 131 EXPECT_CALL(observers[index], OnMediaDeviceDetached(kDeviceId1))
131 .InSequence(mock_sequencer[index]); 132 .InSequence(mock_sequencer[index]);
132 EXPECT_CALL(observers[index], OnMediaDeviceDetached(kDeviceId2)) 133 EXPECT_CALL(observers[index], OnMediaDeviceDetached(kDeviceId2))
133 .InSequence(mock_sequencer[index]); 134 .InSequence(mock_sequencer[index]);
134 } 135 }
135 136
136 system_monitor_->ProcessDevicesChanged(); 137 system_monitor_->ProcessDevicesChanged(base::SystemMonitor::DEVTYPE_UNKNOWN);
137 message_loop_.RunAllPending(); 138 message_loop_.RunAllPending();
138 139
139 system_monitor_->ProcessDevicesChanged(); 140 system_monitor_->ProcessDevicesChanged(base::SystemMonitor::DEVTYPE_UNKNOWN);
140 system_monitor_->ProcessDevicesChanged(); 141 system_monitor_->ProcessDevicesChanged(base::SystemMonitor::DEVTYPE_UNKNOWN);
141 message_loop_.RunAllPending(); 142 message_loop_.RunAllPending();
142 143
143 system_monitor_->ProcessMediaDeviceAttached( 144 system_monitor_->ProcessMediaDeviceAttached(
144 kDeviceId1, 145 kDeviceId1,
145 kDeviceName, 146 kDeviceName,
146 base::SystemMonitor::TYPE_PATH, 147 base::SystemMonitor::TYPE_PATH,
147 FILE_PATH_LITERAL("path")); 148 FILE_PATH_LITERAL("path"));
148 message_loop_.RunAllPending(); 149 message_loop_.RunAllPending();
149 150
150 system_monitor_->ProcessMediaDeviceDetached(kDeviceId1); 151 system_monitor_->ProcessMediaDeviceDetached(kDeviceId1);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 206
206 system_monitor_->ProcessMediaDeviceDetached(kDeviceId2); 207 system_monitor_->ProcessMediaDeviceDetached(kDeviceId2);
207 message_loop_.RunAllPending(); 208 message_loop_.RunAllPending();
208 devices = system_monitor_->GetAttachedMediaDevices(); 209 devices = system_monitor_->GetAttachedMediaDevices();
209 EXPECT_EQ(0U, devices.size()); 210 EXPECT_EQ(0U, devices.size());
210 } 211 }
211 212
212 } // namespace 213 } // namespace
213 214
214 } // namespace base 215 } // namespace base
OLDNEW
« no previous file with comments | « base/system_monitor/system_monitor.cc ('k') | base/test/mock_devices_changed_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698