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_packet_generator.h" | 5 #include "net/quic/quic_packet_generator.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "net/quic/crypto/crypto_protocol.h" | 9 #include "net/quic/crypto/crypto_protocol.h" |
10 #include "net/quic/crypto/null_encrypter.h" | 10 #include "net/quic/crypto/null_encrypter.h" |
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 CheckPacketHasSingleStreamFrame(4); | 1210 CheckPacketHasSingleStreamFrame(4); |
1211 // FEC packet is sent after 2 packets and when send policy is | 1211 // FEC packet is sent after 2 packets and when send policy is |
1212 // FEC_ANY_TRIGGER. | 1212 // FEC_ANY_TRIGGER. |
1213 CheckPacketIsFec(5, 4); | 1213 CheckPacketIsFec(5, 4); |
1214 CheckPacketHasSingleStreamFrame(6); | 1214 CheckPacketHasSingleStreamFrame(6); |
1215 CheckPacketHasSingleStreamFrame(7); | 1215 CheckPacketHasSingleStreamFrame(7); |
1216 // FEC packet is sent after 2 packets and when send policy is | 1216 // FEC packet is sent after 2 packets and when send policy is |
1217 // FEC_ANY_TRIGGER. | 1217 // FEC_ANY_TRIGGER. |
1218 CheckPacketIsFec(8, 7); | 1218 CheckPacketIsFec(8, 7); |
1219 } | 1219 } |
1220 EXPECT_TRUE(creator_->IsFecProtected()); | 1220 EXPECT_FALSE(creator_->IsFecProtected()); |
| 1221 |
| 1222 // Do the another send (with MAY_FEC_PROTECT) on a different stream id, which |
| 1223 // should not produce an FEC packet because the last FEC group has been |
| 1224 // closed. |
| 1225 { |
| 1226 InSequence dummy; |
| 1227 EXPECT_CALL(delegate_, OnSerializedPacket(_)) |
| 1228 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket)); |
| 1229 EXPECT_CALL(delegate_, OnSerializedPacket(_)) |
| 1230 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket)); |
| 1231 EXPECT_CALL(delegate_, OnSerializedPacket(_)) |
| 1232 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket)); |
| 1233 } |
| 1234 consumed = generator_.ConsumeData(9, CreateData(data_len), 0, true, |
| 1235 MAY_FEC_PROTECT, nullptr); |
| 1236 EXPECT_EQ(data_len, consumed.bytes_consumed); |
| 1237 EXPECT_TRUE(consumed.fin_consumed); |
| 1238 EXPECT_FALSE(generator_.HasQueuedFrames()); |
| 1239 if (generator_.fec_send_policy() == FEC_ALARM_TRIGGER) { |
| 1240 CheckPacketHasSingleStreamFrame(6); |
| 1241 CheckPacketHasSingleStreamFrame(7); |
| 1242 CheckPacketHasSingleStreamFrame(8); |
| 1243 } else { |
| 1244 CheckPacketHasSingleStreamFrame(9); |
| 1245 CheckPacketHasSingleStreamFrame(10); |
| 1246 CheckPacketHasSingleStreamFrame(11); |
| 1247 } |
| 1248 EXPECT_FALSE(creator_->IsFecProtected()); |
1221 } | 1249 } |
1222 | 1250 |
1223 // 1. Create and send one packet with MUST_FEC_PROTECT. | 1251 // 1. Create and send one packet with MUST_FEC_PROTECT. |
1224 // 2. Call FecTimeout, expect FEC packet is sent. | 1252 // 2. Call FecTimeout, expect FEC packet is sent. |
1225 // 3. Do the same thing over again, with a different stream id. | 1253 // 3. Do the same thing over again, with a different stream id. |
1226 TEST_P(QuicPacketGeneratorTest, FecPacketSentOnFecTimeout) { | 1254 TEST_P(QuicPacketGeneratorTest, FecPacketSentOnFecTimeout) { |
1227 delegate_.SetCanWriteAnything(); | 1255 delegate_.SetCanWriteAnything(); |
1228 creator_->set_max_packets_per_fec_group(1000); | 1256 creator_->set_max_packets_per_fec_group(1000); |
1229 EXPECT_FALSE(creator_->IsFecProtected()); | 1257 EXPECT_FALSE(creator_->IsFecProtected()); |
1230 | 1258 |
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 // This will not serialize any packets, because of the invalid frame. | 1673 // This will not serialize any packets, because of the invalid frame. |
1646 EXPECT_CALL(delegate_, | 1674 EXPECT_CALL(delegate_, |
1647 CloseConnection(QUIC_FAILED_TO_SERIALIZE_PACKET, false)); | 1675 CloseConnection(QUIC_FAILED_TO_SERIALIZE_PACKET, false)); |
1648 EXPECT_DFATAL(generator_.FinishBatchOperations(), | 1676 EXPECT_DFATAL(generator_.FinishBatchOperations(), |
1649 "packet_number_length 1 is too small " | 1677 "packet_number_length 1 is too small " |
1650 "for least_unacked_delta: 1001"); | 1678 "for least_unacked_delta: 1001"); |
1651 } | 1679 } |
1652 | 1680 |
1653 } // namespace test | 1681 } // namespace test |
1654 } // namespace net | 1682 } // namespace net |
OLD | NEW |