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

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

Issue 471293002: Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
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/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 const char data1[] = "foo"; 51 const char data1[] = "foo";
52 const char data2[] = "bar"; 52 const char data2[] = "bar";
53 53
54 const bool kFin = true; 54 const bool kFin = true;
55 const bool kEntropyFlag = true; 55 const bool kEntropyFlag = true;
56 56
57 const QuicPacketEntropyHash kTestEntropyHash = 76; 57 const QuicPacketEntropyHash kTestEntropyHash = 76;
58 58
59 const int kDefaultRetransmissionTimeMs = 500; 59 const int kDefaultRetransmissionTimeMs = 500;
60 const int kMinRetransmissionTimeMs = 200;
61 60
62 class TestReceiveAlgorithm : public ReceiveAlgorithmInterface { 61 class TestReceiveAlgorithm : public ReceiveAlgorithmInterface {
63 public: 62 public:
64 explicit TestReceiveAlgorithm(QuicCongestionFeedbackFrame* feedback) 63 explicit TestReceiveAlgorithm(QuicCongestionFeedbackFrame* feedback)
65 : feedback_(feedback) { 64 : feedback_(feedback) {
66 } 65 }
67 66
68 bool GenerateCongestionFeedback( 67 bool GenerateCongestionFeedback(
69 QuicCongestionFeedbackFrame* congestion_feedback) { 68 QuicCongestionFeedbackFrame* congestion_feedback) {
70 if (feedback_ == NULL) { 69 if (feedback_ == NULL) {
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 void SetFeedback(QuicCongestionFeedbackFrame* feedback) { 877 void SetFeedback(QuicCongestionFeedbackFrame* feedback) {
879 receive_algorithm_ = new TestReceiveAlgorithm(feedback); 878 receive_algorithm_ = new TestReceiveAlgorithm(feedback);
880 connection_.SetReceiveAlgorithm(receive_algorithm_); 879 connection_.SetReceiveAlgorithm(receive_algorithm_);
881 } 880 }
882 881
883 QuicTime::Delta DefaultRetransmissionTime() { 882 QuicTime::Delta DefaultRetransmissionTime() {
884 return QuicTime::Delta::FromMilliseconds(kDefaultRetransmissionTimeMs); 883 return QuicTime::Delta::FromMilliseconds(kDefaultRetransmissionTimeMs);
885 } 884 }
886 885
887 QuicTime::Delta DefaultDelayedAckTime() { 886 QuicTime::Delta DefaultDelayedAckTime() {
888 return QuicTime::Delta::FromMilliseconds(kMinRetransmissionTimeMs/2); 887 return QuicTime::Delta::FromMilliseconds(kMaxDelayedAckTime);
889 } 888 }
890 889
891 // Initialize a frame acknowledging all packets up to largest_observed. 890 // Initialize a frame acknowledging all packets up to largest_observed.
892 const QuicAckFrame InitAckFrame(QuicPacketSequenceNumber largest_observed) { 891 const QuicAckFrame InitAckFrame(QuicPacketSequenceNumber largest_observed) {
893 QuicAckFrame frame(MakeAckFrame(largest_observed)); 892 QuicAckFrame frame(MakeAckFrame(largest_observed));
894 if (largest_observed > 0) { 893 if (largest_observed > 0) {
895 frame.entropy_hash = 894 frame.entropy_hash =
896 QuicConnectionPeer::GetSentEntropyHash(&connection_, 895 QuicConnectionPeer::GetSentEntropyHash(&connection_,
897 largest_observed); 896 largest_observed);
898 } 897 }
(...skipping 3056 matching lines...) Expand 10 before | Expand all | Expand 10 after
3955 connection_.OnPacketHeader(header); 3954 connection_.OnPacketHeader(header);
3956 } 3955 }
3957 3956
3958 TEST_P(QuicConnectionTest, Pacing) { 3957 TEST_P(QuicConnectionTest, Pacing) {
3959 ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true); 3958 ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true);
3960 3959
3961 TestConnection server(connection_id_, IPEndPoint(), helper_.get(), 3960 TestConnection server(connection_id_, IPEndPoint(), helper_.get(),
3962 writer_.get(), true, version()); 3961 writer_.get(), true, version());
3963 TestConnection client(connection_id_, IPEndPoint(), helper_.get(), 3962 TestConnection client(connection_id_, IPEndPoint(), helper_.get(),
3964 writer_.get(), false, version()); 3963 writer_.get(), false, version());
3965 EXPECT_TRUE(client.sent_packet_manager().using_pacing()); 3964 EXPECT_FALSE(client.sent_packet_manager().using_pacing());
3966 EXPECT_FALSE(server.sent_packet_manager().using_pacing()); 3965 EXPECT_FALSE(server.sent_packet_manager().using_pacing());
3967 } 3966 }
3968 3967
3969 TEST_P(QuicConnectionTest, ControlFramesInstigateAcks) { 3968 TEST_P(QuicConnectionTest, ControlFramesInstigateAcks) {
3970 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3969 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3971 3970
3972 // Send a WINDOW_UPDATE frame. 3971 // Send a WINDOW_UPDATE frame.
3973 QuicWindowUpdateFrame window_update; 3972 QuicWindowUpdateFrame window_update;
3974 window_update.stream_id = 3; 3973 window_update.stream_id = 3;
3975 window_update.byte_offset = 1234; 3974 window_update.byte_offset = 1234;
3976 EXPECT_CALL(visitor_, OnWindowUpdateFrames(_)); 3975 EXPECT_CALL(visitor_, OnWindowUpdateFrames(_));
3977 ProcessFramePacket(QuicFrame(&window_update)); 3976 ProcessFramePacket(QuicFrame(&window_update));
3978 3977
3979 // Ensure that this has caused the ACK alarm to be set. 3978 // Ensure that this has caused the ACK alarm to be set.
3980 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_); 3979 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_);
3981 EXPECT_TRUE(ack_alarm->IsSet()); 3980 EXPECT_TRUE(ack_alarm->IsSet());
3982 3981
3983 // Cancel alarm, and try again with BLOCKED frame. 3982 // Cancel alarm, and try again with BLOCKED frame.
3984 ack_alarm->Cancel(); 3983 ack_alarm->Cancel();
3985 QuicBlockedFrame blocked; 3984 QuicBlockedFrame blocked;
3986 blocked.stream_id = 3; 3985 blocked.stream_id = 3;
3987 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 3986 EXPECT_CALL(visitor_, OnBlockedFrames(_));
3988 ProcessFramePacket(QuicFrame(&blocked)); 3987 ProcessFramePacket(QuicFrame(&blocked));
3989 EXPECT_TRUE(ack_alarm->IsSet()); 3988 EXPECT_TRUE(ack_alarm->IsSet());
3990 } 3989 }
3991 3990
3992 } // namespace 3991 } // namespace
3993 } // namespace test 3992 } // namespace test
3994 } // namespace net 3993 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698