| OLD | NEW |
| 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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 TEST_P(QuicClientSessionTest, GoAwayReceived) { | 226 TEST_P(QuicClientSessionTest, GoAwayReceived) { |
| 227 CompleteCryptoHandshake(); | 227 CompleteCryptoHandshake(); |
| 228 | 228 |
| 229 // 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 |
| 230 // streams. | 230 // streams. |
| 231 session_->connection()->OnGoAwayFrame( | 231 session_->connection()->OnGoAwayFrame( |
| 232 QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); | 232 QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); |
| 233 EXPECT_EQ(nullptr, session_->CreateOutgoingDynamicStream(kDefaultPriority)); | 233 EXPECT_EQ(nullptr, session_->CreateOutgoingDynamicStream(kDefaultPriority)); |
| 234 } | 234 } |
| 235 | 235 |
| 236 TEST_P(QuicClientSessionTest, SetFecProtectionFromConfig) { | |
| 237 ValueRestore<bool> old_flag(&FLAGS_enable_quic_fec, true); | |
| 238 | |
| 239 // Set FEC config in client's connection options. | |
| 240 QuicTagVector copt; | |
| 241 copt.push_back(kFHDR); | |
| 242 session_->config()->SetConnectionOptionsToSend(copt); | |
| 243 | |
| 244 // Doing the handshake should set up FEC config correctly. | |
| 245 CompleteCryptoHandshake(); | |
| 246 | |
| 247 // Verify that headers stream is always protected and data streams are | |
| 248 // optionally protected. | |
| 249 EXPECT_EQ( | |
| 250 FEC_PROTECT_ALWAYS, | |
| 251 QuicSpdySessionPeer::GetHeadersStream(session_.get())->fec_policy()); | |
| 252 QuicSpdyClientStream* stream = | |
| 253 session_->CreateOutgoingDynamicStream(kDefaultPriority); | |
| 254 ASSERT_TRUE(stream); | |
| 255 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream->fec_policy()); | |
| 256 } | |
| 257 | |
| 258 static bool CheckForDecryptionError(QuicFramer* framer) { | 236 static bool CheckForDecryptionError(QuicFramer* framer) { |
| 259 return framer->error() == QUIC_DECRYPTION_FAILURE; | 237 return framer->error() == QUIC_DECRYPTION_FAILURE; |
| 260 } | 238 } |
| 261 | 239 |
| 262 // Regression test for b/17206611. | 240 // Regression test for b/17206611. |
| 263 TEST_P(QuicClientSessionTest, InvalidPacketReceived) { | 241 TEST_P(QuicClientSessionTest, InvalidPacketReceived) { |
| 264 IPEndPoint server_address(TestPeerIPAddress(), kTestPort); | 242 IPEndPoint server_address(TestPeerIPAddress(), kTestPort); |
| 265 IPEndPoint client_address(TestPeerIPAddress(), kTestPort); | 243 IPEndPoint client_address(TestPeerIPAddress(), kTestPort); |
| 266 | 244 |
| 267 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 Loading... |
| 514 QuicClientPromisedInfo* promised = | 492 QuicClientPromisedInfo* promised = |
| 515 session_->GetPromisedById(promised_stream_id_); | 493 session_->GetPromisedById(promised_stream_id_); |
| 516 EXPECT_NE(promised, nullptr); | 494 EXPECT_NE(promised, nullptr); |
| 517 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); | 495 EXPECT_NE(session_->GetPromisedByUrl(promise_url_), nullptr); |
| 518 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); | 496 EXPECT_EQ(session_->GetPromisedStream(promised_stream_id_), nullptr); |
| 519 } | 497 } |
| 520 | 498 |
| 521 } // namespace | 499 } // namespace |
| 522 } // namespace test | 500 } // namespace test |
| 523 } // namespace net | 501 } // namespace net |
| OLD | NEW |