| 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/quic_config.h" | 5 #include "net/quic/quic_config.h" |
| 6 | 6 |
| 7 #include "net/quic/crypto/crypto_handshake_message.h" | 7 #include "net/quic/crypto/crypto_handshake_message.h" |
| 8 #include "net/quic/crypto/crypto_protocol.h" | 8 #include "net/quic/crypto/crypto_protocol.h" |
| 9 #include "net/quic/quic_flags.h" | 9 #include "net/quic/quic_flags.h" |
| 10 #include "net/quic/quic_protocol.h" | 10 #include "net/quic/quic_protocol.h" |
| 11 #include "net/quic/quic_time.h" | 11 #include "net/quic/quic_time.h" |
| 12 #include "net/quic/quic_utils.h" | 12 #include "net/quic/quic_utils.h" |
| 13 #include "net/quic/test_tools/quic_test_utils.h" | 13 #include "net/quic/test_tools/quic_test_utils.h" |
| 14 #include "net/test/gtest_util.h" | 14 #include "net/test/gtest_util.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 16 |
| 17 using std::string; | 17 using std::string; |
| 18 | 18 |
| 19 namespace net { | 19 namespace net { |
| 20 namespace test { | 20 namespace test { |
| 21 namespace { | 21 namespace { |
| 22 | 22 |
| 23 class QuicConfigTest : public ::testing::Test { | 23 class QuicConfigTest : public ::testing::Test { |
| 24 protected: | 24 protected: |
| 25 QuicConfigTest() { | |
| 26 config_.SetDefaults(); | |
| 27 } | |
| 28 | |
| 29 QuicConfig config_; | 25 QuicConfig config_; |
| 30 }; | 26 }; |
| 31 | 27 |
| 32 TEST_F(QuicConfigTest, ToHandshakeMessage) { | 28 TEST_F(QuicConfigTest, ToHandshakeMessage) { |
| 33 config_.SetDefaults(); | |
| 34 config_.SetInitialFlowControlWindowToSend( | 29 config_.SetInitialFlowControlWindowToSend( |
| 35 kInitialSessionFlowControlWindowForTest); | 30 kInitialSessionFlowControlWindowForTest); |
| 36 config_.SetInitialStreamFlowControlWindowToSend( | 31 config_.SetInitialStreamFlowControlWindowToSend( |
| 37 kInitialStreamFlowControlWindowForTest); | 32 kInitialStreamFlowControlWindowForTest); |
| 38 config_.SetInitialSessionFlowControlWindowToSend( | 33 config_.SetInitialSessionFlowControlWindowToSend( |
| 39 kInitialSessionFlowControlWindowForTest); | 34 kInitialSessionFlowControlWindowForTest); |
| 40 config_.SetIdleConnectionStateLifetime(QuicTime::Delta::FromSeconds(5), | 35 config_.SetIdleConnectionStateLifetime(QuicTime::Delta::FromSeconds(5), |
| 41 QuicTime::Delta::FromSeconds(2)); | 36 QuicTime::Delta::FromSeconds(2)); |
| 42 config_.SetMaxStreamsPerConnection(4, 2); | 37 config_.SetMaxStreamsPerConnection(4, 2); |
| 43 config_.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer); | 38 config_.SetSocketReceiveBufferToSend(kDefaultSocketReceiveBuffer); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 CryptoHandshakeMessage msg; | 253 CryptoHandshakeMessage msg; |
| 259 server_config.ToHandshakeMessage(&msg); | 254 server_config.ToHandshakeMessage(&msg); |
| 260 string error_details; | 255 string error_details; |
| 261 const QuicErrorCode error = | 256 const QuicErrorCode error = |
| 262 config_.ProcessPeerHello(msg, SERVER, &error_details); | 257 config_.ProcessPeerHello(msg, SERVER, &error_details); |
| 263 EXPECT_EQ(QUIC_INVALID_NEGOTIATED_VALUE, error); | 258 EXPECT_EQ(QUIC_INVALID_NEGOTIATED_VALUE, error); |
| 264 } | 259 } |
| 265 | 260 |
| 266 TEST_F(QuicConfigTest, NoOverLapInCGST) { | 261 TEST_F(QuicConfigTest, NoOverLapInCGST) { |
| 267 QuicConfig server_config; | 262 QuicConfig server_config; |
| 268 server_config.SetDefaults(); | |
| 269 QuicTagVector cgst; | 263 QuicTagVector cgst; |
| 270 cgst.push_back(kTBBR); | 264 cgst.push_back(kTBBR); |
| 271 server_config.SetCongestionFeedback(cgst, kTBBR); | 265 server_config.SetCongestionFeedback(cgst, kTBBR); |
| 272 | 266 |
| 273 CryptoHandshakeMessage msg; | 267 CryptoHandshakeMessage msg; |
| 274 string error_details; | 268 string error_details; |
| 275 server_config.ToHandshakeMessage(&msg); | 269 server_config.ToHandshakeMessage(&msg); |
| 276 const QuicErrorCode error = | 270 const QuicErrorCode error = |
| 277 config_.ProcessPeerHello(msg, CLIENT, &error_details); | 271 config_.ProcessPeerHello(msg, CLIENT, &error_details); |
| 278 DVLOG(1) << QuicUtils::ErrorToString(error); | 272 DVLOG(1) << QuicUtils::ErrorToString(error); |
| 279 EXPECT_EQ(QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP, error); | 273 EXPECT_EQ(QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP, error); |
| 280 } | 274 } |
| 281 | 275 |
| 282 TEST_F(QuicConfigTest, InvalidFlowControlWindow) { | 276 TEST_F(QuicConfigTest, InvalidFlowControlWindow) { |
| 283 // QuicConfig should not accept an invalid flow control window to send to the | 277 // QuicConfig should not accept an invalid flow control window to send to the |
| 284 // peer: the receive window must be at least the default of 16 Kb. | 278 // peer: the receive window must be at least the default of 16 Kb. |
| 285 QuicConfig config; | 279 QuicConfig config; |
| 286 const uint64 kInvalidWindow = kDefaultFlowControlSendWindow - 1; | 280 const uint64 kInvalidWindow = kDefaultFlowControlSendWindow - 1; |
| 287 EXPECT_DFATAL(config.SetInitialFlowControlWindowToSend(kInvalidWindow), | 281 EXPECT_DFATAL(config.SetInitialFlowControlWindowToSend(kInvalidWindow), |
| 288 "Initial flow control receive window"); | 282 "Initial flow control receive window"); |
| 289 | 283 |
| 290 EXPECT_EQ(kDefaultFlowControlSendWindow, | 284 EXPECT_EQ(kDefaultFlowControlSendWindow, |
| 291 config.GetInitialFlowControlWindowToSend()); | 285 config.GetInitialFlowControlWindowToSend()); |
| 292 } | 286 } |
| 293 | 287 |
| 294 } // namespace | 288 } // namespace |
| 295 } // namespace test | 289 } // namespace test |
| 296 } // namespace net | 290 } // namespace net |
| OLD | NEW |