| 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/files/file_enumerator.h" | 6 #include "base/files/file_enumerator.h" |
| 7 #include "net/disk_cache/block_files.h" | 7 #include "net/disk_cache/blockfile/block_files.h" |
| 8 #include "net/disk_cache/disk_cache.h" | 8 #include "net/disk_cache/disk_cache.h" |
| 9 #include "net/disk_cache/disk_cache_test_base.h" | 9 #include "net/disk_cache/disk_cache_test_base.h" |
| 10 #include "net/disk_cache/disk_cache_test_util.h" | 10 #include "net/disk_cache/disk_cache_test_util.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 using base::Time; | 13 using base::Time; |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 // Returns the number of files in this folder. | 17 // Returns the number of files in this folder. |
| 18 int NumberOfFiles(const base::FilePath& path) { | 18 int NumberOfFiles(const base::FilePath& path) { |
| 19 base::FileEnumerator iter(path, false, base::FileEnumerator::FILES); | 19 base::FileEnumerator iter(path, false, base::FileEnumerator::FILES); |
| 20 int count = 0; | 20 int count = 0; |
| 21 for (base::FilePath file = iter.Next(); !file.value().empty(); | 21 for (base::FilePath file = iter.Next(); !file.value().empty(); |
| 22 file = iter.Next()) { | 22 file = iter.Next()) { |
| 23 count++; | 23 count++; |
| 24 } | 24 } |
| 25 return count; | 25 return count; |
| 26 } | 26 } |
| 27 | 27 |
| 28 } // namespace; | 28 } // namespace |
| 29 | 29 |
| 30 namespace disk_cache { | 30 namespace disk_cache { |
| 31 | 31 |
| 32 TEST_F(DiskCacheTest, BlockFiles_Grow) { | 32 TEST_F(DiskCacheTest, BlockFiles_Grow) { |
| 33 ASSERT_TRUE(CleanupCacheDir()); | 33 ASSERT_TRUE(CleanupCacheDir()); |
| 34 ASSERT_TRUE(base::CreateDirectory(cache_path_)); | 34 ASSERT_TRUE(base::CreateDirectory(cache_path_)); |
| 35 | 35 |
| 36 BlockFiles files(cache_path_); | 36 BlockFiles files(cache_path_); |
| 37 ASSERT_TRUE(files.Init(true)); | 37 ASSERT_TRUE(files.Init(true)); |
| 38 | 38 |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 } | 341 } |
| 342 | 342 |
| 343 // The allocation map should be empty. | 343 // The allocation map should be empty. |
| 344 for (int i =0; i < 50; i++) { | 344 for (int i =0; i < 50; i++) { |
| 345 SCOPED_TRACE(i); | 345 SCOPED_TRACE(i); |
| 346 EXPECT_EQ(0, buffer[i]); | 346 EXPECT_EQ(0, buffer[i]); |
| 347 } | 347 } |
| 348 } | 348 } |
| 349 | 349 |
| 350 } // namespace disk_cache | 350 } // namespace disk_cache |
| OLD | NEW |