OLD | NEW |
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 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1270 EXPECT_EQ(3u, writer_->frame_count()); | 1270 EXPECT_EQ(3u, writer_->frame_count()); |
1271 EXPECT_EQ(1u, writer_->stream_frames().size()); | 1271 EXPECT_EQ(1u, writer_->stream_frames().size()); |
1272 EXPECT_FALSE(writer_->ack_frames().empty()); | 1272 EXPECT_FALSE(writer_->ack_frames().empty()); |
1273 | 1273 |
1274 // But an ack with no missing packets will not send an ack. | 1274 // But an ack with no missing packets will not send an ack. |
1275 AckPacket(original, &frame2); | 1275 AckPacket(original, &frame2); |
1276 ProcessAckPacket(&frame2); | 1276 ProcessAckPacket(&frame2); |
1277 ProcessAckPacket(&frame2); | 1277 ProcessAckPacket(&frame2); |
1278 } | 1278 } |
1279 | 1279 |
| 1280 TEST_P(QuicConnectionTest, 20AcksCausesAckSend) { |
| 1281 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
| 1282 |
| 1283 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); |
| 1284 |
| 1285 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_); |
| 1286 // But an ack with no missing packets will not send an ack. |
| 1287 QuicAckFrame frame = InitAckFrame(1); |
| 1288 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); |
| 1289 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) |
| 1290 .WillRepeatedly(Return(SequenceNumberSet())); |
| 1291 for (int i = 0; i < 20; ++i) { |
| 1292 EXPECT_FALSE(ack_alarm->IsSet()); |
| 1293 ProcessAckPacket(&frame); |
| 1294 } |
| 1295 EXPECT_TRUE(ack_alarm->IsSet()); |
| 1296 } |
| 1297 |
1280 TEST_P(QuicConnectionTest, LeastUnackedLower) { | 1298 TEST_P(QuicConnectionTest, LeastUnackedLower) { |
1281 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); | 1299 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); |
1282 | 1300 |
1283 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); | 1301 SendStreamDataToPeer(1, "foo", 0, !kFin, NULL); |
1284 SendStreamDataToPeer(1, "bar", 3, !kFin, NULL); | 1302 SendStreamDataToPeer(1, "bar", 3, !kFin, NULL); |
1285 SendStreamDataToPeer(1, "eep", 6, !kFin, NULL); | 1303 SendStreamDataToPeer(1, "eep", 6, !kFin, NULL); |
1286 | 1304 |
1287 // Start out saying the least unacked is 2. | 1305 // Start out saying the least unacked is 2. |
1288 peer_creator_.set_sequence_number(5); | 1306 peer_creator_.set_sequence_number(5); |
1289 QuicStopWaitingFrame frame = InitStopWaitingFrame(2); | 1307 QuicStopWaitingFrame frame = InitStopWaitingFrame(2); |
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3006 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PEER_GOING_AWAY, true)); | 3024 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PEER_GOING_AWAY, true)); |
3007 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); | 3025 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(0); |
3008 ProcessClosePacket(2, 0); | 3026 ProcessClosePacket(2, 0); |
3009 } | 3027 } |
3010 | 3028 |
3011 TEST_P(QuicConnectionTest, SendWhenDisconnected) { | 3029 TEST_P(QuicConnectionTest, SendWhenDisconnected) { |
3012 EXPECT_TRUE(connection_.connected()); | 3030 EXPECT_TRUE(connection_.connected()); |
3013 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PEER_GOING_AWAY, false)); | 3031 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PEER_GOING_AWAY, false)); |
3014 connection_.CloseConnection(QUIC_PEER_GOING_AWAY, false); | 3032 connection_.CloseConnection(QUIC_PEER_GOING_AWAY, false); |
3015 EXPECT_FALSE(connection_.connected()); | 3033 EXPECT_FALSE(connection_.connected()); |
| 3034 EXPECT_FALSE(connection_.CanWriteStreamData()); |
3016 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); | 3035 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); |
3017 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 1, _, _)).Times(0); | 3036 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 1, _, _)).Times(0); |
3018 connection_.SendPacket( | 3037 connection_.SendPacket( |
3019 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); | 3038 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); |
3020 } | 3039 } |
3021 | 3040 |
3022 TEST_P(QuicConnectionTest, PublicReset) { | 3041 TEST_P(QuicConnectionTest, PublicReset) { |
3023 QuicPublicResetPacket header; | 3042 QuicPublicResetPacket header; |
3024 header.public_header.connection_id = connection_id_; | 3043 header.public_header.connection_id = connection_id_; |
3025 header.public_header.reset_flag = true; | 3044 header.public_header.reset_flag = true; |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3876 QuicBlockedFrame blocked; | 3895 QuicBlockedFrame blocked; |
3877 blocked.stream_id = 3; | 3896 blocked.stream_id = 3; |
3878 EXPECT_CALL(visitor_, OnBlockedFrames(_)); | 3897 EXPECT_CALL(visitor_, OnBlockedFrames(_)); |
3879 ProcessFramePacket(QuicFrame(&blocked)); | 3898 ProcessFramePacket(QuicFrame(&blocked)); |
3880 EXPECT_TRUE(ack_alarm->IsSet()); | 3899 EXPECT_TRUE(ack_alarm->IsSet()); |
3881 } | 3900 } |
3882 | 3901 |
3883 } // namespace | 3902 } // namespace |
3884 } // namespace test | 3903 } // namespace test |
3885 } // namespace net | 3904 } // namespace net |
OLD | NEW |