OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/storage_monitor/storage_monitor_linux.h" | 7 #include "components/storage_monitor/storage_monitor_linux.h" |
8 | 8 |
9 #include <mntent.h> | 9 #include <mntent.h> |
10 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 for (; i < arraysize(kTestDeviceData); i++) { | 79 for (; i < arraysize(kTestDeviceData); i++) { |
80 if (device_path.value() == kTestDeviceData[i].device_path) { | 80 if (device_path.value() == kTestDeviceData[i].device_path) { |
81 device_found = true; | 81 device_found = true; |
82 break; | 82 break; |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 scoped_ptr<StorageInfo> storage_info; | 86 scoped_ptr<StorageInfo> storage_info; |
87 if (!device_found) { | 87 if (!device_found) { |
88 NOTREACHED(); | 88 NOTREACHED(); |
89 return storage_info.Pass(); | 89 return storage_info; |
90 } | 90 } |
91 | 91 |
92 StorageInfo::Type type = kTestDeviceData[i].type; | 92 StorageInfo::Type type = kTestDeviceData[i].type; |
93 storage_info.reset(new StorageInfo( | 93 storage_info.reset(new StorageInfo( |
94 StorageInfo::MakeDeviceId(type, kTestDeviceData[i].unique_id), | 94 StorageInfo::MakeDeviceId(type, kTestDeviceData[i].unique_id), |
95 mount_point.value(), | 95 mount_point.value(), |
96 base::ASCIIToUTF16("volume label"), | 96 base::ASCIIToUTF16("volume label"), |
97 base::ASCIIToUTF16("vendor name"), | 97 base::ASCIIToUTF16("vendor name"), |
98 base::ASCIIToUTF16("model name"), | 98 base::ASCIIToUTF16("model name"), |
99 kTestDeviceData[i].partition_size_in_bytes)); | 99 kTestDeviceData[i].partition_size_in_bytes)); |
100 return storage_info.Pass(); | 100 return storage_info; |
101 } | 101 } |
102 | 102 |
103 uint64_t GetDevicePartitionSize(const std::string& device) { | 103 uint64_t GetDevicePartitionSize(const std::string& device) { |
104 for (size_t i = 0; i < arraysize(kTestDeviceData); ++i) { | 104 for (size_t i = 0; i < arraysize(kTestDeviceData); ++i) { |
105 if (device == kTestDeviceData[i].device_path) | 105 if (device == kTestDeviceData[i].device_path) |
106 return kTestDeviceData[i].partition_size_in_bytes; | 106 return kTestDeviceData[i].partition_size_in_bytes; |
107 } | 107 } |
108 return 0; | 108 return 0; |
109 } | 109 } |
110 | 110 |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
680 GetStorageSize(test_path_a)); | 680 GetStorageSize(test_path_a)); |
681 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM), | 681 EXPECT_EQ(GetDevicePartitionSize(kDeviceNoDCIM), |
682 GetStorageSize(test_path_b)); | 682 GetStorageSize(test_path_b)); |
683 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath), | 683 EXPECT_EQ(GetDevicePartitionSize(kInvalidPath), |
684 GetStorageSize(base::FilePath(kInvalidPath))); | 684 GetStorageSize(base::FilePath(kInvalidPath))); |
685 } | 685 } |
686 | 686 |
687 } // namespace | 687 } // namespace |
688 | 688 |
689 } // namespace storage_monitor | 689 } // namespace storage_monitor |
OLD | NEW |