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 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "chrome/browser/extensions/api/image_writer_private/removable_storage_p
rovider.h" | 7 #include "chrome/browser/extensions/api/image_writer_private/removable_storage_p
rovider.h" |
8 #include "chromeos/disks/mock_disk_mount_manager.h" | 8 #include "chromeos/disks/mock_disk_mount_manager.h" |
9 #include "content/public/test/test_browser_thread_bundle.h" | 9 #include "content/public/test/test_browser_thread_bundle.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 } | 94 } |
95 } | 95 } |
96 return NULL; | 96 return NULL; |
97 } | 97 } |
98 | 98 |
99 void ExpectDevice(StorageDeviceList* list, | 99 void ExpectDevice(StorageDeviceList* list, |
100 const std::string& device_path, | 100 const std::string& device_path, |
101 const std::string& vendor, | 101 const std::string& vendor, |
102 const std::string& model, | 102 const std::string& model, |
103 uint64 capacity) { | 103 uint64 capacity) { |
104 RemovableStorageDevice* device = FindDevice(devices_, device_path); | 104 RemovableStorageDevice* device = FindDevice(devices_.get(), device_path); |
105 | 105 |
106 ASSERT_TRUE(device != NULL); | 106 ASSERT_TRUE(device != NULL); |
107 | 107 |
108 EXPECT_EQ(device_path, device->storage_unit_id); | 108 EXPECT_EQ(device_path, device->storage_unit_id); |
109 EXPECT_EQ(vendor, device->vendor); | 109 EXPECT_EQ(vendor, device->vendor); |
110 EXPECT_EQ(model, device->model); | 110 EXPECT_EQ(model, device->model); |
111 EXPECT_EQ(capacity, device->capacity); | 111 EXPECT_EQ(capacity, device->capacity); |
112 } | 112 } |
113 | 113 |
114 MockDiskMountManager* disk_mount_manager_mock_; | 114 MockDiskMountManager* disk_mount_manager_mock_; |
(...skipping 17 matching lines...) Expand all Loading... |
132 | 132 |
133 RemovableStorageProvider::GetAllDevices( | 133 RemovableStorageProvider::GetAllDevices( |
134 base::Bind(&RemovableStorageProviderChromeOsUnitTest::DevicesCallback, | 134 base::Bind(&RemovableStorageProviderChromeOsUnitTest::DevicesCallback, |
135 base::Unretained(this))); | 135 base::Unretained(this))); |
136 | 136 |
137 base::RunLoop().RunUntilIdle(); | 137 base::RunLoop().RunUntilIdle(); |
138 | 138 |
139 ASSERT_EQ(2U, devices_->data.size()); | 139 ASSERT_EQ(2U, devices_->data.size()); |
140 | 140 |
141 ExpectDevice( | 141 ExpectDevice( |
142 devices_, kDevicePathUSB, kVendorName, kProductName, kDeviceSize); | 142 devices_.get(), kDevicePathUSB, kVendorName, kProductName, kDeviceSize); |
143 ExpectDevice(devices_, kDevicePathSD, kVendorName, kProductName, kDeviceSize); | 143 ExpectDevice( |
| 144 devices_.get(), kDevicePathSD, kVendorName, kProductName, kDeviceSize); |
144 } | 145 } |
145 | 146 |
146 // Tests that a USB drive with an empty vendor and product gets a generic name. | 147 // Tests that a USB drive with an empty vendor and product gets a generic name. |
147 TEST_F(RemovableStorageProviderChromeOsUnitTest, EmptyProductAndModel) { | 148 TEST_F(RemovableStorageProviderChromeOsUnitTest, EmptyProductAndModel) { |
148 CreateDisk( | 149 CreateDisk( |
149 kDevicePathUSB, "", "", chromeos::DEVICE_TYPE_USB, true, true, false); | 150 kDevicePathUSB, "", "", chromeos::DEVICE_TYPE_USB, true, true, false); |
150 CreateDisk( | 151 CreateDisk( |
151 kDevicePathSD, "", "", chromeos::DEVICE_TYPE_SD, true, true, false); | 152 kDevicePathSD, "", "", chromeos::DEVICE_TYPE_SD, true, true, false); |
152 | 153 |
153 RemovableStorageProvider::GetAllDevices( | 154 RemovableStorageProvider::GetAllDevices( |
154 base::Bind(&RemovableStorageProviderChromeOsUnitTest::DevicesCallback, | 155 base::Bind(&RemovableStorageProviderChromeOsUnitTest::DevicesCallback, |
155 base::Unretained(this))); | 156 base::Unretained(this))); |
156 | 157 |
157 base::RunLoop().RunUntilIdle(); | 158 base::RunLoop().RunUntilIdle(); |
158 | 159 |
159 ASSERT_EQ(2U, devices_->data.size()); | 160 ASSERT_EQ(2U, devices_->data.size()); |
160 | 161 |
161 ExpectDevice(devices_, kDevicePathUSB, "", kUnknownUSBDiskModel, kDeviceSize); | 162 ExpectDevice( |
162 ExpectDevice(devices_, kDevicePathSD, "", kUnknownSDDiskModel, kDeviceSize); | 163 devices_.get(), kDevicePathUSB, "", kUnknownUSBDiskModel, kDeviceSize); |
| 164 ExpectDevice( |
| 165 devices_.get(), kDevicePathSD, "", kUnknownSDDiskModel, kDeviceSize); |
163 } | 166 } |
164 | 167 |
165 } // namespace extensions | 168 } // namespace extensions |
OLD | NEW |