| OLD | NEW |
| 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_server_session.h" | 5 #include "net/tools/quic/quic_server_session.h" |
| 6 | 6 |
| 7 #include "net/quic/crypto/quic_crypto_server_config.h" | 7 #include "net/quic/crypto/quic_crypto_server_config.h" |
| 8 #include "net/quic/crypto/quic_random.h" | 8 #include "net/quic/crypto/quic_random.h" |
| 9 #include "net/quic/quic_connection.h" | 9 #include "net/quic/quic_connection.h" |
| 10 #include "net/quic/quic_flags.h" |
| 10 #include "net/quic/quic_utils.h" | 11 #include "net/quic/quic_utils.h" |
| 12 #include "net/quic/test_tools/quic_config_peer.h" |
| 11 #include "net/quic/test_tools/quic_connection_peer.h" | 13 #include "net/quic/test_tools/quic_connection_peer.h" |
| 12 #include "net/quic/test_tools/quic_data_stream_peer.h" | 14 #include "net/quic/test_tools/quic_data_stream_peer.h" |
| 15 #include "net/quic/test_tools/quic_session_peer.h" |
| 13 #include "net/quic/test_tools/quic_test_utils.h" | 16 #include "net/quic/test_tools/quic_test_utils.h" |
| 14 #include "net/tools/quic/quic_spdy_server_stream.h" | 17 #include "net/tools/quic/quic_spdy_server_stream.h" |
| 15 #include "net/tools/quic/test_tools/quic_test_utils.h" | 18 #include "net/tools/quic/test_tools/quic_test_utils.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 21 |
| 19 using __gnu_cxx::vector; | 22 using __gnu_cxx::vector; |
| 20 using net::test::MockConnection; | 23 using net::test::MockConnection; |
| 24 using net::test::QuicConfigPeer; |
| 21 using net::test::QuicConnectionPeer; | 25 using net::test::QuicConnectionPeer; |
| 22 using net::test::QuicDataStreamPeer; | 26 using net::test::QuicDataStreamPeer; |
| 27 using net::test::QuicSessionPeer; |
| 23 using net::test::SupportedVersions; | 28 using net::test::SupportedVersions; |
| 29 using net::test::ValueRestore; |
| 24 using net::test::kClientDataStreamId1; | 30 using net::test::kClientDataStreamId1; |
| 25 using net::test::kClientDataStreamId2; | 31 using net::test::kClientDataStreamId2; |
| 26 using net::test::kClientDataStreamId3; | 32 using net::test::kClientDataStreamId3; |
| 27 using net::test::kClientDataStreamId4; | 33 using net::test::kClientDataStreamId4; |
| 28 using testing::StrictMock; | 34 using testing::StrictMock; |
| 29 using testing::_; | 35 using testing::_; |
| 30 | 36 |
| 31 namespace net { | 37 namespace net { |
| 32 namespace tools { | 38 namespace tools { |
| 33 namespace test { | 39 namespace test { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 session_.get(), kClientDataStreamId4)); | 181 session_.get(), kClientDataStreamId4)); |
| 176 } | 182 } |
| 177 | 183 |
| 178 TEST_P(QuicServerSessionTest, GetEvenIncomingError) { | 184 TEST_P(QuicServerSessionTest, GetEvenIncomingError) { |
| 179 // Incoming streams on the server session must be odd. | 185 // Incoming streams on the server session must be odd. |
| 180 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); | 186 EXPECT_CALL(*connection_, SendConnectionClose(QUIC_INVALID_STREAM_ID)); |
| 181 EXPECT_EQ(NULL, | 187 EXPECT_EQ(NULL, |
| 182 QuicServerSessionPeer::GetIncomingDataStream(session_.get(), 4)); | 188 QuicServerSessionPeer::GetIncomingDataStream(session_.get(), 4)); |
| 183 } | 189 } |
| 184 | 190 |
| 191 TEST_P(QuicServerSessionTest, SetFecProtectionFromConfig) { |
| 192 ValueRestore<bool> old_flag(&FLAGS_enable_quic_fec, true); |
| 193 |
| 194 // Set received config to have FEC connection option. |
| 195 QuicTagVector copt; |
| 196 copt.push_back(kFHDR); |
| 197 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); |
| 198 session_->OnConfigNegotiated(); |
| 199 |
| 200 // Verify that headers stream is always protected and data streams are |
| 201 // optionally protected. |
| 202 EXPECT_EQ(FEC_PROTECT_ALWAYS, |
| 203 QuicSessionPeer::GetHeadersStream(session_.get())->fec_policy()); |
| 204 QuicDataStream* stream = QuicServerSessionPeer::GetIncomingDataStream( |
| 205 session_.get(), kClientDataStreamId1); |
| 206 ASSERT_TRUE(stream); |
| 207 EXPECT_EQ(FEC_PROTECT_OPTIONAL, stream->fec_policy()); |
| 208 } |
| 209 |
| 185 } // namespace | 210 } // namespace |
| 186 } // namespace test | 211 } // namespace test |
| 187 } // namespace tools | 212 } // namespace tools |
| 188 } // namespace net | 213 } // namespace net |
| OLD | NEW |