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

Side by Side Diff: chrome/browser/system_monitor/removable_device_notifications_chromeos_unittest.cc

Issue 11366144: [Media Gallery][ChromeOS] Improve device media gallery names. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed review comments Created 8 years, 1 month 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::RemovableDeviceNotificationsCros unit tests. 5 // chromeos::RemovableDeviceNotificationsCros unit tests.
6 6
7 #include "chrome/browser/system_monitor/removable_device_notifications_chromeos. h" 7 #include "chrome/browser/system_monitor/removable_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 10 matching lines...) Expand all
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 22
23 namespace chromeos { 23 namespace chromeos {
24 24
25 namespace { 25 namespace {
26 26
27 using content::BrowserThread; 27 using content::BrowserThread;
28 using disks::DiskMountManager; 28 using disks::DiskMountManager;
29 using testing::_; 29 using testing::_;
30 30
31 const char kDeviceNameWithManufacturerDetails[] = "110 KB (CompanyA, Z101)";
31 const char kDevice1[] = "/dev/d1"; 32 const char kDevice1[] = "/dev/d1";
33 const char kDevice1Name[] = "d1";
34 const char kDevice1NameWithSizeInfo[] = "110 KB d1";
32 const char kDevice2[] = "/dev/disk/d2"; 35 const char kDevice2[] = "/dev/disk/d2";
33 const char kDevice1Name[] = "d1";
34 const char kDevice2Name[] = "d2"; 36 const char kDevice2Name[] = "d2";
37 const char kDevice2NameWithSizeInfo[] = "19.8 GB d2";
38 const char kEmptyDeviceLabel[] = "";
35 const char kMountPointA[] = "mnt_a"; 39 const char kMountPointA[] = "mnt_a";
36 const char kMountPointB[] = "mnt_b"; 40 const char kMountPointB[] = "mnt_b";
41 const char kSDCardDeviceName1[] = "8.6 MB Amy_SD";
42 const char kSDCardDeviceName2[] = "8.6 MB SD Card";
43 const char kSDCardMountPoint1[] = "/media/removable/Amy_SD";
44 const char kSDCardMountPoint2[] = "/media/removable/SD Card";
45 const char kProductName[] = "Z101";
46 const char kVendorName[] = "CompanyA";
47
48 uint64 kDevice1SizeInBytes = 113048;
49 uint64 kDevice2SizeInBytes = 21231209600;
50 uint64 kSDCardSizeInBytes = 9000000;
37 51
38 std::string GetDCIMDeviceId(const std::string& unique_id) { 52 std::string GetDCIMDeviceId(const std::string& unique_id) {
39 return chrome::MediaStorageUtil::MakeDeviceId( 53 return chrome::MediaStorageUtil::MakeDeviceId(
40 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM, 54 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM,
41 chrome::kFSUniqueIdPrefix + unique_id); 55 chrome::kFSUniqueIdPrefix + unique_id);
42 } 56 }
43 57
58 // Wrapper class to test RemovableDeviceNotificationsCros.
44 class RemovableDeviceNotificationsCrosTest : public testing::Test { 59 class RemovableDeviceNotificationsCrosTest : public testing::Test {
45 public: 60 public:
46 RemovableDeviceNotificationsCrosTest() 61 RemovableDeviceNotificationsCrosTest()
47 : ui_thread_(BrowserThread::UI, &ui_loop_), 62 : ui_thread_(BrowserThread::UI, &ui_loop_),
48 file_thread_(BrowserThread::FILE) { 63 file_thread_(BrowserThread::FILE) {
49 } 64 }
50 virtual ~RemovableDeviceNotificationsCrosTest() {} 65 virtual ~RemovableDeviceNotificationsCrosTest() {}
51 66
52 protected: 67 protected:
53 virtual void SetUp() { 68 virtual void SetUp() OVERRIDE {
54 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 69 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
55 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); 70 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir());
56 file_thread_.Start(); 71 file_thread_.Start();
57 72
58 mock_devices_changed_observer_.reset(new base::MockDevicesChangedObserver); 73 mock_devices_changed_observer_.reset(new base::MockDevicesChangedObserver);
59 system_monitor_.AddDevicesChangedObserver( 74 system_monitor_.AddDevicesChangedObserver(
60 mock_devices_changed_observer_.get()); 75 mock_devices_changed_observer_.get());
61 76
62 disk_mount_manager_mock_ = new disks::MockDiskMountManager(); 77 disk_mount_manager_mock_ = new disks::MockDiskMountManager();
63 DiskMountManager::InitializeForTesting(disk_mount_manager_mock_); 78 DiskMountManager::InitializeForTesting(disk_mount_manager_mock_);
64 disk_mount_manager_mock_->SetupDefaultReplies(); 79 disk_mount_manager_mock_->SetupDefaultReplies();
65 80
66 // Initialize the test subject. 81 // Initialize the test subject.
67 notifications_ = new RemovableDeviceNotificationsCros(); 82 notifications_ = new RemovableDeviceNotificationsCros();
68 } 83 }
69 84
70 virtual void TearDown() { 85 virtual void TearDown() OVERRIDE {
71 notifications_ = NULL; 86 notifications_ = NULL;
72 disk_mount_manager_mock_ = NULL; 87 disk_mount_manager_mock_ = NULL;
73 DiskMountManager::Shutdown(); 88 DiskMountManager::Shutdown();
74 system_monitor_.RemoveDevicesChangedObserver( 89 system_monitor_.RemoveDevicesChangedObserver(
75 mock_devices_changed_observer_.get()); 90 mock_devices_changed_observer_.get());
76 WaitForFileThread(); 91 WaitForFileThread();
77 } 92 }
78 93
79 base::MockDevicesChangedObserver& observer() { 94 base::MockDevicesChangedObserver& observer() {
80 return *mock_devices_changed_observer_; 95 return *mock_devices_changed_observer_;
81 } 96 }
82 97
83 void MountDevice(MountError error_code, 98 void MountDevice(MountError error_code,
84 const DiskMountManager::MountPointInfo& mount_info, 99 const DiskMountManager::MountPointInfo& mount_info,
85 const std::string& unique_id, 100 const std::string& unique_id,
86 const std::string& device_label) { 101 const std::string& device_label,
102 const std::string& vendor_name,
103 const std::string& product_name,
104 DeviceType device_type,
105 uint64 device_size_in_bytes) {
87 if (error_code == MOUNT_ERROR_NONE) { 106 if (error_code == MOUNT_ERROR_NONE) {
88 disk_mount_manager_mock_->CreateDiskEntryForMountDevice( 107 disk_mount_manager_mock_->CreateDiskEntryForMountDevice(
89 mount_info, unique_id, device_label); 108 mount_info, unique_id, device_label, vendor_name, product_name,
109 device_type, device_size_in_bytes);
90 } 110 }
91 notifications_->MountCompleted(disks::DiskMountManager::MOUNTING, 111 notifications_->MountCompleted(disks::DiskMountManager::MOUNTING,
92 error_code, 112 error_code,
93 mount_info); 113 mount_info);
94 WaitForFileThread(); 114 WaitForFileThread();
95 } 115 }
96 116
97 void UnmountDevice(MountError error_code, 117 void UnmountDevice(MountError error_code,
98 const DiskMountManager::MountPointInfo& mount_info) { 118 const DiskMountManager::MountPointInfo& mount_info) {
99 notifications_->MountCompleted(disks::DiskMountManager::UNMOUNTING, 119 notifications_->MountCompleted(disks::DiskMountManager::UNMOUNTING,
100 error_code, 120 error_code,
101 mount_info); 121 mount_info);
102 if (error_code == MOUNT_ERROR_NONE) { 122 if (error_code == MOUNT_ERROR_NONE) {
103 disk_mount_manager_mock_->RemoveDiskEntryForMountDevice( 123 disk_mount_manager_mock_->RemoveDiskEntryForMountDevice(
104 mount_info); 124 mount_info);
105 } 125 }
106 WaitForFileThread(); 126 WaitForFileThread();
107 } 127 }
108 128
129 uint64 GetDeviceStorageSize(const std::string& device_location) {
130 return notifications_->GetStorageSize(device_location);
131 }
132
109 // Create a directory named |dir| relative to the test directory. 133 // Create a directory named |dir| relative to the test directory.
110 // Set |with_dcim_dir| to true if the created directory will have a "DCIM" 134 // Set |with_dcim_dir| to true if the created directory will have a "DCIM"
111 // subdirectory. 135 // subdirectory.
112 // Returns the full path to the created directory on success, or an empty 136 // Returns the full path to the created directory on success, or an empty
113 // path on failure. 137 // path on failure.
114 FilePath CreateMountPoint(const std::string& dir, bool with_dcim_dir) { 138 FilePath CreateMountPoint(const std::string& dir, bool with_dcim_dir) {
115 FilePath return_path(scoped_temp_dir_.path()); 139 FilePath return_path(scoped_temp_dir_.path());
116 return_path = return_path.AppendASCII(dir); 140 return_path = return_path.AppendASCII(dir);
117 FilePath path(return_path); 141 FilePath path(return_path);
118 if (with_dcim_dir) 142 if (with_dcim_dir)
119 path = path.Append(chrome::kDCIMDirectoryName); 143 path = path.Append(chrome::kDCIMDirectoryName);
120 if (!file_util::CreateDirectory(path)) 144 if (!file_util::CreateDirectory(path))
121 return FilePath(); 145 return FilePath();
122 return return_path; 146 return return_path;
123 } 147 }
124 148
125 static void PostQuitToUIThread() { 149 static void PostQuitToUIThread() {
126 BrowserThread::PostTask(BrowserThread::UI, 150 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
127 FROM_HERE,
128 MessageLoop::QuitClosure()); 151 MessageLoop::QuitClosure());
129 } 152 }
130 153
131 static void WaitForFileThread() { 154 static void WaitForFileThread() {
132 BrowserThread::PostTask(BrowserThread::FILE, 155 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
133 FROM_HERE,
134 base::Bind(&PostQuitToUIThread)); 156 base::Bind(&PostQuitToUIThread));
135 MessageLoop::current()->Run(); 157 MessageLoop::current()->Run();
136 } 158 }
137 159
138 private: 160 private:
139 // The message loops and threads to run tests on. 161 // The message loops and threads to run tests on.
140 MessageLoop ui_loop_; 162 MessageLoop ui_loop_;
141 content::TestBrowserThread ui_thread_; 163 content::TestBrowserThread ui_thread_;
142 content::TestBrowserThread file_thread_; 164 content::TestBrowserThread file_thread_;
143 165
(...skipping 16 matching lines...) Expand all
160 testing::Sequence mock_sequence; 182 testing::Sequence mock_sequence;
161 FilePath mount_path1 = CreateMountPoint(kMountPointA, true); 183 FilePath mount_path1 = CreateMountPoint(kMountPointA, true);
162 ASSERT_FALSE(mount_path1.empty()); 184 ASSERT_FALSE(mount_path1.empty());
163 DiskMountManager::MountPointInfo mount_info(kDevice1, 185 DiskMountManager::MountPointInfo mount_info(kDevice1,
164 mount_path1.value(), 186 mount_path1.value(),
165 MOUNT_TYPE_DEVICE, 187 MOUNT_TYPE_DEVICE,
166 disks::MOUNT_CONDITION_NONE); 188 disks::MOUNT_CONDITION_NONE);
167 const std::string kUniqueId0 = "FFFF-FFFF"; 189 const std::string kUniqueId0 = "FFFF-FFFF";
168 EXPECT_CALL(observer(), 190 EXPECT_CALL(observer(),
169 OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId0), 191 OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId0),
170 ASCIIToUTF16(kDevice1Name), 192 ASCIIToUTF16(kDevice1NameWithSizeInfo),
171 mount_path1.value())) 193 mount_path1.value()))
172 .InSequence(mock_sequence); 194 .InSequence(mock_sequence);
173 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId0, kDevice1Name); 195 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId0, kDevice1Name,
196 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
174 197
175 EXPECT_CALL(observer(), 198 EXPECT_CALL(observer(),
176 OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId0))) 199 OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId0)))
177 .InSequence(mock_sequence); 200 .InSequence(mock_sequence);
178 UnmountDevice(MOUNT_ERROR_NONE, mount_info); 201 UnmountDevice(MOUNT_ERROR_NONE, mount_info);
179 202
180 FilePath mount_path2 = CreateMountPoint(kMountPointB, true); 203 FilePath mount_path2 = CreateMountPoint(kMountPointB, true);
181 ASSERT_FALSE(mount_path2.empty()); 204 ASSERT_FALSE(mount_path2.empty());
182 DiskMountManager::MountPointInfo mount_info2(kDevice2, 205 DiskMountManager::MountPointInfo mount_info2(kDevice2,
183 mount_path2.value(), 206 mount_path2.value(),
184 MOUNT_TYPE_DEVICE, 207 MOUNT_TYPE_DEVICE,
185 disks::MOUNT_CONDITION_NONE); 208 disks::MOUNT_CONDITION_NONE);
186 const std::string kUniqueId1 = "FFF0-FFF0"; 209 const std::string kUniqueId1 = "FFF0-FFF0";
187 210
188 EXPECT_CALL(observer(), 211 EXPECT_CALL(observer(),
189 OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId1), 212 OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId1),
190 ASCIIToUTF16(kDevice2Name), 213 ASCIIToUTF16(kDevice2NameWithSizeInfo),
191 mount_path2.value())) 214 mount_path2.value()))
192 .InSequence(mock_sequence); 215 .InSequence(mock_sequence);
193 MountDevice(MOUNT_ERROR_NONE, mount_info2, kUniqueId1, kDevice2Name); 216 MountDevice(MOUNT_ERROR_NONE, mount_info2, kUniqueId1, kDevice2Name,
217 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice2SizeInBytes);
194 218
195 EXPECT_CALL(observer(), 219 EXPECT_CALL(observer(),
196 OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId1))) 220 OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId1)))
197 .InSequence(mock_sequence); 221 .InSequence(mock_sequence);
198 UnmountDevice(MOUNT_ERROR_NONE, mount_info2); 222 UnmountDevice(MOUNT_ERROR_NONE, mount_info2);
199 } 223 }
200 224
201 // Removable mass storage devices with no dcim folder are also recognized. 225 // Removable mass storage devices with no dcim folder are also recognized.
202 TEST_F(RemovableDeviceNotificationsCrosTest, NoDCIM) { 226 TEST_F(RemovableDeviceNotificationsCrosTest, NoDCIM) {
203 testing::Sequence mock_sequence; 227 testing::Sequence mock_sequence;
204 FilePath mount_path = CreateMountPoint(kMountPointA, false); 228 FilePath mount_path = CreateMountPoint(kMountPointA, false);
205 const std::string kUniqueId = "FFFF-FFFF"; 229 const std::string kUniqueId = "FFFF-FFFF";
206 ASSERT_FALSE(mount_path.empty()); 230 ASSERT_FALSE(mount_path.empty());
207 DiskMountManager::MountPointInfo mount_info(kDevice1, 231 DiskMountManager::MountPointInfo mount_info(kDevice1,
208 mount_path.value(), 232 mount_path.value(),
209 MOUNT_TYPE_DEVICE, 233 MOUNT_TYPE_DEVICE,
210 disks::MOUNT_CONDITION_NONE); 234 disks::MOUNT_CONDITION_NONE);
211 const std::string device_id = chrome::MediaStorageUtil::MakeDeviceId( 235 const std::string device_id = chrome::MediaStorageUtil::MakeDeviceId(
212 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM, 236 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM,
213 chrome::kFSUniqueIdPrefix + kUniqueId); 237 chrome::kFSUniqueIdPrefix + kUniqueId);
214 EXPECT_CALL(observer(), 238 EXPECT_CALL(observer(),
215 OnRemovableStorageAttached(device_id, ASCIIToUTF16(kDevice1Name), 239 OnRemovableStorageAttached(device_id,
240 ASCIIToUTF16(kDevice1NameWithSizeInfo),
216 mount_path.value())).Times(1); 241 mount_path.value())).Times(1);
217 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name); 242 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name,
243 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
218 } 244 }
219 245
220 // Non device mounts and mount errors are ignored. 246 // Non device mounts and mount errors are ignored.
221 TEST_F(RemovableDeviceNotificationsCrosTest, Ignore) { 247 TEST_F(RemovableDeviceNotificationsCrosTest, Ignore) {
222 testing::Sequence mock_sequence; 248 testing::Sequence mock_sequence;
223 FilePath mount_path = CreateMountPoint(kMountPointA, true); 249 FilePath mount_path = CreateMountPoint(kMountPointA, true);
224 const std::string kUniqueId = "FFFF-FFFF"; 250 const std::string kUniqueId = "FFFF-FFFF";
225 ASSERT_FALSE(mount_path.empty()); 251 ASSERT_FALSE(mount_path.empty());
226 252
227 // Mount error. 253 // Mount error.
228 DiskMountManager::MountPointInfo mount_info(kDevice1, 254 DiskMountManager::MountPointInfo mount_info(kDevice1,
229 mount_path.value(), 255 mount_path.value(),
230 MOUNT_TYPE_DEVICE, 256 MOUNT_TYPE_DEVICE,
231 disks::MOUNT_CONDITION_NONE); 257 disks::MOUNT_CONDITION_NONE);
232 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); 258 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0);
233 MountDevice(MOUNT_ERROR_UNKNOWN, mount_info, kUniqueId, kDevice1Name); 259 MountDevice(MOUNT_ERROR_UNKNOWN, mount_info, kUniqueId, kDevice1Name,
260 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
234 261
235 // Not a device 262 // Not a device
236 mount_info.mount_type = MOUNT_TYPE_ARCHIVE; 263 mount_info.mount_type = MOUNT_TYPE_ARCHIVE;
237 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); 264 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0);
238 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name); 265 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name,
266 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
239 267
240 // Unsupported file system. 268 // Unsupported file system.
241 mount_info.mount_type = MOUNT_TYPE_DEVICE; 269 mount_info.mount_type = MOUNT_TYPE_DEVICE;
242 mount_info.mount_condition = disks::MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM; 270 mount_info.mount_condition = disks::MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM;
243 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); 271 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0);
244 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name); 272 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name,
273 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
274 }
275
276 TEST_F(RemovableDeviceNotificationsCrosTest, SDCardAttachDetach) {
277 testing::Sequence mock_sequence;
278 FilePath mount_path1 = CreateMountPoint(kSDCardMountPoint1, true);
279 ASSERT_FALSE(mount_path1.empty());
280 DiskMountManager::MountPointInfo mount_info1(kSDCardDeviceName1,
281 mount_path1.value(),
282 MOUNT_TYPE_DEVICE,
283 disks::MOUNT_CONDITION_NONE);
284 const std::string kUniqueId1 = "FFFF-FFFF";
Lei Zhang 2012/11/12 23:20:52 These can go to the top as const char []s and be s
kmadhusu 2012/11/13 01:03:58 Done.
285 EXPECT_CALL(observer(),
286 OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId1),
287 ASCIIToUTF16(kSDCardDeviceName1),
288 mount_path1.value()))
289 .InSequence(mock_sequence);
290 MountDevice(MOUNT_ERROR_NONE, mount_info1, kUniqueId1, kSDCardDeviceName1,
291 kVendorName, kProductName, DEVICE_TYPE_SD, kSDCardSizeInBytes);
292
293 EXPECT_CALL(observer(),
294 OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId1)))
295 .InSequence(mock_sequence);
296 UnmountDevice(MOUNT_ERROR_NONE, mount_info1);
297
298 FilePath mount_path2 = CreateMountPoint(kSDCardMountPoint2, true);
299 ASSERT_FALSE(mount_path2.empty());
300 DiskMountManager::MountPointInfo mount_info2(kSDCardDeviceName2,
301 mount_path2.value(),
302 MOUNT_TYPE_DEVICE,
303 disks::MOUNT_CONDITION_NONE);
304 const std::string kUniqueId2 = "F0FF-FFF0";
305 EXPECT_CALL(observer(),
306 OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId2),
307 ASCIIToUTF16(kSDCardDeviceName2),
308 mount_path2.value()))
309 .InSequence(mock_sequence);
310 MountDevice(MOUNT_ERROR_NONE, mount_info2, kUniqueId2, kSDCardDeviceName2,
311 kVendorName, kProductName, DEVICE_TYPE_SD, kSDCardSizeInBytes);
312
313 EXPECT_CALL(observer(),
314 OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId2)))
315 .InSequence(mock_sequence);
316 UnmountDevice(MOUNT_ERROR_NONE, mount_info2);
317 }
318
319 TEST_F(RemovableDeviceNotificationsCrosTest, AttachDeviceWithEmptyLabel) {
320 testing::Sequence mock_sequence;
321 FilePath mount_path1 = CreateMountPoint(kMountPointA, true);
322 ASSERT_FALSE(mount_path1.empty());
323 DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel,
324 mount_path1.value(),
325 MOUNT_TYPE_DEVICE,
326 disks::MOUNT_CONDITION_NONE);
327 const std::string kUniqueId0 = "FFFF-FFFF";
328 EXPECT_CALL(observer(), OnRemovableStorageAttached(
329 GetDCIMDeviceId(kUniqueId0),
330 ASCIIToUTF16(kDeviceNameWithManufacturerDetails),
331 mount_path1.value()))
332 .InSequence(mock_sequence);
333 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId0, kEmptyDeviceLabel,
334 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
335
336 EXPECT_CALL(observer(),
337 OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId0)))
338 .InSequence(mock_sequence);
339 UnmountDevice(MOUNT_ERROR_NONE, mount_info);
340 }
341
342 TEST_F(RemovableDeviceNotificationsCrosTest, GetStorageSize) {
343 testing::Sequence mock_sequence;
344 FilePath mount_path1 = CreateMountPoint(kMountPointA, true);
345 ASSERT_FALSE(mount_path1.empty());
346 DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel,
347 mount_path1.value(),
348 MOUNT_TYPE_DEVICE,
349 disks::MOUNT_CONDITION_NONE);
350 const std::string kUniqueId0 = "FFFF-FFFF";
351 EXPECT_CALL(observer(), OnRemovableStorageAttached(
352 GetDCIMDeviceId(kUniqueId0),
353 ASCIIToUTF16(kDeviceNameWithManufacturerDetails),
354 mount_path1.value()))
355 .InSequence(mock_sequence);
356 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId0, kEmptyDeviceLabel,
357 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
358
359 EXPECT_EQ(kDevice1SizeInBytes, GetDeviceStorageSize(mount_path1.value()));
360 EXPECT_CALL(observer(),
361 OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId0)))
362 .InSequence(mock_sequence);
363 UnmountDevice(MOUNT_ERROR_NONE, mount_info);
245 } 364 }
246 365
247 } // namespace 366 } // namespace
248 367
249 } // namespace chrome 368 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698