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 // StorageMonitorLinux unit tests. | 5 // StorageMonitorLinux unit tests. |
6 | 6 |
7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" | 7 #include "chrome/browser/storage_monitor/storage_monitor_linux.h" |
8 | 8 |
9 #include <mntent.h> | 9 #include <mntent.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 // Create a directory named |dir| relative to the test directory. | 228 // Create a directory named |dir| relative to the test directory. |
229 // It does not have a DCIM directory, so StorageMonitorLinux does not | 229 // It does not have a DCIM directory, so StorageMonitorLinux does not |
230 // recognize it as a media directory. | 230 // recognize it as a media directory. |
231 base::FilePath CreateMountPointWithoutDCIMDir(const std::string& dir) { | 231 base::FilePath CreateMountPointWithoutDCIMDir(const std::string& dir) { |
232 return CreateMountPoint(dir, false /* do not create DCIM dir */); | 232 return CreateMountPoint(dir, false /* do not create DCIM dir */); |
233 } | 233 } |
234 | 234 |
235 void RemoveDCIMDirFromMountPoint(const std::string& dir) { | 235 void RemoveDCIMDirFromMountPoint(const std::string& dir) { |
236 base::FilePath dcim = | 236 base::FilePath dcim = |
237 scoped_temp_dir_.path().AppendASCII(dir).Append(kDCIMDirectoryName); | 237 scoped_temp_dir_.path().AppendASCII(dir).Append(kDCIMDirectoryName); |
238 base::Delete(dcim, false); | 238 base::DeleteFile(dcim, false); |
239 } | 239 } |
240 | 240 |
241 MockRemovableStorageObserver& observer() { | 241 MockRemovableStorageObserver& observer() { |
242 return *mock_storage_observer_; | 242 return *mock_storage_observer_; |
243 } | 243 } |
244 | 244 |
245 StorageMonitor* notifier() { | 245 StorageMonitor* notifier() { |
246 return monitor_.get(); | 246 return monitor_.get(); |
247 } | 247 } |
248 | 248 |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
551 EXPECT_EQ(2, observer().attach_calls()); | 551 EXPECT_EQ(2, observer().attach_calls()); |
552 EXPECT_EQ(1, observer().detach_calls()); | 552 EXPECT_EQ(1, observer().detach_calls()); |
553 | 553 |
554 // Attach |kDeviceNoDCIM| (a non-DCIM device) to |kMountPointB|. | 554 // Attach |kDeviceNoDCIM| (a non-DCIM device) to |kMountPointB|. |
555 // kDeviceDCIM1 -> kMountPointA * | 555 // kDeviceDCIM1 -> kMountPointA * |
556 // kDeviceDCIM1 -> kMountPointB | 556 // kDeviceDCIM1 -> kMountPointB |
557 // kDeviceNoDCIM -> kMountPointB * | 557 // kDeviceNoDCIM -> kMountPointB * |
558 MtabTestData test_data5[] = { | 558 MtabTestData test_data5[] = { |
559 MtabTestData(kDeviceNoDCIM, test_path_b.value(), kValidFS), | 559 MtabTestData(kDeviceNoDCIM, test_path_b.value(), kValidFS), |
560 }; | 560 }; |
561 base::Delete(test_path_b.Append(kDCIMDirectoryName), false); | 561 base::DeleteFile(test_path_b.Append(kDCIMDirectoryName), false); |
562 AppendToMtabAndRunLoop(test_data5, arraysize(test_data5)); | 562 AppendToMtabAndRunLoop(test_data5, arraysize(test_data5)); |
563 EXPECT_EQ(4, observer().attach_calls()); | 563 EXPECT_EQ(4, observer().attach_calls()); |
564 EXPECT_EQ(2, observer().detach_calls()); | 564 EXPECT_EQ(2, observer().detach_calls()); |
565 | 565 |
566 // Detach |kDeviceNoDCIM|. | 566 // Detach |kDeviceNoDCIM|. |
567 // kDeviceDCIM1 -> kMountPointA * | 567 // kDeviceDCIM1 -> kMountPointA * |
568 // kDeviceDCIM1 -> kMountPointB | 568 // kDeviceDCIM1 -> kMountPointB |
569 MtabTestData test_data6[] = { | 569 MtabTestData test_data6[] = { |
570 MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), | 570 MtabTestData(kDeviceDCIM1, test_path_a.value(), kValidFS), |
571 MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS), | 571 MtabTestData(kDeviceDCIM1, test_path_b.value(), kValidFS), |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 GetStorageSize(test_path_a)); | 684 GetStorageSize(test_path_a)); |
685 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM), | 685 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM), |
686 GetStorageSize(test_path_b)); | 686 GetStorageSize(test_path_b)); |
687 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath), | 687 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath), |
688 GetStorageSize(base::FilePath(kInvalidPath))); | 688 GetStorageSize(base::FilePath(kInvalidPath))); |
689 } | 689 } |
690 | 690 |
691 } // namespace | 691 } // namespace |
692 | 692 |
693 } // namespace chrome | 693 } // namespace chrome |
OLD | NEW |