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

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

Issue 1330973002: relnote: Refactor QuicAckFrame::missing_packets to support a change to a (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Tidy_up_DLOG_messages_101773586
Patch Set: Created 5 years, 3 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 <ostream> 7 #include <ostream>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 966
967 const QuicStopWaitingFrame InitStopWaitingFrame( 967 const QuicStopWaitingFrame InitStopWaitingFrame(
968 QuicPacketNumber least_unacked) { 968 QuicPacketNumber least_unacked) {
969 QuicStopWaitingFrame frame; 969 QuicStopWaitingFrame frame;
970 frame.least_unacked = least_unacked; 970 frame.least_unacked = least_unacked;
971 return frame; 971 return frame;
972 } 972 }
973 973
974 // Explicitly nack a packet. 974 // Explicitly nack a packet.
975 void NackPacket(QuicPacketNumber missing, QuicAckFrame* frame) { 975 void NackPacket(QuicPacketNumber missing, QuicAckFrame* frame) {
976 frame->missing_packets.insert(missing); 976 frame->missing_packets.Add(missing);
977 frame->entropy_hash ^= 977 frame->entropy_hash ^=
978 QuicConnectionPeer::PacketEntropy(&connection_, missing); 978 QuicConnectionPeer::PacketEntropy(&connection_, missing);
979 } 979 }
980 980
981 // Undo nacking a packet within the frame. 981 // Undo nacking a packet within the frame.
982 void AckPacket(QuicPacketNumber arrived, QuicAckFrame* frame) { 982 void AckPacket(QuicPacketNumber arrived, QuicAckFrame* frame) {
983 EXPECT_THAT(frame->missing_packets, Contains(arrived)); 983 EXPECT_TRUE(frame->missing_packets.Contains(arrived));
984 frame->missing_packets.erase(arrived); 984 frame->missing_packets.Remove(arrived);
985 frame->entropy_hash ^= 985 frame->entropy_hash ^=
986 QuicConnectionPeer::PacketEntropy(&connection_, arrived); 986 QuicConnectionPeer::PacketEntropy(&connection_, arrived);
987 } 987 }
988 988
989 void TriggerConnectionClose() { 989 void TriggerConnectionClose() {
990 // Send an erroneous packet to close the connection. 990 // Send an erroneous packet to close the connection.
991 EXPECT_CALL(visitor_, 991 EXPECT_CALL(visitor_,
992 OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false)); 992 OnConnectionClosed(QUIC_INVALID_PACKET_HEADER, false));
993 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a 993 // Call ProcessDataPacket rather than ProcessPacket, as we should not get a
994 // packet call to the visitor. 994 // packet call to the visitor.
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 factory_, Perspective::IS_CLIENT, version()); 1145 factory_, Perspective::IS_CLIENT, version());
1146 EXPECT_EQ(Perspective::IS_CLIENT, connection.perspective()); 1146 EXPECT_EQ(Perspective::IS_CLIENT, connection.perspective());
1147 EXPECT_EQ(lower_max_packet_size, connection.max_packet_length()); 1147 EXPECT_EQ(lower_max_packet_size, connection.max_packet_length());
1148 } 1148 }
1149 1149
1150 TEST_P(QuicConnectionTest, PacketsInOrder) { 1150 TEST_P(QuicConnectionTest, PacketsInOrder) {
1151 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1151 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1152 1152
1153 ProcessPacket(1); 1153 ProcessPacket(1);
1154 EXPECT_EQ(1u, outgoing_ack()->largest_observed); 1154 EXPECT_EQ(1u, outgoing_ack()->largest_observed);
1155 EXPECT_EQ(0u, outgoing_ack()->missing_packets.size()); 1155 EXPECT_TRUE(outgoing_ack()->missing_packets.Empty());
1156 1156
1157 ProcessPacket(2); 1157 ProcessPacket(2);
1158 EXPECT_EQ(2u, outgoing_ack()->largest_observed); 1158 EXPECT_EQ(2u, outgoing_ack()->largest_observed);
1159 EXPECT_EQ(0u, outgoing_ack()->missing_packets.size()); 1159 EXPECT_TRUE(outgoing_ack()->missing_packets.Empty());
1160 1160
1161 ProcessPacket(3); 1161 ProcessPacket(3);
1162 EXPECT_EQ(3u, outgoing_ack()->largest_observed); 1162 EXPECT_EQ(3u, outgoing_ack()->largest_observed);
1163 EXPECT_EQ(0u, outgoing_ack()->missing_packets.size()); 1163 EXPECT_TRUE(outgoing_ack()->missing_packets.Empty());
1164 } 1164 }
1165 1165
1166 TEST_P(QuicConnectionTest, PacketsOutOfOrder) { 1166 TEST_P(QuicConnectionTest, PacketsOutOfOrder) {
1167 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1167 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1168 1168
1169 ProcessPacket(3); 1169 ProcessPacket(3);
1170 EXPECT_EQ(3u, outgoing_ack()->largest_observed); 1170 EXPECT_EQ(3u, outgoing_ack()->largest_observed);
1171 EXPECT_TRUE(IsMissing(2)); 1171 EXPECT_TRUE(IsMissing(2));
1172 EXPECT_TRUE(IsMissing(1)); 1172 EXPECT_TRUE(IsMissing(1));
1173 1173
(...skipping 2850 matching lines...) Expand 10 before | Expand all | Expand 10 after
4024 QuicEncryptedPacket encrypted(nullptr, 0); 4024 QuicEncryptedPacket encrypted(nullptr, 0);
4025 connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, encrypted); 4025 connection_.ProcessUdpPacket(kSelfAddress, kPeerAddress, encrypted);
4026 } 4026 }
4027 4027
4028 TEST_P(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) { 4028 TEST_P(QuicConnectionTest, MissingPacketsBeforeLeastUnacked) {
4029 // Set the packet number of the ack packet to be least unacked (4). 4029 // Set the packet number of the ack packet to be least unacked (4).
4030 QuicPacketCreatorPeer::SetPacketNumber(&peer_creator_, 3); 4030 QuicPacketCreatorPeer::SetPacketNumber(&peer_creator_, 3);
4031 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 4031 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
4032 QuicStopWaitingFrame frame = InitStopWaitingFrame(4); 4032 QuicStopWaitingFrame frame = InitStopWaitingFrame(4);
4033 ProcessStopWaitingPacket(&frame); 4033 ProcessStopWaitingPacket(&frame);
4034 EXPECT_TRUE(outgoing_ack()->missing_packets.empty()); 4034 EXPECT_TRUE(outgoing_ack()->missing_packets.Empty());
4035 } 4035 }
4036 4036
4037 TEST_P(QuicConnectionTest, ReceivedEntropyHashCalculation) { 4037 TEST_P(QuicConnectionTest, ReceivedEntropyHashCalculation) {
4038 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AtLeast(1)); 4038 EXPECT_CALL(visitor_, OnStreamFrame(_)).Times(AtLeast(1));
4039 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 4039 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
4040 ProcessDataPacket(1, 1, kEntropyFlag); 4040 ProcessDataPacket(1, 1, kEntropyFlag);
4041 ProcessDataPacket(4, 1, kEntropyFlag); 4041 ProcessDataPacket(4, 1, kEntropyFlag);
4042 ProcessDataPacket(3, 1, !kEntropyFlag); 4042 ProcessDataPacket(3, 1, !kEntropyFlag);
4043 ProcessDataPacket(7, 1, kEntropyFlag); 4043 ProcessDataPacket(7, 1, kEntropyFlag);
4044 EXPECT_EQ(146u, outgoing_ack()->entropy_hash); 4044 EXPECT_EQ(146u, outgoing_ack()->entropy_hash);
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after
4818 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 4818 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
4819 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); 4819 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away.");
4820 EXPECT_TRUE(connection_.goaway_sent()); 4820 EXPECT_TRUE(connection_.goaway_sent());
4821 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); 4821 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0);
4822 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away."); 4822 connection_.SendGoAway(QUIC_PEER_GOING_AWAY, kHeadersStreamId, "Going Away.");
4823 } 4823 }
4824 4824
4825 } // namespace 4825 } // namespace
4826 } // namespace test 4826 } // namespace test
4827 } // namespace net 4827 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698