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

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

Issue 18307003: Implement the variable length changes necessary to easily accommodate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merging with TOT Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/quic/quic_framer.h » ('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 "net/base/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/quic/congestion_control/receive_algorithm_interface.h" 10 #include "net/quic/congestion_control/receive_algorithm_interface.h"
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 EXPECT_EQ(8u, last_ack()->sent_info.least_unacked); 962 EXPECT_EQ(8u, last_ack()->sent_info.least_unacked);
963 963
964 // But if we send more data it should. 964 // But if we send more data it should.
965 SendStreamDataToPeer(1, "eep", 6, !kFin, &last_packet); // Packet 9 965 SendStreamDataToPeer(1, "eep", 6, !kFin, &last_packet); // Packet 9
966 EXPECT_EQ(9u, last_packet); 966 EXPECT_EQ(9u, last_packet);
967 SendAckPacketToPeer(); // Packet10 967 SendAckPacketToPeer(); // Packet10
968 EXPECT_EQ(9u, last_ack()->sent_info.least_unacked); 968 EXPECT_EQ(9u, last_ack()->sent_info.least_unacked);
969 } 969 }
970 970
971 TEST_F(QuicConnectionTest, FECSending) { 971 TEST_F(QuicConnectionTest, FECSending) {
972 // Limit to one byte per packet.
973 // All packets carry version info till version is negotiated. 972 // All packets carry version info till version is negotiated.
973 size_t payload_length;
974 connection_.options()->max_packet_length = 974 connection_.options()->max_packet_length =
975 GetPacketLengthForOneStream(kIncludeVersion, IN_FEC_GROUP, 4); 975 GetPacketLengthForOneStream(
976 kIncludeVersion, IN_FEC_GROUP, &payload_length);
976 // And send FEC every two packets. 977 // And send FEC every two packets.
977 connection_.options()->max_packets_per_fec_group = 2; 978 connection_.options()->max_packets_per_fec_group = 2;
978 979
979 // Send 4 data packets and 2 FEC packets. 980 // Send 4 data packets and 2 FEC packets.
980 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(6); 981 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(6);
981 connection_.SendStreamData(1, "foodfoodfoodfood", 0, !kFin); 982 // TODO(ianswett): The first stream frame will consume 2 fewer bytes.
983 const string payload(payload_length * 4, 'a');
984 connection_.SendStreamData(1, payload, 0, !kFin);
982 // Expect the FEC group to be closed after SendStreamData. 985 // Expect the FEC group to be closed after SendStreamData.
983 EXPECT_FALSE(creator_.ShouldSendFec(true)); 986 EXPECT_FALSE(creator_.ShouldSendFec(true));
984 } 987 }
985 988
986 TEST_F(QuicConnectionTest, FECQueueing) { 989 TEST_F(QuicConnectionTest, FECQueueing) {
987 // Limit to one byte per packet.
988 // All packets carry version info till version is negotiated. 990 // All packets carry version info till version is negotiated.
991 size_t payload_length;
989 connection_.options()->max_packet_length = 992 connection_.options()->max_packet_length =
990 GetPacketLengthForOneStream(kIncludeVersion, IN_FEC_GROUP, 4); 993 GetPacketLengthForOneStream(
994 kIncludeVersion, IN_FEC_GROUP, &payload_length);
991 // And send FEC every two packets. 995 // And send FEC every two packets.
992 connection_.options()->max_packets_per_fec_group = 2; 996 connection_.options()->max_packets_per_fec_group = 2;
993 997
994 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 998 EXPECT_EQ(0u, connection_.NumQueuedPackets());
995 helper_->set_blocked(true); 999 helper_->set_blocked(true);
996 connection_.SendStreamData(1, "food", 0, !kFin); 1000 const string payload(payload_length, 'a');
1001 connection_.SendStreamData(1, payload, 0, !kFin);
997 EXPECT_FALSE(creator_.ShouldSendFec(true)); 1002 EXPECT_FALSE(creator_.ShouldSendFec(true));
998 // Expect the first data packet and the fec packet to be queued. 1003 // Expect the first data packet and the fec packet to be queued.
999 EXPECT_EQ(2u, connection_.NumQueuedPackets()); 1004 EXPECT_EQ(2u, connection_.NumQueuedPackets());
1000 } 1005 }
1001 1006
1002 TEST_F(QuicConnectionTest, AbandonFECFromCongestionWindow) { 1007 TEST_F(QuicConnectionTest, AbandonFECFromCongestionWindow) {
1003 connection_.options()->max_packets_per_fec_group = 1; 1008 connection_.options()->max_packets_per_fec_group = 1;
1004 // 1 Data and 1 FEC packet. 1009 // 1 Data and 1 FEC packet.
1005 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(2); 1010 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(2);
1006 connection_.SendStreamData(1, "foo", 0, !kFin); 1011 connection_.SendStreamData(1, "foo", 0, !kFin);
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); 1903 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
1899 EXPECT_EQ(1u, connection_.NumQueuedPackets()); 1904 EXPECT_EQ(1u, connection_.NumQueuedPackets());
1900 1905
1901 // OnCanWrite should not send the packet (because of the delay) 1906 // OnCanWrite should not send the packet (because of the delay)
1902 // but should still return true. 1907 // but should still return true.
1903 EXPECT_TRUE(connection_.OnCanWrite()); 1908 EXPECT_TRUE(connection_.OnCanWrite());
1904 EXPECT_EQ(1u, connection_.NumQueuedPackets()); 1909 EXPECT_EQ(1u, connection_.NumQueuedPackets());
1905 } 1910 }
1906 1911
1907 TEST_F(QuicConnectionTest, TestQueueLimitsOnSendStreamData) { 1912 TEST_F(QuicConnectionTest, TestQueueLimitsOnSendStreamData) {
1908 // Limit to one byte per packet.
1909 // All packets carry version info till version is negotiated. 1913 // All packets carry version info till version is negotiated.
1914 size_t payload_length;
1910 connection_.options()->max_packet_length = 1915 connection_.options()->max_packet_length =
1911 GetPacketLengthForOneStream(kIncludeVersion, NOT_IN_FEC_GROUP, 4); 1916 GetPacketLengthForOneStream(
1917 kIncludeVersion, NOT_IN_FEC_GROUP, &payload_length);
1912 1918
1913 // Queue the first packet. 1919 // Queue the first packet.
1914 EXPECT_CALL(*send_algorithm_, 1920 EXPECT_CALL(*send_algorithm_,
1915 TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillOnce( 1921 TimeUntilSend(_, NOT_RETRANSMISSION, _)).WillOnce(
1916 testing::Return(QuicTime::Delta::FromMicroseconds(10))); 1922 testing::Return(QuicTime::Delta::FromMicroseconds(10)));
1917 EXPECT_EQ(0u, connection_.SendStreamData( 1923 const string payload(payload_length, 'a');
1918 1, "EnoughDataToQueue", 0, !kFin).bytes_consumed); 1924 EXPECT_EQ(0u,
1925 connection_.SendStreamData(1, payload, 0, !kFin).bytes_consumed);
1919 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 1926 EXPECT_EQ(0u, connection_.NumQueuedPackets());
1920 } 1927 }
1921 1928
1922 TEST_F(QuicConnectionTest, LoopThroughSendingPackets) { 1929 TEST_F(QuicConnectionTest, LoopThroughSendingPackets) {
1923 // Limit to 4 bytes per packet.
1924 // All packets carry version info till version is negotiated. 1930 // All packets carry version info till version is negotiated.
1931 size_t payload_length;
1925 connection_.options()->max_packet_length = 1932 connection_.options()->max_packet_length =
1926 GetPacketLengthForOneStream(kIncludeVersion, NOT_IN_FEC_GROUP, 4); 1933 GetPacketLengthForOneStream(
1934 kIncludeVersion, NOT_IN_FEC_GROUP, &payload_length);
1927 1935
1928 // Queue the first packet. 1936 // Queue the first packet.
1929 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(7); 1937 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(7);
1930 EXPECT_EQ(27u, connection_.SendStreamData( 1938 // TODO(ianswett): The first stream frame will consume 2 fewer bytes.
1931 1, "EnoughDataToQueueStreamData", 0, !kFin).bytes_consumed); 1939 const string payload(payload_length * 7, 'a');
1940 EXPECT_EQ(payload.size(),
1941 connection_.SendStreamData(1, payload, 0, !kFin).bytes_consumed);
1932 } 1942 }
1933 1943
1934 TEST_F(QuicConnectionTest, NoAckForClose) { 1944 TEST_F(QuicConnectionTest, NoAckForClose) {
1935 ProcessPacket(1); 1945 ProcessPacket(1);
1936 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(0); 1946 EXPECT_CALL(*send_algorithm_, OnIncomingAck(_, _, _)).Times(0);
1937 EXPECT_CALL(visitor_, ConnectionClose(QUIC_PEER_GOING_AWAY, true)); 1947 EXPECT_CALL(visitor_, ConnectionClose(QUIC_PEER_GOING_AWAY, true));
1938 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(0); 1948 EXPECT_CALL(*send_algorithm_, SentPacket(_, _, _, _)).Times(0);
1939 ProcessClosePacket(2, 0); 1949 ProcessClosePacket(2, 0);
1940 } 1950 }
1941 1951
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2237 EXPECT_CALL(visitor_, OnCanWrite()).Times(1).WillOnce(Return(true)); 2247 EXPECT_CALL(visitor_, OnCanWrite()).Times(1).WillOnce(Return(true));
2238 EXPECT_CALL(visitor_, ConnectionClose(QUIC_PEER_GOING_AWAY, true)); 2248 EXPECT_CALL(visitor_, ConnectionClose(QUIC_PEER_GOING_AWAY, true));
2239 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).Times(0); 2249 EXPECT_CALL(visitor_, OnPacket(_, _, _, _)).Times(0);
2240 2250
2241 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); 2251 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
2242 } 2252 }
2243 2253
2244 } // namespace 2254 } // namespace
2245 } // namespace test 2255 } // namespace test
2246 } // namespace net 2256 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/quic/quic_framer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698