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

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

Issue 149218: Disk cache: Keep a map of all open entries.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 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) 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/platform_thread.h" 8 #include "base/platform_thread.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "net/base/io_buffer.h" 10 #include "net/base/io_buffer.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 void BackendTrimInvalidEntry(); 50 void BackendTrimInvalidEntry();
51 void BackendEnumerations(); 51 void BackendEnumerations();
52 void BackendInvalidEntryEnumeration(); 52 void BackendInvalidEntryEnumeration();
53 void BackendFixEnumerators(); 53 void BackendFixEnumerators();
54 void BackendDoomRecent(); 54 void BackendDoomRecent();
55 void BackendDoomBetween(); 55 void BackendDoomBetween();
56 void BackendTransaction(const std::wstring& name, int num_entries, bool load); 56 void BackendTransaction(const std::wstring& name, int num_entries, bool load);
57 void BackendRecoverInsert(); 57 void BackendRecoverInsert();
58 void BackendRecoverRemove(); 58 void BackendRecoverRemove();
59 void BackendInvalidEntry2(); 59 void BackendInvalidEntry2();
60 void BackendNotMarkedButDirty(); 60 void BackendNotMarkedButDirty(const std::wstring& name);
61 void BackendDoomAll(); 61 void BackendDoomAll();
62 void BackendDoomAll2(); 62 void BackendDoomAll2();
63 void BackendInvalidRankings(); 63 void BackendInvalidRankings();
64 void BackendInvalidRankings2(); 64 void BackendInvalidRankings2();
65 void BackendDisable(); 65 void BackendDisable();
66 void BackendDisable2(); 66 void BackendDisable2();
67 void BackendDisable3(); 67 void BackendDisable3();
68 }; 68 };
69 69
70 void DiskCacheBackendTest::BackendBasics() { 70 void DiskCacheBackendTest::BackendBasics() {
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 TEST_F(DiskCacheBackendTest, InvalidEntry2) { 967 TEST_F(DiskCacheBackendTest, InvalidEntry2) {
968 BackendInvalidEntry2(); 968 BackendInvalidEntry2();
969 } 969 }
970 970
971 TEST_F(DiskCacheBackendTest, NewEvictionInvalidEntry2) { 971 TEST_F(DiskCacheBackendTest, NewEvictionInvalidEntry2) {
972 SetNewEviction(); 972 SetNewEviction();
973 BackendInvalidEntry2(); 973 BackendInvalidEntry2();
974 } 974 }
975 975
976 // We want to be able to deal with abnormal dirty entries. 976 // We want to be able to deal with abnormal dirty entries.
977 void DiskCacheBackendTest::BackendNotMarkedButDirty() { 977 void DiskCacheBackendTest::BackendNotMarkedButDirty(const std::wstring& name) {
978 ASSERT_TRUE(CopyTestCache(L"dirty_entry")); 978 ASSERT_TRUE(CopyTestCache(name));
979 DisableFirstCleanup(); 979 DisableFirstCleanup();
980 InitCache(); 980 InitCache();
981 981
982 disk_cache::Entry *entry1, *entry2; 982 disk_cache::Entry *entry1, *entry2;
983 ASSERT_TRUE(cache_->OpenEntry("the first key", &entry1)); 983 ASSERT_TRUE(cache_->OpenEntry("the first key", &entry1));
984 EXPECT_FALSE(cache_->OpenEntry("some other key", &entry2)); 984 EXPECT_FALSE(cache_->OpenEntry("some other key", &entry2));
985 entry1->Close(); 985 entry1->Close();
986 } 986 }
987 987
988 TEST_F(DiskCacheBackendTest, NotMarkedButDirty) { 988 TEST_F(DiskCacheBackendTest, NotMarkedButDirty) {
989 BackendNotMarkedButDirty(); 989 BackendNotMarkedButDirty(L"dirty_entry");
990 } 990 }
991 991
992 TEST_F(DiskCacheBackendTest, NewEvictionNotMarkedButDirty) { 992 TEST_F(DiskCacheBackendTest, NewEvictionNotMarkedButDirty) {
993 SetNewEviction(); 993 SetNewEviction();
994 BackendNotMarkedButDirty(); 994 BackendNotMarkedButDirty(L"dirty_entry");
995 }
996
997 TEST_F(DiskCacheBackendTest, NotMarkedButDirty2) {
998 BackendNotMarkedButDirty(L"dirty_entry2");
999 }
1000
1001 TEST_F(DiskCacheBackendTest, NewEvictionNotMarkedButDirty2) {
1002 SetNewEviction();
1003 BackendNotMarkedButDirty(L"dirty_entry2");
995 } 1004 }
996 1005
997 // We want to be able to deal with messed up entries on disk. 1006 // We want to be able to deal with messed up entries on disk.
998 void DiskCacheBackendTest::BackendInvalidRankings2() { 1007 void DiskCacheBackendTest::BackendInvalidRankings2() {
999 ASSERT_TRUE(CopyTestCache(L"bad_rankings")); 1008 ASSERT_TRUE(CopyTestCache(L"bad_rankings"));
1000 std::wstring path = GetCachePath(); 1009 std::wstring path = GetCachePath();
1001 DisableFirstCleanup(); 1010 DisableFirstCleanup();
1002 InitCache(); 1011 InitCache();
1003 1012
1004 disk_cache::Entry *entry1, *entry2; 1013 disk_cache::Entry *entry1, *entry2;
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
1350 EXPECT_EQ(kDefaultSize * 5 / 2, 1359 EXPECT_EQ(kDefaultSize * 5 / 2,
1351 disk_cache::PreferedCacheSize(large_size * 100 / 2)); 1360 disk_cache::PreferedCacheSize(large_size * 100 / 2));
1352 EXPECT_EQ(kDefaultSize * 5 / 2, 1361 EXPECT_EQ(kDefaultSize * 5 / 2,
1353 disk_cache::PreferedCacheSize(large_size * 500 / 2)); 1362 disk_cache::PreferedCacheSize(large_size * 500 / 2));
1354 1363
1355 EXPECT_EQ(kDefaultSize * 6 / 2, 1364 EXPECT_EQ(kDefaultSize * 6 / 2,
1356 disk_cache::PreferedCacheSize(large_size * 600 / 2)); 1365 disk_cache::PreferedCacheSize(large_size * 600 / 2));
1357 EXPECT_EQ(kDefaultSize * 7 / 2, 1366 EXPECT_EQ(kDefaultSize * 7 / 2,
1358 disk_cache::PreferedCacheSize(large_size * 700 / 2)); 1367 disk_cache::PreferedCacheSize(large_size * 700 / 2));
1359 } 1368 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698