OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/quic/core/quic_config.h" | 5 #include "net/quic/core/quic_config.h" |
6 | 6 |
7 #include "net/quic/core/crypto/crypto_handshake_message.h" | 7 #include "net/quic/core/crypto/crypto_handshake_message.h" |
8 #include "net/quic/core/crypto/crypto_protocol.h" | 8 #include "net/quic/core/crypto/crypto_protocol.h" |
9 #include "net/quic/core/quic_flags.h" | 9 #include "net/quic/core/quic_flags.h" |
10 #include "net/quic/core/quic_protocol.h" | 10 #include "net/quic/core/quic_packets.h" |
11 #include "net/quic/core/quic_time.h" | 11 #include "net/quic/core/quic_time.h" |
12 #include "net/quic/core/quic_utils.h" | 12 #include "net/quic/core/quic_utils.h" |
13 #include "net/quic/test_tools/quic_config_peer.h" | 13 #include "net/quic/test_tools/quic_config_peer.h" |
14 #include "net/quic/test_tools/quic_test_utils.h" | 14 #include "net/quic/test_tools/quic_test_utils.h" |
15 #include "net/test/gtest_util.h" | 15 #include "net/test/gtest_util.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 using std::string; | 18 using std::string; |
19 | 19 |
20 namespace net { | 20 namespace net { |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 config_.ProcessPeerHello(msg, CLIENT, &error_details); | 245 config_.ProcessPeerHello(msg, CLIENT, &error_details); |
246 EXPECT_EQ(QUIC_NO_ERROR, error); | 246 EXPECT_EQ(QUIC_NO_ERROR, error); |
247 EXPECT_TRUE(config_.negotiated()); | 247 EXPECT_TRUE(config_.negotiated()); |
248 | 248 |
249 EXPECT_TRUE(config_.HasReceivedConnectionOptions()); | 249 EXPECT_TRUE(config_.HasReceivedConnectionOptions()); |
250 EXPECT_EQ(1u, config_.ReceivedConnectionOptions().size()); | 250 EXPECT_EQ(1u, config_.ReceivedConnectionOptions().size()); |
251 EXPECT_TRUE( | 251 EXPECT_TRUE( |
252 config_.HasClientSentConnectionOption(kTBBR, Perspective::IS_SERVER)); | 252 config_.HasClientSentConnectionOption(kTBBR, Perspective::IS_SERVER)); |
253 } | 253 } |
254 | 254 |
| 255 TEST_F(QuicConfigTest, DontSendClientConnectionOptions) { |
| 256 QuicConfig client_config; |
| 257 QuicTagVector copt; |
| 258 copt.push_back(kTBBR); |
| 259 client_config.SetClientConnectionOptions(copt); |
| 260 |
| 261 CryptoHandshakeMessage msg; |
| 262 client_config.ToHandshakeMessage(&msg); |
| 263 |
| 264 string error_details; |
| 265 const QuicErrorCode error = |
| 266 config_.ProcessPeerHello(msg, CLIENT, &error_details); |
| 267 EXPECT_EQ(QUIC_NO_ERROR, error); |
| 268 EXPECT_TRUE(config_.negotiated()); |
| 269 |
| 270 EXPECT_FALSE(config_.HasReceivedConnectionOptions()); |
| 271 } |
| 272 |
| 273 TEST_F(QuicConfigTest, HasClientRequestedIndependentOption) { |
| 274 QuicConfig client_config; |
| 275 QuicTagVector client_opt; |
| 276 client_opt.push_back(kRENO); |
| 277 QuicTagVector copt; |
| 278 copt.push_back(kTBBR); |
| 279 client_config.SetClientConnectionOptions(client_opt); |
| 280 client_config.SetConnectionOptionsToSend(copt); |
| 281 EXPECT_TRUE(client_config.HasClientSentConnectionOption( |
| 282 kTBBR, Perspective::IS_CLIENT)); |
| 283 EXPECT_TRUE(client_config.HasClientRequestedIndependentOption( |
| 284 kRENO, Perspective::IS_CLIENT)); |
| 285 EXPECT_FALSE(client_config.HasClientRequestedIndependentOption( |
| 286 kTBBR, Perspective::IS_CLIENT)); |
| 287 |
| 288 CryptoHandshakeMessage msg; |
| 289 client_config.ToHandshakeMessage(&msg); |
| 290 |
| 291 string error_details; |
| 292 const QuicErrorCode error = |
| 293 config_.ProcessPeerHello(msg, CLIENT, &error_details); |
| 294 EXPECT_EQ(QUIC_NO_ERROR, error); |
| 295 EXPECT_TRUE(config_.negotiated()); |
| 296 |
| 297 EXPECT_TRUE(config_.HasReceivedConnectionOptions()); |
| 298 EXPECT_EQ(1u, config_.ReceivedConnectionOptions().size()); |
| 299 EXPECT_FALSE(config_.HasClientRequestedIndependentOption( |
| 300 kRENO, Perspective::IS_SERVER)); |
| 301 EXPECT_TRUE(config_.HasClientRequestedIndependentOption( |
| 302 kTBBR, Perspective::IS_SERVER)); |
| 303 } |
| 304 |
255 } // namespace | 305 } // namespace |
256 } // namespace test | 306 } // namespace test |
257 } // namespace net | 307 } // namespace net |
OLD | NEW |