| 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 "net/base/ip_endpoint.h" | 9 #include "net/base/ip_endpoint.h" |
| 10 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" | 10 #include "net/quic/crypto/aes_128_gcm_12_encrypter.h" |
| 11 #include "net/quic/quic_flags.h" |
| 11 #include "net/quic/test_tools/crypto_test_utils.h" | 12 #include "net/quic/test_tools/crypto_test_utils.h" |
| 13 #include "net/quic/test_tools/quic_session_peer.h" |
| 12 #include "net/quic/test_tools/quic_test_utils.h" | 14 #include "net/quic/test_tools/quic_test_utils.h" |
| 13 #include "net/tools/quic/quic_spdy_client_stream.h" | 15 #include "net/tools/quic/quic_spdy_client_stream.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 17 |
| 16 using net::test::CryptoTestUtils; | 18 using net::test::CryptoTestUtils; |
| 17 using net::test::DefaultQuicConfig; | 19 using net::test::DefaultQuicConfig; |
| 18 using net::test::PacketSavingConnection; | 20 using net::test::PacketSavingConnection; |
| 21 using net::test::QuicSessionPeer; |
| 19 using net::test::SupportedVersions; | 22 using net::test::SupportedVersions; |
| 23 using net::test::ValueRestore; |
| 20 using testing::_; | 24 using testing::_; |
| 21 | 25 |
| 22 namespace net { | 26 namespace net { |
| 23 namespace tools { | 27 namespace tools { |
| 24 namespace test { | 28 namespace test { |
| 25 namespace { | 29 namespace { |
| 26 | 30 |
| 27 const char kServerHostname[] = "www.example.com"; | 31 const char kServerHostname[] = "www.example.com"; |
| 28 const uint16 kPort = 80; | 32 const uint16 kPort = 80; |
| 29 | 33 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 | 83 |
| 80 TEST_P(ToolsQuicClientSessionTest, GoAwayReceived) { | 84 TEST_P(ToolsQuicClientSessionTest, GoAwayReceived) { |
| 81 CompleteCryptoHandshake(); | 85 CompleteCryptoHandshake(); |
| 82 | 86 |
| 83 // After receiving a GoAway, I should no longer be able to create outgoing | 87 // After receiving a GoAway, I should no longer be able to create outgoing |
| 84 // streams. | 88 // streams. |
| 85 session_->OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); | 89 session_->OnGoAway(QuicGoAwayFrame(QUIC_PEER_GOING_AWAY, 1u, "Going away.")); |
| 86 EXPECT_EQ(NULL, session_->CreateOutgoingDataStream()); | 90 EXPECT_EQ(NULL, session_->CreateOutgoingDataStream()); |
| 87 } | 91 } |
| 88 | 92 |
| 93 TEST_P(ToolsQuicClientSessionTest, SetFecProtectionFromConfig) { |
| 94 ValueRestore<bool> old_flag(&FLAGS_enable_quic_fec, true); |
| 95 |
| 96 // Set FEC config in client's connection options. |
| 97 QuicTagVector copt; |
| 98 copt.push_back(kFHDR); |
| 99 session_->config()->SetConnectionOptionsToSend(copt); |
| 100 |
| 101 // Doing the handshake should set up FEC config correctly. |
| 102 CompleteCryptoHandshake(); |
| 103 |
| 104 // Verify that headers stream is always protected and data streams are |
| 105 // optionally protected. |
| 106 EXPECT_EQ(FEC_PROTECT_ALWAYS, |
| 107 QuicSessionPeer::GetHeadersStream(session_.get())->fec_policy()); |
| 108 QuicSpdyClientStream* stream = session_->CreateOutgoingDataStream(); |
| 109 ASSERT_TRUE(stream); |
| 110 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream->fec_policy()); |
| 111 } |
| 112 |
| 89 } // namespace | 113 } // namespace |
| 90 } // namespace test | 114 } // namespace test |
| 91 } // namespace tools | 115 } // namespace tools |
| 92 } // namespace net | 116 } // namespace net |
| OLD | NEW |