OLD | NEW |
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::StorageMonitorCros unit tests. |
6 | 6 |
7 #include "chrome/browser/storage_monitor/removable_device_notifications_chromeos
.h" | 7 #include "chrome/browser/storage_monitor/storage_monitor_chromeos.h" |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/message_loop.h" | 13 #include "base/message_loop.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/storage_monitor/media_storage_util.h" | 15 #include "chrome/browser/storage_monitor/media_storage_util.h" |
16 #include "chrome/browser/storage_monitor/mock_removable_storage_observer.h" | 16 #include "chrome/browser/storage_monitor/mock_removable_storage_observer.h" |
17 #include "chrome/browser/storage_monitor/removable_device_constants.h" | 17 #include "chrome/browser/storage_monitor/removable_device_constants.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 uint64 kDevice1SizeInBytes = 113048; | 49 uint64 kDevice1SizeInBytes = 113048; |
50 uint64 kDevice2SizeInBytes = 212312; | 50 uint64 kDevice2SizeInBytes = 212312; |
51 uint64 kSDCardSizeInBytes = 9000000; | 51 uint64 kSDCardSizeInBytes = 9000000; |
52 | 52 |
53 std::string GetDCIMDeviceId(const std::string& unique_id) { | 53 std::string GetDCIMDeviceId(const std::string& unique_id) { |
54 return chrome::MediaStorageUtil::MakeDeviceId( | 54 return chrome::MediaStorageUtil::MakeDeviceId( |
55 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM, | 55 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_WITH_DCIM, |
56 chrome::kFSUniqueIdPrefix + unique_id); | 56 chrome::kFSUniqueIdPrefix + unique_id); |
57 } | 57 } |
58 | 58 |
59 // Wrapper class to test RemovableDeviceNotificationsCros. | 59 // Wrapper class to test StorageMonitorCros. |
60 class RemovableDeviceNotificationsCrosTest : public testing::Test { | 60 class StorageMonitorCrosTest : public testing::Test { |
61 public: | 61 public: |
62 RemovableDeviceNotificationsCrosTest(); | 62 StorageMonitorCrosTest(); |
63 virtual ~RemovableDeviceNotificationsCrosTest(); | 63 virtual ~StorageMonitorCrosTest(); |
64 | 64 |
65 protected: | 65 protected: |
66 // testing::Test: | 66 // testing::Test: |
67 virtual void SetUp() OVERRIDE; | 67 virtual void SetUp() OVERRIDE; |
68 virtual void TearDown() OVERRIDE; | 68 virtual void TearDown() OVERRIDE; |
69 | 69 |
70 void MountDevice(MountError error_code, | 70 void MountDevice(MountError error_code, |
71 const DiskMountManager::MountPointInfo& mount_info, | 71 const DiskMountManager::MountPointInfo& mount_info, |
72 const std::string& unique_id, | 72 const std::string& unique_id, |
73 const std::string& device_label, | 73 const std::string& device_label, |
(...skipping 23 matching lines...) Expand all Loading... |
97 | 97 |
98 private: | 98 private: |
99 // The message loops and threads to run tests on. | 99 // The message loops and threads to run tests on. |
100 MessageLoop ui_loop_; | 100 MessageLoop ui_loop_; |
101 content::TestBrowserThread ui_thread_; | 101 content::TestBrowserThread ui_thread_; |
102 content::TestBrowserThread file_thread_; | 102 content::TestBrowserThread file_thread_; |
103 | 103 |
104 // Temporary directory for created test data. | 104 // Temporary directory for created test data. |
105 base::ScopedTempDir scoped_temp_dir_; | 105 base::ScopedTempDir scoped_temp_dir_; |
106 | 106 |
107 // Objects that talks with RemovableDeviceNotificationsCros. | 107 // Objects that talks with StorageMonitorCros. |
108 scoped_ptr<chrome::MockRemovableStorageObserver> mock_storage_observer_; | 108 scoped_ptr<chrome::MockRemovableStorageObserver> mock_storage_observer_; |
109 // Owned by DiskMountManager. | 109 // Owned by DiskMountManager. |
110 disks::MockDiskMountManager* disk_mount_manager_mock_; | 110 disks::MockDiskMountManager* disk_mount_manager_mock_; |
111 | 111 |
112 scoped_refptr<RemovableDeviceNotificationsCros> notifications_; | 112 scoped_refptr<StorageMonitorCros> monitor_; |
113 | 113 |
114 DISALLOW_COPY_AND_ASSIGN(RemovableDeviceNotificationsCrosTest); | 114 DISALLOW_COPY_AND_ASSIGN(StorageMonitorCrosTest); |
115 }; | 115 }; |
116 | 116 |
117 RemovableDeviceNotificationsCrosTest::RemovableDeviceNotificationsCrosTest() | 117 StorageMonitorCrosTest::StorageMonitorCrosTest() |
118 : ui_thread_(BrowserThread::UI, &ui_loop_), | 118 : ui_thread_(BrowserThread::UI, &ui_loop_), |
119 file_thread_(BrowserThread::FILE) { | 119 file_thread_(BrowserThread::FILE) { |
120 } | 120 } |
121 | 121 |
122 RemovableDeviceNotificationsCrosTest::~RemovableDeviceNotificationsCrosTest() { | 122 StorageMonitorCrosTest::~StorageMonitorCrosTest() { |
123 } | 123 } |
124 | 124 |
125 void RemovableDeviceNotificationsCrosTest::SetUp() { | 125 void StorageMonitorCrosTest::SetUp() { |
126 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 126 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
127 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); | 127 ASSERT_TRUE(scoped_temp_dir_.CreateUniqueTempDir()); |
128 file_thread_.Start(); | 128 file_thread_.Start(); |
129 disk_mount_manager_mock_ = new disks::MockDiskMountManager(); | 129 disk_mount_manager_mock_ = new disks::MockDiskMountManager(); |
130 DiskMountManager::InitializeForTesting(disk_mount_manager_mock_); | 130 DiskMountManager::InitializeForTesting(disk_mount_manager_mock_); |
131 disk_mount_manager_mock_->SetupDefaultReplies(); | 131 disk_mount_manager_mock_->SetupDefaultReplies(); |
132 | 132 |
133 mock_storage_observer_.reset(new chrome::MockRemovableStorageObserver); | 133 mock_storage_observer_.reset(new chrome::MockRemovableStorageObserver); |
134 | 134 |
135 // Initialize the test subject. | 135 // Initialize the test subject. |
136 notifications_ = new RemovableDeviceNotificationsCros(); | 136 monitor_ = new StorageMonitorCros(); |
137 notifications_->AddObserver(mock_storage_observer_.get()); | 137 monitor_->AddObserver(mock_storage_observer_.get()); |
138 } | 138 } |
139 | 139 |
140 void RemovableDeviceNotificationsCrosTest::TearDown() { | 140 void StorageMonitorCrosTest::TearDown() { |
141 notifications_->RemoveObserver(mock_storage_observer_.get()); | 141 monitor_->RemoveObserver(mock_storage_observer_.get()); |
142 notifications_ = NULL; | 142 monitor_ = NULL; |
143 | 143 |
144 disk_mount_manager_mock_ = NULL; | 144 disk_mount_manager_mock_ = NULL; |
145 DiskMountManager::Shutdown(); | 145 DiskMountManager::Shutdown(); |
146 WaitForFileThread(); | 146 WaitForFileThread(); |
147 } | 147 } |
148 | 148 |
149 void RemovableDeviceNotificationsCrosTest::MountDevice( | 149 void StorageMonitorCrosTest::MountDevice( |
150 MountError error_code, | 150 MountError error_code, |
151 const DiskMountManager::MountPointInfo& mount_info, | 151 const DiskMountManager::MountPointInfo& mount_info, |
152 const std::string& unique_id, | 152 const std::string& unique_id, |
153 const std::string& device_label, | 153 const std::string& device_label, |
154 const std::string& vendor_name, | 154 const std::string& vendor_name, |
155 const std::string& product_name, | 155 const std::string& product_name, |
156 DeviceType device_type, | 156 DeviceType device_type, |
157 uint64 device_size_in_bytes) { | 157 uint64 device_size_in_bytes) { |
158 if (error_code == MOUNT_ERROR_NONE) { | 158 if (error_code == MOUNT_ERROR_NONE) { |
159 disk_mount_manager_mock_->CreateDiskEntryForMountDevice( | 159 disk_mount_manager_mock_->CreateDiskEntryForMountDevice( |
160 mount_info, unique_id, device_label, vendor_name, product_name, | 160 mount_info, unique_id, device_label, vendor_name, product_name, |
161 device_type, device_size_in_bytes); | 161 device_type, device_size_in_bytes); |
162 } | 162 } |
163 notifications_->OnMountEvent(disks::DiskMountManager::MOUNTING, | 163 monitor_->OnMountEvent(disks::DiskMountManager::MOUNTING, error_code, |
164 error_code, | 164 mount_info); |
165 mount_info); | |
166 WaitForFileThread(); | 165 WaitForFileThread(); |
167 } | 166 } |
168 | 167 |
169 void RemovableDeviceNotificationsCrosTest::UnmountDevice( | 168 void StorageMonitorCrosTest::UnmountDevice( |
170 MountError error_code, | 169 MountError error_code, |
171 const DiskMountManager::MountPointInfo& mount_info) { | 170 const DiskMountManager::MountPointInfo& mount_info) { |
172 notifications_->OnMountEvent(disks::DiskMountManager::UNMOUNTING, | 171 monitor_->OnMountEvent(disks::DiskMountManager::UNMOUNTING, error_code, |
173 error_code, | 172 mount_info); |
174 mount_info); | |
175 if (error_code == MOUNT_ERROR_NONE) | 173 if (error_code == MOUNT_ERROR_NONE) |
176 disk_mount_manager_mock_->RemoveDiskEntryForMountDevice(mount_info); | 174 disk_mount_manager_mock_->RemoveDiskEntryForMountDevice(mount_info); |
177 WaitForFileThread(); | 175 WaitForFileThread(); |
178 } | 176 } |
179 | 177 |
180 uint64 RemovableDeviceNotificationsCrosTest::GetDeviceStorageSize( | 178 uint64 StorageMonitorCrosTest::GetDeviceStorageSize( |
181 const std::string& device_location) { | 179 const std::string& device_location) { |
182 return notifications_->GetStorageSize(device_location); | 180 return monitor_->GetStorageSize(device_location); |
183 } | 181 } |
184 | 182 |
185 base::FilePath RemovableDeviceNotificationsCrosTest::CreateMountPoint( | 183 base::FilePath StorageMonitorCrosTest::CreateMountPoint( |
186 const std::string& dir, bool with_dcim_dir) { | 184 const std::string& dir, bool with_dcim_dir) { |
187 base::FilePath return_path(scoped_temp_dir_.path()); | 185 base::FilePath return_path(scoped_temp_dir_.path()); |
188 return_path = return_path.AppendASCII(dir); | 186 return_path = return_path.AppendASCII(dir); |
189 base::FilePath path(return_path); | 187 base::FilePath path(return_path); |
190 if (with_dcim_dir) | 188 if (with_dcim_dir) |
191 path = path.Append(chrome::kDCIMDirectoryName); | 189 path = path.Append(chrome::kDCIMDirectoryName); |
192 if (!file_util::CreateDirectory(path)) | 190 if (!file_util::CreateDirectory(path)) |
193 return base::FilePath(); | 191 return base::FilePath(); |
194 return return_path; | 192 return return_path; |
195 } | 193 } |
196 | 194 |
197 // static | 195 // static |
198 void RemovableDeviceNotificationsCrosTest::PostQuitToUIThread() { | 196 void StorageMonitorCrosTest::PostQuitToUIThread() { |
199 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 197 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
200 MessageLoop::QuitClosure()); | 198 MessageLoop::QuitClosure()); |
201 } | 199 } |
202 | 200 |
203 // static | 201 // static |
204 void RemovableDeviceNotificationsCrosTest::WaitForFileThread() { | 202 void StorageMonitorCrosTest::WaitForFileThread() { |
205 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 203 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
206 base::Bind(&PostQuitToUIThread)); | 204 base::Bind(&PostQuitToUIThread)); |
207 MessageLoop::current()->Run(); | 205 MessageLoop::current()->Run(); |
208 } | 206 } |
209 | 207 |
210 // Simple test case where we attach and detach a media device. | 208 // Simple test case where we attach and detach a media device. |
211 TEST_F(RemovableDeviceNotificationsCrosTest, BasicAttachDetach) { | 209 TEST_F(StorageMonitorCrosTest, BasicAttachDetach) { |
212 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); | 210 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); |
213 ASSERT_FALSE(mount_path1.empty()); | 211 ASSERT_FALSE(mount_path1.empty()); |
214 DiskMountManager::MountPointInfo mount_info(kDevice1, | 212 DiskMountManager::MountPointInfo mount_info(kDevice1, |
215 mount_path1.value(), | 213 mount_path1.value(), |
216 MOUNT_TYPE_DEVICE, | 214 MOUNT_TYPE_DEVICE, |
217 disks::MOUNT_CONDITION_NONE); | 215 disks::MOUNT_CONDITION_NONE); |
218 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kDevice1Name, | 216 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kDevice1Name, |
219 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); | 217 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); |
220 EXPECT_EQ(1, observer().attach_calls()); | 218 EXPECT_EQ(1, observer().attach_calls()); |
221 EXPECT_EQ(0, observer().detach_calls()); | 219 EXPECT_EQ(0, observer().detach_calls()); |
(...skipping 22 matching lines...) Expand all Loading... |
244 observer().last_attached().name); | 242 observer().last_attached().name); |
245 EXPECT_EQ(mount_path2.value(), observer().last_attached().location); | 243 EXPECT_EQ(mount_path2.value(), observer().last_attached().location); |
246 | 244 |
247 UnmountDevice(MOUNT_ERROR_NONE, mount_info2); | 245 UnmountDevice(MOUNT_ERROR_NONE, mount_info2); |
248 EXPECT_EQ(2, observer().attach_calls()); | 246 EXPECT_EQ(2, observer().attach_calls()); |
249 EXPECT_EQ(2, observer().detach_calls()); | 247 EXPECT_EQ(2, observer().detach_calls()); |
250 EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), observer().last_detached().device_id); | 248 EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), observer().last_detached().device_id); |
251 } | 249 } |
252 | 250 |
253 // Removable mass storage devices with no dcim folder are also recognized. | 251 // Removable mass storage devices with no dcim folder are also recognized. |
254 TEST_F(RemovableDeviceNotificationsCrosTest, NoDCIM) { | 252 TEST_F(StorageMonitorCrosTest, NoDCIM) { |
255 testing::Sequence mock_sequence; | 253 testing::Sequence mock_sequence; |
256 base::FilePath mount_path = CreateMountPoint(kMountPointA, false); | 254 base::FilePath mount_path = CreateMountPoint(kMountPointA, false); |
257 const std::string kUniqueId = "FFFF-FFFF"; | 255 const std::string kUniqueId = "FFFF-FFFF"; |
258 ASSERT_FALSE(mount_path.empty()); | 256 ASSERT_FALSE(mount_path.empty()); |
259 DiskMountManager::MountPointInfo mount_info(kDevice1, | 257 DiskMountManager::MountPointInfo mount_info(kDevice1, |
260 mount_path.value(), | 258 mount_path.value(), |
261 MOUNT_TYPE_DEVICE, | 259 MOUNT_TYPE_DEVICE, |
262 disks::MOUNT_CONDITION_NONE); | 260 disks::MOUNT_CONDITION_NONE); |
263 const std::string device_id = chrome::MediaStorageUtil::MakeDeviceId( | 261 const std::string device_id = chrome::MediaStorageUtil::MakeDeviceId( |
264 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM, | 262 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM, |
265 chrome::kFSUniqueIdPrefix + kUniqueId); | 263 chrome::kFSUniqueIdPrefix + kUniqueId); |
266 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name, | 264 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name, |
267 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); | 265 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); |
268 EXPECT_EQ(1, observer().attach_calls()); | 266 EXPECT_EQ(1, observer().attach_calls()); |
269 EXPECT_EQ(0, observer().detach_calls()); | 267 EXPECT_EQ(0, observer().detach_calls()); |
270 EXPECT_EQ(device_id, observer().last_attached().device_id); | 268 EXPECT_EQ(device_id, observer().last_attached().device_id); |
271 EXPECT_EQ(ASCIIToUTF16(kDevice1NameWithSizeInfo), | 269 EXPECT_EQ(ASCIIToUTF16(kDevice1NameWithSizeInfo), |
272 observer().last_attached().name); | 270 observer().last_attached().name); |
273 EXPECT_EQ(mount_path.value(), observer().last_attached().location); | 271 EXPECT_EQ(mount_path.value(), observer().last_attached().location); |
274 } | 272 } |
275 | 273 |
276 // Non device mounts and mount errors are ignored. | 274 // Non device mounts and mount errors are ignored. |
277 TEST_F(RemovableDeviceNotificationsCrosTest, Ignore) { | 275 TEST_F(StorageMonitorCrosTest, Ignore) { |
278 testing::Sequence mock_sequence; | 276 testing::Sequence mock_sequence; |
279 base::FilePath mount_path = CreateMountPoint(kMountPointA, true); | 277 base::FilePath mount_path = CreateMountPoint(kMountPointA, true); |
280 const std::string kUniqueId = "FFFF-FFFF"; | 278 const std::string kUniqueId = "FFFF-FFFF"; |
281 ASSERT_FALSE(mount_path.empty()); | 279 ASSERT_FALSE(mount_path.empty()); |
282 | 280 |
283 // Mount error. | 281 // Mount error. |
284 DiskMountManager::MountPointInfo mount_info(kDevice1, | 282 DiskMountManager::MountPointInfo mount_info(kDevice1, |
285 mount_path.value(), | 283 mount_path.value(), |
286 MOUNT_TYPE_DEVICE, | 284 MOUNT_TYPE_DEVICE, |
287 disks::MOUNT_CONDITION_NONE); | 285 disks::MOUNT_CONDITION_NONE); |
(...skipping 11 matching lines...) Expand all Loading... |
299 | 297 |
300 // Unsupported file system. | 298 // Unsupported file system. |
301 mount_info.mount_type = MOUNT_TYPE_DEVICE; | 299 mount_info.mount_type = MOUNT_TYPE_DEVICE; |
302 mount_info.mount_condition = disks::MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM; | 300 mount_info.mount_condition = disks::MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM; |
303 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name, | 301 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name, |
304 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); | 302 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); |
305 EXPECT_EQ(0, observer().attach_calls()); | 303 EXPECT_EQ(0, observer().attach_calls()); |
306 EXPECT_EQ(0, observer().detach_calls()); | 304 EXPECT_EQ(0, observer().detach_calls()); |
307 } | 305 } |
308 | 306 |
309 TEST_F(RemovableDeviceNotificationsCrosTest, SDCardAttachDetach) { | 307 TEST_F(StorageMonitorCrosTest, SDCardAttachDetach) { |
310 base::FilePath mount_path1 = CreateMountPoint(kSDCardMountPoint1, true); | 308 base::FilePath mount_path1 = CreateMountPoint(kSDCardMountPoint1, true); |
311 ASSERT_FALSE(mount_path1.empty()); | 309 ASSERT_FALSE(mount_path1.empty()); |
312 DiskMountManager::MountPointInfo mount_info1(kSDCardDeviceName1, | 310 DiskMountManager::MountPointInfo mount_info1(kSDCardDeviceName1, |
313 mount_path1.value(), | 311 mount_path1.value(), |
314 MOUNT_TYPE_DEVICE, | 312 MOUNT_TYPE_DEVICE, |
315 disks::MOUNT_CONDITION_NONE); | 313 disks::MOUNT_CONDITION_NONE); |
316 MountDevice(MOUNT_ERROR_NONE, mount_info1, kUniqueId2, kSDCardDeviceName1, | 314 MountDevice(MOUNT_ERROR_NONE, mount_info1, kUniqueId2, kSDCardDeviceName1, |
317 kVendorName, kProductName, DEVICE_TYPE_SD, kSDCardSizeInBytes); | 315 kVendorName, kProductName, DEVICE_TYPE_SD, kSDCardSizeInBytes); |
318 EXPECT_EQ(1, observer().attach_calls()); | 316 EXPECT_EQ(1, observer().attach_calls()); |
319 EXPECT_EQ(0, observer().detach_calls()); | 317 EXPECT_EQ(0, observer().detach_calls()); |
(...skipping 21 matching lines...) Expand all Loading... |
341 EXPECT_EQ(ASCIIToUTF16(kSDCardDeviceName2), | 339 EXPECT_EQ(ASCIIToUTF16(kSDCardDeviceName2), |
342 observer().last_attached().name); | 340 observer().last_attached().name); |
343 EXPECT_EQ(mount_path2.value(), observer().last_attached().location); | 341 EXPECT_EQ(mount_path2.value(), observer().last_attached().location); |
344 | 342 |
345 UnmountDevice(MOUNT_ERROR_NONE, mount_info2); | 343 UnmountDevice(MOUNT_ERROR_NONE, mount_info2); |
346 EXPECT_EQ(2, observer().attach_calls()); | 344 EXPECT_EQ(2, observer().attach_calls()); |
347 EXPECT_EQ(2, observer().detach_calls()); | 345 EXPECT_EQ(2, observer().detach_calls()); |
348 EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), observer().last_detached().device_id); | 346 EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), observer().last_detached().device_id); |
349 } | 347 } |
350 | 348 |
351 TEST_F(RemovableDeviceNotificationsCrosTest, AttachDeviceWithEmptyLabel) { | 349 TEST_F(StorageMonitorCrosTest, AttachDeviceWithEmptyLabel) { |
352 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); | 350 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); |
353 ASSERT_FALSE(mount_path1.empty()); | 351 ASSERT_FALSE(mount_path1.empty()); |
354 DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel, | 352 DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel, |
355 mount_path1.value(), | 353 mount_path1.value(), |
356 MOUNT_TYPE_DEVICE, | 354 MOUNT_TYPE_DEVICE, |
357 disks::MOUNT_CONDITION_NONE); | 355 disks::MOUNT_CONDITION_NONE); |
358 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kEmptyDeviceLabel, | 356 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kEmptyDeviceLabel, |
359 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); | 357 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); |
360 EXPECT_EQ(1, observer().attach_calls()); | 358 EXPECT_EQ(1, observer().attach_calls()); |
361 EXPECT_EQ(0, observer().detach_calls()); | 359 EXPECT_EQ(0, observer().detach_calls()); |
362 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_attached().device_id); | 360 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_attached().device_id); |
363 EXPECT_EQ(ASCIIToUTF16(kDeviceNameWithManufacturerDetails), | 361 EXPECT_EQ(ASCIIToUTF16(kDeviceNameWithManufacturerDetails), |
364 observer().last_attached().name); | 362 observer().last_attached().name); |
365 EXPECT_EQ(mount_path1.value(), observer().last_attached().location); | 363 EXPECT_EQ(mount_path1.value(), observer().last_attached().location); |
366 | 364 |
367 UnmountDevice(MOUNT_ERROR_NONE, mount_info); | 365 UnmountDevice(MOUNT_ERROR_NONE, mount_info); |
368 EXPECT_EQ(1, observer().attach_calls()); | 366 EXPECT_EQ(1, observer().attach_calls()); |
369 EXPECT_EQ(1, observer().detach_calls()); | 367 EXPECT_EQ(1, observer().detach_calls()); |
370 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_detached().device_id); | 368 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_detached().device_id); |
371 } | 369 } |
372 | 370 |
373 TEST_F(RemovableDeviceNotificationsCrosTest, GetStorageSize) { | 371 TEST_F(StorageMonitorCrosTest, GetStorageSize) { |
374 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); | 372 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); |
375 ASSERT_FALSE(mount_path1.empty()); | 373 ASSERT_FALSE(mount_path1.empty()); |
376 DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel, | 374 DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel, |
377 mount_path1.value(), | 375 mount_path1.value(), |
378 MOUNT_TYPE_DEVICE, | 376 MOUNT_TYPE_DEVICE, |
379 disks::MOUNT_CONDITION_NONE); | 377 disks::MOUNT_CONDITION_NONE); |
380 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kEmptyDeviceLabel, | 378 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kEmptyDeviceLabel, |
381 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); | 379 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); |
382 EXPECT_EQ(1, observer().attach_calls()); | 380 EXPECT_EQ(1, observer().attach_calls()); |
383 EXPECT_EQ(0, observer().detach_calls()); | 381 EXPECT_EQ(0, observer().detach_calls()); |
384 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_attached().device_id); | 382 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_attached().device_id); |
385 EXPECT_EQ(ASCIIToUTF16(kDeviceNameWithManufacturerDetails), | 383 EXPECT_EQ(ASCIIToUTF16(kDeviceNameWithManufacturerDetails), |
386 observer().last_attached().name); | 384 observer().last_attached().name); |
387 EXPECT_EQ(mount_path1.value(), observer().last_attached().location); | 385 EXPECT_EQ(mount_path1.value(), observer().last_attached().location); |
388 | 386 |
389 EXPECT_EQ(kDevice1SizeInBytes, GetDeviceStorageSize(mount_path1.value())); | 387 EXPECT_EQ(kDevice1SizeInBytes, GetDeviceStorageSize(mount_path1.value())); |
390 UnmountDevice(MOUNT_ERROR_NONE, mount_info); | 388 UnmountDevice(MOUNT_ERROR_NONE, mount_info); |
391 EXPECT_EQ(1, observer().attach_calls()); | 389 EXPECT_EQ(1, observer().attach_calls()); |
392 EXPECT_EQ(1, observer().detach_calls()); | 390 EXPECT_EQ(1, observer().detach_calls()); |
393 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_detached().device_id); | 391 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_detached().device_id); |
394 } | 392 } |
395 | 393 |
396 } // namespace | 394 } // namespace |
397 | 395 |
398 } // namespace chromeos | 396 } // namespace chromeos |
OLD | NEW |