| Index: net/disk_cache/block_files_unittest.cc
|
| ===================================================================
|
| --- net/disk_cache/block_files_unittest.cc (revision 60165)
|
| +++ net/disk_cache/block_files_unittest.cc (working copy)
|
| @@ -28,9 +28,11 @@
|
| namespace disk_cache {
|
|
|
| TEST_F(DiskCacheTest, BlockFiles_Grow) {
|
| - ScopedTestCache test_cache;
|
| + FilePath path = GetCacheFilePath();
|
| + ASSERT_TRUE(DeleteCache(path));
|
| + ASSERT_TRUE(file_util::CreateDirectory(path));
|
|
|
| - BlockFiles files(test_cache.path());
|
| + BlockFiles files(path);
|
| ASSERT_TRUE(files.Init(true));
|
|
|
| const int kMaxSize = 35000;
|
| @@ -40,7 +42,7 @@
|
| for (int i = 0; i < kMaxSize; i++) {
|
| EXPECT_TRUE(files.CreateBlock(RANKINGS, 4, &address[i]));
|
| }
|
| - EXPECT_EQ(6, NumberOfFiles(test_cache.path()));
|
| + EXPECT_EQ(6, NumberOfFiles(path));
|
|
|
| // Make sure we don't keep adding files.
|
| for (int i = 0; i < kMaxSize * 4; i += 2) {
|
| @@ -48,14 +50,16 @@
|
| files.DeleteBlock(address[target], false);
|
| EXPECT_TRUE(files.CreateBlock(RANKINGS, 4, &address[target]));
|
| }
|
| - EXPECT_EQ(6, NumberOfFiles(test_cache.path()));
|
| + EXPECT_EQ(6, NumberOfFiles(path));
|
| }
|
|
|
| // We should be able to delete empty block files.
|
| TEST_F(DiskCacheTest, BlockFiles_Shrink) {
|
| - ScopedTestCache test_cache;
|
| + FilePath path = GetCacheFilePath();
|
| + ASSERT_TRUE(DeleteCache(path));
|
| + ASSERT_TRUE(file_util::CreateDirectory(path));
|
|
|
| - BlockFiles files(test_cache.path());
|
| + BlockFiles files(path);
|
| ASSERT_TRUE(files.Init(true));
|
|
|
| const int kMaxSize = 35000;
|
| @@ -70,14 +74,16 @@
|
| for (int i = 0; i < kMaxSize; i++) {
|
| files.DeleteBlock(address[i], false);
|
| }
|
| - EXPECT_EQ(4, NumberOfFiles(test_cache.path()));
|
| + EXPECT_EQ(4, NumberOfFiles(path));
|
| }
|
|
|
| // Handling of block files not properly closed.
|
| TEST_F(DiskCacheTest, BlockFiles_Recover) {
|
| - ScopedTestCache test_cache;
|
| + FilePath path = GetCacheFilePath();
|
| + ASSERT_TRUE(DeleteCache(path));
|
| + ASSERT_TRUE(file_util::CreateDirectory(path));
|
|
|
| - BlockFiles files(test_cache.path());
|
| + BlockFiles files(path);
|
| ASSERT_TRUE(files.Init(true));
|
|
|
| const int kNumEntries = 2000;
|
| @@ -151,9 +157,11 @@
|
|
|
| // Handling of truncated files.
|
| TEST_F(DiskCacheTest, BlockFiles_ZeroSizeFile) {
|
| - ScopedTestCache test_cache;
|
| + FilePath path = GetCacheFilePath();
|
| + ASSERT_TRUE(DeleteCache(path));
|
| + ASSERT_TRUE(file_util::CreateDirectory(path));
|
|
|
| - BlockFiles files(test_cache.path());
|
| + BlockFiles files(path);
|
| ASSERT_TRUE(files.Init(true));
|
|
|
| FilePath filename = files.Name(0);
|
| @@ -171,9 +179,11 @@
|
|
|
| // An invalid file can be detected after init.
|
| TEST_F(DiskCacheTest, BlockFiles_InvalidFile) {
|
| - ScopedTestCache test_cache;
|
| + FilePath path = GetCacheFilePath();
|
| + ASSERT_TRUE(DeleteCache(path));
|
| + ASSERT_TRUE(file_util::CreateDirectory(path));
|
|
|
| - BlockFiles files(test_cache.path());
|
| + BlockFiles files(path);
|
| ASSERT_TRUE(files.Init(true));
|
|
|
| // Let's access block 10 of file 5. (There is no file).
|
| @@ -195,11 +205,10 @@
|
|
|
| // Tests that we generate the correct file stats.
|
| TEST_F(DiskCacheTest, BlockFiles_Stats) {
|
| - ScopedTestCache test_cache;
|
| + ASSERT_TRUE(CopyTestCache("remove_load1"));
|
| + FilePath path = GetCacheFilePath();
|
|
|
| - ASSERT_TRUE(CopyTestCache("remove_load1", test_cache.path()));
|
| -
|
| - BlockFiles files(test_cache.path());
|
| + BlockFiles files(path);
|
| ASSERT_TRUE(files.Init(false));
|
| int used, load;
|
|
|
| @@ -218,9 +227,11 @@
|
|
|
| // Tests that we add and remove blocks correctly.
|
| TEST_F(DiskCacheTest, AllocationMap) {
|
| - ScopedTestCache test_cache;
|
| + FilePath path = GetCacheFilePath();
|
| + ASSERT_TRUE(DeleteCache(path));
|
| + ASSERT_TRUE(file_util::CreateDirectory(path));
|
|
|
| - BlockFiles files(test_cache.path());
|
| + BlockFiles files(path);
|
| ASSERT_TRUE(files.Init(true));
|
|
|
| // Create a bunch of entries.
|
|
|