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

Side by Side Diff: net/http/http_cache_unittest.cc

Issue 2668563002: Change MockHttpCache constructor to take boolean to set quic server info factory (Closed)
Patch Set: sync with master Created 3 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
« no previous file with comments | « net/http/disk_cache_based_quic_server_info_unittest.cc ('k') | net/http/mock_http_cache.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 "net/http/http_cache.h" 5 #include "net/http/http_cache.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 640
641 TEST(HttpCache, CreateThenDestroy) { 641 TEST(HttpCache, CreateThenDestroy) {
642 MockHttpCache cache; 642 MockHttpCache cache;
643 643
644 std::unique_ptr<HttpTransaction> trans; 644 std::unique_ptr<HttpTransaction> trans;
645 EXPECT_THAT(cache.CreateTransaction(&trans), IsOk()); 645 EXPECT_THAT(cache.CreateTransaction(&trans), IsOk());
646 ASSERT_TRUE(trans.get()); 646 ASSERT_TRUE(trans.get());
647 } 647 }
648 648
649 TEST(HttpCache, GetBackend) { 649 TEST(HttpCache, GetBackend) {
650 MockHttpCache cache(HttpCache::DefaultBackend::InMemory(0)); 650 MockHttpCache cache(HttpCache::DefaultBackend::InMemory(0), false);
Ryan Hamilton 2017/02/02 01:07:09 I think you can revert these changes now, right?
Zhongyi Shi 2017/02/02 01:32:13 Added one more constructor in the MockHttpCache so
651 651
652 disk_cache::Backend* backend; 652 disk_cache::Backend* backend;
653 TestCompletionCallback cb; 653 TestCompletionCallback cb;
654 // This will lazily initialize the backend. 654 // This will lazily initialize the backend.
655 int rv = cache.http_cache()->GetBackend(&backend, cb.callback()); 655 int rv = cache.http_cache()->GetBackend(&backend, cb.callback());
656 EXPECT_THAT(cb.GetResult(rv), IsOk()); 656 EXPECT_THAT(cb.GetResult(rv), IsOk());
657 } 657 }
658 658
659 TEST(HttpCache, SimpleGET) { 659 TEST(HttpCache, SimpleGET) {
660 MockHttpCache cache; 660 MockHttpCache cache;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 EXPECT_EQ(0, cache.disk_cache()->create_count()); 708 EXPECT_EQ(0, cache.disk_cache()->create_count());
709 TestLoadTimingNetworkRequest(load_timing_info); 709 TestLoadTimingNetworkRequest(load_timing_info);
710 } 710 }
711 711
712 TEST(HttpCache, SimpleGETNoDiskCache2) { 712 TEST(HttpCache, SimpleGETNoDiskCache2) {
713 // This will initialize a cache object with NULL backend. 713 // This will initialize a cache object with NULL backend.
714 std::unique_ptr<MockBlockingBackendFactory> factory( 714 std::unique_ptr<MockBlockingBackendFactory> factory(
715 new MockBlockingBackendFactory()); 715 new MockBlockingBackendFactory());
716 factory->set_fail(true); 716 factory->set_fail(true);
717 factory->FinishCreation(); // We'll complete synchronously. 717 factory->FinishCreation(); // We'll complete synchronously.
718 MockHttpCache cache(std::move(factory)); 718 MockHttpCache cache(std::move(factory), false);
719 719
720 // Read from the network, and don't use the cache. 720 // Read from the network, and don't use the cache.
721 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction); 721 RunTransactionTest(cache.http_cache(), kSimpleGET_Transaction);
722 722
723 EXPECT_EQ(1, cache.network_layer()->transaction_count()); 723 EXPECT_EQ(1, cache.network_layer()->transaction_count());
724 EXPECT_FALSE(cache.http_cache()->GetCurrentBackend()); 724 EXPECT_FALSE(cache.http_cache()->GetCurrentBackend());
725 } 725 }
726 726
727 // Tests that IOBuffers are not referenced after IO completes. 727 // Tests that IOBuffers are not referenced after IO completes.
728 TEST(HttpCache, ReleaseBuffer) { 728 TEST(HttpCache, ReleaseBuffer) {
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 Context* c = context_list[i]; 1457 Context* c = context_list[i];
1458 delete c; 1458 delete c;
1459 } 1459 }
1460 } 1460 }
1461 1461
1462 // Tests that we can doom an entry with pending transactions and delete one of 1462 // Tests that we can doom an entry with pending transactions and delete one of
1463 // the pending transactions before the first one completes. 1463 // the pending transactions before the first one completes.
1464 // See http://code.google.com/p/chromium/issues/detail?id=25588 1464 // See http://code.google.com/p/chromium/issues/detail?id=25588
1465 TEST(HttpCache, SimpleGET_DoomWithPending) { 1465 TEST(HttpCache, SimpleGET_DoomWithPending) {
1466 // We need simultaneous doomed / not_doomed entries so let's use a real cache. 1466 // We need simultaneous doomed / not_doomed entries so let's use a real cache.
1467 MockHttpCache cache(HttpCache::DefaultBackend::InMemory(1024 * 1024)); 1467 MockHttpCache cache(HttpCache::DefaultBackend::InMemory(1024 * 1024), false);
1468 1468
1469 MockHttpRequest request(kSimpleGET_Transaction); 1469 MockHttpRequest request(kSimpleGET_Transaction);
1470 MockHttpRequest writer_request(kSimpleGET_Transaction); 1470 MockHttpRequest writer_request(kSimpleGET_Transaction);
1471 writer_request.load_flags = LOAD_BYPASS_CACHE; 1471 writer_request.load_flags = LOAD_BYPASS_CACHE;
1472 1472
1473 std::vector<std::unique_ptr<Context>> context_list; 1473 std::vector<std::unique_ptr<Context>> context_list;
1474 const int kNumTransactions = 4; 1474 const int kNumTransactions = 4;
1475 1475
1476 for (int i = 0; i < kNumTransactions; ++i) { 1476 for (int i = 0; i < kNumTransactions; ++i) {
1477 context_list.push_back(base::WrapUnique(new Context())); 1477 context_list.push_back(base::WrapUnique(new Context()));
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
1795 1795
1796 // Make sure we pump any pending events, which should include a call to 1796 // Make sure we pump any pending events, which should include a call to
1797 // HttpCache::Transaction::OnCacheReadCompleted. 1797 // HttpCache::Transaction::OnCacheReadCompleted.
1798 base::RunLoop().RunUntilIdle(); 1798 base::RunLoop().RunUntilIdle();
1799 } 1799 }
1800 1800
1801 // Tests that we can delete the HttpCache and deal with queued transactions 1801 // Tests that we can delete the HttpCache and deal with queued transactions
1802 // ("waiting for the backend" as opposed to Active or Doomed entries). 1802 // ("waiting for the backend" as opposed to Active or Doomed entries).
1803 TEST(HttpCache, SimpleGET_ManyWriters_DeleteCache) { 1803 TEST(HttpCache, SimpleGET_ManyWriters_DeleteCache) {
1804 std::unique_ptr<MockHttpCache> cache( 1804 std::unique_ptr<MockHttpCache> cache(
1805 new MockHttpCache(base::WrapUnique(new MockBackendNoCbFactory()))); 1805 new MockHttpCache(base::WrapUnique(new MockBackendNoCbFactory()), false));
1806 1806
1807 MockHttpRequest request(kSimpleGET_Transaction); 1807 MockHttpRequest request(kSimpleGET_Transaction);
1808 1808
1809 std::vector<Context*> context_list; 1809 std::vector<Context*> context_list;
1810 const int kNumTransactions = 5; 1810 const int kNumTransactions = 5;
1811 1811
1812 for (int i = 0; i < kNumTransactions; i++) { 1812 for (int i = 0; i < kNumTransactions; i++) {
1813 context_list.push_back(new Context()); 1813 context_list.push_back(new Context());
1814 Context* c = context_list[i]; 1814 Context* c = context_list[i];
1815 1815
(...skipping 16 matching lines...) Expand all
1832 // There is not much to do with the transactions at this point... they are 1832 // There is not much to do with the transactions at this point... they are
1833 // waiting for a callback that will not fire. 1833 // waiting for a callback that will not fire.
1834 for (int i = 0; i < kNumTransactions; ++i) { 1834 for (int i = 0; i < kNumTransactions; ++i) {
1835 delete context_list[i]; 1835 delete context_list[i];
1836 } 1836 }
1837 } 1837 }
1838 1838
1839 // Tests that we queue requests when initializing the backend. 1839 // Tests that we queue requests when initializing the backend.
1840 TEST(HttpCache, SimpleGET_WaitForBackend) { 1840 TEST(HttpCache, SimpleGET_WaitForBackend) {
1841 MockBlockingBackendFactory* factory = new MockBlockingBackendFactory(); 1841 MockBlockingBackendFactory* factory = new MockBlockingBackendFactory();
1842 MockHttpCache cache(base::WrapUnique(factory)); 1842 MockHttpCache cache(base::WrapUnique(factory), false);
1843 1843
1844 MockHttpRequest request0(kSimpleGET_Transaction); 1844 MockHttpRequest request0(kSimpleGET_Transaction);
1845 MockHttpRequest request1(kTypicalGET_Transaction); 1845 MockHttpRequest request1(kTypicalGET_Transaction);
1846 MockHttpRequest request2(kETagGET_Transaction); 1846 MockHttpRequest request2(kETagGET_Transaction);
1847 1847
1848 std::vector<Context*> context_list; 1848 std::vector<Context*> context_list;
1849 const int kNumTransactions = 3; 1849 const int kNumTransactions = 3;
1850 1850
1851 for (int i = 0; i < kNumTransactions; i++) { 1851 for (int i = 0; i < kNumTransactions; i++) {
1852 context_list.push_back(new Context()); 1852 context_list.push_back(new Context());
(...skipping 25 matching lines...) Expand all
1878 for (int i = 0; i < kNumTransactions; ++i) { 1878 for (int i = 0; i < kNumTransactions; ++i) {
1879 EXPECT_TRUE(context_list[i]->callback.have_result()); 1879 EXPECT_TRUE(context_list[i]->callback.have_result());
1880 delete context_list[i]; 1880 delete context_list[i];
1881 } 1881 }
1882 } 1882 }
1883 1883
1884 // Tests that we can cancel requests that are queued waiting for the backend 1884 // Tests that we can cancel requests that are queued waiting for the backend
1885 // to be initialized. 1885 // to be initialized.
1886 TEST(HttpCache, SimpleGET_WaitForBackend_CancelCreate) { 1886 TEST(HttpCache, SimpleGET_WaitForBackend_CancelCreate) {
1887 MockBlockingBackendFactory* factory = new MockBlockingBackendFactory(); 1887 MockBlockingBackendFactory* factory = new MockBlockingBackendFactory();
1888 MockHttpCache cache(base::WrapUnique(factory)); 1888 MockHttpCache cache(base::WrapUnique(factory), false);
1889 1889
1890 MockHttpRequest request0(kSimpleGET_Transaction); 1890 MockHttpRequest request0(kSimpleGET_Transaction);
1891 MockHttpRequest request1(kTypicalGET_Transaction); 1891 MockHttpRequest request1(kTypicalGET_Transaction);
1892 MockHttpRequest request2(kETagGET_Transaction); 1892 MockHttpRequest request2(kETagGET_Transaction);
1893 1893
1894 std::vector<Context*> context_list; 1894 std::vector<Context*> context_list;
1895 const int kNumTransactions = 3; 1895 const int kNumTransactions = 3;
1896 1896
1897 for (int i = 0; i < kNumTransactions; i++) { 1897 for (int i = 0; i < kNumTransactions; i++) {
1898 context_list.push_back(new Context()); 1898 context_list.push_back(new Context());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 EXPECT_EQ(1, cache.network_layer()->transaction_count()); 1933 EXPECT_EQ(1, cache.network_layer()->transaction_count());
1934 EXPECT_EQ(1, cache.disk_cache()->create_count()); 1934 EXPECT_EQ(1, cache.disk_cache()->create_count());
1935 1935
1936 delete context_list[2]; 1936 delete context_list[2];
1937 } 1937 }
1938 1938
1939 // Tests that we can delete the cache while creating the backend. 1939 // Tests that we can delete the cache while creating the backend.
1940 TEST(HttpCache, DeleteCacheWaitingForBackend) { 1940 TEST(HttpCache, DeleteCacheWaitingForBackend) {
1941 MockBlockingBackendFactory* factory = new MockBlockingBackendFactory(); 1941 MockBlockingBackendFactory* factory = new MockBlockingBackendFactory();
1942 std::unique_ptr<MockHttpCache> cache( 1942 std::unique_ptr<MockHttpCache> cache(
1943 new MockHttpCache(base::WrapUnique(factory))); 1943 new MockHttpCache(base::WrapUnique(factory), false));
1944 1944
1945 MockHttpRequest request(kSimpleGET_Transaction); 1945 MockHttpRequest request(kSimpleGET_Transaction);
1946 1946
1947 std::unique_ptr<Context> c(new Context()); 1947 std::unique_ptr<Context> c(new Context());
1948 c->result = cache->CreateTransaction(&c->trans); 1948 c->result = cache->CreateTransaction(&c->trans);
1949 ASSERT_THAT(c->result, IsOk()); 1949 ASSERT_THAT(c->result, IsOk());
1950 1950
1951 c->trans->Start(&request, c->callback.callback(), NetLogWithSource()); 1951 c->trans->Start(&request, c->callback.callback(), NetLogWithSource());
1952 1952
1953 // Just to make sure that everything is still pending. 1953 // Just to make sure that everything is still pending.
(...skipping 11 matching lines...) Expand all
1965 base::RunLoop().RunUntilIdle(); 1965 base::RunLoop().RunUntilIdle();
1966 1966
1967 backend->reset(); 1967 backend->reset();
1968 callback.Run(ERR_ABORTED); 1968 callback.Run(ERR_ABORTED);
1969 } 1969 }
1970 1970
1971 // Tests that we can delete the cache while creating the backend, from within 1971 // Tests that we can delete the cache while creating the backend, from within
1972 // one of the callbacks. 1972 // one of the callbacks.
1973 TEST(HttpCache, DeleteCacheWaitingForBackend2) { 1973 TEST(HttpCache, DeleteCacheWaitingForBackend2) {
1974 MockBlockingBackendFactory* factory = new MockBlockingBackendFactory(); 1974 MockBlockingBackendFactory* factory = new MockBlockingBackendFactory();
1975 MockHttpCache* cache = new MockHttpCache(base::WrapUnique(factory)); 1975 MockHttpCache* cache = new MockHttpCache(base::WrapUnique(factory), false);
1976 1976
1977 DeleteCacheCompletionCallback cb(cache); 1977 DeleteCacheCompletionCallback cb(cache);
1978 disk_cache::Backend* backend; 1978 disk_cache::Backend* backend;
1979 int rv = cache->http_cache()->GetBackend(&backend, cb.callback()); 1979 int rv = cache->http_cache()->GetBackend(&backend, cb.callback());
1980 EXPECT_THAT(rv, IsError(ERR_IO_PENDING)); 1980 EXPECT_THAT(rv, IsError(ERR_IO_PENDING));
1981 1981
1982 // Now let's queue a regular transaction 1982 // Now let's queue a regular transaction
1983 MockHttpRequest request(kSimpleGET_Transaction); 1983 MockHttpRequest request(kSimpleGET_Transaction);
1984 1984
1985 std::unique_ptr<Context> c(new Context()); 1985 std::unique_ptr<Context> c(new Context());
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
3141 RemoveMockTransaction(&transaction); 3141 RemoveMockTransaction(&transaction);
3142 } 3142 }
3143 3143
3144 // Tests that processing a POST before creating the backend doesn't crash. 3144 // Tests that processing a POST before creating the backend doesn't crash.
3145 TEST(HttpCache, SimplePOST_NoUploadId_NoBackend) { 3145 TEST(HttpCache, SimplePOST_NoUploadId_NoBackend) {
3146 // This will initialize a cache object with NULL backend. 3146 // This will initialize a cache object with NULL backend.
3147 std::unique_ptr<MockBlockingBackendFactory> factory( 3147 std::unique_ptr<MockBlockingBackendFactory> factory(
3148 new MockBlockingBackendFactory()); 3148 new MockBlockingBackendFactory());
3149 factory->set_fail(true); 3149 factory->set_fail(true);
3150 factory->FinishCreation(); 3150 factory->FinishCreation();
3151 MockHttpCache cache(std::move(factory)); 3151 MockHttpCache cache(std::move(factory), false);
3152 3152
3153 std::vector<std::unique_ptr<UploadElementReader>> element_readers; 3153 std::vector<std::unique_ptr<UploadElementReader>> element_readers;
3154 element_readers.push_back( 3154 element_readers.push_back(
3155 base::WrapUnique(new UploadBytesElementReader("hello", 5))); 3155 base::WrapUnique(new UploadBytesElementReader("hello", 5)));
3156 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0); 3156 ElementsUploadDataStream upload_data_stream(std::move(element_readers), 0);
3157 3157
3158 MockTransaction transaction(kSimplePOST_Transaction); 3158 MockTransaction transaction(kSimplePOST_Transaction);
3159 AddMockTransaction(&transaction); 3159 AddMockTransaction(&transaction);
3160 MockHttpRequest req(transaction); 3160 MockHttpRequest req(transaction);
3161 req.upload_data_stream = &upload_data_stream; 3161 req.upload_data_stream = &upload_data_stream;
(...skipping 2288 matching lines...) Expand 10 before | Expand all | Expand 10 after
5450 // Verify that the entry is gone. 5450 // Verify that the entry is gone.
5451 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); 5451 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK);
5452 EXPECT_EQ(1, cache.disk_cache()->open_count()); 5452 EXPECT_EQ(1, cache.disk_cache()->open_count());
5453 EXPECT_EQ(2, cache.disk_cache()->create_count()); 5453 EXPECT_EQ(2, cache.disk_cache()->create_count());
5454 RemoveMockTransaction(&kRangeGET_TransactionOK); 5454 RemoveMockTransaction(&kRangeGET_TransactionOK);
5455 } 5455 }
5456 5456
5457 // Tests that we handle large range values properly. 5457 // Tests that we handle large range values properly.
5458 TEST(HttpCache, RangeGET_LargeValues) { 5458 TEST(HttpCache, RangeGET_LargeValues) {
5459 // We need a real sparse cache for this test. 5459 // We need a real sparse cache for this test.
5460 MockHttpCache cache(HttpCache::DefaultBackend::InMemory(1024 * 1024)); 5460 MockHttpCache cache(HttpCache::DefaultBackend::InMemory(1024 * 1024), false);
5461 std::string headers; 5461 std::string headers;
5462 5462
5463 MockTransaction transaction(kRangeGET_TransactionOK); 5463 MockTransaction transaction(kRangeGET_TransactionOK);
5464 transaction.handler = NULL; 5464 transaction.handler = NULL;
5465 transaction.request_headers = "Range: bytes = 4294967288-4294967297\r\n" 5465 transaction.request_headers = "Range: bytes = 4294967288-4294967297\r\n"
5466 EXTRA_HEADER; 5466 EXTRA_HEADER;
5467 transaction.response_headers = 5467 transaction.response_headers =
5468 "ETag: \"foo\"\n" 5468 "ETag: \"foo\"\n"
5469 "Content-Range: bytes 4294967288-4294967297/4294967299\n" 5469 "Content-Range: bytes 4294967288-4294967297/4294967299\n"
5470 "Content-Length: 10\n"; 5470 "Content-Length: 10\n";
(...skipping 15 matching lines...) Expand all
5486 RemoveMockTransaction(&kRangeGET_TransactionOK); 5486 RemoveMockTransaction(&kRangeGET_TransactionOK);
5487 } 5487 }
5488 5488
5489 // Tests that we don't crash with a range request if the disk cache was not 5489 // Tests that we don't crash with a range request if the disk cache was not
5490 // initialized properly. 5490 // initialized properly.
5491 TEST(HttpCache, RangeGET_NoDiskCache) { 5491 TEST(HttpCache, RangeGET_NoDiskCache) {
5492 std::unique_ptr<MockBlockingBackendFactory> factory( 5492 std::unique_ptr<MockBlockingBackendFactory> factory(
5493 new MockBlockingBackendFactory()); 5493 new MockBlockingBackendFactory());
5494 factory->set_fail(true); 5494 factory->set_fail(true);
5495 factory->FinishCreation(); // We'll complete synchronously. 5495 factory->FinishCreation(); // We'll complete synchronously.
5496 MockHttpCache cache(std::move(factory)); 5496 MockHttpCache cache(std::move(factory), false);
5497 5497
5498 AddMockTransaction(&kRangeGET_TransactionOK); 5498 AddMockTransaction(&kRangeGET_TransactionOK);
5499 5499
5500 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK); 5500 RunTransactionTest(cache.http_cache(), kRangeGET_TransactionOK);
5501 EXPECT_EQ(1, cache.network_layer()->transaction_count()); 5501 EXPECT_EQ(1, cache.network_layer()->transaction_count());
5502 5502
5503 RemoveMockTransaction(&kRangeGET_TransactionOK); 5503 RemoveMockTransaction(&kRangeGET_TransactionOK);
5504 } 5504 }
5505 5505
5506 // Tests that we handle byte range requests that skip the cache. 5506 // Tests that we handle byte range requests that skip the cache.
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after
6607 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk()); 6607 ASSERT_THAT(cache.CreateTransaction(&trans), IsOk());
6608 6608
6609 int rv = trans->Start(&request, callback.callback(), NetLogWithSource()); 6609 int rv = trans->Start(&request, callback.callback(), NetLogWithSource());
6610 if (rv == ERR_IO_PENDING) 6610 if (rv == ERR_IO_PENDING)
6611 rv = callback.WaitForResult(); 6611 rv = callback.WaitForResult();
6612 ASSERT_THAT(rv, IsError(ERR_CACHE_MISS)); 6612 ASSERT_THAT(rv, IsError(ERR_CACHE_MISS));
6613 } 6613 }
6614 6614
6615 // Ensure that we don't crash by if left-behind transactions. 6615 // Ensure that we don't crash by if left-behind transactions.
6616 TEST(HttpCache, OutlivedTransactions) { 6616 TEST(HttpCache, OutlivedTransactions) {
6617 MockHttpCache* cache = new MockHttpCache; 6617 MockHttpCache* cache = new MockHttpCache(false);
6618 6618
6619 std::unique_ptr<HttpTransaction> trans; 6619 std::unique_ptr<HttpTransaction> trans;
6620 EXPECT_THAT(cache->CreateTransaction(&trans), IsOk()); 6620 EXPECT_THAT(cache->CreateTransaction(&trans), IsOk());
6621 6621
6622 delete cache; 6622 delete cache;
6623 trans.reset(); 6623 trans.reset();
6624 } 6624 }
6625 6625
6626 // Test that the disabled mode works. 6626 // Test that the disabled mode works.
6627 TEST(HttpCache, CacheDisabledMode) { 6627 TEST(HttpCache, CacheDisabledMode) {
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after
7735 7735
7736 RemoveMockTransaction(&kRangeGET_TransactionOK); 7736 RemoveMockTransaction(&kRangeGET_TransactionOK);
7737 } 7737 }
7738 7738
7739 class HttpCachePrefetchValidationTest : public ::testing::Test { 7739 class HttpCachePrefetchValidationTest : public ::testing::Test {
7740 protected: 7740 protected:
7741 static const int kNumSecondsPerMinute = 60; 7741 static const int kNumSecondsPerMinute = 60;
7742 static const int kMaxAgeSecs = 100; 7742 static const int kMaxAgeSecs = 100;
7743 static const int kRequireValidationSecs = kMaxAgeSecs + 1; 7743 static const int kRequireValidationSecs = kMaxAgeSecs + 1;
7744 7744
7745 HttpCachePrefetchValidationTest() : transaction_(kSimpleGET_Transaction) { 7745 HttpCachePrefetchValidationTest()
7746 : cache_(false), transaction_(kSimpleGET_Transaction) {
7746 DCHECK_LT(kMaxAgeSecs, prefetch_reuse_mins() * kNumSecondsPerMinute); 7747 DCHECK_LT(kMaxAgeSecs, prefetch_reuse_mins() * kNumSecondsPerMinute);
7747 7748
7748 clock_ = new base::SimpleTestClock(); 7749 clock_ = new base::SimpleTestClock();
7749 cache_.http_cache()->SetClockForTesting(base::WrapUnique(clock_)); 7750 cache_.http_cache()->SetClockForTesting(base::WrapUnique(clock_));
7750 cache_.network_layer()->SetClock(clock_); 7751 cache_.network_layer()->SetClock(clock_);
7751 7752
7752 transaction_.response_headers = "Cache-Control: max-age=100\n"; 7753 transaction_.response_headers = "Cache-Control: max-age=100\n";
7753 } 7754 }
7754 7755
7755 bool TransactionRequiredNetwork(int load_flags) { 7756 bool TransactionRequiredNetwork(int load_flags) {
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
8254 RunTransactionTestWithResponseInfo(cache.http_cache(), 8255 RunTransactionTestWithResponseInfo(cache.http_cache(),
8255 kTypicalGET_Transaction, &response_info); 8256 kTypicalGET_Transaction, &response_info);
8256 8257
8257 EXPECT_FALSE(response_info.was_cached); 8258 EXPECT_FALSE(response_info.was_cached);
8258 EXPECT_TRUE(response_info.network_accessed); 8259 EXPECT_TRUE(response_info.network_accessed);
8259 EXPECT_EQ(CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE, 8260 EXPECT_EQ(CacheEntryStatus::ENTRY_CANT_CONDITIONALIZE,
8260 response_info.cache_entry_status); 8261 response_info.cache_entry_status);
8261 } 8262 }
8262 8263
8263 } // namespace net 8264 } // namespace net
OLDNEW
« no previous file with comments | « net/http/disk_cache_based_quic_server_info_unittest.cc ('k') | net/http/mock_http_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698