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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/threading/sequenced_worker_pool.h" | 10 #include "base/threading/sequenced_worker_pool.h" |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
368 GDataCache::CACHE_TYPE_PINNED, | 368 GDataCache::CACHE_TYPE_PINNED, |
369 GDataCache::CACHED_FILE_FROM_SERVER), FilePath())); | 369 GDataCache::CACHED_FILE_FROM_SERVER), FilePath())); |
370 paths_to_verify.push_back( // Index 3: CACHE_TYPE_OUTGOING. | 370 paths_to_verify.push_back( // Index 3: CACHE_TYPE_OUTGOING. |
371 PathToVerify(cache_->GetCacheFilePath(resource_id, "", | 371 PathToVerify(cache_->GetCacheFilePath(resource_id, "", |
372 GDataCache::CACHE_TYPE_OUTGOING, | 372 GDataCache::CACHE_TYPE_OUTGOING, |
373 GDataCache::CACHED_FILE_FROM_SERVER), FilePath())); | 373 GDataCache::CACHED_FILE_FROM_SERVER), FilePath())); |
374 if (!cache_entry_found) { | 374 if (!cache_entry_found) { |
375 for (size_t i = 0; i < paths_to_verify.size(); ++i) { | 375 for (size_t i = 0; i < paths_to_verify.size(); ++i) { |
376 file_util::FileEnumerator enumerator( | 376 file_util::FileEnumerator enumerator( |
377 paths_to_verify[i].path_to_scan.DirName(), false /* not recursive*/, | 377 paths_to_verify[i].path_to_scan.DirName(), false /* not recursive*/, |
378 static_cast<file_util::FileEnumerator::FileType>( | 378 file_util::FileEnumerator::FILES | |
379 file_util::FileEnumerator::FILES | | 379 file_util::FileEnumerator::SHOW_SYM_LINKS, |
380 file_util::FileEnumerator::SHOW_SYM_LINKS), | |
381 paths_to_verify[i].path_to_scan.BaseName().value()); | 380 paths_to_verify[i].path_to_scan.BaseName().value()); |
382 EXPECT_TRUE(enumerator.Next().empty()); | 381 EXPECT_TRUE(enumerator.Next().empty()); |
383 } | 382 } |
384 } else { | 383 } else { |
385 // Entry is dirty, verify that: | 384 // Entry is dirty, verify that: |
386 // - no files with "<resource_id>.*" exist in tmp dir | 385 // - no files with "<resource_id>.*" exist in tmp dir |
387 // - only 1 "<resource_id>.local" exists in persistent dir | 386 // - only 1 "<resource_id>.local" exists in persistent dir |
388 // - only 1 <resource_id> exists in outgoing dir | 387 // - only 1 <resource_id> exists in outgoing dir |
389 // - if entry is pinned, only 1 <resource_id> exists in pinned dir. | 388 // - if entry is pinned, only 1 <resource_id> exists in pinned dir. |
390 | 389 |
(...skipping 17 matching lines...) Expand all Loading... |
408 paths_to_verify[2].expected_existing_path = | 407 paths_to_verify[2].expected_existing_path = |
409 GetCacheFilePath(resource_id, | 408 GetCacheFilePath(resource_id, |
410 std::string(), | 409 std::string(), |
411 GDataCache::CACHE_TYPE_PINNED, | 410 GDataCache::CACHE_TYPE_PINNED, |
412 GDataCache::CACHED_FILE_FROM_SERVER); | 411 GDataCache::CACHED_FILE_FROM_SERVER); |
413 } | 412 } |
414 | 413 |
415 for (size_t i = 0; i < paths_to_verify.size(); ++i) { | 414 for (size_t i = 0; i < paths_to_verify.size(); ++i) { |
416 const struct PathToVerify& verify = paths_to_verify[i]; | 415 const struct PathToVerify& verify = paths_to_verify[i]; |
417 file_util::FileEnumerator enumerator( | 416 file_util::FileEnumerator enumerator( |
418 verify.path_to_scan.DirName(), false /* not recursive*/, | 417 verify.path_to_scan.DirName(), false /* not recursive */, |
419 static_cast<file_util::FileEnumerator::FileType>( | 418 file_util::FileEnumerator::FILES | |
420 file_util::FileEnumerator::FILES | | 419 file_util::FileEnumerator::SHOW_SYM_LINKS, |
421 file_util::FileEnumerator::SHOW_SYM_LINKS), | |
422 verify.path_to_scan.BaseName().value()); | 420 verify.path_to_scan.BaseName().value()); |
423 size_t num_files_found = 0; | 421 size_t num_files_found = 0; |
424 for (FilePath current = enumerator.Next(); !current.empty(); | 422 for (FilePath current = enumerator.Next(); !current.empty(); |
425 current = enumerator.Next()) { | 423 current = enumerator.Next()) { |
426 ++num_files_found; | 424 ++num_files_found; |
427 EXPECT_EQ(verify.expected_existing_path, current); | 425 EXPECT_EQ(verify.expected_existing_path, current); |
428 } | 426 } |
429 if (verify.expected_existing_path.empty()) | 427 if (verify.expected_existing_path.empty()) |
430 EXPECT_EQ(0U, num_files_found); | 428 EXPECT_EQ(0U, num_files_found); |
431 else | 429 else |
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 &file_path)); | 1499 &file_path)); |
1502 test_util::RunBlockingPoolTask(); | 1500 test_util::RunBlockingPoolTask(); |
1503 EXPECT_EQ(GDATA_FILE_OK, error); | 1501 EXPECT_EQ(GDATA_FILE_OK, error); |
1504 | 1502 |
1505 // Verify that all the cache is removed. | 1503 // Verify that all the cache is removed. |
1506 VerifyRemoveFromCache(error, resource_id, md5); | 1504 VerifyRemoveFromCache(error, resource_id, md5); |
1507 EXPECT_EQ(0U, CountCacheFiles(resource_id, md5)); | 1505 EXPECT_EQ(0U, CountCacheFiles(resource_id, md5)); |
1508 } | 1506 } |
1509 | 1507 |
1510 } // namespace gdata | 1508 } // namespace gdata |
OLD | NEW |