Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: net/quic/quic_connection_test.cc

Issue 1048493002: Remove the using_pacing argument from QuicSentPacketManager::SetFromConfig because it's always true. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender_test.cc ('k') | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/quic/quic_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 2855 matching lines...) Expand 10 before | Expand all | Expand 10 after
2866 // the forward-secure encrypter is now used. 2866 // the forward-secure encrypter is now used.
2867 for (uint64 i = 0; i < 3 * congestion_window - 1; ++i) { 2867 for (uint64 i = 0; i < 3 * congestion_window - 1; ++i) {
2868 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet()); 2868 EXPECT_EQ(0x02020202u, writer_->final_bytes_of_last_packet());
2869 SendAckPacketToPeer(); 2869 SendAckPacketToPeer();
2870 } 2870 }
2871 EXPECT_EQ(0x03030303u, writer_->final_bytes_of_last_packet()); 2871 EXPECT_EQ(0x03030303u, writer_->final_bytes_of_last_packet());
2872 } 2872 }
2873 2873
2874 TEST_P(QuicConnectionTest, BufferNonDecryptablePackets) { 2874 TEST_P(QuicConnectionTest, BufferNonDecryptablePackets) {
2875 // SetFromConfig is always called after construction from InitializeSession. 2875 // SetFromConfig is always called after construction from InitializeSession.
2876 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 2876 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
2877 QuicConfig config; 2877 QuicConfig config;
2878 connection_.SetFromConfig(config); 2878 connection_.SetFromConfig(config);
2879 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2879 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2880 use_tagging_decrypter(); 2880 use_tagging_decrypter();
2881 2881
2882 const uint8 tag = 0x07; 2882 const uint8 tag = 0x07;
2883 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag)); 2883 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
2884 2884
2885 // Process an encrypted packet which can not yet be decrypted which should 2885 // Process an encrypted packet which can not yet be decrypted which should
2886 // result in the packet being buffered. 2886 // result in the packet being buffered.
2887 ProcessDataPacketAtLevel(1, 0, kEntropyFlag, ENCRYPTION_INITIAL); 2887 ProcessDataPacketAtLevel(1, 0, kEntropyFlag, ENCRYPTION_INITIAL);
2888 2888
2889 // Transition to the new encryption state and process another encrypted packet 2889 // Transition to the new encryption state and process another encrypted packet
2890 // which should result in the original packet being processed. 2890 // which should result in the original packet being processed.
2891 connection_.SetDecrypter(new StrictTaggingDecrypter(tag), 2891 connection_.SetDecrypter(new StrictTaggingDecrypter(tag),
2892 ENCRYPTION_INITIAL); 2892 ENCRYPTION_INITIAL);
2893 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL); 2893 connection_.SetDefaultEncryptionLevel(ENCRYPTION_INITIAL);
2894 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag)); 2894 connection_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
2895 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(2); 2895 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(2);
2896 ProcessDataPacketAtLevel(2, 0, kEntropyFlag, ENCRYPTION_INITIAL); 2896 ProcessDataPacketAtLevel(2, 0, kEntropyFlag, ENCRYPTION_INITIAL);
2897 2897
2898 // Finally, process a third packet and note that we do not reprocess the 2898 // Finally, process a third packet and note that we do not reprocess the
2899 // buffered packet. 2899 // buffered packet.
2900 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1); 2900 EXPECT_CALL(visitor_, OnStreamFrames(_)).Times(1);
2901 ProcessDataPacketAtLevel(3, 0, kEntropyFlag, ENCRYPTION_INITIAL); 2901 ProcessDataPacketAtLevel(3, 0, kEntropyFlag, ENCRYPTION_INITIAL);
2902 } 2902 }
2903 2903
2904 TEST_P(QuicConnectionTest, Buffer100NonDecryptablePackets) { 2904 TEST_P(QuicConnectionTest, Buffer100NonDecryptablePackets) {
2905 // SetFromConfig is always called after construction from InitializeSession. 2905 // SetFromConfig is always called after construction from InitializeSession.
2906 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 2906 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
2907 QuicConfig config; 2907 QuicConfig config;
2908 config.set_max_undecryptable_packets(100); 2908 config.set_max_undecryptable_packets(100);
2909 connection_.SetFromConfig(config); 2909 connection_.SetFromConfig(config);
2910 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2910 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2911 use_tagging_decrypter(); 2911 use_tagging_decrypter();
2912 2912
2913 const uint8 tag = 0x07; 2913 const uint8 tag = 0x07;
2914 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag)); 2914 framer_.SetEncrypter(ENCRYPTION_INITIAL, new TaggingEncrypter(tag));
2915 2915
2916 // Process an encrypted packet which can not yet be decrypted which should 2916 // Process an encrypted packet which can not yet be decrypted which should
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
3044 ProcessStopWaitingPacket(&frame); 3044 ProcessStopWaitingPacket(&frame);
3045 ASSERT_EQ(0u, connection_.NumFecGroups()); 3045 ASSERT_EQ(0u, connection_.NumFecGroups());
3046 } 3046 }
3047 3047
3048 TEST_P(QuicConnectionTest, InitialTimeout) { 3048 TEST_P(QuicConnectionTest, InitialTimeout) {
3049 EXPECT_TRUE(connection_.connected()); 3049 EXPECT_TRUE(connection_.connected());
3050 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber()); 3050 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(AnyNumber());
3051 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 3051 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
3052 3052
3053 // SetFromConfig sets the initial timeouts before negotiation. 3053 // SetFromConfig sets the initial timeouts before negotiation.
3054 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 3054 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
3055 QuicConfig config; 3055 QuicConfig config;
3056 connection_.SetFromConfig(config); 3056 connection_.SetFromConfig(config);
3057 // Subtract a second from the idle timeout on the client side. 3057 // Subtract a second from the idle timeout on the client side.
3058 QuicTime default_timeout = clock_.ApproximateNow().Add( 3058 QuicTime default_timeout = clock_.ApproximateNow().Add(
3059 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1)); 3059 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1));
3060 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline()); 3060 EXPECT_EQ(default_timeout, connection_.GetTimeoutAlarm()->deadline());
3061 3061
3062 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false)); 3062 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_CONNECTION_TIMED_OUT, false));
3063 // Simulate the timeout alarm firing. 3063 // Simulate the timeout alarm firing.
3064 clock_.AdvanceTime( 3064 clock_.AdvanceTime(
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
3156 3156
3157 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(false)); 3157 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(false));
3158 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5)); 3158 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(5));
3159 SendAckPacketToPeer(); 3159 SendAckPacketToPeer();
3160 3160
3161 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet()); 3161 EXPECT_FALSE(connection_.GetPingAlarm()->IsSet());
3162 } 3162 }
3163 3163
3164 TEST_P(QuicConnectionTest, TimeoutAfterSend) { 3164 TEST_P(QuicConnectionTest, TimeoutAfterSend) {
3165 EXPECT_TRUE(connection_.connected()); 3165 EXPECT_TRUE(connection_.connected());
3166 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 3166 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
3167 QuicConfig config; 3167 QuicConfig config;
3168 connection_.SetFromConfig(config); 3168 connection_.SetFromConfig(config);
3169 EXPECT_FALSE(QuicConnectionPeer::IsSilentCloseEnabled(&connection_)); 3169 EXPECT_FALSE(QuicConnectionPeer::IsSilentCloseEnabled(&connection_));
3170 3170
3171 const QuicTime::Delta initial_idle_timeout = 3171 const QuicTime::Delta initial_idle_timeout =
3172 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1); 3172 QuicTime::Delta::FromSeconds(kInitialIdleTimeoutSecs - 1);
3173 const QuicTime::Delta five_ms = QuicTime::Delta::FromMilliseconds(5); 3173 const QuicTime::Delta five_ms = QuicTime::Delta::FromMilliseconds(5);
3174 QuicTime default_timeout = clock_.ApproximateNow().Add(initial_idle_timeout); 3174 QuicTime default_timeout = clock_.ApproximateNow().Add(initial_idle_timeout);
3175 3175
3176 // When we send a packet, the timeout will change to 5ms + 3176 // When we send a packet, the timeout will change to 5ms +
(...skipping 21 matching lines...) Expand all
3198 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow()); 3198 EXPECT_EQ(default_timeout.Add(five_ms), clock_.ApproximateNow());
3199 connection_.GetTimeoutAlarm()->Fire(); 3199 connection_.GetTimeoutAlarm()->Fire();
3200 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 3200 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
3201 EXPECT_FALSE(connection_.connected()); 3201 EXPECT_FALSE(connection_.connected());
3202 } 3202 }
3203 3203
3204 TEST_P(QuicConnectionTest, TimeoutAfterSendSilentClose) { 3204 TEST_P(QuicConnectionTest, TimeoutAfterSendSilentClose) {
3205 // Same test as above, but complete a handshake which enables silent close, 3205 // Same test as above, but complete a handshake which enables silent close,
3206 // causing no connection close packet to be sent. 3206 // causing no connection close packet to be sent.
3207 EXPECT_TRUE(connection_.connected()); 3207 EXPECT_TRUE(connection_.connected());
3208 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 3208 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
3209 QuicConfig config; 3209 QuicConfig config;
3210 3210
3211 // Create a handshake message that also enables silent close. 3211 // Create a handshake message that also enables silent close.
3212 CryptoHandshakeMessage msg; 3212 CryptoHandshakeMessage msg;
3213 string error_details; 3213 string error_details;
3214 QuicConfig client_config; 3214 QuicConfig client_config;
3215 client_config.SetInitialStreamFlowControlWindowToSend( 3215 client_config.SetInitialStreamFlowControlWindowToSend(
3216 kInitialStreamFlowControlWindowForTest); 3216 kInitialStreamFlowControlWindowForTest);
3217 client_config.SetInitialSessionFlowControlWindowToSend( 3217 client_config.SetInitialSessionFlowControlWindowToSend(
3218 kInitialSessionFlowControlWindowForTest); 3218 kInitialSessionFlowControlWindowForTest);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
3315 // The first stream frame will have 2 fewer overhead bytes than the other six. 3315 // The first stream frame will have 2 fewer overhead bytes than the other six.
3316 const string payload(payload_length * 7 + 2, 'a'); 3316 const string payload(payload_length * 7 + 2, 'a');
3317 EXPECT_EQ(payload.size(), 3317 EXPECT_EQ(payload.size(),
3318 connection_.SendStreamDataWithString(1, payload, 0, !kFin, nullptr) 3318 connection_.SendStreamDataWithString(1, payload, 0, !kFin, nullptr)
3319 .bytes_consumed); 3319 .bytes_consumed);
3320 } 3320 }
3321 3321
3322 TEST_P(QuicConnectionTest, LoopThroughSendingPacketsWithTruncation) { 3322 TEST_P(QuicConnectionTest, LoopThroughSendingPacketsWithTruncation) {
3323 // Set up a larger payload than will fit in one packet. 3323 // Set up a larger payload than will fit in one packet.
3324 const string payload(connection_.max_packet_length(), 'a'); 3324 const string payload(connection_.max_packet_length(), 'a');
3325 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)).Times(AnyNumber()); 3325 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)).Times(AnyNumber());
3326 3326
3327 // Now send some packets with no truncation. 3327 // Now send some packets with no truncation.
3328 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); 3328 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
3329 EXPECT_EQ(payload.size(), 3329 EXPECT_EQ(payload.size(),
3330 connection_.SendStreamDataWithString( 3330 connection_.SendStreamDataWithString(
3331 3, payload, 0, !kFin, nullptr).bytes_consumed); 3331 3, payload, 0, !kFin, nullptr).bytes_consumed);
3332 // Track the size of the second packet here. The overhead will be the largest 3332 // Track the size of the second packet here. The overhead will be the largest
3333 // we see in this test, due to the non-truncated connection id. 3333 // we see in this test, due to the non-truncated connection id.
3334 size_t non_truncated_packet_size = writer_->last_packet_size(); 3334 size_t non_truncated_packet_size = writer_->last_packet_size();
3335 3335
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after
4327 4327
4328 TEST_P(QuicConnectionTest, NetworkChangeVisitorConfigCallbackChangesFecState) { 4328 TEST_P(QuicConnectionTest, NetworkChangeVisitorConfigCallbackChangesFecState) {
4329 QuicSentPacketManager::NetworkChangeVisitor* visitor = 4329 QuicSentPacketManager::NetworkChangeVisitor* visitor =
4330 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(manager_); 4330 QuicSentPacketManagerPeer::GetNetworkChangeVisitor(manager_);
4331 EXPECT_TRUE(visitor); 4331 EXPECT_TRUE(visitor);
4332 EXPECT_EQ(QuicTime::Delta::Zero(), 4332 EXPECT_EQ(QuicTime::Delta::Zero(),
4333 QuicPacketGeneratorPeer::GetFecTimeout(generator_)); 4333 QuicPacketGeneratorPeer::GetFecTimeout(generator_));
4334 4334
4335 // Verify that sending a config with a new initial rtt changes fec timeout. 4335 // Verify that sending a config with a new initial rtt changes fec timeout.
4336 // Create and process a config with a non-zero initial RTT. 4336 // Create and process a config with a non-zero initial RTT.
4337 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _, _)); 4337 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
4338 QuicConfig config; 4338 QuicConfig config;
4339 config.SetInitialRoundTripTimeUsToSend(300000); 4339 config.SetInitialRoundTripTimeUsToSend(300000);
4340 connection_.SetFromConfig(config); 4340 connection_.SetFromConfig(config);
4341 EXPECT_LT(QuicTime::Delta::Zero(), 4341 EXPECT_LT(QuicTime::Delta::Zero(),
4342 QuicPacketGeneratorPeer::GetFecTimeout(generator_)); 4342 QuicPacketGeneratorPeer::GetFecTimeout(generator_));
4343 } 4343 }
4344 4344
4345 TEST_P(QuicConnectionTest, NetworkChangeVisitorRttCallbackChangesFecState) { 4345 TEST_P(QuicConnectionTest, NetworkChangeVisitorRttCallbackChangesFecState) {
4346 // Verify that sending a config with a new initial rtt changes fec timeout. 4346 // Verify that sending a config with a new initial rtt changes fec timeout.
4347 QuicSentPacketManager::NetworkChangeVisitor* visitor = 4347 QuicSentPacketManager::NetworkChangeVisitor* visitor =
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
4407 // Regression test for b/18594622 4407 // Regression test for b/18594622
4408 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate); 4408 scoped_refptr<MockAckNotifierDelegate> delegate(new MockAckNotifierDelegate);
4409 EXPECT_DFATAL( 4409 EXPECT_DFATAL(
4410 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()), 4410 connection_.SendStreamDataWithString(3, "", 0, !kFin, delegate.get()),
4411 "Attempt to send empty stream frame"); 4411 "Attempt to send empty stream frame");
4412 } 4412 }
4413 4413
4414 } // namespace 4414 } // namespace
4415 } // namespace test 4415 } // namespace test
4416 } // namespace net 4416 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/congestion_control/tcp_cubic_sender_test.cc ('k') | net/quic/quic_http_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698