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

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

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « net/disk_cache/blockfile/storage_block-inl.h ('k') | net/disk_cache/blockfile/stress_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/files/file_path.h"
6 #include "net/disk_cache/blockfile/disk_format.h"
7 #include "net/disk_cache/blockfile/storage_block-inl.h"
8 #include "net/disk_cache/blockfile/storage_block.h"
9 #include "net/disk_cache/disk_cache_test_base.h"
10 #include "net/disk_cache/disk_cache_test_util.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12
13 typedef disk_cache::StorageBlock<disk_cache::EntryStore> CacheEntryBlock;
14
15 TEST_F(DiskCacheTest, StorageBlock_LoadStore) {
16 base::FilePath filename = cache_path_.AppendASCII("a_test");
17 scoped_refptr<disk_cache::MappedFile> file(new disk_cache::MappedFile);
18 ASSERT_TRUE(CreateCacheTestFile(filename));
19 ASSERT_TRUE(file->Init(filename, 8192));
20
21 CacheEntryBlock entry1(file.get(), disk_cache::Addr(0xa0010001));
22 memset(entry1.Data(), 0, sizeof(disk_cache::EntryStore));
23 entry1.Data()->hash = 0xaa5555aa;
24 entry1.Data()->rankings_node = 0xa0010002;
25
26 EXPECT_TRUE(entry1.Store());
27 entry1.Data()->hash = 0x88118811;
28 entry1.Data()->rankings_node = 0xa0040009;
29
30 EXPECT_TRUE(entry1.Load());
31 EXPECT_EQ(0xaa5555aa, entry1.Data()->hash);
32 EXPECT_EQ(0xa0010002, entry1.Data()->rankings_node);
33 }
34
35 TEST_F(DiskCacheTest, StorageBlock_SetData) {
36 base::FilePath filename = cache_path_.AppendASCII("a_test");
37 scoped_refptr<disk_cache::MappedFile> file(new disk_cache::MappedFile);
38 ASSERT_TRUE(CreateCacheTestFile(filename));
39 ASSERT_TRUE(file->Init(filename, 8192));
40
41 CacheEntryBlock entry1(file.get(), disk_cache::Addr(0xa0010001));
42 entry1.Data()->hash = 0xaa5555aa;
43
44 CacheEntryBlock entry2(file.get(), disk_cache::Addr(0xa0010002));
45 EXPECT_TRUE(entry2.Load());
46 EXPECT_TRUE(entry2.Data() != NULL);
47 EXPECT_TRUE(0 == entry2.Data()->hash);
48
49 EXPECT_TRUE(entry2.Data() != entry1.Data());
50 entry2.SetData(entry1.Data());
51 EXPECT_EQ(0xaa5555aa, entry2.Data()->hash);
52 EXPECT_TRUE(entry2.Data() == entry1.Data());
53 }
54
55 TEST_F(DiskCacheTest, StorageBlock_SetModified) {
56 base::FilePath filename = cache_path_.AppendASCII("a_test");
57 scoped_refptr<disk_cache::MappedFile> file(new disk_cache::MappedFile);
58 ASSERT_TRUE(CreateCacheTestFile(filename));
59 ASSERT_TRUE(file->Init(filename, 8192));
60
61 CacheEntryBlock* entry1 =
62 new CacheEntryBlock(file.get(), disk_cache::Addr(0xa0010003));
63 EXPECT_TRUE(entry1->Load());
64 EXPECT_TRUE(0 == entry1->Data()->hash);
65 entry1->Data()->hash = 0x45687912;
66 entry1->set_modified();
67 delete entry1;
68
69 CacheEntryBlock entry2(file.get(), disk_cache::Addr(0xa0010003));
70 EXPECT_TRUE(entry2.Load());
71 EXPECT_TRUE(0x45687912 == entry2.Data()->hash);
72 }
OLDNEW
« no previous file with comments | « net/disk_cache/blockfile/storage_block-inl.h ('k') | net/disk_cache/blockfile/stress_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698