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

Side by Side Diff: net/tools/quic/quic_in_memory_cache_test.cc

Issue 2516033003: Landing Recent QUIC changes until Mon Nov 14 04:43:50 2016 +0000 (Closed)
Patch Set: Remove unused UpdatePacketGapSentHistogram() function. Created 4 years, 1 month 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/tools/quic/quic_dispatcher_test.cc ('k') | net/tools/quic/quic_packet_printer_bin.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <string> 5 #include <string>
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/memory/singleton.h" 8 #include "base/memory/singleton.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } 103 }
104 104
105 TEST_F(QuicInMemoryCacheTest, ReadsCacheDir) { 105 TEST_F(QuicInMemoryCacheTest, ReadsCacheDir) {
106 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory()); 106 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory());
107 const QuicInMemoryCache::Response* response = 107 const QuicInMemoryCache::Response* response =
108 QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url", 108 QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url",
109 "/index.html"); 109 "/index.html");
110 ASSERT_TRUE(response); 110 ASSERT_TRUE(response);
111 ASSERT_TRUE(ContainsKey(response->headers(), ":status")); 111 ASSERT_TRUE(ContainsKey(response->headers(), ":status"));
112 EXPECT_EQ("200", response->headers().find(":status")->second); 112 EXPECT_EQ("200", response->headers().find(":status")->second);
113 ASSERT_FALSE(ContainsKey(response->headers(), "connection")); 113 // Connection headers are not valid in HTTP/2.
114 EXPECT_FALSE(ContainsKey(response->headers(), "connection"));
114 EXPECT_LT(0U, response->body().length()); 115 EXPECT_LT(0U, response->body().length());
115 } 116 }
116 117
117 TEST_F(QuicInMemoryCacheTest, ReadsCacheDirWithServerPushResource) { 118 TEST_F(QuicInMemoryCacheTest, ReadsCacheDirWithServerPushResource) {
118 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory() + 119 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory() +
119 "_with_push"); 120 "_with_push");
120 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); 121 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance();
121 list<ServerPushInfo> resources = 122 list<ServerPushInfo> resources =
122 cache->GetServerPushResources("quic.test.url/"); 123 cache->GetServerPushResources("quic.test.url/");
123 ASSERT_EQ(1UL, resources.size()); 124 ASSERT_EQ(1UL, resources.size());
124 } 125 }
125 126
126 TEST_F(QuicInMemoryCacheTest, ReadsCacheDirWithServerPushResources) { 127 TEST_F(QuicInMemoryCacheTest, ReadsCacheDirWithServerPushResources) {
127 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory() + 128 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory() +
128 "_with_push"); 129 "_with_push");
129 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); 130 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance();
130 list<ServerPushInfo> resources = 131 list<ServerPushInfo> resources =
131 cache->GetServerPushResources("quic.test.url/index2.html"); 132 cache->GetServerPushResources("quic.test.url/index2.html");
132 ASSERT_EQ(2UL, resources.size()); 133 ASSERT_EQ(2UL, resources.size());
133 } 134 }
134 135
135 TEST_F(QuicInMemoryCacheTest, UsesOriginalUrl) { 136 TEST_F(QuicInMemoryCacheTest, UsesOriginalUrl) {
136 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory()); 137 QuicInMemoryCache::GetInstance()->InitializeFromDirectory(CacheDirectory());
137 const QuicInMemoryCache::Response* response = 138 const QuicInMemoryCache::Response* response =
138 QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url", 139 QuicInMemoryCache::GetInstance()->GetResponse("quic.test.url",
139 "/index.html"); 140 "/index.html");
140 ASSERT_TRUE(response); 141 ASSERT_TRUE(response);
141 ASSERT_TRUE(ContainsKey(response->headers(), ":status")); 142 ASSERT_TRUE(ContainsKey(response->headers(), ":status"));
142 EXPECT_EQ("200", response->headers().find(":status")->second); 143 EXPECT_EQ("200", response->headers().find(":status")->second);
143 ASSERT_FALSE(ContainsKey(response->headers(), "connection")); 144 // Connection headers are not valid in HTTP/2.
145 EXPECT_FALSE(ContainsKey(response->headers(), "connection"));
144 EXPECT_LT(0U, response->body().length()); 146 EXPECT_LT(0U, response->body().length());
145 } 147 }
146 148
147 TEST_F(QuicInMemoryCacheTest, DefaultResponse) { 149 TEST_F(QuicInMemoryCacheTest, DefaultResponse) {
148 // Verify GetResponse returns nullptr when no default is set. 150 // Verify GetResponse returns nullptr when no default is set.
149 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance(); 151 QuicInMemoryCache* cache = QuicInMemoryCache::GetInstance();
150 const QuicInMemoryCache::Response* response = 152 const QuicInMemoryCache::Response* response =
151 cache->GetResponse("www.google.com", "/"); 153 cache->GetResponse("www.google.com", "/");
152 ASSERT_FALSE(response); 154 ASSERT_FALSE(response);
153 155
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 ASSERT_TRUE(ContainsKey(response->headers(), ":status")); 254 ASSERT_TRUE(ContainsKey(response->headers(), ":status"));
253 EXPECT_EQ(push_response_status[i++], 255 EXPECT_EQ(push_response_status[i++],
254 response->headers().find(":status")->second); 256 response->headers().find(":status")->second);
255 EXPECT_EQ(push_resource.body, response->body()); 257 EXPECT_EQ(push_resource.body, response->body());
256 resources.pop_front(); 258 resources.pop_front();
257 } 259 }
258 } 260 }
259 261
260 } // namespace test 262 } // namespace test
261 } // namespace net 263 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_dispatcher_test.cc ('k') | net/tools/quic/quic_packet_printer_bin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698