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

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

Issue 2518063007: Pass QuicInMemoryCache directly instead of using a singleton. (Closed)
Patch Set: Fix Cronet compile error Created 4 years 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/quic/test_tools/mock_quic_dispatcher.cc ('k') | net/tools/quic/quic_in_memory_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 <stddef.h> 5 #include <stddef.h>
6 #include <sys/epoll.h> 6 #include <sys/epoll.h>
7 7
8 #include <cstdint> 8 #include <cstdint>
9 #include <list> 9 #include <list>
10 #include <memory> 10 #include <memory>
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 #include "net/tools/quic/quic_in_memory_cache.h" 47 #include "net/tools/quic/quic_in_memory_cache.h"
48 #include "net/tools/quic/quic_packet_writer_wrapper.h" 48 #include "net/tools/quic/quic_packet_writer_wrapper.h"
49 #include "net/tools/quic/quic_server.h" 49 #include "net/tools/quic/quic_server.h"
50 #include "net/tools/quic/quic_simple_server_stream.h" 50 #include "net/tools/quic/quic_simple_server_stream.h"
51 #include "net/tools/quic/quic_socket_utils.h" 51 #include "net/tools/quic/quic_socket_utils.h"
52 #include "net/tools/quic/quic_spdy_client_stream.h" 52 #include "net/tools/quic/quic_spdy_client_stream.h"
53 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h" 53 #include "net/tools/quic/test_tools/packet_dropping_test_writer.h"
54 #include "net/tools/quic/test_tools/packet_reordering_writer.h" 54 #include "net/tools/quic/test_tools/packet_reordering_writer.h"
55 #include "net/tools/quic/test_tools/quic_client_peer.h" 55 #include "net/tools/quic/test_tools/quic_client_peer.h"
56 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h" 56 #include "net/tools/quic/test_tools/quic_dispatcher_peer.h"
57 #include "net/tools/quic/test_tools/quic_in_memory_cache_peer.h"
58 #include "net/tools/quic/test_tools/quic_server_peer.h" 57 #include "net/tools/quic/test_tools/quic_server_peer.h"
59 #include "net/tools/quic/test_tools/quic_test_client.h" 58 #include "net/tools/quic/test_tools/quic_test_client.h"
60 #include "net/tools/quic/test_tools/quic_test_server.h" 59 #include "net/tools/quic/test_tools/quic_test_server.h"
61 #include "net/tools/quic/test_tools/server_thread.h" 60 #include "net/tools/quic/test_tools/server_thread.h"
62 #include "testing/gtest/include/gtest/gtest.h" 61 #include "testing/gtest/include/gtest/gtest.h"
63 62
64 using base::IntToString; 63 using base::IntToString;
65 using base::StringPiece; 64 using base::StringPiece;
66 using base::WaitableEvent; 65 using base::WaitableEvent;
67 using net::EpollServer; 66 using net::EpollServer;
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 3 * kInitialSessionFlowControlWindowForTest); 297 3 * kInitialSessionFlowControlWindowForTest);
299 298
300 // The default idle timeouts can be too strict when running on a busy 299 // The default idle timeouts can be too strict when running on a busy
301 // machine. 300 // machine.
302 const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(30); 301 const QuicTime::Delta timeout = QuicTime::Delta::FromSeconds(30);
303 client_config_.set_max_time_before_crypto_handshake(timeout); 302 client_config_.set_max_time_before_crypto_handshake(timeout);
304 client_config_.set_max_idle_time_before_crypto_handshake(timeout); 303 client_config_.set_max_idle_time_before_crypto_handshake(timeout);
305 server_config_.set_max_time_before_crypto_handshake(timeout); 304 server_config_.set_max_time_before_crypto_handshake(timeout);
306 server_config_.set_max_idle_time_before_crypto_handshake(timeout); 305 server_config_.set_max_idle_time_before_crypto_handshake(timeout);
307 306
308 QuicInMemoryCachePeer::ResetForTests();
309 AddToCache("/foo", 200, kFooResponseBody); 307 AddToCache("/foo", 200, kFooResponseBody);
310 AddToCache("/bar", 200, kBarResponseBody); 308 AddToCache("/bar", 200, kBarResponseBody);
311 } 309 }
312 310
313 ~EndToEndTest() override { 311 ~EndToEndTest() override {
314 // TODO(rtenneti): port RecycleUnusedPort if needed. 312 // TODO(rtenneti): port RecycleUnusedPort if needed.
315 // RecycleUnusedPort(server_address_.port()); 313 // RecycleUnusedPort(server_address_.port());
316 QuicInMemoryCachePeer::ResetForTests();
317 } 314 }
318 315
319 virtual void CreateClientWithWriter() { 316 virtual void CreateClientWithWriter() {
320 client_.reset(CreateQuicClient(client_writer_)); 317 client_.reset(CreateQuicClient(client_writer_));
321 } 318 }
322 319
323 QuicTestClient* CreateQuicClient(QuicPacketWriterWrapper* writer) { 320 QuicTestClient* CreateQuicClient(QuicPacketWriterWrapper* writer) {
324 QuicTestClient* client = new QuicTestClient( 321 QuicTestClient* client = new QuicTestClient(
325 server_address_, server_hostname_, client_config_, 322 server_address_, server_hostname_, client_config_,
326 client_supported_versions_, CryptoTestUtils::ProofVerifierForTesting()); 323 client_supported_versions_, CryptoTestUtils::ProofVerifierForTesting());
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 void TearDown() override { 420 void TearDown() override {
424 ASSERT_TRUE(initialized_) << "You must call Initialize() in every test " 421 ASSERT_TRUE(initialized_) << "You must call Initialize() in every test "
425 << "case. Otherwise, your test will leak memory."; 422 << "case. Otherwise, your test will leak memory.";
426 StopServer(); 423 StopServer();
427 } 424 }
428 425
429 void StartServer() { 426 void StartServer() {
430 FLAGS_quic_use_cheap_stateless_rejects = 427 FLAGS_quic_use_cheap_stateless_rejects =
431 GetParam().use_cheap_stateless_reject; 428 GetParam().use_cheap_stateless_reject;
432 429
433 auto test_server = 430 auto test_server = new QuicTestServer(
434 new QuicTestServer(CryptoTestUtils::ProofSourceForTesting(), 431 CryptoTestUtils::ProofSourceForTesting(), server_config_,
435 server_config_, server_supported_versions_); 432 server_supported_versions_, &in_memory_cache_);
436 server_thread_.reset(new ServerThread(test_server, server_address_)); 433 server_thread_.reset(new ServerThread(test_server, server_address_));
437 if (chlo_multiplier_ != 0) { 434 if (chlo_multiplier_ != 0) {
438 server_thread_->server()->SetChloMultiplier(chlo_multiplier_); 435 server_thread_->server()->SetChloMultiplier(chlo_multiplier_);
439 } 436 }
440 server_thread_->Initialize(); 437 server_thread_->Initialize();
441 server_address_ = 438 server_address_ =
442 QuicSocketAddress(server_address_.host(), server_thread_->GetPort()); 439 QuicSocketAddress(server_address_.host(), server_thread_->GetPort());
443 QuicDispatcher* dispatcher = 440 QuicDispatcher* dispatcher =
444 QuicServerPeer::GetDispatcher(server_thread_->server()); 441 QuicServerPeer::GetDispatcher(server_thread_->server());
445 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_); 442 QuicDispatcherPeer::UseWriter(dispatcher, server_writer_);
(...skipping 16 matching lines...) Expand all
462 void StopServer() { 459 void StopServer() {
463 if (!server_started_) 460 if (!server_started_)
464 return; 461 return;
465 if (server_thread_.get()) { 462 if (server_thread_.get()) {
466 server_thread_->Quit(); 463 server_thread_->Quit();
467 server_thread_->Join(); 464 server_thread_->Join();
468 } 465 }
469 } 466 }
470 467
471 void AddToCache(StringPiece path, int response_code, StringPiece body) { 468 void AddToCache(StringPiece path, int response_code, StringPiece body) {
472 QuicInMemoryCache::GetInstance()->AddSimpleResponse(server_hostname_, path, 469 in_memory_cache_.AddSimpleResponse(server_hostname_, path, response_code,
473 response_code, body); 470 body);
474 } 471 }
475 472
476 void SetPacketLossPercentage(int32_t loss) { 473 void SetPacketLossPercentage(int32_t loss) {
477 // TODO(rtenneti): enable when we can do random packet loss tests in 474 // TODO(rtenneti): enable when we can do random packet loss tests in
478 // chrome's tree. 475 // chrome's tree.
479 if (loss != 0 && loss != 100) 476 if (loss != 0 && loss != 100)
480 return; 477 return;
481 client_writer_->set_fake_packet_loss_percentage(loss); 478 client_writer_->set_fake_packet_loss_percentage(loss);
482 server_writer_->set_fake_packet_loss_percentage(loss); 479 server_writer_->set_fake_packet_loss_percentage(loss);
483 } 480 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 550
554 // Must be called before Initialize to have effect. 551 // Must be called before Initialize to have effect.
555 void SetSpdyStreamFactory(QuicTestServer::StreamFactory* factory) { 552 void SetSpdyStreamFactory(QuicTestServer::StreamFactory* factory) {
556 stream_factory_ = factory; 553 stream_factory_ = factory;
557 } 554 }
558 555
559 QuicFlagSaver flags_; // Save/restore all QUIC flag values. 556 QuicFlagSaver flags_; // Save/restore all QUIC flag values.
560 bool initialized_; 557 bool initialized_;
561 QuicSocketAddress server_address_; 558 QuicSocketAddress server_address_;
562 string server_hostname_; 559 string server_hostname_;
560 QuicInMemoryCache in_memory_cache_;
563 std::unique_ptr<ServerThread> server_thread_; 561 std::unique_ptr<ServerThread> server_thread_;
564 std::unique_ptr<QuicTestClient> client_; 562 std::unique_ptr<QuicTestClient> client_;
565 PacketDroppingTestWriter* client_writer_; 563 PacketDroppingTestWriter* client_writer_;
566 PacketDroppingTestWriter* server_writer_; 564 PacketDroppingTestWriter* server_writer_;
567 bool server_started_; 565 bool server_started_;
568 QuicConfig client_config_; 566 QuicConfig client_config_;
569 QuicConfig server_config_; 567 QuicConfig server_config_;
570 QuicVersionVector client_supported_versions_; 568 QuicVersionVector client_supported_versions_;
571 QuicVersionVector server_supported_versions_; 569 QuicVersionVector server_supported_versions_;
572 QuicVersion negotiated_version_; 570 QuicVersion negotiated_version_;
(...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 // The connection should not be terminated. 2140 // The connection should not be terminated.
2143 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo")); 2141 EXPECT_EQ(kFooResponseBody, client_->SendSynchronousRequest("/foo"));
2144 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); 2142 EXPECT_EQ("200", client_->response_headers()->find(":status")->second);
2145 } 2143 }
2146 2144
2147 // A test stream that gives |response_body_| as an error response body. 2145 // A test stream that gives |response_body_| as an error response body.
2148 class ServerStreamWithErrorResponseBody : public QuicSimpleServerStream { 2146 class ServerStreamWithErrorResponseBody : public QuicSimpleServerStream {
2149 public: 2147 public:
2150 ServerStreamWithErrorResponseBody(QuicStreamId id, 2148 ServerStreamWithErrorResponseBody(QuicStreamId id,
2151 QuicSpdySession* session, 2149 QuicSpdySession* session,
2150 QuicInMemoryCache* in_memory_cache,
2152 string response_body) 2151 string response_body)
2153 : QuicSimpleServerStream(id, session), 2152 : QuicSimpleServerStream(id, session, in_memory_cache),
2154 response_body_(std::move(response_body)) {} 2153 response_body_(std::move(response_body)) {}
2155 2154
2156 ~ServerStreamWithErrorResponseBody() override {} 2155 ~ServerStreamWithErrorResponseBody() override {}
2157 2156
2158 protected: 2157 protected:
2159 void SendErrorResponse() override { 2158 void SendErrorResponse() override {
2160 DVLOG(1) << "Sending error response for stream " << id(); 2159 DVLOG(1) << "Sending error response for stream " << id();
2161 SpdyHeaderBlock headers; 2160 SpdyHeaderBlock headers;
2162 headers[":status"] = "500"; 2161 headers[":status"] = "500";
2163 headers["content-length"] = base::UintToString(response_body_.size()); 2162 headers["content-length"] = base::UintToString(response_body_.size());
2164 // This method must call CloseReadSide to cause the test case, StopReading 2163 // This method must call CloseReadSide to cause the test case, StopReading
2165 // is not sufficient. 2164 // is not sufficient.
2166 QuicStreamPeer::CloseReadSide(this); 2165 QuicStreamPeer::CloseReadSide(this);
2167 SendHeadersAndBody(std::move(headers), response_body_); 2166 SendHeadersAndBody(std::move(headers), response_body_);
2168 } 2167 }
2169 2168
2170 string response_body_; 2169 string response_body_;
2171 }; 2170 };
2172 2171
2173 class StreamWithErrorFactory : public QuicTestServer::StreamFactory { 2172 class StreamWithErrorFactory : public QuicTestServer::StreamFactory {
2174 public: 2173 public:
2175 explicit StreamWithErrorFactory(string response_body) 2174 explicit StreamWithErrorFactory(string response_body)
2176 : response_body_(std::move(response_body)) {} 2175 : response_body_(std::move(response_body)) {}
2177 2176
2178 ~StreamWithErrorFactory() override {} 2177 ~StreamWithErrorFactory() override {}
2179 2178
2180 QuicSimpleServerStream* CreateStream(QuicStreamId id, 2179 QuicSimpleServerStream* CreateStream(
2181 QuicSpdySession* session) override { 2180 QuicStreamId id,
2182 return new ServerStreamWithErrorResponseBody(id, session, response_body_); 2181 QuicSpdySession* session,
2182 QuicInMemoryCache* in_memory_cache) override {
2183 return new ServerStreamWithErrorResponseBody(id, session, in_memory_cache,
2184 response_body_);
2183 } 2185 }
2184 2186
2185 private: 2187 private:
2186 string response_body_; 2188 string response_body_;
2187 }; 2189 };
2188 2190
2189 // A test server stream that drops all received body. 2191 // A test server stream that drops all received body.
2190 class ServerStreamThatDropsBody : public QuicSimpleServerStream { 2192 class ServerStreamThatDropsBody : public QuicSimpleServerStream {
2191 public: 2193 public:
2192 ServerStreamThatDropsBody(QuicStreamId id, QuicSpdySession* session) 2194 ServerStreamThatDropsBody(QuicStreamId id,
2193 : QuicSimpleServerStream(id, session) {} 2195 QuicSpdySession* session,
2196 QuicInMemoryCache* in_memory_cache)
2197 : QuicSimpleServerStream(id, session, in_memory_cache) {}
2194 2198
2195 ~ServerStreamThatDropsBody() override {} 2199 ~ServerStreamThatDropsBody() override {}
2196 2200
2197 protected: 2201 protected:
2198 void OnDataAvailable() override { 2202 void OnDataAvailable() override {
2199 while (HasBytesToRead()) { 2203 while (HasBytesToRead()) {
2200 struct iovec iov; 2204 struct iovec iov;
2201 if (GetReadableRegions(&iov, 1) == 0) { 2205 if (GetReadableRegions(&iov, 1) == 0) {
2202 // No more data to read. 2206 // No more data to read.
2203 break; 2207 break;
(...skipping 18 matching lines...) Expand all
2222 SendResponse(); 2226 SendResponse();
2223 } 2227 }
2224 }; 2228 };
2225 2229
2226 class ServerStreamThatDropsBodyFactory : public QuicTestServer::StreamFactory { 2230 class ServerStreamThatDropsBodyFactory : public QuicTestServer::StreamFactory {
2227 public: 2231 public:
2228 ServerStreamThatDropsBodyFactory() {} 2232 ServerStreamThatDropsBodyFactory() {}
2229 2233
2230 ~ServerStreamThatDropsBodyFactory() override{}; 2234 ~ServerStreamThatDropsBodyFactory() override{};
2231 2235
2232 QuicSimpleServerStream* CreateStream(QuicStreamId id, 2236 QuicSimpleServerStream* CreateStream(
2233 QuicSpdySession* session) override { 2237 QuicStreamId id,
2234 return new ServerStreamThatDropsBody(id, session); 2238 QuicSpdySession* session,
2239 QuicInMemoryCache* in_memory_cache) override {
2240 return new ServerStreamThatDropsBody(id, session, in_memory_cache);
2235 } 2241 }
2236 }; 2242 };
2237 2243
2238 // A test server stream that sends response with body size greater than 4GB. 2244 // A test server stream that sends response with body size greater than 4GB.
2239 class ServerStreamThatSendsHugeResponse : public QuicSimpleServerStream { 2245 class ServerStreamThatSendsHugeResponse : public QuicSimpleServerStream {
2240 public: 2246 public:
2241 ServerStreamThatSendsHugeResponse(QuicStreamId id, 2247 ServerStreamThatSendsHugeResponse(QuicStreamId id,
2242 QuicSpdySession* session, 2248 QuicSpdySession* session,
2249 QuicInMemoryCache* in_memory_cache,
2243 int64_t body_bytes) 2250 int64_t body_bytes)
2244 : QuicSimpleServerStream(id, session), body_bytes_(body_bytes) {} 2251 : QuicSimpleServerStream(id, session, in_memory_cache),
2252 body_bytes_(body_bytes) {}
2245 2253
2246 ~ServerStreamThatSendsHugeResponse() override {} 2254 ~ServerStreamThatSendsHugeResponse() override {}
2247 2255
2248 protected: 2256 protected:
2249 void SendResponse() override { 2257 void SendResponse() override {
2250 QuicInMemoryCache::Response response; 2258 QuicInMemoryCache::Response response;
2251 string body; 2259 string body;
2252 GenerateBody(&body, body_bytes_); 2260 GenerateBody(&body, body_bytes_);
2253 response.set_body(body); 2261 response.set_body(body);
2254 SendHeadersAndBodyAndTrailers(response.headers().Clone(), response.body(), 2262 SendHeadersAndBodyAndTrailers(response.headers().Clone(), response.body(),
2255 response.trailers().Clone()); 2263 response.trailers().Clone());
2256 } 2264 }
2257 2265
2258 private: 2266 private:
2259 // Use a explicit int64_t rather than size_t to simulate a 64-bit server 2267 // Use a explicit int64_t rather than size_t to simulate a 64-bit server
2260 // talking to a 32-bit client. 2268 // talking to a 32-bit client.
2261 int64_t body_bytes_; 2269 int64_t body_bytes_;
2262 }; 2270 };
2263 2271
2264 class ServerStreamThatSendsHugeResponseFactory 2272 class ServerStreamThatSendsHugeResponseFactory
2265 : public QuicTestServer::StreamFactory { 2273 : public QuicTestServer::StreamFactory {
2266 public: 2274 public:
2267 explicit ServerStreamThatSendsHugeResponseFactory(int64_t body_bytes) 2275 explicit ServerStreamThatSendsHugeResponseFactory(int64_t body_bytes)
2268 : body_bytes_(body_bytes) {} 2276 : body_bytes_(body_bytes) {}
2269 2277
2270 ~ServerStreamThatSendsHugeResponseFactory() override{}; 2278 ~ServerStreamThatSendsHugeResponseFactory() override{};
2271 2279
2272 QuicSimpleServerStream* CreateStream(QuicStreamId id, 2280 QuicSimpleServerStream* CreateStream(
2273 QuicSpdySession* session) override { 2281 QuicStreamId id,
2274 return new ServerStreamThatSendsHugeResponse(id, session, body_bytes_); 2282 QuicSpdySession* session,
2283 QuicInMemoryCache* in_memory_cache) override {
2284 return new ServerStreamThatSendsHugeResponse(id, session, in_memory_cache,
2285 body_bytes_);
2275 } 2286 }
2276 2287
2277 int64_t body_bytes_; 2288 int64_t body_bytes_;
2278 }; 2289 };
2279 2290
2280 // A test client stream that drops all received body. 2291 // A test client stream that drops all received body.
2281 class ClientStreamThatDropsBody : public QuicSpdyClientStream { 2292 class ClientStreamThatDropsBody : public QuicSpdyClientStream {
2282 public: 2293 public:
2283 ClientStreamThatDropsBody(QuicStreamId id, QuicClientSession* session) 2294 ClientStreamThatDropsBody(QuicStreamId id, QuicClientSession* session)
2284 : QuicSpdyClientStream(id, session) {} 2295 : QuicSpdyClientStream(id, session) {}
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
2482 const string kBody = "body content"; 2493 const string kBody = "body content";
2483 2494
2484 SpdyHeaderBlock headers; 2495 SpdyHeaderBlock headers;
2485 headers[":status"] = "200"; 2496 headers[":status"] = "200";
2486 headers[":version"] = "HTTP/1.1"; 2497 headers[":version"] = "HTTP/1.1";
2487 headers["content-length"] = IntToString(kBody.size()); 2498 headers["content-length"] = IntToString(kBody.size());
2488 2499
2489 SpdyHeaderBlock trailers; 2500 SpdyHeaderBlock trailers;
2490 trailers["some-trailing-header"] = "trailing-header-value"; 2501 trailers["some-trailing-header"] = "trailing-header-value";
2491 2502
2492 QuicInMemoryCache::GetInstance()->AddResponse( 2503 in_memory_cache_.AddResponse(server_hostname_, "/trailer_url",
2493 server_hostname_, "/trailer_url", std::move(headers), kBody, 2504 std::move(headers), kBody, trailers.Clone());
2494 trailers.Clone());
2495 2505
2496 EXPECT_EQ(kBody, client_->SendSynchronousRequest("/trailer_url")); 2506 EXPECT_EQ(kBody, client_->SendSynchronousRequest("/trailer_url"));
2497 EXPECT_EQ("200", client_->response_headers()->find(":status")->second); 2507 EXPECT_EQ("200", client_->response_headers()->find(":status")->second);
2498 EXPECT_EQ(trailers, client_->response_trailers()); 2508 EXPECT_EQ(trailers, client_->response_trailers());
2499 } 2509 }
2500 2510
2501 class EndToEndTestServerPush : public EndToEndTest { 2511 class EndToEndTestServerPush : public EndToEndTest {
2502 protected: 2512 protected:
2503 const size_t kNumMaxStreams = 10; 2513 const size_t kNumMaxStreams = 10;
2504 2514
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2536 ? large_resource 2546 ? large_resource
2537 : "This is server push response body for " + url; 2547 : "This is server push response body for " + url;
2538 SpdyHeaderBlock response_headers; 2548 SpdyHeaderBlock response_headers;
2539 response_headers[":version"] = "HTTP/1.1"; 2549 response_headers[":version"] = "HTTP/1.1";
2540 response_headers[":status"] = "200"; 2550 response_headers[":status"] = "200";
2541 response_headers["content-length"] = IntToString(body.size()); 2551 response_headers["content-length"] = IntToString(body.size());
2542 push_resources.push_back(QuicInMemoryCache::ServerPushInfo( 2552 push_resources.push_back(QuicInMemoryCache::ServerPushInfo(
2543 resource_url, std::move(response_headers), kV3LowestPriority, body)); 2553 resource_url, std::move(response_headers), kV3LowestPriority, body));
2544 } 2554 }
2545 2555
2546 QuicInMemoryCache::GetInstance()->AddSimpleResponseWithServerPushResources( 2556 in_memory_cache_.AddSimpleResponseWithServerPushResources(
2547 host, path, 200, response_body, push_resources); 2557 host, path, 200, response_body, push_resources);
2548 } 2558 }
2549 }; 2559 };
2550 2560
2551 // Run all server push end to end tests with all supported versions. 2561 // Run all server push end to end tests with all supported versions.
2552 INSTANTIATE_TEST_CASE_P(EndToEndTestsServerPush, 2562 INSTANTIATE_TEST_CASE_P(EndToEndTestsServerPush,
2553 EndToEndTestServerPush, 2563 EndToEndTestServerPush,
2554 ::testing::ValuesIn(GetTestParams())); 2564 ::testing::ValuesIn(GetTestParams()));
2555 2565
2556 TEST_P(EndToEndTestServerPush, ServerPush) { 2566 TEST_P(EndToEndTestServerPush, ServerPush) {
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2947 client_->WaitForResponse(); 2957 client_->WaitForResponse();
2948 EXPECT_EQ(kBarResponseBody, client_->response_body()); 2958 EXPECT_EQ(kBarResponseBody, client_->response_body());
2949 QuicConnectionStats client_stats = 2959 QuicConnectionStats client_stats =
2950 client_->client()->session()->connection()->GetStats(); 2960 client_->client()->session()->connection()->GetStats();
2951 EXPECT_EQ(0u, client_stats.packets_lost); 2961 EXPECT_EQ(0u, client_stats.packets_lost);
2952 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos()); 2962 EXPECT_EQ(1, client_->client()->GetNumSentClientHellos());
2953 } 2963 }
2954 } // namespace 2964 } // namespace
2955 } // namespace test 2965 } // namespace test
2956 } // namespace net 2966 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/test_tools/mock_quic_dispatcher.cc ('k') | net/tools/quic/quic_in_memory_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698