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

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

Issue 1761263002: Landing recent QUIC changes until 7:19 PM, Feb 26, 2016 UTC-5. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add ActivateStream() call to QuicChromiumClientSession to fix server push failure Created 4 years, 9 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/tools/quic/quic_client_session.cc ('k') | net/tools/quic/quic_client_test.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 (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/tools/quic/quic_client_session.h" 5 #include "net/tools/quic/quic_client_session.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "net/base/ip_endpoint.h" 10 #include "net/base/ip_endpoint.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 server_id, 62 server_id,
63 crypto_config, 63 crypto_config,
64 push_promise_index) {} 64 push_promise_index) {}
65 65
66 QuicSpdyClientStream* CreateClientStream() override { 66 QuicSpdyClientStream* CreateClientStream() override {
67 return new MockQuicSpdyClientStream(GetNextOutgoingStreamId(), this); 67 return new MockQuicSpdyClientStream(GetNextOutgoingStreamId(), this);
68 } 68 }
69 69
70 MockQuicSpdyClientStream* CreateIncomingDynamicStream( 70 MockQuicSpdyClientStream* CreateIncomingDynamicStream(
71 QuicStreamId id) override { 71 QuicStreamId id) override {
72 return new MockQuicSpdyClientStream(id, this); 72 MockQuicSpdyClientStream* stream = new MockQuicSpdyClientStream(id, this);
73 ActivateStream(stream);
74 return stream;
73 } 75 }
74 }; 76 };
75 77
76 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> { 78 class QuicClientSessionTest : public ::testing::TestWithParam<QuicVersion> {
77 protected: 79 protected:
78 QuicClientSessionTest() 80 QuicClientSessionTest()
79 : crypto_config_(CryptoTestUtils::ProofVerifierForTesting()), 81 : crypto_config_(CryptoTestUtils::ProofVerifierForTesting()),
80 promised_stream_id_(kServerDataStreamId1), 82 promised_stream_id_(kServerDataStreamId1),
81 associated_stream_id_(kClientDataStreamId1) { 83 associated_stream_id_(kClientDataStreamId1) {
82 Initialize(); 84 Initialize();
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 TEST_P(QuicClientSessionTest, GoAwayReceived) { 226 TEST_P(QuicClientSessionTest, GoAwayReceived) {
225 CompleteCryptoHandshake(); 227 CompleteCryptoHandshake();
226 228
227 // After receiving a GoAway, I should no longer be able to create outgoing 229 // After receiving a GoAway, I should no longer be able to create outgoing
228 // streams. 230 // streams.
229 session_->connection()->OnGoAwayFrame( 231 session_->connection()->OnGoAwayFrame(
230 QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); 232 QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away."));
231 EXPECT_EQ(nullptr, session_->CreateOutgoingDynamicStream(kDefaultPriority)); 233 EXPECT_EQ(nullptr, session_->CreateOutgoingDynamicStream(kDefaultPriority));
232 } 234 }
233 235
234 TEST_P(QuicClientSessionTest, SetFecProtectionFromConfig) {
235 ValueRestore<bool> old_flag(&FLAGS_enable_quic_fec, true);
236
237 // Set FEC config in client's connection options.
238 QuicTagVector copt;
239 copt.push_back(kFHDR);
240 session_->config()->SetConnectionOptionsToSend(copt);
241
242 // Doing the handshake should set up FEC config correctly.
243 CompleteCryptoHandshake();
244
245 // Verify that headers stream is always protected and data streams are
246 // optionally protected.
247 EXPECT_EQ(
248 FEC_PROTECT_ALWAYS,
249 QuicSpdySessionPeer::GetHeadersStream(session_.get())->fec_policy());
250 QuicSpdyClientStream* stream =
251 session_->CreateOutgoingDynamicStream(kDefaultPriority);
252 ASSERT_TRUE(stream);
253 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream->fec_policy());
254 }
255
256 static bool CheckForDecryptionError(QuicFramer* framer) { 236 static bool CheckForDecryptionError(QuicFramer* framer) {
257 return framer->error() == QUIC_DECRYPTION_FAILURE; 237 return framer->error() == QUIC_DECRYPTION_FAILURE;
258 } 238 }
259 239
260 // Regression test for b/17206611. 240 // Regression test for b/17206611.
261 TEST_P(QuicClientSessionTest, InvalidPacketReceived) { 241 TEST_P(QuicClientSessionTest, InvalidPacketReceived) {
262 IPEndPoint server_address(TestPeerIPAddress(), kTestPort); 242 IPEndPoint server_address(TestPeerIPAddress(), kTestPort);
263 IPEndPoint client_address(TestPeerIPAddress(), kTestPort); 243 IPEndPoint client_address(TestPeerIPAddress(), kTestPort);
264 244
265 EXPECT_CALL(*connection_, ProcessUdpPacket(server_address, client_address, _)) 245 EXPECT_CALL(*connection_, ProcessUdpPacket(server_address, client_address, _))
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 QuicClientPromisedInfo* promised = 492 QuicClientPromisedInfo* promised =
513 session_->GetPromisedById(promised_stream_id_); 493 session_->GetPromisedById(promised_stream_id_);
514 EXPECT_NE(promised, nullptr); 494 EXPECT_NE(promised, nullptr);
515 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); 495 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr);
516 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); 496 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr);
517 } 497 }
518 498
519 } // namespace 499 } // namespace
520 } // namespace test 500 } // namespace test
521 } // namespace net 501 } // namespace net
OLDNEW
« no previous file with comments | « net/tools/quic/quic_client_session.cc ('k') | net/tools/quic/quic_client_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698