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

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

Powered by Google App Engine
This is Rietveld 408576698