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

Side by Side Diff: chrome/browser/media_gallery/media_device_notifications_chromeos_unittest.cc

Issue 10829384: SystemMonitor: Pull device type into the device id (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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
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 // chromeos::MediaDeviceNotifications unit tests. 5 // chromeos::MediaDeviceNotifications unit tests.
6 6
7 #include "chrome/browser/media_gallery/media_device_notifications_chromeos.h" 7 #include "chrome/browser/media_gallery/media_device_notifications_chromeos.h"
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 mock_devices_changed_observer_.get()); 67 mock_devices_changed_observer_.get());
68 WaitForFileThread(); 68 WaitForFileThread();
69 } 69 }
70 70
71 base::MockDevicesChangedObserver& observer() { 71 base::MockDevicesChangedObserver& observer() {
72 return *mock_devices_changed_observer_; 72 return *mock_devices_changed_observer_;
73 } 73 }
74 74
75 void MountDevice(MountError error_code, 75 void MountDevice(MountError error_code,
76 const DiskMountManager::MountPointInfo& mount_info, 76 const DiskMountManager::MountPointInfo& mount_info,
77 const std::string& device_id) { 77 const std::string& unique_id) {
78 if (error_code == MOUNT_ERROR_NONE) { 78 if (error_code == MOUNT_ERROR_NONE) {
79 disk_mount_manager_mock_->CreateDiskEntryForMountDevice( 79 disk_mount_manager_mock_->CreateDiskEntryForMountDevice(
80 mount_info, device_id); 80 mount_info, unique_id);
81 } 81 }
82 notifications_->MountCompleted(disks::DiskMountManager::MOUNTING, 82 notifications_->MountCompleted(disks::DiskMountManager::MOUNTING,
83 error_code, 83 error_code,
84 mount_info); 84 mount_info);
85 WaitForFileThread(); 85 WaitForFileThread();
86 } 86 }
87 87
88 void UnmountDevice(MountError error_code, 88 void UnmountDevice(MountError error_code,
89 const DiskMountManager::MountPointInfo& mount_info) { 89 const DiskMountManager::MountPointInfo& mount_info) {
90 notifications_->MountCompleted(disks::DiskMountManager::UNMOUNTING, 90 notifications_->MountCompleted(disks::DiskMountManager::UNMOUNTING,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 // Simple test case where we attach and detach a media device. 149 // Simple test case where we attach and detach a media device.
150 TEST_F(MediaDeviceNotificationsTest, BasicAttachDetach) { 150 TEST_F(MediaDeviceNotificationsTest, BasicAttachDetach) {
151 testing::Sequence mock_sequence; 151 testing::Sequence mock_sequence;
152 FilePath mount_path1 = CreateMountPoint(kMountPointA, true); 152 FilePath mount_path1 = CreateMountPoint(kMountPointA, true);
153 ASSERT_FALSE(mount_path1.empty()); 153 ASSERT_FALSE(mount_path1.empty());
154 DiskMountManager::MountPointInfo mount_info(kDevice1, 154 DiskMountManager::MountPointInfo mount_info(kDevice1,
155 mount_path1.value(), 155 mount_path1.value(),
156 MOUNT_TYPE_DEVICE, 156 MOUNT_TYPE_DEVICE,
157 disks::MOUNT_CONDITION_NONE); 157 disks::MOUNT_CONDITION_NONE);
158 const std::string kDeviceId0 = "FFFF-FFFF"; 158 const std::string kDeviceId0 = "FFFF-FFFF";
kmadhusu 2012/08/17 18:53:35 nit: Fix the device id formats. It is no longer "F
vandebo (ex-Chrome) 2012/08/17 22:55:51 Done.
159 EXPECT_CALL(observer(), 159 EXPECT_CALL(observer(),
160 OnMediaDeviceAttached(kDeviceId0, 160 OnMediaDeviceAttached(kDeviceId0,
161 ASCIIToUTF16(kDevice1Name), 161 ASCIIToUTF16(kDevice1Name),
162 base::SystemMonitor::TYPE_PATH,
163 mount_path1.value())) 162 mount_path1.value()))
164 .InSequence(mock_sequence); 163 .InSequence(mock_sequence);
165 MountDevice(MOUNT_ERROR_NONE, mount_info, kDeviceId0); 164 MountDevice(MOUNT_ERROR_NONE, mount_info, kDeviceId0);
166 165
167 EXPECT_CALL(observer(), OnMediaDeviceDetached(kDeviceId0)) 166 EXPECT_CALL(observer(), OnMediaDeviceDetached(kDeviceId0))
168 .InSequence(mock_sequence); 167 .InSequence(mock_sequence);
169 UnmountDevice(MOUNT_ERROR_NONE, mount_info); 168 UnmountDevice(MOUNT_ERROR_NONE, mount_info);
170 169
171 FilePath mount_path2 = CreateMountPoint(kMountPointB, true); 170 FilePath mount_path2 = CreateMountPoint(kMountPointB, true);
172 ASSERT_FALSE(mount_path2.empty()); 171 ASSERT_FALSE(mount_path2.empty());
173 DiskMountManager::MountPointInfo mount_info2(kDevice2, 172 DiskMountManager::MountPointInfo mount_info2(kDevice2,
174 mount_path2.value(), 173 mount_path2.value(),
175 MOUNT_TYPE_DEVICE, 174 MOUNT_TYPE_DEVICE,
176 disks::MOUNT_CONDITION_NONE); 175 disks::MOUNT_CONDITION_NONE);
177 const std::string kDeviceId1 = "FFF0-FFF0"; 176 const std::string kDeviceId1 = "FFF0-FFF0";
178 177
179 EXPECT_CALL(observer(), 178 EXPECT_CALL(observer(),
180 OnMediaDeviceAttached(kDeviceId1, 179 OnMediaDeviceAttached(kDeviceId1,
181 ASCIIToUTF16(kDevice2Name), 180 ASCIIToUTF16(kDevice2Name),
182 base::SystemMonitor::TYPE_PATH,
183 mount_path2.value())) 181 mount_path2.value()))
184 .InSequence(mock_sequence); 182 .InSequence(mock_sequence);
185 MountDevice(MOUNT_ERROR_NONE, mount_info2, kDeviceId1); 183 MountDevice(MOUNT_ERROR_NONE, mount_info2, kDeviceId1);
186 184
187 EXPECT_CALL(observer(), OnMediaDeviceDetached(kDeviceId1)) 185 EXPECT_CALL(observer(), OnMediaDeviceDetached(kDeviceId1))
188 .InSequence(mock_sequence); 186 .InSequence(mock_sequence);
189 UnmountDevice(MOUNT_ERROR_NONE, mount_info2); 187 UnmountDevice(MOUNT_ERROR_NONE, mount_info2);
190 } 188 }
191 189
192 // Only mount points with DCIM directories are recognized. 190 // Only mount points with DCIM directories are recognized.
193 TEST_F(MediaDeviceNotificationsTest, DCIM) { 191 TEST_F(MediaDeviceNotificationsTest, DCIM) {
194 testing::Sequence mock_sequence; 192 testing::Sequence mock_sequence;
195 FilePath mount_path = CreateMountPoint(kMountPointA, false); 193 FilePath mount_path = CreateMountPoint(kMountPointA, false);
196 const std::string kDeviceId = "FFFF-FFFF"; 194 const std::string kDeviceId = "FFFF-FFFF";
197 ASSERT_FALSE(mount_path.empty()); 195 ASSERT_FALSE(mount_path.empty());
198 DiskMountManager::MountPointInfo mount_info(kDevice1, 196 DiskMountManager::MountPointInfo mount_info(kDevice1,
199 mount_path.value(), 197 mount_path.value(),
200 MOUNT_TYPE_DEVICE, 198 MOUNT_TYPE_DEVICE,
201 disks::MOUNT_CONDITION_NONE); 199 disks::MOUNT_CONDITION_NONE);
202 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(0); 200 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0);
203 MountDevice(MOUNT_ERROR_NONE, mount_info, kDeviceId); 201 MountDevice(MOUNT_ERROR_NONE, mount_info, kDeviceId);
204 } 202 }
205 203
206 // Non device mounts and mount errors are ignored. 204 // Non device mounts and mount errors are ignored.
207 TEST_F(MediaDeviceNotificationsTest, Ignore) { 205 TEST_F(MediaDeviceNotificationsTest, Ignore) {
208 testing::Sequence mock_sequence; 206 testing::Sequence mock_sequence;
209 FilePath mount_path = CreateMountPoint(kMountPointA, true); 207 FilePath mount_path = CreateMountPoint(kMountPointA, true);
210 const std::string kDeviceId = "FFFF-FFFF"; 208 const std::string kDeviceId = "FFFF-FFFF";
211 ASSERT_FALSE(mount_path.empty()); 209 ASSERT_FALSE(mount_path.empty());
212 210
213 // Mount error. 211 // Mount error.
214 DiskMountManager::MountPointInfo mount_info(kDevice1, 212 DiskMountManager::MountPointInfo mount_info(kDevice1,
215 mount_path.value(), 213 mount_path.value(),
216 MOUNT_TYPE_DEVICE, 214 MOUNT_TYPE_DEVICE,
217 disks::MOUNT_CONDITION_NONE); 215 disks::MOUNT_CONDITION_NONE);
218 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(0); 216 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0);
219 MountDevice(MOUNT_ERROR_UNKNOWN, mount_info, kDeviceId); 217 MountDevice(MOUNT_ERROR_UNKNOWN, mount_info, kDeviceId);
220 218
221 // Not a device 219 // Not a device
222 mount_info.mount_type = MOUNT_TYPE_ARCHIVE; 220 mount_info.mount_type = MOUNT_TYPE_ARCHIVE;
223 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(0); 221 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0);
224 MountDevice(MOUNT_ERROR_NONE, mount_info, kDeviceId); 222 MountDevice(MOUNT_ERROR_NONE, mount_info, kDeviceId);
225 223
226 // Unsupported file system. 224 // Unsupported file system.
227 mount_info.mount_type = MOUNT_TYPE_DEVICE; 225 mount_info.mount_type = MOUNT_TYPE_DEVICE;
228 mount_info.mount_condition = disks::MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM; 226 mount_info.mount_condition = disks::MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM;
229 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _, _)).Times(0); 227 EXPECT_CALL(observer(), OnMediaDeviceAttached(_, _, _)).Times(0);
230 MountDevice(MOUNT_ERROR_NONE, mount_info, kDeviceId); 228 MountDevice(MOUNT_ERROR_NONE, mount_info, kDeviceId);
231 } 229 }
232 230
233 } // namespace 231 } // namespace
234 232
235 } // namespace chrome 233 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698