Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(181)

Side by Side Diff: net/disk_cache/blockfile/block_files_unittest.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/blockfile/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"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 files.DeleteBlock(address, false); 110 files.DeleteBlock(address, false);
111 } 111 }
112 112
113 // At this point, there are kNumEntries / 2 entries on the file, randomly 113 // At this point, there are kNumEntries / 2 entries on the file, randomly
114 // distributed both on location and size. 114 // distributed both on location and size.
115 115
116 Addr address(entries[kNumEntries / 2]); 116 Addr address(entries[kNumEntries / 2]);
117 MappedFile* file = files.GetFile(address); 117 MappedFile* file = files.GetFile(address);
118 ASSERT_TRUE(NULL != file); 118 ASSERT_TRUE(NULL != file);
119 119
120 BlockFileHeader* header = 120 BlockFileHeader* header = reinterpret_cast<BlockFileHeader*>(file->buffer());
121 reinterpret_cast<BlockFileHeader*>(file->buffer());
122 ASSERT_TRUE(NULL != header); 121 ASSERT_TRUE(NULL != header);
123 122
124 ASSERT_EQ(0, header->updating); 123 ASSERT_EQ(0, header->updating);
125 124
126 int max_entries = header->max_entries; 125 int max_entries = header->max_entries;
127 int empty_1 = header->empty[0]; 126 int empty_1 = header->empty[0];
128 int empty_2 = header->empty[1]; 127 int empty_2 = header->empty[1];
129 int empty_3 = header->empty[2]; 128 int empty_3 = header->empty[2];
130 int empty_4 = header->empty[3]; 129 int empty_4 = header->empty[3];
131 130
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 for (int i = 0; i < kSize; i++) { 322 for (int i = 0; i < kSize; i++) {
324 SCOPED_TRACE(i); 323 SCOPED_TRACE(i);
325 EXPECT_TRUE(files.IsValid(address[i])); 324 EXPECT_TRUE(files.IsValid(address[i]));
326 } 325 }
327 326
328 // The first part of the allocation map should be completely filled. We used 327 // The first part of the allocation map should be completely filled. We used
329 // 10 bits per each four entries, so 250 bits total. 328 // 10 bits per each four entries, so 250 bits total.
330 BlockFileHeader* header = 329 BlockFileHeader* header =
331 reinterpret_cast<BlockFileHeader*>(files.GetFile(address[0])->buffer()); 330 reinterpret_cast<BlockFileHeader*>(files.GetFile(address[0])->buffer());
332 uint8* buffer = reinterpret_cast<uint8*>(&header->allocation_map); 331 uint8* buffer = reinterpret_cast<uint8*>(&header->allocation_map);
333 for (int i =0; i < 29; i++) { 332 for (int i = 0; i < 29; i++) {
334 SCOPED_TRACE(i); 333 SCOPED_TRACE(i);
335 EXPECT_EQ(0xff, buffer[i]); 334 EXPECT_EQ(0xff, buffer[i]);
336 } 335 }
337 336
338 for (int i = 0; i < kSize; i++) { 337 for (int i = 0; i < kSize; i++) {
339 SCOPED_TRACE(i); 338 SCOPED_TRACE(i);
340 files.DeleteBlock(address[i], false); 339 files.DeleteBlock(address[i], false);
341 } 340 }
342 341
343 // The allocation map should be empty. 342 // The allocation map should be empty.
344 for (int i =0; i < 50; i++) { 343 for (int i = 0; i < 50; i++) {
345 SCOPED_TRACE(i); 344 SCOPED_TRACE(i);
346 EXPECT_EQ(0, buffer[i]); 345 EXPECT_EQ(0, buffer[i]);
347 } 346 }
348 } 347 }
349 348
350 } // namespace disk_cache 349 } // namespace disk_cache
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698