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

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

Issue 11363236: Revert 167606 - [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)";
32 const char kDevice1[] = "/dev/d1"; 31 const char kDevice1[] = "/dev/d1";
32 const char kDevice2[] = "/dev/disk/d2";
33 const char kDevice1Name[] = "d1"; 33 const char kDevice1Name[] = "d1";
34 const char kDevice1NameWithSizeInfo[] = "110 KB d1";
35 const char kDevice2[] = "/dev/disk/d2";
36 const char kDevice2Name[] = "d2"; 34 const char kDevice2Name[] = "d2";
37 const char kDevice2NameWithSizeInfo[] = "19.8 GB d2";
38 const char kEmptyDeviceLabel[] = "";
39 const char kMountPointA[] = "mnt_a"; 35 const char kMountPointA[] = "mnt_a";
40 const char kMountPointB[] = "mnt_b"; 36 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;
53 37
54 std::string GetDCIMDeviceId(const std::string& unique_id) { 38 std::string GetDCIMDeviceId(const std::string& unique_id) {
55 return chrome::MediaStorageUtil::MakeDeviceId( 39 return chrome::MediaStorageUtil::MakeDeviceId(
56 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM, 40 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM,
57 chrome::kFSUniqueIdPrefix + unique_id); 41 chrome::kFSUniqueIdPrefix + unique_id);
58 } 42 }
59 43
60 // Wrapper class to test RemovableDeviceNotificationsCros.
61 class RemovableDeviceNotificationsCrosTest : public testing::Test { 44 class RemovableDeviceNotificationsCrosTest : public testing::Test {
62 public: 45 public:
63 RemovableDeviceNotificationsCrosTest() 46 RemovableDeviceNotificationsCrosTest()
64 : ui_thread_(BrowserThread::UI, &ui_loop_), 47 : ui_thread_(BrowserThread::UI, &ui_loop_),
65 file_thread_(BrowserThread::FILE) { 48 file_thread_(BrowserThread::FILE) {
66 } 49 }
67 virtual ~RemovableDeviceNotificationsCrosTest() {} 50 virtual ~RemovableDeviceNotificationsCrosTest() {}
68 51
69 protected: 52 protected:
70 virtual void SetUp() OVERRIDE { 53 virtual void SetUp() {
71 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); 54 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
72 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); 55 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir());
73 file_thread_.Start(); 56 file_thread_.Start();
74 57
75 mock_devices_changed_observer_.reset(new base::MockDevicesChangedObserver); 58 mock_devices_changed_observer_.reset(new base::MockDevicesChangedObserver);
76 system_monitor_.AddDevicesChangedObserver( 59 system_monitor_.AddDevicesChangedObserver(
77 mock_devices_changed_observer_.get()); 60 mock_devices_changed_observer_.get());
78 61
79 disk_mount_manager_mock_ = new disks::MockDiskMountManager(); 62 disk_mount_manager_mock_ = new disks::MockDiskMountManager();
80 DiskMountManager::InitializeForTesting(disk_mount_manager_mock_); 63 DiskMountManager::InitializeForTesting(disk_mount_manager_mock_);
81 disk_mount_manager_mock_->SetupDefaultReplies(); 64 disk_mount_manager_mock_->SetupDefaultReplies();
82 65
83 // Initialize the test subject. 66 // Initialize the test subject.
84 notifications_ = new RemovableDeviceNotificationsCros(); 67 notifications_ = new RemovableDeviceNotificationsCros();
85 } 68 }
86 69
87 virtual void TearDown() OVERRIDE { 70 virtual void TearDown() {
88 notifications_ = NULL; 71 notifications_ = NULL;
89 disk_mount_manager_mock_ = NULL; 72 disk_mount_manager_mock_ = NULL;
90 DiskMountManager::Shutdown(); 73 DiskMountManager::Shutdown();
91 system_monitor_.RemoveDevicesChangedObserver( 74 system_monitor_.RemoveDevicesChangedObserver(
92 mock_devices_changed_observer_.get()); 75 mock_devices_changed_observer_.get());
93 WaitForFileThread(); 76 WaitForFileThread();
94 } 77 }
95 78
96 base::MockDevicesChangedObserver& observer() { 79 base::MockDevicesChangedObserver& observer() {
97 return *mock_devices_changed_observer_; 80 return *mock_devices_changed_observer_;
98 } 81 }
99 82
100 void MountDevice(MountError error_code, 83 void MountDevice(MountError error_code,
101 const DiskMountManager::MountPointInfo& mount_info, 84 const DiskMountManager::MountPointInfo& mount_info,
102 const std::string& unique_id, 85 const std::string& unique_id,
103 const std::string& device_label, 86 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) {
108 if (error_code == MOUNT_ERROR_NONE) { 87 if (error_code == MOUNT_ERROR_NONE) {
109 disk_mount_manager_mock_->CreateDiskEntryForMountDevice( 88 disk_mount_manager_mock_->CreateDiskEntryForMountDevice(
110 mount_info, unique_id, device_label, vendor_name, product_name, 89 mount_info, unique_id, device_label);
111 device_type, device_size_in_bytes);
112 } 90 }
113 notifications_->MountCompleted(disks::DiskMountManager::MOUNTING, 91 notifications_->MountCompleted(disks::DiskMountManager::MOUNTING,
114 error_code, 92 error_code,
115 mount_info); 93 mount_info);
116 WaitForFileThread(); 94 WaitForFileThread();
117 } 95 }
118 96
119 void UnmountDevice(MountError error_code, 97 void UnmountDevice(MountError error_code,
120 const DiskMountManager::MountPointInfo& mount_info) { 98 const DiskMountManager::MountPointInfo& mount_info) {
121 notifications_->MountCompleted(disks::DiskMountManager::UNMOUNTING, 99 notifications_->MountCompleted(disks::DiskMountManager::UNMOUNTING,
122 error_code, 100 error_code,
123 mount_info); 101 mount_info);
124 if (error_code == MOUNT_ERROR_NONE) { 102 if (error_code == MOUNT_ERROR_NONE) {
125 disk_mount_manager_mock_->RemoveDiskEntryForMountDevice( 103 disk_mount_manager_mock_->RemoveDiskEntryForMountDevice(
126 mount_info); 104 mount_info);
127 } 105 }
128 WaitForFileThread(); 106 WaitForFileThread();
129 } 107 }
130 108
131 uint64 GetDeviceStorageSize(const std::string& device_location) {
132 return notifications_->GetStorageSize(device_location);
133 }
134
135 // Create a directory named |dir| relative to the test directory. 109 // Create a directory named |dir| relative to the test directory.
136 // Set |with_dcim_dir| to true if the created directory will have a "DCIM" 110 // Set |with_dcim_dir| to true if the created directory will have a "DCIM"
137 // subdirectory. 111 // subdirectory.
138 // Returns the full path to the created directory on success, or an empty 112 // Returns the full path to the created directory on success, or an empty
139 // path on failure. 113 // path on failure.
140 FilePath CreateMountPoint(const std::string& dir, bool with_dcim_dir) { 114 FilePath CreateMountPoint(const std::string& dir, bool with_dcim_dir) {
141 FilePath return_path(scoped_temp_dir_.path()); 115 FilePath return_path(scoped_temp_dir_.path());
142 return_path = return_path.AppendASCII(dir); 116 return_path = return_path.AppendASCII(dir);
143 FilePath path(return_path); 117 FilePath path(return_path);
144 if (with_dcim_dir) 118 if (with_dcim_dir)
145 path = path.Append(chrome::kDCIMDirectoryName); 119 path = path.Append(chrome::kDCIMDirectoryName);
146 if (!file_util::CreateDirectory(path)) 120 if (!file_util::CreateDirectory(path))
147 return FilePath(); 121 return FilePath();
148 return return_path; 122 return return_path;
149 } 123 }
150 124
151 static void PostQuitToUIThread() { 125 static void PostQuitToUIThread() {
152 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 126 BrowserThread::PostTask(BrowserThread::UI,
127 FROM_HERE,
153 MessageLoop::QuitClosure()); 128 MessageLoop::QuitClosure());
154 } 129 }
155 130
156 static void WaitForFileThread() { 131 static void WaitForFileThread() {
157 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 132 BrowserThread::PostTask(BrowserThread::FILE,
133 FROM_HERE,
158 base::Bind(&PostQuitToUIThread)); 134 base::Bind(&PostQuitToUIThread));
159 MessageLoop::current()->Run(); 135 MessageLoop::current()->Run();
160 } 136 }
161 137
162 private: 138 private:
163 // The message loops and threads to run tests on. 139 // The message loops and threads to run tests on.
164 MessageLoop ui_loop_; 140 MessageLoop ui_loop_;
165 content::TestBrowserThread ui_thread_; 141 content::TestBrowserThread ui_thread_;
166 content::TestBrowserThread file_thread_; 142 content::TestBrowserThread file_thread_;
167 143
(...skipping 13 matching lines...) Expand all
181 157
182 // Simple test case where we attach and detach a media device. 158 // Simple test case where we attach and detach a media device.
183 TEST_F(RemovableDeviceNotificationsCrosTest, BasicAttachDetach) { 159 TEST_F(RemovableDeviceNotificationsCrosTest, BasicAttachDetach) {
184 testing::Sequence mock_sequence; 160 testing::Sequence mock_sequence;
185 FilePath mount_path1 = CreateMountPoint(kMountPointA, true); 161 FilePath mount_path1 = CreateMountPoint(kMountPointA, true);
186 ASSERT_FALSE(mount_path1.empty()); 162 ASSERT_FALSE(mount_path1.empty());
187 DiskMountManager::MountPointInfo mount_info(kDevice1, 163 DiskMountManager::MountPointInfo mount_info(kDevice1,
188 mount_path1.value(), 164 mount_path1.value(),
189 MOUNT_TYPE_DEVICE, 165 MOUNT_TYPE_DEVICE,
190 disks::MOUNT_CONDITION_NONE); 166 disks::MOUNT_CONDITION_NONE);
167 const std::string kUniqueId0 = "FFFF-FFFF";
191 EXPECT_CALL(observer(), 168 EXPECT_CALL(observer(),
192 OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId1), 169 OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId0),
193 ASCIIToUTF16(kDevice1NameWithSizeInfo), 170 ASCIIToUTF16(kDevice1Name),
194 mount_path1.value())) 171 mount_path1.value()))
195 .InSequence(mock_sequence); 172 .InSequence(mock_sequence);
196 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kDevice1Name, 173 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId0, kDevice1Name);
197 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
198 174
199 EXPECT_CALL(observer(), 175 EXPECT_CALL(observer(),
200 OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId1))) 176 OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId0)))
201 .InSequence(mock_sequence); 177 .InSequence(mock_sequence);
202 UnmountDevice(MOUNT_ERROR_NONE, mount_info); 178 UnmountDevice(MOUNT_ERROR_NONE, mount_info);
203 179
204 FilePath mount_path2 = CreateMountPoint(kMountPointB, true); 180 FilePath mount_path2 = CreateMountPoint(kMountPointB, true);
205 ASSERT_FALSE(mount_path2.empty()); 181 ASSERT_FALSE(mount_path2.empty());
206 DiskMountManager::MountPointInfo mount_info2(kDevice2, 182 DiskMountManager::MountPointInfo mount_info2(kDevice2,
207 mount_path2.value(), 183 mount_path2.value(),
208 MOUNT_TYPE_DEVICE, 184 MOUNT_TYPE_DEVICE,
209 disks::MOUNT_CONDITION_NONE); 185 disks::MOUNT_CONDITION_NONE);
186 const std::string kUniqueId1 = "FFF0-FFF0";
187
210 EXPECT_CALL(observer(), 188 EXPECT_CALL(observer(),
211 OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId2), 189 OnRemovableStorageAttached(GetDCIMDeviceId(kUniqueId1),
212 ASCIIToUTF16(kDevice2NameWithSizeInfo), 190 ASCIIToUTF16(kDevice2Name),
213 mount_path2.value())) 191 mount_path2.value()))
214 .InSequence(mock_sequence); 192 .InSequence(mock_sequence);
215 MountDevice(MOUNT_ERROR_NONE, mount_info2, kUniqueId2, kDevice2Name, 193 MountDevice(MOUNT_ERROR_NONE, mount_info2, kUniqueId1, kDevice2Name);
216 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice2SizeInBytes);
217 194
218 EXPECT_CALL(observer(), 195 EXPECT_CALL(observer(),
219 OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId2))) 196 OnRemovableStorageDetached(GetDCIMDeviceId(kUniqueId1)))
220 .InSequence(mock_sequence); 197 .InSequence(mock_sequence);
221 UnmountDevice(MOUNT_ERROR_NONE, mount_info2); 198 UnmountDevice(MOUNT_ERROR_NONE, mount_info2);
222 } 199 }
223 200
224 // Removable mass storage devices with no dcim folder are also recognized. 201 // Removable mass storage devices with no dcim folder are also recognized.
225 TEST_F(RemovableDeviceNotificationsCrosTest, NoDCIM) { 202 TEST_F(RemovableDeviceNotificationsCrosTest, NoDCIM) {
226 testing::Sequence mock_sequence; 203 testing::Sequence mock_sequence;
227 FilePath mount_path = CreateMountPoint(kMountPointA, false); 204 FilePath mount_path = CreateMountPoint(kMountPointA, false);
228 const std::string kUniqueId = "FFFF-FFFF"; 205 const std::string kUniqueId = "FFFF-FFFF";
229 ASSERT_FALSE(mount_path.empty()); 206 ASSERT_FALSE(mount_path.empty());
230 DiskMountManager::MountPointInfo mount_info(kDevice1, 207 DiskMountManager::MountPointInfo mount_info(kDevice1,
231 mount_path.value(), 208 mount_path.value(),
232 MOUNT_TYPE_DEVICE, 209 MOUNT_TYPE_DEVICE,
233 disks::MOUNT_CONDITION_NONE); 210 disks::MOUNT_CONDITION_NONE);
234 const std::string device_id = chrome::MediaStorageUtil::MakeDeviceId( 211 const std::string device_id = chrome::MediaStorageUtil::MakeDeviceId(
235 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM, 212 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM,
236 chrome::kFSUniqueIdPrefix + kUniqueId); 213 chrome::kFSUniqueIdPrefix + kUniqueId);
237 EXPECT_CALL(observer(), 214 EXPECT_CALL(observer(),
238 OnRemovableStorageAttached(device_id, 215 OnRemovableStorageAttached(device_id, ASCIIToUTF16(kDevice1Name),
239 ASCIIToUTF16(kDevice1NameWithSizeInfo),
240 mount_path.value())).Times(1); 216 mount_path.value())).Times(1);
241 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name, 217 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name);
242 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
243 } 218 }
244 219
245 // Non device mounts and mount errors are ignored. 220 // Non device mounts and mount errors are ignored.
246 TEST_F(RemovableDeviceNotificationsCrosTest, Ignore) { 221 TEST_F(RemovableDeviceNotificationsCrosTest, Ignore) {
247 testing::Sequence mock_sequence; 222 testing::Sequence mock_sequence;
248 FilePath mount_path = CreateMountPoint(kMountPointA, true); 223 FilePath mount_path = CreateMountPoint(kMountPointA, true);
249 const std::string kUniqueId = "FFFF-FFFF"; 224 const std::string kUniqueId = "FFFF-FFFF";
250 ASSERT_FALSE(mount_path.empty()); 225 ASSERT_FALSE(mount_path.empty());
251 226
252 // Mount error. 227 // Mount error.
253 DiskMountManager::MountPointInfo mount_info(kDevice1, 228 DiskMountManager::MountPointInfo mount_info(kDevice1,
254 mount_path.value(), 229 mount_path.value(),
255 MOUNT_TYPE_DEVICE, 230 MOUNT_TYPE_DEVICE,
256 disks::MOUNT_CONDITION_NONE); 231 disks::MOUNT_CONDITION_NONE);
257 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); 232 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0);
258 MountDevice(MOUNT_ERROR_UNKNOWN, mount_info, kUniqueId, kDevice1Name, 233 MountDevice(MOUNT_ERROR_UNKNOWN, mount_info, kUniqueId, kDevice1Name);
259 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
260 234
261 // Not a device 235 // Not a device
262 mount_info.mount_type = MOUNT_TYPE_ARCHIVE; 236 mount_info.mount_type = MOUNT_TYPE_ARCHIVE;
263 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); 237 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0);
264 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name, 238 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name);
265 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
266 239
267 // Unsupported file system. 240 // Unsupported file system.
268 mount_info.mount_type = MOUNT_TYPE_DEVICE; 241 mount_info.mount_type = MOUNT_TYPE_DEVICE;
269 mount_info.mount_condition = disks::MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM; 242 mount_info.mount_condition = disks::MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM;
270 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0); 243 EXPECT_CALL(observer(), OnRemovableStorageAttached(_, _, _)).Times(0);
271 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name, 244 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);
359 } 245 }
360 246
361 } // namespace 247 } // namespace
362 248
363 } // namespace chrome 249 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/system_monitor/removable_device_notifications_chromeos.cc ('k') | chromeos/disks/mock_disk_mount_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698