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

Side by Side Diff: chrome/browser/storage_monitor/storage_monitor_chromeos_unittest.cc

Issue 12382005: Rename RemovableDeviceNotifications=>StorageMonitor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix some includes from recent merge. Created 7 years, 9 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
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::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
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
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> notifications_;
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 notifications_ = new StorageMonitorCros();
137 notifications_->AddObserver(mock_storage_observer_.get()); 137 notifications_->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 notifications_->RemoveObserver(mock_storage_observer_.get());
142 notifications_ = NULL; 142 notifications_ = 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 notifications_->OnMountEvent(disks::DiskMountManager::MOUNTING,
164 error_code, 164 error_code,
165 mount_info); 165 mount_info);
166 WaitForFileThread(); 166 WaitForFileThread();
167 } 167 }
168 168
169 void RemovableDeviceNotificationsCrosTest::UnmountDevice( 169 void StorageMonitorCrosTest::UnmountDevice(
170 MountError error_code, 170 MountError error_code,
171 const DiskMountManager::MountPointInfo& mount_info) { 171 const DiskMountManager::MountPointInfo& mount_info) {
172 notifications_->OnMountEvent(disks::DiskMountManager::UNMOUNTING, 172 notifications_->OnMountEvent(disks::DiskMountManager::UNMOUNTING,
173 error_code, 173 error_code,
174 mount_info); 174 mount_info);
175 if (error_code == MOUNT_ERROR_NONE) 175 if (error_code == MOUNT_ERROR_NONE)
176 disk_mount_manager_mock_->RemoveDiskEntryForMountDevice(mount_info); 176 disk_mount_manager_mock_->RemoveDiskEntryForMountDevice(mount_info);
177 WaitForFileThread(); 177 WaitForFileThread();
178 } 178 }
179 179
180 uint64 RemovableDeviceNotificationsCrosTest::GetDeviceStorageSize( 180 uint64 StorageMonitorCrosTest::GetDeviceStorageSize(
181 const std::string& device_location) { 181 const std::string& device_location) {
182 return notifications_->GetStorageSize(device_location); 182 return notifications_->GetStorageSize(device_location);
183 } 183 }
184 184
185 base::FilePath RemovableDeviceNotificationsCrosTest::CreateMountPoint( 185 base::FilePath StorageMonitorCrosTest::CreateMountPoint(
186 const std::string& dir, bool with_dcim_dir) { 186 const std::string& dir, bool with_dcim_dir) {
187 base::FilePath return_path(scoped_temp_dir_.path()); 187 base::FilePath return_path(scoped_temp_dir_.path());
188 return_path = return_path.AppendASCII(dir); 188 return_path = return_path.AppendASCII(dir);
189 base::FilePath path(return_path); 189 base::FilePath path(return_path);
190 if (with_dcim_dir) 190 if (with_dcim_dir)
191 path = path.Append(chrome::kDCIMDirectoryName); 191 path = path.Append(chrome::kDCIMDirectoryName);
192 if (!file_util::CreateDirectory(path)) 192 if (!file_util::CreateDirectory(path))
193 return base::FilePath(); 193 return base::FilePath();
194 return return_path; 194 return return_path;
195 } 195 }
196 196
197 // static 197 // static
198 void RemovableDeviceNotificationsCrosTest::PostQuitToUIThread() { 198 void StorageMonitorCrosTest::PostQuitToUIThread() {
199 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 199 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
200 MessageLoop::QuitClosure()); 200 MessageLoop::QuitClosure());
201 } 201 }
202 202
203 // static 203 // static
204 void RemovableDeviceNotificationsCrosTest::WaitForFileThread() { 204 void StorageMonitorCrosTest::WaitForFileThread() {
205 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, 205 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
206 base::Bind(&PostQuitToUIThread)); 206 base::Bind(&PostQuitToUIThread));
207 MessageLoop::current()->Run(); 207 MessageLoop::current()->Run();
208 } 208 }
209 209
210 // Simple test case where we attach and detach a media device. 210 // Simple test case where we attach and detach a media device.
211 TEST_F(RemovableDeviceNotificationsCrosTest, BasicAttachDetach) { 211 TEST_F(StorageMonitorCrosTest, BasicAttachDetach) {
212 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); 212 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true);
213 ASSERT_FALSE(mount_path1.empty()); 213 ASSERT_FALSE(mount_path1.empty());
214 DiskMountManager::MountPointInfo mount_info(kDevice1, 214 DiskMountManager::MountPointInfo mount_info(kDevice1,
215 mount_path1.value(), 215 mount_path1.value(),
216 MOUNT_TYPE_DEVICE, 216 MOUNT_TYPE_DEVICE,
217 disks::MOUNT_CONDITION_NONE); 217 disks::MOUNT_CONDITION_NONE);
218 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kDevice1Name, 218 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kDevice1Name,
219 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); 219 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
220 EXPECT_EQ(1, observer().attach_calls()); 220 EXPECT_EQ(1, observer().attach_calls());
221 EXPECT_EQ(0, observer().detach_calls()); 221 EXPECT_EQ(0, observer().detach_calls());
(...skipping 22 matching lines...) Expand all
244 observer().last_attached().name); 244 observer().last_attached().name);
245 EXPECT_EQ(mount_path2.value(), observer().last_attached().location); 245 EXPECT_EQ(mount_path2.value(), observer().last_attached().location);
246 246
247 UnmountDevice(MOUNT_ERROR_NONE, mount_info2); 247 UnmountDevice(MOUNT_ERROR_NONE, mount_info2);
248 EXPECT_EQ(2, observer().attach_calls()); 248 EXPECT_EQ(2, observer().attach_calls());
249 EXPECT_EQ(2, observer().detach_calls()); 249 EXPECT_EQ(2, observer().detach_calls());
250 EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), observer().last_detached().device_id); 250 EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), observer().last_detached().device_id);
251 } 251 }
252 252
253 // Removable mass storage devices with no dcim folder are also recognized. 253 // Removable mass storage devices with no dcim folder are also recognized.
254 TEST_F(RemovableDeviceNotificationsCrosTest, NoDCIM) { 254 TEST_F(StorageMonitorCrosTest, NoDCIM) {
255 testing::Sequence mock_sequence; 255 testing::Sequence mock_sequence;
256 base::FilePath mount_path = CreateMountPoint(kMountPointA, false); 256 base::FilePath mount_path = CreateMountPoint(kMountPointA, false);
257 const std::string kUniqueId = "FFFF-FFFF"; 257 const std::string kUniqueId = "FFFF-FFFF";
258 ASSERT_FALSE(mount_path.empty()); 258 ASSERT_FALSE(mount_path.empty());
259 DiskMountManager::MountPointInfo mount_info(kDevice1, 259 DiskMountManager::MountPointInfo mount_info(kDevice1,
260 mount_path.value(), 260 mount_path.value(),
261 MOUNT_TYPE_DEVICE, 261 MOUNT_TYPE_DEVICE,
262 disks::MOUNT_CONDITION_NONE); 262 disks::MOUNT_CONDITION_NONE);
263 const std::string device_id = chrome::MediaStorageUtil::MakeDeviceId( 263 const std::string device_id = chrome::MediaStorageUtil::MakeDeviceId(
264 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM, 264 chrome::MediaStorageUtil::REMOVABLE_MASS_STORAGE_NO_DCIM,
265 chrome::kFSUniqueIdPrefix + kUniqueId); 265 chrome::kFSUniqueIdPrefix + kUniqueId);
266 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name, 266 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name,
267 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); 267 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
268 EXPECT_EQ(1, observer().attach_calls()); 268 EXPECT_EQ(1, observer().attach_calls());
269 EXPECT_EQ(0, observer().detach_calls()); 269 EXPECT_EQ(0, observer().detach_calls());
270 EXPECT_EQ(device_id, observer().last_attached().device_id); 270 EXPECT_EQ(device_id, observer().last_attached().device_id);
271 EXPECT_EQ(ASCIIToUTF16(kDevice1NameWithSizeInfo), 271 EXPECT_EQ(ASCIIToUTF16(kDevice1NameWithSizeInfo),
272 observer().last_attached().name); 272 observer().last_attached().name);
273 EXPECT_EQ(mount_path.value(), observer().last_attached().location); 273 EXPECT_EQ(mount_path.value(), observer().last_attached().location);
274 } 274 }
275 275
276 // Non device mounts and mount errors are ignored. 276 // Non device mounts and mount errors are ignored.
277 TEST_F(RemovableDeviceNotificationsCrosTest, Ignore) { 277 TEST_F(StorageMonitorCrosTest, Ignore) {
278 testing::Sequence mock_sequence; 278 testing::Sequence mock_sequence;
279 base::FilePath mount_path = CreateMountPoint(kMountPointA, true); 279 base::FilePath mount_path = CreateMountPoint(kMountPointA, true);
280 const std::string kUniqueId = "FFFF-FFFF"; 280 const std::string kUniqueId = "FFFF-FFFF";
281 ASSERT_FALSE(mount_path.empty()); 281 ASSERT_FALSE(mount_path.empty());
282 282
283 // Mount error. 283 // Mount error.
284 DiskMountManager::MountPointInfo mount_info(kDevice1, 284 DiskMountManager::MountPointInfo mount_info(kDevice1,
285 mount_path.value(), 285 mount_path.value(),
286 MOUNT_TYPE_DEVICE, 286 MOUNT_TYPE_DEVICE,
287 disks::MOUNT_CONDITION_NONE); 287 disks::MOUNT_CONDITION_NONE);
(...skipping 11 matching lines...) Expand all
299 299
300 // Unsupported file system. 300 // Unsupported file system.
301 mount_info.mount_type = MOUNT_TYPE_DEVICE; 301 mount_info.mount_type = MOUNT_TYPE_DEVICE;
302 mount_info.mount_condition = disks::MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM; 302 mount_info.mount_condition = disks::MOUNT_CONDITION_UNSUPPORTED_FILESYSTEM;
303 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name, 303 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId, kDevice1Name,
304 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); 304 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
305 EXPECT_EQ(0, observer().attach_calls()); 305 EXPECT_EQ(0, observer().attach_calls());
306 EXPECT_EQ(0, observer().detach_calls()); 306 EXPECT_EQ(0, observer().detach_calls());
307 } 307 }
308 308
309 TEST_F(RemovableDeviceNotificationsCrosTest, SDCardAttachDetach) { 309 TEST_F(StorageMonitorCrosTest, SDCardAttachDetach) {
310 base::FilePath mount_path1 = CreateMountPoint(kSDCardMountPoint1, true); 310 base::FilePath mount_path1 = CreateMountPoint(kSDCardMountPoint1, true);
311 ASSERT_FALSE(mount_path1.empty()); 311 ASSERT_FALSE(mount_path1.empty());
312 DiskMountManager::MountPointInfo mount_info1(kSDCardDeviceName1, 312 DiskMountManager::MountPointInfo mount_info1(kSDCardDeviceName1,
313 mount_path1.value(), 313 mount_path1.value(),
314 MOUNT_TYPE_DEVICE, 314 MOUNT_TYPE_DEVICE,
315 disks::MOUNT_CONDITION_NONE); 315 disks::MOUNT_CONDITION_NONE);
316 MountDevice(MOUNT_ERROR_NONE, mount_info1, kUniqueId2, kSDCardDeviceName1, 316 MountDevice(MOUNT_ERROR_NONE, mount_info1, kUniqueId2, kSDCardDeviceName1,
317 kVendorName, kProductName, DEVICE_TYPE_SD, kSDCardSizeInBytes); 317 kVendorName, kProductName, DEVICE_TYPE_SD, kSDCardSizeInBytes);
318 EXPECT_EQ(1, observer().attach_calls()); 318 EXPECT_EQ(1, observer().attach_calls());
319 EXPECT_EQ(0, observer().detach_calls()); 319 EXPECT_EQ(0, observer().detach_calls());
(...skipping 21 matching lines...) Expand all
341 EXPECT_EQ(ASCIIToUTF16(kSDCardDeviceName2), 341 EXPECT_EQ(ASCIIToUTF16(kSDCardDeviceName2),
342 observer().last_attached().name); 342 observer().last_attached().name);
343 EXPECT_EQ(mount_path2.value(), observer().last_attached().location); 343 EXPECT_EQ(mount_path2.value(), observer().last_attached().location);
344 344
345 UnmountDevice(MOUNT_ERROR_NONE, mount_info2); 345 UnmountDevice(MOUNT_ERROR_NONE, mount_info2);
346 EXPECT_EQ(2, observer().attach_calls()); 346 EXPECT_EQ(2, observer().attach_calls());
347 EXPECT_EQ(2, observer().detach_calls()); 347 EXPECT_EQ(2, observer().detach_calls());
348 EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), observer().last_detached().device_id); 348 EXPECT_EQ(GetDCIMDeviceId(kUniqueId2), observer().last_detached().device_id);
349 } 349 }
350 350
351 TEST_F(RemovableDeviceNotificationsCrosTest, AttachDeviceWithEmptyLabel) { 351 TEST_F(StorageMonitorCrosTest, AttachDeviceWithEmptyLabel) {
352 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); 352 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true);
353 ASSERT_FALSE(mount_path1.empty()); 353 ASSERT_FALSE(mount_path1.empty());
354 DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel, 354 DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel,
355 mount_path1.value(), 355 mount_path1.value(),
356 MOUNT_TYPE_DEVICE, 356 MOUNT_TYPE_DEVICE,
357 disks::MOUNT_CONDITION_NONE); 357 disks::MOUNT_CONDITION_NONE);
358 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kEmptyDeviceLabel, 358 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kEmptyDeviceLabel,
359 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); 359 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
360 EXPECT_EQ(1, observer().attach_calls()); 360 EXPECT_EQ(1, observer().attach_calls());
361 EXPECT_EQ(0, observer().detach_calls()); 361 EXPECT_EQ(0, observer().detach_calls());
362 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_attached().device_id); 362 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_attached().device_id);
363 EXPECT_EQ(ASCIIToUTF16(kDeviceNameWithManufacturerDetails), 363 EXPECT_EQ(ASCIIToUTF16(kDeviceNameWithManufacturerDetails),
364 observer().last_attached().name); 364 observer().last_attached().name);
365 EXPECT_EQ(mount_path1.value(), observer().last_attached().location); 365 EXPECT_EQ(mount_path1.value(), observer().last_attached().location);
366 366
367 UnmountDevice(MOUNT_ERROR_NONE, mount_info); 367 UnmountDevice(MOUNT_ERROR_NONE, mount_info);
368 EXPECT_EQ(1, observer().attach_calls()); 368 EXPECT_EQ(1, observer().attach_calls());
369 EXPECT_EQ(1, observer().detach_calls()); 369 EXPECT_EQ(1, observer().detach_calls());
370 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_detached().device_id); 370 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_detached().device_id);
371 } 371 }
372 372
373 TEST_F(RemovableDeviceNotificationsCrosTest, GetStorageSize) { 373 TEST_F(StorageMonitorCrosTest, GetStorageSize) {
374 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true); 374 base::FilePath mount_path1 = CreateMountPoint(kMountPointA, true);
375 ASSERT_FALSE(mount_path1.empty()); 375 ASSERT_FALSE(mount_path1.empty());
376 DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel, 376 DiskMountManager::MountPointInfo mount_info(kEmptyDeviceLabel,
377 mount_path1.value(), 377 mount_path1.value(),
378 MOUNT_TYPE_DEVICE, 378 MOUNT_TYPE_DEVICE,
379 disks::MOUNT_CONDITION_NONE); 379 disks::MOUNT_CONDITION_NONE);
380 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kEmptyDeviceLabel, 380 MountDevice(MOUNT_ERROR_NONE, mount_info, kUniqueId1, kEmptyDeviceLabel,
381 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes); 381 kVendorName, kProductName, DEVICE_TYPE_USB, kDevice1SizeInBytes);
382 EXPECT_EQ(1, observer().attach_calls()); 382 EXPECT_EQ(1, observer().attach_calls());
383 EXPECT_EQ(0, observer().detach_calls()); 383 EXPECT_EQ(0, observer().detach_calls());
384 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_attached().device_id); 384 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_attached().device_id);
385 EXPECT_EQ(ASCIIToUTF16(kDeviceNameWithManufacturerDetails), 385 EXPECT_EQ(ASCIIToUTF16(kDeviceNameWithManufacturerDetails),
386 observer().last_attached().name); 386 observer().last_attached().name);
387 EXPECT_EQ(mount_path1.value(), observer().last_attached().location); 387 EXPECT_EQ(mount_path1.value(), observer().last_attached().location);
388 388
389 EXPECT_EQ(kDevice1SizeInBytes, GetDeviceStorageSize(mount_path1.value())); 389 EXPECT_EQ(kDevice1SizeInBytes, GetDeviceStorageSize(mount_path1.value()));
390 UnmountDevice(MOUNT_ERROR_NONE, mount_info); 390 UnmountDevice(MOUNT_ERROR_NONE, mount_info);
391 EXPECT_EQ(1, observer().attach_calls()); 391 EXPECT_EQ(1, observer().attach_calls());
392 EXPECT_EQ(1, observer().detach_calls()); 392 EXPECT_EQ(1, observer().detach_calls());
393 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_detached().device_id); 393 EXPECT_EQ(GetDCIMDeviceId(kUniqueId1), observer().last_detached().device_id);
394 } 394 }
395 395
396 } // namespace 396 } // namespace
397 397
398 } // namespace chromeos 398 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698