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

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

Issue 2547583002: Landing Recent QUIC changes until Fri Nov 18 23:21:04 2016 +0000 (Closed)
Patch Set: Remove explicit HTTP/2 enum usage 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
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 "net/tools/quic/quic_simple_server_session.h" 5 #include "net/tools/quic/quic_simple_server_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 config_.SetInitialStreamFlowControlWindowToSend( 189 config_.SetInitialStreamFlowControlWindowToSend(
190 kInitialStreamFlowControlWindowForTest); 190 kInitialStreamFlowControlWindowForTest);
191 config_.SetInitialSessionFlowControlWindowToSend( 191 config_.SetInitialSessionFlowControlWindowToSend(
192 kInitialSessionFlowControlWindowForTest); 192 kInitialSessionFlowControlWindowForTest);
193 193
194 connection_ = new StrictMock<MockQuicConnectionWithSendStreamData>( 194 connection_ = new StrictMock<MockQuicConnectionWithSendStreamData>(
195 &helper_, &alarm_factory_, Perspective::IS_SERVER, 195 &helper_, &alarm_factory_, Perspective::IS_SERVER,
196 SupportedVersions(GetParam())); 196 SupportedVersions(GetParam()));
197 session_.reset(new QuicSimpleServerSession( 197 session_.reset(new QuicSimpleServerSession(
198 config_, connection_, &owner_, &stream_helper_, &crypto_config_, 198 config_, connection_, &owner_, &stream_helper_, &crypto_config_,
199 &compressed_certs_cache_, &in_memory_cache_)); 199 &compressed_certs_cache_, &response_cache_));
200 MockClock clock; 200 MockClock clock;
201 handshake_message_.reset(crypto_config_.AddDefaultConfig( 201 handshake_message_.reset(crypto_config_.AddDefaultConfig(
202 QuicRandom::GetInstance(), &clock, 202 QuicRandom::GetInstance(), &clock,
203 QuicCryptoServerConfig::ConfigOptions())); 203 QuicCryptoServerConfig::ConfigOptions()));
204 session_->Initialize(); 204 session_->Initialize();
205 visitor_ = QuicConnectionPeer::GetVisitor(connection_); 205 visitor_ = QuicConnectionPeer::GetVisitor(connection_);
206 headers_stream_ = new MockQuicHeadersStream(session_.get()); 206 headers_stream_ = new MockQuicHeadersStream(session_.get());
207 QuicSpdySessionPeer::SetHeadersStream(session_.get(), headers_stream_); 207 QuicSpdySessionPeer::SetHeadersStream(session_.get(), headers_stream_);
208 208
209 session_->OnConfigNegotiated(); 209 session_->OnConfigNegotiated();
210 } 210 }
211 211
212 StrictMock<MockQuicSessionVisitor> owner_; 212 StrictMock<MockQuicSessionVisitor> owner_;
213 StrictMock<MockQuicCryptoServerStreamHelper> stream_helper_; 213 StrictMock<MockQuicCryptoServerStreamHelper> stream_helper_;
214 MockQuicConnectionHelper helper_; 214 MockQuicConnectionHelper helper_;
215 MockAlarmFactory alarm_factory_; 215 MockAlarmFactory alarm_factory_;
216 StrictMock<MockQuicConnectionWithSendStreamData>* connection_; 216 StrictMock<MockQuicConnectionWithSendStreamData>* connection_;
217 QuicConfig config_; 217 QuicConfig config_;
218 QuicCryptoServerConfig crypto_config_; 218 QuicCryptoServerConfig crypto_config_;
219 QuicCompressedCertsCache compressed_certs_cache_; 219 QuicCompressedCertsCache compressed_certs_cache_;
220 QuicInMemoryCache in_memory_cache_; 220 QuicHttpResponseCache response_cache_;
221 std::unique_ptr<QuicSimpleServerSession> session_; 221 std::unique_ptr<QuicSimpleServerSession> session_;
222 std::unique_ptr<CryptoHandshakeMessage> handshake_message_; 222 std::unique_ptr<CryptoHandshakeMessage> handshake_message_;
223 QuicConnectionVisitorInterface* visitor_; 223 QuicConnectionVisitorInterface* visitor_;
224 MockQuicHeadersStream* headers_stream_; 224 MockQuicHeadersStream* headers_stream_;
225 }; 225 };
226 226
227 INSTANTIATE_TEST_CASE_P(Tests, 227 INSTANTIATE_TEST_CASE_P(Tests,
228 QuicSimpleServerSessionTest, 228 QuicSimpleServerSessionTest,
229 ::testing::ValuesIn(AllSupportedVersions())); 229 ::testing::ValuesIn(AllSupportedVersions()));
230 230
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 // Enable server push. 429 // Enable server push.
430 QuicTagVector copt; 430 QuicTagVector copt;
431 copt.push_back(kSPSH); 431 copt.push_back(kSPSH);
432 QuicConfigPeer::SetReceivedConnectionOptions(&config_, copt); 432 QuicConfigPeer::SetReceivedConnectionOptions(&config_, copt);
433 433
434 connection_ = new StrictMock<MockQuicConnectionWithSendStreamData>( 434 connection_ = new StrictMock<MockQuicConnectionWithSendStreamData>(
435 &helper_, &alarm_factory_, Perspective::IS_SERVER, 435 &helper_, &alarm_factory_, Perspective::IS_SERVER,
436 SupportedVersions(GetParam())); 436 SupportedVersions(GetParam()));
437 session_.reset(new QuicSimpleServerSession( 437 session_.reset(new QuicSimpleServerSession(
438 config_, connection_, &owner_, &stream_helper_, &crypto_config_, 438 config_, connection_, &owner_, &stream_helper_, &crypto_config_,
439 &compressed_certs_cache_, &in_memory_cache_)); 439 &compressed_certs_cache_, &response_cache_));
440 session_->Initialize(); 440 session_->Initialize();
441 // Needed to make new session flow control window and server push work. 441 // Needed to make new session flow control window and server push work.
442 session_->OnConfigNegotiated(); 442 session_->OnConfigNegotiated();
443 443
444 visitor_ = QuicConnectionPeer::GetVisitor(connection_); 444 visitor_ = QuicConnectionPeer::GetVisitor(connection_);
445 headers_stream_ = new MockQuicHeadersStream(session_.get()); 445 headers_stream_ = new MockQuicHeadersStream(session_.get());
446 QuicSpdySessionPeer::SetHeadersStream(session_.get(), headers_stream_); 446 QuicSpdySessionPeer::SetHeadersStream(session_.get(), headers_stream_);
447 447
448 // Assume encryption already established. 448 // Assume encryption already established.
449 MockQuicCryptoServerStream* crypto_stream = new MockQuicCryptoServerStream( 449 MockQuicCryptoServerStream* crypto_stream = new MockQuicCryptoServerStream(
(...skipping 12 matching lines...) Expand all
462 // To prevent push streams from being closed the response need to be larger 462 // To prevent push streams from being closed the response need to be larger
463 // than stream flow control window so stream won't send the full body. 463 // than stream flow control window so stream won't send the full body.
464 size_t body_size = 2 * kStreamFlowControlWindowSize; // 64KB. 464 size_t body_size = 2 * kStreamFlowControlWindowSize; // 64KB.
465 465
466 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest); 466 config_.SetMaxStreamsPerConnection(kMaxStreamsForTest, kMaxStreamsForTest);
467 467
468 string request_url = "mail.google.com/"; 468 string request_url = "mail.google.com/";
469 SpdyHeaderBlock request_headers; 469 SpdyHeaderBlock request_headers;
470 string resource_host = "www.google.com"; 470 string resource_host = "www.google.com";
471 string partial_push_resource_path = "/server_push_src"; 471 string partial_push_resource_path = "/server_push_src";
472 std::list<QuicInMemoryCache::ServerPushInfo> push_resources; 472 std::list<QuicHttpResponseCache::ServerPushInfo> push_resources;
473 string scheme = "http"; 473 string scheme = "http";
474 for (unsigned int i = 1; i <= num_resources; ++i) { 474 for (unsigned int i = 1; i <= num_resources; ++i) {
475 QuicStreamId stream_id = i * 2; 475 QuicStreamId stream_id = i * 2;
476 string path = partial_push_resource_path + base::UintToString(i); 476 string path = partial_push_resource_path + base::UintToString(i);
477 string url = scheme + "://" + resource_host + path; 477 string url = scheme + "://" + resource_host + path;
478 GURL resource_url = GURL(url); 478 GURL resource_url = GURL(url);
479 string body; 479 string body(body_size, 'a');
480 GenerateBody(&body, body_size); 480 response_cache_.AddSimpleResponse(resource_host, path, 200, body);
481 in_memory_cache_.AddSimpleResponse(resource_host, path, 200, body); 481 push_resources.push_back(QuicHttpResponseCache::ServerPushInfo(
482 push_resources.push_back(QuicInMemoryCache::ServerPushInfo(
483 resource_url, SpdyHeaderBlock(), kDefaultPriority, body)); 482 resource_url, SpdyHeaderBlock(), kDefaultPriority, body));
484 // PUSH_PROMISED are sent for all the resources. 483 // PUSH_PROMISED are sent for all the resources.
485 EXPECT_CALL(*headers_stream_, 484 EXPECT_CALL(*headers_stream_,
486 WritePushPromiseMock(kClientDataStreamId1, stream_id, _)); 485 WritePushPromiseMock(kClientDataStreamId1, stream_id, _));
487 if (i <= kMaxStreamsForTest) { 486 if (i <= kMaxStreamsForTest) {
488 // |kMaxStreamsForTest| promised responses should be sent. 487 // |kMaxStreamsForTest| promised responses should be sent.
489 EXPECT_CALL( 488 EXPECT_CALL(
490 *headers_stream_, 489 *headers_stream_,
491 WriteHeadersMock(stream_id, _, false, kDefaultPriority, nullptr)); 490 WriteHeadersMock(stream_id, _, false, kDefaultPriority, nullptr));
492 // Since flow control window is smaller than response body, not the 491 // Since flow control window is smaller than response body, not the
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 .WillOnce(Return(QuicConsumedData(kStreamFlowControlWindowSize, false))); 622 .WillOnce(Return(QuicConsumedData(kStreamFlowControlWindowSize, false)));
624 623
625 EXPECT_CALL(*connection_, SendBlocked(stream_to_open)); 624 EXPECT_CALL(*connection_, SendBlocked(stream_to_open));
626 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0); 625 QuicRstStreamFrame rst(stream_got_reset, QUIC_STREAM_CANCELLED, 0);
627 visitor_->OnRstStream(rst); 626 visitor_->OnRstStream(rst);
628 } 627 }
629 628
630 } // namespace 629 } // namespace
631 } // namespace test 630 } // namespace test
632 } // namespace net 631 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_simple_server_session.cc ('k') | net/tools/quic/quic_simple_server_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698