| 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 "chrome/browser/chromeos/drive/file_cache.h" | 5 #include "chrome/browser/chromeos/drive/file_cache.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 344 |
| 345 // Store a different existing file to the same |id| but different | 345 // Store a different existing file to the same |id| but different |
| 346 // |md5|. | 346 // |md5|. |
| 347 md5 = "new_md5"; | 347 md5 = "new_md5"; |
| 348 TestStoreToCache(id, md5, dummy_file_path_, | 348 TestStoreToCache(id, md5, dummy_file_path_, |
| 349 FILE_ERROR_OK, TEST_CACHE_STATE_PRESENT); | 349 FILE_ERROR_OK, TEST_CACHE_STATE_PRESENT); |
| 350 | 350 |
| 351 // Verify that there's only one file with name <id>, i.e. previously | 351 // Verify that there's only one file with name <id>, i.e. previously |
| 352 // cached file with the different md5 should be deleted. | 352 // cached file with the different md5 should be deleted. |
| 353 EXPECT_EQ(1U, CountCacheFiles(id, md5)); | 353 EXPECT_EQ(1U, CountCacheFiles(id, md5)); |
| 354 |
| 355 // Passing empty MD5 marks the entry as dirty. |
| 356 TestStoreToCache(id, std::string(), dummy_file_path_, FILE_ERROR_OK, |
| 357 TEST_CACHE_STATE_PRESENT | TEST_CACHE_STATE_DIRTY); |
| 354 } | 358 } |
| 355 | 359 |
| 356 TEST_F(FileCacheTestOnUIThread, RemoveFromCacheSimple) { | 360 TEST_F(FileCacheTestOnUIThread, RemoveFromCacheSimple) { |
| 357 std::string id("pdf:1a2b"); | 361 std::string id("pdf:1a2b"); |
| 358 std::string md5("abcdef0123456789"); | 362 std::string md5("abcdef0123456789"); |
| 359 // First store a file to cache. | 363 // First store a file to cache. |
| 360 TestStoreToCache(id, md5, dummy_file_path_, | 364 TestStoreToCache(id, md5, dummy_file_path_, |
| 361 FILE_ERROR_OK, TEST_CACHE_STATE_PRESENT); | 365 FILE_ERROR_OK, TEST_CACHE_STATE_PRESENT); |
| 362 | 366 |
| 363 // Then try to remove existing file from cache. | 367 // Then try to remove existing file from cache. |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 // Clear cache. | 888 // Clear cache. |
| 885 EXPECT_TRUE(cache_->ClearAll()); | 889 EXPECT_TRUE(cache_->ClearAll()); |
| 886 | 890 |
| 887 // Verify that the cache is removed. | 891 // Verify that the cache is removed. |
| 888 EXPECT_FALSE(cache_->GetCacheEntry(id, &cache_entry)); | 892 EXPECT_FALSE(cache_->GetCacheEntry(id, &cache_entry)); |
| 889 EXPECT_TRUE(base::IsDirectoryEmpty(cache_files_dir_)); | 893 EXPECT_TRUE(base::IsDirectoryEmpty(cache_files_dir_)); |
| 890 } | 894 } |
| 891 | 895 |
| 892 } // namespace internal | 896 } // namespace internal |
| 893 } // namespace drive | 897 } // namespace drive |
| OLD | NEW |