| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/disk_format.h" |
| 6 #include "net/disk_cache/storage_block.h" | 7 #include "net/disk_cache/storage_block.h" |
| 7 #include "net/disk_cache/storage_block-inl.h" | 8 #include "net/disk_cache/storage_block-inl.h" |
| 8 #include "net/disk_cache/disk_cache_test_base.h" | 9 #include "net/disk_cache/disk_cache_test_base.h" |
| 9 #include "net/disk_cache/disk_cache_test_util.h" | 10 #include "net/disk_cache/disk_cache_test_util.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 12 |
| 13 namespace disk_cache { |
| 14 struct EntryStore; |
| 15 typedef StorageBlock<EntryStore> CacheEntryBlock; |
| 16 } |
| 17 |
| 12 TEST_F(DiskCacheTest, StorageBlock_LoadStore) { | 18 TEST_F(DiskCacheTest, StorageBlock_LoadStore) { |
| 13 base::FilePath filename = cache_path_.AppendASCII("a_test"); | 19 base::FilePath filename = cache_path_.AppendASCII("a_test"); |
| 14 scoped_refptr<disk_cache::MappedFile> file(new disk_cache::MappedFile); | 20 scoped_refptr<disk_cache::MappedFile> file(new disk_cache::MappedFile); |
| 15 ASSERT_TRUE(CreateCacheTestFile(filename)); | 21 ASSERT_TRUE(CreateCacheTestFile(filename)); |
| 16 ASSERT_TRUE(file->Init(filename, 8192)); | 22 ASSERT_TRUE(file->Init(filename, 8192)); |
| 17 | 23 |
| 18 disk_cache::CacheEntryBlock entry1(file, disk_cache::Addr(0xa0010001)); | 24 disk_cache::CacheEntryBlock entry1(file, disk_cache::Addr(0xa0010001)); |
| 19 memset(entry1.Data(), 0, sizeof(disk_cache::EntryStore)); | 25 memset(entry1.Data(), 0, sizeof(disk_cache::EntryStore)); |
| 20 entry1.Data()->hash = 0xaa5555aa; | 26 entry1.Data()->hash = 0xaa5555aa; |
| 21 entry1.Data()->rankings_node = 0xa0010002; | 27 entry1.Data()->rankings_node = 0xa0010002; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 EXPECT_TRUE(entry1->Load()); | 66 EXPECT_TRUE(entry1->Load()); |
| 61 EXPECT_TRUE(0 == entry1->Data()->hash); | 67 EXPECT_TRUE(0 == entry1->Data()->hash); |
| 62 entry1->Data()->hash = 0x45687912; | 68 entry1->Data()->hash = 0x45687912; |
| 63 entry1->set_modified(); | 69 entry1->set_modified(); |
| 64 delete entry1; | 70 delete entry1; |
| 65 | 71 |
| 66 disk_cache::CacheEntryBlock entry2(file, disk_cache::Addr(0xa0010003)); | 72 disk_cache::CacheEntryBlock entry2(file, disk_cache::Addr(0xa0010003)); |
| 67 EXPECT_TRUE(entry2.Load()); | 73 EXPECT_TRUE(entry2.Load()); |
| 68 EXPECT_TRUE(0x45687912 == entry2.Data()->hash); | 74 EXPECT_TRUE(0x45687912 == entry2.Data()->hash); |
| 69 } | 75 } |
| OLD | NEW |