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

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

Issue 12224017: Create a new disk_cache type, SHADER_CACHE. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Better fix for OnExternalCacheHit Created 7 years, 10 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
« no previous file with comments | « net/disk_cache/backend_unittest.cc ('k') | net/disk_cache/histogram_macros.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 6 #include "base/bind.h"
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/threading/platform_thread.h" 9 #include "base/threading/platform_thread.h"
10 #include "base/timer.h" 10 #include "base/timer.h"
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 649
650 AddDelay(); 650 AddDelay();
651 Time t3 = Time::Now(); 651 Time t3 = Time::Now();
652 EXPECT_TRUE(t3 > t2); 652 EXPECT_TRUE(t3 > t2);
653 const int kSize = 200; 653 const int kSize = 200;
654 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kSize)); 654 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kSize));
655 EXPECT_EQ(kSize, ReadData(entry, 0, 0, buffer, kSize)); 655 EXPECT_EQ(kSize, ReadData(entry, 0, 0, buffer, kSize));
656 if (type_ == net::APP_CACHE) { 656 if (type_ == net::APP_CACHE) {
657 EXPECT_TRUE(entry->GetLastUsed() < t2); 657 EXPECT_TRUE(entry->GetLastUsed() < t2);
658 EXPECT_TRUE(entry->GetLastModified() < t2); 658 EXPECT_TRUE(entry->GetLastModified() < t2);
659 } else if (type_ == net::SHADER_CACHE) {
660 EXPECT_TRUE(entry->GetLastUsed() < t3);
661 EXPECT_TRUE(entry->GetLastModified() < t3);
659 } else { 662 } else {
660 EXPECT_TRUE(entry->GetLastUsed() >= t3); 663 EXPECT_TRUE(entry->GetLastUsed() >= t3);
661 EXPECT_TRUE(entry->GetLastModified() < t3); 664 EXPECT_TRUE(entry->GetLastModified() < t3);
662 } 665 }
663 entry->Close(); 666 entry->Close();
664 } 667 }
665 668
666 TEST_F(DiskCacheEntryTest, GetTimes) { 669 TEST_F(DiskCacheEntryTest, GetTimes) {
667 InitCache(); 670 InitCache();
668 GetTimes(); 671 GetTimes();
669 } 672 }
670 673
671 TEST_F(DiskCacheEntryTest, MemoryOnlyGetTimes) { 674 TEST_F(DiskCacheEntryTest, MemoryOnlyGetTimes) {
672 SetMemoryOnlyMode(); 675 SetMemoryOnlyMode();
673 InitCache(); 676 InitCache();
674 GetTimes(); 677 GetTimes();
675 } 678 }
676 679
677 TEST_F(DiskCacheEntryTest, AppCacheGetTimes) { 680 TEST_F(DiskCacheEntryTest, AppCacheGetTimes) {
678 SetCacheType(net::APP_CACHE); 681 SetCacheType(net::APP_CACHE);
679 InitCache(); 682 InitCache();
680 GetTimes(); 683 GetTimes();
681 } 684 }
682 685
686 TEST_F(DiskCacheEntryTest, ShaderCacheGetTimes) {
687 SetCacheType(net::SHADER_CACHE);
688 InitCache();
689 GetTimes();
690 }
691
683 void DiskCacheEntryTest::GrowData() { 692 void DiskCacheEntryTest::GrowData() {
684 std::string key1("the first key"); 693 std::string key1("the first key");
685 disk_cache::Entry* entry; 694 disk_cache::Entry* entry;
686 ASSERT_EQ(net::OK, CreateEntry(key1, &entry)); 695 ASSERT_EQ(net::OK, CreateEntry(key1, &entry));
687 696
688 const int kSize = 20000; 697 const int kSize = 20000;
689 scoped_refptr<net::IOBuffer> buffer1(new net::IOBuffer(kSize)); 698 scoped_refptr<net::IOBuffer> buffer1(new net::IOBuffer(kSize));
690 scoped_refptr<net::IOBuffer> buffer2(new net::IOBuffer(kSize)); 699 scoped_refptr<net::IOBuffer> buffer2(new net::IOBuffer(kSize));
691 CacheTestFillBuffer(buffer1->data(), kSize, false); 700 CacheTestFillBuffer(buffer1->data(), kSize, false);
692 memset(buffer2->data(), 0, kSize); 701 memset(buffer2->data(), 0, kSize);
(...skipping 1431 matching lines...) Expand 10 before | Expand all | Expand 10 after
2124 store->key_len = 800; 2133 store->key_len = 800;
2125 memset(store->key + key.size(), 'k', sizeof(store->key) - key.size()); 2134 memset(store->key + key.size(), 'k', sizeof(store->key) - key.size());
2126 entry_impl->entry()->set_modified(); 2135 entry_impl->entry()->set_modified();
2127 entry->Close(); 2136 entry->Close();
2128 2137
2129 // We have a corrupt entry. Now reload it. We should NOT read beyond the 2138 // We have a corrupt entry. Now reload it. We should NOT read beyond the
2130 // allocated buffer here. 2139 // allocated buffer here.
2131 ASSERT_NE(net::OK, OpenEntry(key, &entry)); 2140 ASSERT_NE(net::OK, OpenEntry(key, &entry));
2132 DisableIntegrityCheck(); 2141 DisableIntegrityCheck();
2133 } 2142 }
OLDNEW
« no previous file with comments | « net/disk_cache/backend_unittest.cc ('k') | net/disk_cache/histogram_macros.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698