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

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

Issue 3410008: GTTF: Make net_unittests run successfully with parallel test launcher (Closed)
Patch Set: fixes Created 10 years, 3 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/mapped_file_unittest.cc ('k') | net/disk_cache/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
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/storage_block.h" 6 #include "net/disk_cache/storage_block.h"
7 #include "net/disk_cache/storage_block-inl.h" 7 #include "net/disk_cache/storage_block-inl.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"
11 11
12 TEST_F(DiskCacheTest, StorageBlock_LoadStore) { 12 TEST_F(DiskCacheTest, StorageBlock_LoadStore) {
13 FilePath filename = GetCacheFilePath().AppendASCII("a_test"); 13 ScopedTestCache test_cache;
14 FilePath filename = test_cache.path().AppendASCII("a_test");
15
14 scoped_refptr<disk_cache::MappedFile> file(new disk_cache::MappedFile); 16 scoped_refptr<disk_cache::MappedFile> file(new disk_cache::MappedFile);
15 ASSERT_TRUE(CreateCacheTestFile(filename)); 17 ASSERT_TRUE(CreateCacheTestFile(filename));
16 ASSERT_TRUE(file->Init(filename, 8192)); 18 ASSERT_TRUE(file->Init(filename, 8192));
17 19
18 disk_cache::CacheEntryBlock entry1(file, disk_cache::Addr(0xa0010001)); 20 disk_cache::CacheEntryBlock entry1(file, disk_cache::Addr(0xa0010001));
19 memset(entry1.Data(), 0, sizeof(disk_cache::EntryStore)); 21 memset(entry1.Data(), 0, sizeof(disk_cache::EntryStore));
20 entry1.Data()->hash = 0xaa5555aa; 22 entry1.Data()->hash = 0xaa5555aa;
21 entry1.Data()->rankings_node = 0xa0010002; 23 entry1.Data()->rankings_node = 0xa0010002;
22 24
23 EXPECT_TRUE(entry1.Store()); 25 EXPECT_TRUE(entry1.Store());
24 entry1.Data()->hash = 0x88118811; 26 entry1.Data()->hash = 0x88118811;
25 entry1.Data()->rankings_node = 0xa0040009; 27 entry1.Data()->rankings_node = 0xa0040009;
26 28
27 EXPECT_TRUE(entry1.Load()); 29 EXPECT_TRUE(entry1.Load());
28 EXPECT_EQ(0xaa5555aa, entry1.Data()->hash); 30 EXPECT_EQ(0xaa5555aa, entry1.Data()->hash);
29 EXPECT_EQ(0xa0010002, entry1.Data()->rankings_node); 31 EXPECT_EQ(0xa0010002, entry1.Data()->rankings_node);
30 } 32 }
31 33
32 TEST_F(DiskCacheTest, StorageBlock_SetData) { 34 TEST_F(DiskCacheTest, StorageBlock_SetData) {
33 FilePath filename = GetCacheFilePath().AppendASCII("a_test"); 35 ScopedTestCache test_cache;
36 FilePath filename = test_cache.path().AppendASCII("a_test");
37
34 scoped_refptr<disk_cache::MappedFile> file(new disk_cache::MappedFile); 38 scoped_refptr<disk_cache::MappedFile> file(new disk_cache::MappedFile);
35 ASSERT_TRUE(CreateCacheTestFile(filename)); 39 ASSERT_TRUE(CreateCacheTestFile(filename));
36 ASSERT_TRUE(file->Init(filename, 8192)); 40 ASSERT_TRUE(file->Init(filename, 8192));
37 41
38 disk_cache::CacheEntryBlock entry1(file, disk_cache::Addr(0xa0010001)); 42 disk_cache::CacheEntryBlock entry1(file, disk_cache::Addr(0xa0010001));
39 entry1.Data()->hash = 0xaa5555aa; 43 entry1.Data()->hash = 0xaa5555aa;
40 44
41 disk_cache::CacheEntryBlock entry2(file, disk_cache::Addr(0xa0010002)); 45 disk_cache::CacheEntryBlock entry2(file, disk_cache::Addr(0xa0010002));
42 EXPECT_TRUE(entry2.Load()); 46 EXPECT_TRUE(entry2.Load());
43 EXPECT_TRUE(entry2.Data() != NULL); 47 EXPECT_TRUE(entry2.Data() != NULL);
44 EXPECT_TRUE(0 == entry2.Data()->hash); 48 EXPECT_TRUE(0 == entry2.Data()->hash);
45 49
46 EXPECT_TRUE(entry2.Data() != entry1.Data()); 50 EXPECT_TRUE(entry2.Data() != entry1.Data());
47 entry2.SetData(entry1.Data()); 51 entry2.SetData(entry1.Data());
48 EXPECT_EQ(0xaa5555aa, entry2.Data()->hash); 52 EXPECT_EQ(0xaa5555aa, entry2.Data()->hash);
49 EXPECT_TRUE(entry2.Data() == entry1.Data()); 53 EXPECT_TRUE(entry2.Data() == entry1.Data());
50 } 54 }
51 55
52 TEST_F(DiskCacheTest, StorageBlock_SetModified) { 56 TEST_F(DiskCacheTest, StorageBlock_SetModified) {
53 FilePath filename = GetCacheFilePath().AppendASCII("a_test"); 57 ScopedTestCache test_cache;
58 FilePath filename = test_cache.path().AppendASCII("a_test");
59
54 scoped_refptr<disk_cache::MappedFile> file(new disk_cache::MappedFile); 60 scoped_refptr<disk_cache::MappedFile> file(new disk_cache::MappedFile);
55 ASSERT_TRUE(CreateCacheTestFile(filename)); 61 ASSERT_TRUE(CreateCacheTestFile(filename));
56 ASSERT_TRUE(file->Init(filename, 8192)); 62 ASSERT_TRUE(file->Init(filename, 8192));
57 63
58 disk_cache::CacheEntryBlock* entry1 = 64 disk_cache::CacheEntryBlock* entry1 =
59 new disk_cache::CacheEntryBlock(file, disk_cache::Addr(0xa0010003)); 65 new disk_cache::CacheEntryBlock(file, disk_cache::Addr(0xa0010003));
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 }
OLDNEW
« no previous file with comments | « net/disk_cache/mapped_file_unittest.cc ('k') | net/disk_cache/stress_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698