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 "net/disk_cache/addr.h" | 5 #include "net/disk_cache/addr.h" |
6 #include "net/disk_cache/block_files.h" | 6 #include "net/disk_cache/block_files.h" |
7 #include "net/disk_cache/disk_format_base.h" | 7 #include "net/disk_cache/disk_format_base.h" |
8 #include "net/disk_cache/v3/block_bitmaps.h" | 8 #include "net/disk_cache/v3/block_bitmaps.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 // Tests that we add and remove blocks correctly. | 11 // Tests that we add and remove blocks correctly. |
12 TEST(DiskCacheBlockBitmaps, V3AllocationMap) { | 12 TEST(DiskCacheBlockBitmaps, V3AllocationMap) { |
13 disk_cache::BlockBitmaps block_bitmaps; | 13 disk_cache::BlockBitmaps block_bitmaps(NULL); |
14 disk_cache::BlockFilesBitmaps bitmaps; | 14 disk_cache::BlockFilesBitmaps bitmaps; |
15 | 15 |
16 const int kNumHeaders = 10; | 16 const int kNumHeaders = 10; |
17 disk_cache::BlockFileHeader headers[kNumHeaders]; | 17 disk_cache::BlockFileHeader headers[kNumHeaders]; |
18 for (int i = 0; i < kNumHeaders; i++) { | 18 for (int i = 0; i < kNumHeaders; i++) { |
19 memset(&headers[i], 0, sizeof(headers[i])); | 19 memset(&headers[i], 0, sizeof(headers[i])); |
20 headers[i].magic = disk_cache::kBlockMagic; | 20 headers[i].magic = disk_cache::kBlockMagic; |
21 headers[i].version = disk_cache::kBlockCurrentVersion; | 21 headers[i].version = disk_cache::kBlockCurrentVersion; |
22 headers[i].this_file = static_cast<int16>(i); | 22 headers[i].this_file = static_cast<int16>(i); |
23 headers[i].empty[3] = 200; | 23 headers[i].empty[3] = 200; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 SCOPED_TRACE(i); | 61 SCOPED_TRACE(i); |
62 block_bitmaps.DeleteBlock(address[i]); | 62 block_bitmaps.DeleteBlock(address[i]); |
63 } | 63 } |
64 | 64 |
65 // The allocation map should be empty. | 65 // The allocation map should be empty. |
66 for (int i =0; i < 50; i++) { | 66 for (int i =0; i < 50; i++) { |
67 SCOPED_TRACE(i); | 67 SCOPED_TRACE(i); |
68 EXPECT_EQ(0, buffer[i]); | 68 EXPECT_EQ(0, buffer[i]); |
69 } | 69 } |
70 } | 70 } |
OLD | NEW |