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 #include "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 FetchFileSystems(); | 207 FetchFileSystems(); |
208 | 208 |
209 EXPECT_EQ(3UL, file_system_info_list_->size()); | 209 EXPECT_EQ(3UL, file_system_info_list_->size()); |
210 | 210 |
211 // Order is arbitrary, verify all three origins. | 211 // Order is arbitrary, verify all three origins. |
212 bool test_hosts_found[3] = {false, false, false}; | 212 bool test_hosts_found[3] = {false, false, false}; |
213 for (const auto& info : *file_system_info_list_) { | 213 for (const auto& info : *file_system_info_list_) { |
214 if (info.origin == kOrigin1) { | 214 if (info.origin == kOrigin1) { |
215 EXPECT_FALSE(test_hosts_found[0]); | 215 EXPECT_FALSE(test_hosts_found[0]); |
216 test_hosts_found[0] = true; | 216 test_hosts_found[0] = true; |
217 EXPECT_FALSE(ContainsKey(info.usage_map, kPersistent)); | 217 EXPECT_FALSE(base::ContainsKey(info.usage_map, kPersistent)); |
218 EXPECT_TRUE(ContainsKey(info.usage_map, kTemporary)); | 218 EXPECT_TRUE(base::ContainsKey(info.usage_map, kTemporary)); |
219 EXPECT_EQ(kEmptyFileSystemSize, | 219 EXPECT_EQ(kEmptyFileSystemSize, |
220 info.usage_map.at(storage::kFileSystemTypeTemporary)); | 220 info.usage_map.at(storage::kFileSystemTypeTemporary)); |
221 } else if (info.origin == kOrigin2) { | 221 } else if (info.origin == kOrigin2) { |
222 EXPECT_FALSE(test_hosts_found[1]); | 222 EXPECT_FALSE(test_hosts_found[1]); |
223 test_hosts_found[1] = true; | 223 test_hosts_found[1] = true; |
224 EXPECT_TRUE(ContainsKey(info.usage_map, kPersistent)); | 224 EXPECT_TRUE(base::ContainsKey(info.usage_map, kPersistent)); |
225 EXPECT_FALSE(ContainsKey(info.usage_map, kTemporary)); | 225 EXPECT_FALSE(base::ContainsKey(info.usage_map, kTemporary)); |
226 EXPECT_EQ(kEmptyFileSystemSize, info.usage_map.at(kPersistent)); | 226 EXPECT_EQ(kEmptyFileSystemSize, info.usage_map.at(kPersistent)); |
227 } else if (info.origin == kOrigin3) { | 227 } else if (info.origin == kOrigin3) { |
228 EXPECT_FALSE(test_hosts_found[2]); | 228 EXPECT_FALSE(test_hosts_found[2]); |
229 test_hosts_found[2] = true; | 229 test_hosts_found[2] = true; |
230 EXPECT_TRUE(ContainsKey(info.usage_map, kPersistent)); | 230 EXPECT_TRUE(base::ContainsKey(info.usage_map, kPersistent)); |
231 EXPECT_TRUE(ContainsKey(info.usage_map, kTemporary)); | 231 EXPECT_TRUE(base::ContainsKey(info.usage_map, kTemporary)); |
232 EXPECT_EQ(kEmptyFileSystemSize, info.usage_map.at(kPersistent)); | 232 EXPECT_EQ(kEmptyFileSystemSize, info.usage_map.at(kPersistent)); |
233 EXPECT_EQ(kEmptyFileSystemSize, info.usage_map.at(kTemporary)); | 233 EXPECT_EQ(kEmptyFileSystemSize, info.usage_map.at(kTemporary)); |
234 } else { | 234 } else { |
235 ADD_FAILURE() << info.origin.spec() << " isn't an origin we added."; | 235 ADD_FAILURE() << info.origin.spec() << " isn't an origin we added."; |
236 } | 236 } |
237 } | 237 } |
238 for (size_t i = 0; i < arraysize(test_hosts_found); i++) { | 238 for (size_t i = 0; i < arraysize(test_hosts_found); i++) { |
239 EXPECT_TRUE(test_hosts_found[i]); | 239 EXPECT_TRUE(test_hosts_found[i]); |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 // Verifies that the BrowsingDataFileSystemHelper correctly deletes file | 243 // Verifies that the BrowsingDataFileSystemHelper correctly deletes file |
244 // systems via DeleteFileSystemOrigin(). | 244 // systems via DeleteFileSystemOrigin(). |
245 TEST_F(BrowsingDataFileSystemHelperTest, DeleteData) { | 245 TEST_F(BrowsingDataFileSystemHelperTest, DeleteData) { |
246 PopulateTestFileSystemData(); | 246 PopulateTestFileSystemData(); |
247 | 247 |
248 helper_->DeleteFileSystemOrigin(kOrigin1); | 248 helper_->DeleteFileSystemOrigin(kOrigin1); |
249 helper_->DeleteFileSystemOrigin(kOrigin2); | 249 helper_->DeleteFileSystemOrigin(kOrigin2); |
250 | 250 |
251 FetchFileSystems(); | 251 FetchFileSystems(); |
252 | 252 |
253 EXPECT_EQ(1UL, file_system_info_list_->size()); | 253 EXPECT_EQ(1UL, file_system_info_list_->size()); |
254 BrowsingDataFileSystemHelper::FileSystemInfo info = | 254 BrowsingDataFileSystemHelper::FileSystemInfo info = |
255 *(file_system_info_list_->begin()); | 255 *(file_system_info_list_->begin()); |
256 EXPECT_EQ(kOrigin3, info.origin); | 256 EXPECT_EQ(kOrigin3, info.origin); |
257 EXPECT_TRUE(ContainsKey(info.usage_map, kPersistent)); | 257 EXPECT_TRUE(base::ContainsKey(info.usage_map, kPersistent)); |
258 EXPECT_TRUE(ContainsKey(info.usage_map, kTemporary)); | 258 EXPECT_TRUE(base::ContainsKey(info.usage_map, kTemporary)); |
259 EXPECT_EQ(kEmptyFileSystemSize, info.usage_map[kPersistent]); | 259 EXPECT_EQ(kEmptyFileSystemSize, info.usage_map[kPersistent]); |
260 EXPECT_EQ(kEmptyFileSystemSize, info.usage_map[kTemporary]); | 260 EXPECT_EQ(kEmptyFileSystemSize, info.usage_map[kTemporary]); |
261 } | 261 } |
262 | 262 |
263 // Verifies that the CannedBrowsingDataFileSystemHelper correctly reports | 263 // Verifies that the CannedBrowsingDataFileSystemHelper correctly reports |
264 // whether or not it currently contains file systems. | 264 // whether or not it currently contains file systems. |
265 TEST_F(BrowsingDataFileSystemHelperTest, Empty) { | 265 TEST_F(BrowsingDataFileSystemHelperTest, Empty) { |
266 ASSERT_TRUE(canned_helper_->empty()); | 266 ASSERT_TRUE(canned_helper_->empty()); |
267 canned_helper_->AddFileSystem(kOrigin1, kTemporary, 0); | 267 canned_helper_->AddFileSystem(kOrigin1, kTemporary, 0); |
268 ASSERT_FALSE(canned_helper_->empty()); | 268 ASSERT_FALSE(canned_helper_->empty()); |
269 canned_helper_->Reset(); | 269 canned_helper_->Reset(); |
270 ASSERT_TRUE(canned_helper_->empty()); | 270 ASSERT_TRUE(canned_helper_->empty()); |
271 } | 271 } |
272 | 272 |
273 // Verifies that AddFileSystem correctly adds file systems, and that both | 273 // Verifies that AddFileSystem correctly adds file systems, and that both |
274 // the type and usage metadata are reported as provided. | 274 // the type and usage metadata are reported as provided. |
275 TEST_F(BrowsingDataFileSystemHelperTest, CannedAddFileSystem) { | 275 TEST_F(BrowsingDataFileSystemHelperTest, CannedAddFileSystem) { |
276 canned_helper_->AddFileSystem(kOrigin1, kPersistent, 200); | 276 canned_helper_->AddFileSystem(kOrigin1, kPersistent, 200); |
277 canned_helper_->AddFileSystem(kOrigin2, kTemporary, 100); | 277 canned_helper_->AddFileSystem(kOrigin2, kTemporary, 100); |
278 | 278 |
279 FetchCannedFileSystems(); | 279 FetchCannedFileSystems(); |
280 | 280 |
281 EXPECT_EQ(2U, file_system_info_list_->size()); | 281 EXPECT_EQ(2U, file_system_info_list_->size()); |
282 std::list<BrowsingDataFileSystemHelper::FileSystemInfo>::iterator info = | 282 std::list<BrowsingDataFileSystemHelper::FileSystemInfo>::iterator info = |
283 file_system_info_list_->begin(); | 283 file_system_info_list_->begin(); |
284 EXPECT_EQ(kOrigin1, info->origin); | 284 EXPECT_EQ(kOrigin1, info->origin); |
285 EXPECT_TRUE(ContainsKey(info->usage_map, kPersistent)); | 285 EXPECT_TRUE(base::ContainsKey(info->usage_map, kPersistent)); |
286 EXPECT_FALSE(ContainsKey(info->usage_map, kTemporary)); | 286 EXPECT_FALSE(base::ContainsKey(info->usage_map, kTemporary)); |
287 EXPECT_EQ(200, info->usage_map[kPersistent]); | 287 EXPECT_EQ(200, info->usage_map[kPersistent]); |
288 | 288 |
289 info++; | 289 info++; |
290 EXPECT_EQ(kOrigin2, info->origin); | 290 EXPECT_EQ(kOrigin2, info->origin); |
291 EXPECT_FALSE(ContainsKey(info->usage_map, kPersistent)); | 291 EXPECT_FALSE(base::ContainsKey(info->usage_map, kPersistent)); |
292 EXPECT_TRUE(ContainsKey(info->usage_map, kTemporary)); | 292 EXPECT_TRUE(base::ContainsKey(info->usage_map, kTemporary)); |
293 EXPECT_EQ(100, info->usage_map[kTemporary]); | 293 EXPECT_EQ(100, info->usage_map[kTemporary]); |
294 } | 294 } |
295 | 295 |
296 // Verifies that the CannedBrowsingDataFileSystemHelper correctly ignores | 296 // Verifies that the CannedBrowsingDataFileSystemHelper correctly ignores |
297 // extension and devtools schemes. | 297 // extension and devtools schemes. |
298 TEST_F(BrowsingDataFileSystemHelperTest, IgnoreExtensionsAndDevTools) { | 298 TEST_F(BrowsingDataFileSystemHelperTest, IgnoreExtensionsAndDevTools) { |
299 ASSERT_TRUE(canned_helper_->empty()); | 299 ASSERT_TRUE(canned_helper_->empty()); |
300 canned_helper_->AddFileSystem(kOriginExt, kTemporary, 0); | 300 canned_helper_->AddFileSystem(kOriginExt, kTemporary, 0); |
301 ASSERT_TRUE(canned_helper_->empty()); | 301 ASSERT_TRUE(canned_helper_->empty()); |
302 canned_helper_->AddFileSystem(kOriginDevTools, kTemporary, 0); | 302 canned_helper_->AddFileSystem(kOriginDevTools, kTemporary, 0); |
303 ASSERT_TRUE(canned_helper_->empty()); | 303 ASSERT_TRUE(canned_helper_->empty()); |
304 } | 304 } |
305 | 305 |
306 } // namespace | 306 } // namespace |
OLD | NEW |