| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
| 7 #include "net/disk_cache/cache_util.h" | 7 #include "net/disk_cache/cache_util.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "testing/platform_test.h" | 9 #include "testing/platform_test.h" |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 base::FilePath file2_; | 41 base::FilePath file2_; |
| 42 base::FilePath dir1_; | 42 base::FilePath dir1_; |
| 43 base::FilePath dest_dir_; | 43 base::FilePath dest_dir_; |
| 44 base::FilePath dest_file1_; | 44 base::FilePath dest_file1_; |
| 45 base::FilePath dest_file2_; | 45 base::FilePath dest_file2_; |
| 46 base::FilePath dest_dir1_; | 46 base::FilePath dest_dir1_; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 TEST_F(CacheUtilTest, MoveCache) { | 49 TEST_F(CacheUtilTest, MoveCache) { |
| 50 EXPECT_TRUE(disk_cache::MoveCache(cache_dir_, dest_dir_)); | 50 EXPECT_TRUE(disk_cache::MoveCache(cache_dir_, dest_dir_)); |
| 51 EXPECT_TRUE(file_util::PathExists(dest_dir_)); | 51 EXPECT_TRUE(base::PathExists(dest_dir_)); |
| 52 EXPECT_TRUE(file_util::PathExists(dest_file1_)); | 52 EXPECT_TRUE(base::PathExists(dest_file1_)); |
| 53 EXPECT_TRUE(file_util::PathExists(dest_file2_)); | 53 EXPECT_TRUE(base::PathExists(dest_file2_)); |
| 54 EXPECT_TRUE(file_util::PathExists(dest_dir1_)); | 54 EXPECT_TRUE(base::PathExists(dest_dir1_)); |
| 55 #if defined(OS_CHROMEOS) | 55 #if defined(OS_CHROMEOS) |
| 56 EXPECT_TRUE(file_util::PathExists(cache_dir_)); // old cache dir stays | 56 EXPECT_TRUE(base::PathExists(cache_dir_)); // old cache dir stays |
| 57 #else | 57 #else |
| 58 EXPECT_FALSE(file_util::PathExists(cache_dir_)); // old cache is gone | 58 EXPECT_FALSE(base::PathExists(cache_dir_)); // old cache is gone |
| 59 #endif | 59 #endif |
| 60 EXPECT_FALSE(file_util::PathExists(file1_)); | 60 EXPECT_FALSE(base::PathExists(file1_)); |
| 61 EXPECT_FALSE(file_util::PathExists(file2_)); | 61 EXPECT_FALSE(base::PathExists(file2_)); |
| 62 EXPECT_FALSE(file_util::PathExists(dir1_)); | 62 EXPECT_FALSE(base::PathExists(dir1_)); |
| 63 } | 63 } |
| 64 | 64 |
| 65 TEST_F(CacheUtilTest, DeleteCache) { | 65 TEST_F(CacheUtilTest, DeleteCache) { |
| 66 // DeleteCache won't delete subdirs, so let's not start with this | 66 // DeleteCache won't delete subdirs, so let's not start with this |
| 67 // one around. | 67 // one around. |
| 68 base::Delete(dir1_, false); | 68 base::Delete(dir1_, false); |
| 69 disk_cache::DeleteCache(cache_dir_, false); | 69 disk_cache::DeleteCache(cache_dir_, false); |
| 70 EXPECT_TRUE(file_util::PathExists(cache_dir_)); // cache dir stays | 70 EXPECT_TRUE(base::PathExists(cache_dir_)); // cache dir stays |
| 71 EXPECT_FALSE(file_util::PathExists(file1_)); | 71 EXPECT_FALSE(base::PathExists(file1_)); |
| 72 EXPECT_FALSE(file_util::PathExists(file2_)); | 72 EXPECT_FALSE(base::PathExists(file2_)); |
| 73 } | 73 } |
| 74 | 74 |
| 75 TEST_F(CacheUtilTest, DeleteCacheAndDir) { | 75 TEST_F(CacheUtilTest, DeleteCacheAndDir) { |
| 76 // DeleteCache won't delete subdirs, so let's not start with this | 76 // DeleteCache won't delete subdirs, so let's not start with this |
| 77 // one around. | 77 // one around. |
| 78 base::Delete(dir1_, false); | 78 base::Delete(dir1_, false); |
| 79 disk_cache::DeleteCache(cache_dir_, true); | 79 disk_cache::DeleteCache(cache_dir_, true); |
| 80 EXPECT_FALSE(file_util::PathExists(cache_dir_)); // cache dir is gone | 80 EXPECT_FALSE(base::PathExists(cache_dir_)); // cache dir is gone |
| 81 EXPECT_FALSE(file_util::PathExists(file1_)); | 81 EXPECT_FALSE(base::PathExists(file1_)); |
| 82 EXPECT_FALSE(file_util::PathExists(file2_)); | 82 EXPECT_FALSE(base::PathExists(file2_)); |
| 83 } | 83 } |
| 84 | 84 |
| 85 TEST_F(CacheUtilTest, DeleteCacheFile) { | 85 TEST_F(CacheUtilTest, DeleteCacheFile) { |
| 86 EXPECT_TRUE(disk_cache::DeleteCacheFile(file1_)); | 86 EXPECT_TRUE(disk_cache::DeleteCacheFile(file1_)); |
| 87 EXPECT_FALSE(file_util::PathExists(file1_)); | 87 EXPECT_FALSE(base::PathExists(file1_)); |
| 88 EXPECT_TRUE(file_util::PathExists(cache_dir_)); // cache dir stays | 88 EXPECT_TRUE(base::PathExists(cache_dir_)); // cache dir stays |
| 89 } | 89 } |
| 90 | 90 |
| 91 } // namespace disk_cache | 91 } // namespace disk_cache |
| OLD | NEW |