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

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

Issue 159643: Disk cache: Remove remaining uses of RankingsNode.pointer.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 4 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 void BackendKeying(); 43 void BackendKeying();
44 void BackendSetSize(); 44 void BackendSetSize();
45 void BackendLoad(); 45 void BackendLoad();
46 void BackendValidEntry(); 46 void BackendValidEntry();
47 void BackendInvalidEntry(); 47 void BackendInvalidEntry();
48 void BackendInvalidEntryRead(); 48 void BackendInvalidEntryRead();
49 void BackendInvalidEntryWithLoad(); 49 void BackendInvalidEntryWithLoad();
50 void BackendTrimInvalidEntry(); 50 void BackendTrimInvalidEntry();
51 void BackendTrimInvalidEntry2(); 51 void BackendTrimInvalidEntry2();
52 void BackendEnumerations(); 52 void BackendEnumerations();
53 void BackendEnumerations2();
53 void BackendInvalidEntryEnumeration(); 54 void BackendInvalidEntryEnumeration();
54 void BackendFixEnumerators(); 55 void BackendFixEnumerators();
55 void BackendDoomRecent(); 56 void BackendDoomRecent();
56 void BackendDoomBetween(); 57 void BackendDoomBetween();
57 void BackendTransaction(const std::wstring& name, int num_entries, bool load); 58 void BackendTransaction(const std::wstring& name, int num_entries, bool load);
58 void BackendRecoverInsert(); 59 void BackendRecoverInsert();
59 void BackendRecoverRemove(); 60 void BackendRecoverRemove();
60 void BackendInvalidEntry2(); 61 void BackendInvalidEntry2();
61 void BackendNotMarkedButDirty(const std::wstring& name); 62 void BackendNotMarkedButDirty(const std::wstring& name);
62 void BackendDoomAll(); 63 void BackendDoomAll();
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 TEST_F(DiskCacheBackendTest, NewEvictionEnumerations) { 650 TEST_F(DiskCacheBackendTest, NewEvictionEnumerations) {
650 SetNewEviction(); 651 SetNewEviction();
651 BackendEnumerations(); 652 BackendEnumerations();
652 } 653 }
653 654
654 TEST_F(DiskCacheBackendTest, MemoryOnlyEnumerations) { 655 TEST_F(DiskCacheBackendTest, MemoryOnlyEnumerations) {
655 SetMemoryOnlyMode(); 656 SetMemoryOnlyMode();
656 BackendEnumerations(); 657 BackendEnumerations();
657 } 658 }
658 659
660 // Verifies enumerations while entries are open.
661 void DiskCacheBackendTest::BackendEnumerations2() {
662 InitCache();
663 const std::string first("first");
664 const std::string second("second");
665 disk_cache::Entry *entry1, *entry2;
666 ASSERT_TRUE(cache_->CreateEntry(first, &entry1));
667 entry1->Close();
668 ASSERT_TRUE(cache_->CreateEntry(second, &entry2));
669 entry2->Close();
670
671 // Make sure that the timestamp is not the same.
672 PlatformThread::Sleep(20);
673 ASSERT_TRUE(cache_->OpenEntry(second, &entry1));
674 void* iter = NULL;
675 ASSERT_TRUE(cache_->OpenNextEntry(&iter, &entry2));
676 ASSERT_EQ(entry2->GetKey(), second);
677
678 // Two entries and the iterator pointing at "first".
679 entry1->Close();
680 entry2->Close();
681
682 // The iterator should still be valid, se we should not crash.
683 ASSERT_TRUE(cache_->OpenNextEntry(&iter, &entry2));
684 ASSERT_EQ(entry2->GetKey(), first);
685 entry2->Close();
686 cache_->EndEnumeration(&iter);
687 }
688
689 TEST_F(DiskCacheBackendTest, Enumerations2) {
690 BackendEnumerations2();
691 }
692
693 TEST_F(DiskCacheBackendTest, NewEvictionEnumerations2) {
694 SetNewEviction();
695 BackendEnumerations2();
696 }
697
698 TEST_F(DiskCacheBackendTest, MemoryOnlyEnumerations2) {
699 SetMemoryOnlyMode();
700 BackendEnumerations2();
701 }
702
703
659 // Verify handling of invalid entries while doing enumerations. 704 // Verify handling of invalid entries while doing enumerations.
660 // We'll be leaking memory from this test. 705 // We'll be leaking memory from this test.
661 void DiskCacheBackendTest::BackendInvalidEntryEnumeration() { 706 void DiskCacheBackendTest::BackendInvalidEntryEnumeration() {
662 // Use the implementation directly... we need to simulate a crash. 707 // Use the implementation directly... we need to simulate a crash.
663 SetDirectMode(); 708 SetDirectMode();
664 InitCache(); 709 InitCache();
665 710
666 std::string key("Some key"); 711 std::string key("Some key");
667 disk_cache::Entry *entry, *entry1, *entry2; 712 disk_cache::Entry *entry, *entry1, *entry2;
668 ASSERT_TRUE(cache_->CreateEntry(key, &entry1)); 713 ASSERT_TRUE(cache_->CreateEntry(key, &entry1));
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
1426 EXPECT_EQ(kDefaultSize * 5 / 2, 1471 EXPECT_EQ(kDefaultSize * 5 / 2,
1427 disk_cache::PreferedCacheSize(large_size * 100 / 2)); 1472 disk_cache::PreferedCacheSize(large_size * 100 / 2));
1428 EXPECT_EQ(kDefaultSize * 5 / 2, 1473 EXPECT_EQ(kDefaultSize * 5 / 2,
1429 disk_cache::PreferedCacheSize(large_size * 500 / 2)); 1474 disk_cache::PreferedCacheSize(large_size * 500 / 2));
1430 1475
1431 EXPECT_EQ(kDefaultSize * 6 / 2, 1476 EXPECT_EQ(kDefaultSize * 6 / 2,
1432 disk_cache::PreferedCacheSize(large_size * 600 / 2)); 1477 disk_cache::PreferedCacheSize(large_size * 600 / 2));
1433 EXPECT_EQ(kDefaultSize * 7 / 2, 1478 EXPECT_EQ(kDefaultSize * 7 / 2,
1434 disk_cache::PreferedCacheSize(large_size * 700 / 2)); 1479 disk_cache::PreferedCacheSize(large_size * 700 / 2));
1435 } 1480 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698