| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "net/disk_cache/block_files.h" | 6 #include "net/disk_cache/block_files.h" |
| 7 #include "net/disk_cache/disk_cache.h" | 7 #include "net/disk_cache/disk_cache.h" |
| 8 #include "net/disk_cache/disk_cache_test_base.h" | 8 #include "net/disk_cache/disk_cache_test_base.h" |
| 9 #include "net/disk_cache/disk_cache_test_util.h" | 9 #include "net/disk_cache/disk_cache_test_util.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 memset(header, 'a', kBlockHeaderSize); | 196 memset(header, 'a', kBlockHeaderSize); |
| 197 EXPECT_EQ(kBlockHeaderSize, | 197 EXPECT_EQ(kBlockHeaderSize, |
| 198 file_util::WriteFile(filename, header, kBlockHeaderSize)); | 198 file_util::WriteFile(filename, header, kBlockHeaderSize)); |
| 199 | 199 |
| 200 EXPECT_TRUE(NULL == files.GetFile(addr)); | 200 EXPECT_TRUE(NULL == files.GetFile(addr)); |
| 201 | 201 |
| 202 // The file should not have been cached (it is still invalid). | 202 // The file should not have been cached (it is still invalid). |
| 203 EXPECT_TRUE(NULL == files.GetFile(addr)); | 203 EXPECT_TRUE(NULL == files.GetFile(addr)); |
| 204 } | 204 } |
| 205 | 205 |
| 206 // Tests that we generate the correct file stats. |
| 207 TEST_F(DiskCacheTest, BlockFiles_Stats) { |
| 208 ASSERT_TRUE(CopyTestCache("remove_load1")); |
| 209 FilePath path = GetCacheFilePath(); |
| 210 |
| 211 BlockFiles files(path); |
| 212 ASSERT_TRUE(files.Init(false)); |
| 213 int used, load; |
| 214 |
| 215 files.GetFileStats(0, &used, &load); |
| 216 EXPECT_EQ(101, used); |
| 217 EXPECT_EQ(9, load); |
| 218 |
| 219 files.GetFileStats(1, &used, &load); |
| 220 EXPECT_EQ(203, used); |
| 221 EXPECT_EQ(19, load); |
| 222 |
| 223 files.GetFileStats(2, &used, &load); |
| 224 EXPECT_EQ(0, used); |
| 225 EXPECT_EQ(0, load); |
| 226 } |
| 227 |
| 206 } // namespace disk_cache | 228 } // namespace disk_cache |
| OLD | NEW |