| 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/quic/core/quic_server_session_base.h" | 5 #include "net/quic/core/quic_server_session_base.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 StrictMock<MockQuicCryptoServerStreamHelper> stream_helper_; | 155 StrictMock<MockQuicCryptoServerStreamHelper> stream_helper_; |
| 156 MockQuicConnectionHelper helper_; | 156 MockQuicConnectionHelper helper_; |
| 157 MockAlarmFactory alarm_factory_; | 157 MockAlarmFactory alarm_factory_; |
| 158 StrictMock<MockQuicConnection>* connection_; | 158 StrictMock<MockQuicConnection>* connection_; |
| 159 QuicConfig config_; | 159 QuicConfig config_; |
| 160 QuicCryptoServerConfig crypto_config_; | 160 QuicCryptoServerConfig crypto_config_; |
| 161 QuicCompressedCertsCache compressed_certs_cache_; | 161 QuicCompressedCertsCache compressed_certs_cache_; |
| 162 std::unique_ptr<TestServerSession> session_; | 162 std::unique_ptr<TestServerSession> session_; |
| 163 std::unique_ptr<CryptoHandshakeMessage> handshake_message_; | 163 std::unique_ptr<CryptoHandshakeMessage> handshake_message_; |
| 164 QuicConnectionVisitorInterface* visitor_; | 164 QuicConnectionVisitorInterface* visitor_; |
| 165 QuicFlagSaver flags_; // Save/restore all QUIC flag values. |
| 165 }; | 166 }; |
| 166 | 167 |
| 167 // Compares CachedNetworkParameters. | 168 // Compares CachedNetworkParameters. |
| 168 MATCHER_P(EqualsProto, network_params, "") { | 169 MATCHER_P(EqualsProto, network_params, "") { |
| 169 CachedNetworkParameters reference(network_params); | 170 CachedNetworkParameters reference(network_params); |
| 170 return (arg->bandwidth_estimate_bytes_per_second() == | 171 return (arg->bandwidth_estimate_bytes_per_second() == |
| 171 reference.bandwidth_estimate_bytes_per_second() && | 172 reference.bandwidth_estimate_bytes_per_second() && |
| 172 arg->bandwidth_estimate_bytes_per_second() == | 173 arg->bandwidth_estimate_bytes_per_second() == |
| 173 reference.bandwidth_estimate_bytes_per_second() && | 174 reference.bandwidth_estimate_bytes_per_second() && |
| 174 arg->max_bandwidth_estimate_bytes_per_second() == | 175 arg->max_bandwidth_estimate_bytes_per_second() == |
| 175 reference.max_bandwidth_estimate_bytes_per_second() && | 176 reference.max_bandwidth_estimate_bytes_per_second() && |
| 176 arg->max_bandwidth_timestamp_seconds() == | 177 arg->max_bandwidth_timestamp_seconds() == |
| 177 reference.max_bandwidth_timestamp_seconds() && | 178 reference.max_bandwidth_timestamp_seconds() && |
| 178 arg->min_rtt_ms() == reference.min_rtt_ms() && | 179 arg->min_rtt_ms() == reference.min_rtt_ms() && |
| 179 arg->previous_connection_state() == | 180 arg->previous_connection_state() == |
| 180 reference.previous_connection_state()); | 181 reference.previous_connection_state()); |
| 181 } | 182 } |
| 182 | 183 |
| 183 INSTANTIATE_TEST_CASE_P(Tests, | 184 INSTANTIATE_TEST_CASE_P(Tests, |
| 184 QuicServerSessionBaseTest, | 185 QuicServerSessionBaseTest, |
| 185 ::testing::ValuesIn(AllSupportedVersions())); | 186 ::testing::ValuesIn(AllSupportedVersions())); |
| 186 | 187 |
| 187 TEST_P(QuicServerSessionBaseTest, ServerPushDisabledByDefault) { | 188 TEST_P(QuicServerSessionBaseTest, ServerPushDisabledByDefault) { |
| 189 FLAGS_quic_enable_server_push_by_default = true; |
| 188 // Without the client explicitly sending kSPSH, server push will be disabled | 190 // Without the client explicitly sending kSPSH, server push will be disabled |
| 189 // at the server. | 191 // at the server, until version 35 when it is enabled by default. |
| 190 EXPECT_FALSE( | 192 EXPECT_FALSE( |
| 191 session_->config()->HasReceivedConnectionOptions() && | 193 session_->config()->HasReceivedConnectionOptions() && |
| 192 ContainsQuicTag(session_->config()->ReceivedConnectionOptions(), kSPSH)); | 194 ContainsQuicTag(session_->config()->ReceivedConnectionOptions(), kSPSH)); |
| 193 session_->OnConfigNegotiated(); | 195 session_->OnConfigNegotiated(); |
| 194 EXPECT_FALSE(session_->server_push_enabled()); | 196 if (GetParam() <= QUIC_VERSION_34) { |
| 197 EXPECT_FALSE(session_->server_push_enabled()); |
| 198 } else { |
| 199 EXPECT_TRUE(session_->server_push_enabled()); |
| 200 } |
| 195 } | 201 } |
| 196 | 202 |
| 197 TEST_P(QuicServerSessionBaseTest, CloseStreamDueToReset) { | 203 TEST_P(QuicServerSessionBaseTest, CloseStreamDueToReset) { |
| 198 // Open a stream, then reset it. | 204 // Open a stream, then reset it. |
| 199 // Send two bytes of payload to open it. | 205 // Send two bytes of payload to open it. |
| 200 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); | 206 QuicStreamFrame data1(kClientDataStreamId1, false, 0, StringPiece("HT")); |
| 201 session_->OnStreamFrame(data1); | 207 session_->OnStreamFrame(data1); |
| 202 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); | 208 EXPECT_EQ(1u, session_->GetNumOpenIncomingStreams()); |
| 203 | 209 |
| 204 // Send a reset (and expect the peer to send a RST in response). | 210 // Send a reset (and expect the peer to send a RST in response). |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 341 |
| 336 // A further available stream will result in connection close. | 342 // A further available stream will result in connection close. |
| 337 EXPECT_CALL(*connection_, | 343 EXPECT_CALL(*connection_, |
| 338 CloseConnection(QUIC_TOO_MANY_AVAILABLE_STREAMS, _, _)); | 344 CloseConnection(QUIC_TOO_MANY_AVAILABLE_STREAMS, _, _)); |
| 339 // This forces stream kLimitingStreamId + 2 to become available, which | 345 // This forces stream kLimitingStreamId + 2 to become available, which |
| 340 // violates the quota. | 346 // violates the quota. |
| 341 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( | 347 EXPECT_FALSE(QuicServerSessionBasePeer::GetOrCreateDynamicStream( |
| 342 session_.get(), kLimitingStreamId + 4)); | 348 session_.get(), kLimitingStreamId + 4)); |
| 343 } | 349 } |
| 344 | 350 |
| 351 // TODO(ckrasic): remove this when |
| 352 // FLAGS_quic_enable_server_push_by_default is |
| 353 // deprecated. |
| 345 TEST_P(QuicServerSessionBaseTest, EnableServerPushThroughConnectionOption) { | 354 TEST_P(QuicServerSessionBaseTest, EnableServerPushThroughConnectionOption) { |
| 355 FLAGS_quic_enable_server_push_by_default = false; |
| 346 // Assume server received server push connection option. | 356 // Assume server received server push connection option. |
| 347 QuicTagVector copt; | 357 QuicTagVector copt; |
| 348 copt.push_back(kSPSH); | 358 copt.push_back(kSPSH); |
| 349 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); | 359 QuicConfigPeer::SetReceivedConnectionOptions(session_->config(), copt); |
| 350 session_->OnConfigNegotiated(); | 360 session_->OnConfigNegotiated(); |
| 351 EXPECT_TRUE(session_->server_push_enabled()); | 361 EXPECT_TRUE(session_->server_push_enabled()); |
| 352 } | 362 } |
| 353 | 363 |
| 354 TEST_P(QuicServerSessionBaseTest, GetEvenIncomingError) { | 364 TEST_P(QuicServerSessionBaseTest, GetEvenIncomingError) { |
| 355 // Incoming streams on the server session must be odd. | 365 // Incoming streams on the server session must be odd. |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 EXPECT_FALSE( | 568 EXPECT_FALSE( |
| 559 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 569 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
| 560 session_->OnConfigNegotiated(); | 570 session_->OnConfigNegotiated(); |
| 561 EXPECT_FALSE( | 571 EXPECT_FALSE( |
| 562 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); | 572 QuicServerSessionBasePeer::IsBandwidthResumptionEnabled(session_.get())); |
| 563 } | 573 } |
| 564 | 574 |
| 565 } // namespace | 575 } // namespace |
| 566 } // namespace test | 576 } // namespace test |
| 567 } // namespace net | 577 } // namespace net |
| OLD | NEW |