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 1608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1619 PacketContents probe_contents; | 1619 PacketContents probe_contents; |
1620 probe_contents.num_mtu_discovery_frames = 1; | 1620 probe_contents.num_mtu_discovery_frames = 1; |
1621 | 1621 |
1622 CheckPacketHasSingleStreamFrame(0); | 1622 CheckPacketHasSingleStreamFrame(0); |
1623 CheckPacketHasSingleStreamFrame(1); | 1623 CheckPacketHasSingleStreamFrame(1); |
1624 CheckPacketContains(probe_contents, 2); | 1624 CheckPacketContains(probe_contents, 2); |
1625 CheckPacketHasSingleStreamFrame(3); | 1625 CheckPacketHasSingleStreamFrame(3); |
1626 CheckPacketHasSingleStreamFrame(4); | 1626 CheckPacketHasSingleStreamFrame(4); |
1627 } | 1627 } |
1628 | 1628 |
1629 TEST_P(QuicPacketGeneratorTest, DontCrashOnInvalidStopWaiting) { | |
1630 // Test added to ensure the generator does not crash when an invalid frame is | |
1631 // added. Because this is an indication of internal programming errors, | |
1632 // DFATALs are expected. | |
1633 // A 1 byte sequence number length can't encode a gap of 1000. | |
1634 QuicPacketCreatorPeer::SetSequenceNumber(creator_, 1000); | |
1635 | |
1636 delegate_.SetCanNotWrite(); | |
1637 generator_.SetShouldSendAck(true); | |
1638 delegate_.SetCanWriteAnything(); | |
1639 generator_.StartBatchOperations(); | |
1640 | |
1641 // Set up frames to write into the creator when control frames are written. | |
1642 EXPECT_CALL(delegate_, PopulateAckFrame(_)); | |
1643 EXPECT_CALL(delegate_, PopulateStopWaitingFrame(_)); | |
1644 // Generator should have queued control frames, and creator should be empty. | |
1645 EXPECT_TRUE(generator_.HasQueuedFrames()); | |
1646 EXPECT_FALSE(creator_->HasPendingFrames()); | |
1647 | |
1648 // This will not serialize any packets, because of the invalid frame. | |
1649 EXPECT_CALL(delegate_, | |
1650 CloseConnection(QUIC_FAILED_TO_SERIALIZE_PACKET, false)); | |
1651 EXPECT_DFATAL(generator_.FinishBatchOperations(), | |
1652 "sequence_number_length 1 is too small " | |
1653 "for least_unacked_delta: 1001"); | |
1654 } | |
1655 | |
1656 } // namespace test | 1629 } // namespace test |
1657 } // namespace net | 1630 } // namespace net |
OLD | NEW |