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

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

Issue 10873072: Rename SystemMonitor's MediaDevice calls to RemovableStorage. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 const string16 kDeviceName = ASCIIToUTF16("media device"); 109 const string16 kDeviceName = ASCIIToUTF16("media device");
110 const std::string kDeviceId1 = "1"; 110 const std::string kDeviceId1 = "1";
111 const std::string kDeviceId2 = "2"; 111 const std::string kDeviceId2 = "2";
112 112
113 testing::Sequence mock_sequencer[kObservers]; 113 testing::Sequence mock_sequencer[kObservers];
114 MockDevicesChangedObserver observers[kObservers]; 114 MockDevicesChangedObserver observers[kObservers];
115 for (int index = 0; index < kObservers; ++index) { 115 for (int index = 0; index < kObservers; ++index) {
116 system_monitor_->AddDevicesChangedObserver(&observers[index]); 116 system_monitor_->AddDevicesChangedObserver(&observers[index]);
117 117
118 EXPECT_CALL(observers[index], 118 EXPECT_CALL(observers[index],
119 OnDevicesChanged(base::SystemMonitor::DEVTYPE_UNKNOWN)) 119 OnDevicesChanged(SystemMonitor::DEVTYPE_UNKNOWN))
120 .Times(3) 120 .Times(3)
121 .InSequence(mock_sequencer[index]); 121 .InSequence(mock_sequencer[index]);
122 EXPECT_CALL(observers[index], 122 EXPECT_CALL(observers[index], OnRemovableStorageAttached(kDeviceId1,
123 OnMediaDeviceAttached(kDeviceId1, 123 kDeviceName,
124 kDeviceName, 124 testing::_))
125 testing::_))
126 .InSequence(mock_sequencer[index]); 125 .InSequence(mock_sequencer[index]);
127 EXPECT_CALL(observers[index], OnMediaDeviceDetached(kDeviceId1)) 126 EXPECT_CALL(observers[index], OnRemovableStorageDetached(kDeviceId1))
128 .InSequence(mock_sequencer[index]); 127 .InSequence(mock_sequencer[index]);
129 EXPECT_CALL(observers[index], OnMediaDeviceDetached(kDeviceId2)) 128 EXPECT_CALL(observers[index], OnRemovableStorageDetached(kDeviceId2))
130 .Times(0).InSequence(mock_sequencer[index]); 129 .Times(0).InSequence(mock_sequencer[index]);
131 } 130 }
132 131
133 system_monitor_->ProcessDevicesChanged(base::SystemMonitor::DEVTYPE_UNKNOWN); 132 system_monitor_->ProcessDevicesChanged(SystemMonitor::DEVTYPE_UNKNOWN);
134 message_loop_.RunAllPending(); 133 message_loop_.RunAllPending();
135 134
136 system_monitor_->ProcessDevicesChanged(base::SystemMonitor::DEVTYPE_UNKNOWN); 135 system_monitor_->ProcessDevicesChanged(SystemMonitor::DEVTYPE_UNKNOWN);
137 system_monitor_->ProcessDevicesChanged(base::SystemMonitor::DEVTYPE_UNKNOWN); 136 system_monitor_->ProcessDevicesChanged(SystemMonitor::DEVTYPE_UNKNOWN);
138 message_loop_.RunAllPending(); 137 message_loop_.RunAllPending();
139 138
140 system_monitor_->ProcessMediaDeviceAttached( 139 system_monitor_->ProcessRemovableStorageAttached(kDeviceId1,
141 kDeviceId1, 140 kDeviceName,
142 kDeviceName, 141 FILE_PATH_LITERAL("path"));
143 FILE_PATH_LITERAL("path"));
144 message_loop_.RunAllPending(); 142 message_loop_.RunAllPending();
145 143
146 system_monitor_->ProcessMediaDeviceDetached(kDeviceId1); 144 system_monitor_->ProcessRemovableStorageDetached(kDeviceId1);
147 system_monitor_->ProcessMediaDeviceDetached(kDeviceId2); 145 system_monitor_->ProcessRemovableStorageDetached(kDeviceId2);
148 message_loop_.RunAllPending(); 146 message_loop_.RunAllPending();
149 } 147 }
150 148
151 TEST_F(SystemMonitorTest, GetAttachedMediaDevicesEmpty) { 149 TEST_F(SystemMonitorTest, GetAttachedRemovableStorageEmpty) {
152 std::vector<SystemMonitor::MediaDeviceInfo> devices = 150 std::vector<SystemMonitor::RemovableStorageInfo> devices =
153 system_monitor_->GetAttachedMediaDevices(); 151 system_monitor_->GetAttachedRemovableStorage();
154 EXPECT_EQ(0U, devices.size()); 152 EXPECT_EQ(0U, devices.size());
155 } 153 }
156 154
157 TEST_F(SystemMonitorTest, GetAttachedMediaDevicesAttachDetach) { 155 TEST_F(SystemMonitorTest, GetAttachedRemovableStorageAttachDetach) {
158 const std::string kDeviceId1 = "42"; 156 const std::string kDeviceId1 = "42";
159 const string16 kDeviceName1 = ASCIIToUTF16("test"); 157 const string16 kDeviceName1 = ASCIIToUTF16("test");
160 const FilePath kDevicePath1(FILE_PATH_LITERAL("/testfoo")); 158 const FilePath kDevicePath1(FILE_PATH_LITERAL("/testfoo"));
161 system_monitor_->ProcessMediaDeviceAttached(kDeviceId1, 159 system_monitor_->ProcessRemovableStorageAttached(kDeviceId1,
162 kDeviceName1, 160 kDeviceName1,
163 kDevicePath1.value()); 161 kDevicePath1.value());
164 message_loop_.RunAllPending(); 162 message_loop_.RunAllPending();
165 std::vector<SystemMonitor::MediaDeviceInfo> devices = 163 std::vector<SystemMonitor::RemovableStorageInfo> devices =
166 system_monitor_->GetAttachedMediaDevices(); 164 system_monitor_->GetAttachedRemovableStorage();
167 ASSERT_EQ(1U, devices.size()); 165 ASSERT_EQ(1U, devices.size());
168 EXPECT_EQ(kDeviceId1, devices[0].unique_id); 166 EXPECT_EQ(kDeviceId1, devices[0].device_id);
169 EXPECT_EQ(kDeviceName1, devices[0].name); 167 EXPECT_EQ(kDeviceName1, devices[0].name);
170 EXPECT_EQ(kDevicePath1.value(), devices[0].location); 168 EXPECT_EQ(kDevicePath1.value(), devices[0].location);
171 169
172 const std::string kDeviceId2 = "44"; 170 const std::string kDeviceId2 = "44";
173 const string16 kDeviceName2 = ASCIIToUTF16("test2"); 171 const string16 kDeviceName2 = ASCIIToUTF16("test2");
174 const FilePath kDevicePath2(FILE_PATH_LITERAL("/testbar")); 172 const FilePath kDevicePath2(FILE_PATH_LITERAL("/testbar"));
175 system_monitor_->ProcessMediaDeviceAttached(kDeviceId2, 173 system_monitor_->ProcessRemovableStorageAttached(kDeviceId2,
176 kDeviceName2, 174 kDeviceName2,
177 kDevicePath2.value()); 175 kDevicePath2.value());
178 message_loop_.RunAllPending(); 176 message_loop_.RunAllPending();
179 devices = system_monitor_->GetAttachedMediaDevices(); 177 devices = system_monitor_->GetAttachedRemovableStorage();
180 ASSERT_EQ(2U, devices.size()); 178 ASSERT_EQ(2U, devices.size());
181 EXPECT_EQ(kDeviceId1, devices[0].unique_id); 179 EXPECT_EQ(kDeviceId1, devices[0].device_id);
182 EXPECT_EQ(kDeviceName1, devices[0].name); 180 EXPECT_EQ(kDeviceName1, devices[0].name);
183 EXPECT_EQ(kDevicePath1.value(), devices[0].location); 181 EXPECT_EQ(kDevicePath1.value(), devices[0].location);
184 EXPECT_EQ(kDeviceId2, devices[1].unique_id); 182 EXPECT_EQ(kDeviceId2, devices[1].device_id);
185 EXPECT_EQ(kDeviceName2, devices[1].name); 183 EXPECT_EQ(kDeviceName2, devices[1].name);
186 EXPECT_EQ(kDevicePath2.value(), devices[1].location); 184 EXPECT_EQ(kDevicePath2.value(), devices[1].location);
187 185
188 system_monitor_->ProcessMediaDeviceDetached(kDeviceId1); 186 system_monitor_->ProcessRemovableStorageDetached(kDeviceId1);
189 message_loop_.RunAllPending(); 187 message_loop_.RunAllPending();
190 devices = system_monitor_->GetAttachedMediaDevices(); 188 devices = system_monitor_->GetAttachedRemovableStorage();
191 ASSERT_EQ(1U, devices.size()); 189 ASSERT_EQ(1U, devices.size());
192 EXPECT_EQ(kDeviceId2, devices[0].unique_id); 190 EXPECT_EQ(kDeviceId2, devices[0].device_id);
193 EXPECT_EQ(kDeviceName2, devices[0].name); 191 EXPECT_EQ(kDeviceName2, devices[0].name);
194 EXPECT_EQ(kDevicePath2.value(), devices[0].location); 192 EXPECT_EQ(kDevicePath2.value(), devices[0].location);
195 193
196 system_monitor_->ProcessMediaDeviceDetached(kDeviceId2); 194 system_monitor_->ProcessRemovableStorageDetached(kDeviceId2);
197 message_loop_.RunAllPending(); 195 message_loop_.RunAllPending();
198 devices = system_monitor_->GetAttachedMediaDevices(); 196 devices = system_monitor_->GetAttachedRemovableStorage();
199 EXPECT_EQ(0U, devices.size()); 197 EXPECT_EQ(0U, devices.size());
200 } 198 }
201 199
202 } // namespace 200 } // namespace
203 201
204 } // namespace base 202 } // 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