#include "quiche/quic/core/quic_packet_creator.h"
#include <cstdint>
#include <limits>
#include <memory>
#include <ostream>
#include <string>
#include <utility>
#include <vector>
#include "absl/base/macros.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "quiche/quic/core/crypto/quic_decrypter.h"
#include "quiche/quic/core/crypto/quic_encrypter.h"
#include "quiche/quic/core/frames/quic_frame.h"
#include "quiche/quic/core/frames/quic_stream_frame.h"
#include "quiche/quic/core/quic_connection_id.h"
#include "quiche/quic/core/quic_data_writer.h"
#include "quiche/quic/core/quic_types.h"
#include "quiche/quic/core/quic_utils.h"
#include "quiche/quic/platform/api/quic_expect_bug.h"
#include "quiche/quic/platform/api/quic_flags.h"
#include "quiche/quic/platform/api/quic_socket_address.h"
#include "quiche/quic/platform/api/quic_test.h"
#include "quiche/quic/test_tools/quic_framer_peer.h"
#include "quiche/quic/test_tools/quic_packet_creator_peer.h"
#include "quiche/quic/test_tools/quic_test_utils.h"
#include "quiche/quic/test_tools/simple_data_producer.h"
#include "quiche/quic/test_tools/simple_quic_framer.h"
#include "quiche/common/simple_buffer_allocator.h"
#include "quiche/common/test_tools/quiche_test_utils.h"
_;
AtLeast;
DoAll;
InSequence;
Invoke;
Return;
SaveArg;
StrictMock;
namespace quic {
namespace test {
namespace {
const QuicPacketNumber kPacketNumber = …;
QuicConnectionId CreateTestConnectionId() { … }
struct TestParams { … };
std::string PrintToString(const TestParams& p) { … }
std::vector<TestParams> GetTestParams() { … }
class MockDebugDelegate : public QuicPacketCreator::DebugDelegate { … };
class TestPacketCreator : public QuicPacketCreator { … };
class QuicPacketCreatorTest : public QuicTestWithParam<TestParams> { … };
INSTANTIATE_TEST_SUITE_P(…);
TEST_P(QuicPacketCreatorTest, SerializeFrames) { … }
TEST_P(QuicPacketCreatorTest, SerializeConnectionClose) { … }
TEST_P(QuicPacketCreatorTest, SerializePacketWithPadding) { … }
TEST_P(QuicPacketCreatorTest, SerializeLargerPacketWithPadding) { … }
TEST_P(QuicPacketCreatorTest, IncreaseMaxPacketLengthWithFramesPending) { … }
TEST_P(QuicPacketCreatorTest, ConsumeCryptoDataToFillCurrentPacket) { … }
TEST_P(QuicPacketCreatorTest, ConsumeDataToFillCurrentPacket) { … }
TEST_P(QuicPacketCreatorTest, ConsumeDataFin) { … }
TEST_P(QuicPacketCreatorTest, ConsumeDataFinOnly) { … }
TEST_P(QuicPacketCreatorTest, CreateAllFreeBytesForStreamFrames) { … }
TEST_P(QuicPacketCreatorTest, StreamFrameConsumption) { … }
TEST_P(QuicPacketCreatorTest, CryptoStreamFramePacketPadding) { … }
TEST_P(QuicPacketCreatorTest, NonCryptoStreamFramePacketNonPadding) { … }
TEST_P(QuicPacketCreatorTest, BuildPathChallengePacket) { … }
TEST_P(QuicPacketCreatorTest, BuildConnectivityProbingPacket) { … }
TEST_P(QuicPacketCreatorTest, BuildPathResponsePacket1ResponseUnpadded) { … }
TEST_P(QuicPacketCreatorTest, BuildPathResponsePacket1ResponsePadded) { … }
TEST_P(QuicPacketCreatorTest, BuildPathResponsePacket3ResponsesUnpadded) { … }
TEST_P(QuicPacketCreatorTest, BuildPathResponsePacket3ResponsesPadded) { … }
TEST_P(QuicPacketCreatorTest, SerializeConnectivityProbingPacket) { … }
TEST_P(QuicPacketCreatorTest, SerializePathChallengeProbePacket) { … }
TEST_P(QuicPacketCreatorTest, SerializePathResponseProbePacket1PayloadPadded) { … }
TEST_P(QuicPacketCreatorTest,
SerializePathResponseProbePacket1PayloadUnPadded) { … }
TEST_P(QuicPacketCreatorTest, SerializePathResponseProbePacket2PayloadsPadded) { … }
TEST_P(QuicPacketCreatorTest,
SerializePathResponseProbePacket2PayloadsUnPadded) { … }
TEST_P(QuicPacketCreatorTest, SerializePathResponseProbePacket3PayloadsPadded) { … }
TEST_P(QuicPacketCreatorTest,
SerializePathResponseProbePacket3PayloadsUnpadded) { … }
TEST_P(QuicPacketCreatorTest, SerializeLargePacketNumberConnectionClosePacket) { … }
TEST_P(QuicPacketCreatorTest, UpdatePacketSequenceNumberLengthLeastAwaiting) { … }
TEST_P(QuicPacketCreatorTest, UpdatePacketSequenceNumberLengthCwnd) { … }
TEST_P(QuicPacketCreatorTest, SkipNPacketNumbers) { … }
TEST_P(QuicPacketCreatorTest, SerializeFrame) { … }
TEST_P(QuicPacketCreatorTest, SerializeFrameShortData) { … }
void QuicPacketCreatorTest::TestChaosProtection(bool enabled) { … }
TEST_P(QuicPacketCreatorTest, ChaosProtectionEnabled) { … }
TEST_P(QuicPacketCreatorTest, ChaosProtectionDisabled) { … }
TEST_P(QuicPacketCreatorTest, ConsumeDataLargerThanOneStreamFrame) { … }
TEST_P(QuicPacketCreatorTest, AddFrameAndFlush) { … }
TEST_P(QuicPacketCreatorTest, SerializeAndSendStreamFrame) { … }
TEST_P(QuicPacketCreatorTest, SerializeStreamFrameWithPadding) { … }
TEST_P(QuicPacketCreatorTest, AddUnencryptedStreamDataClosesConnection) { … }
TEST_P(QuicPacketCreatorTest, SendStreamDataWithEncryptionHandshake) { … }
TEST_P(QuicPacketCreatorTest, ChloTooLarge) { … }
TEST_P(QuicPacketCreatorTest, PendingPadding) { … }
TEST_P(QuicPacketCreatorTest, FullPaddingDoesNotConsumePendingPadding) { … }
TEST_P(QuicPacketCreatorTest, ConsumeDataAndRandomPadding) { … }
TEST_P(QuicPacketCreatorTest, FlushWithExternalBuffer) { … }
TEST_P(QuicPacketCreatorTest, IetfAckGapErrorRegression) { … }
TEST_P(QuicPacketCreatorTest, AddMessageFrame) { … }
TEST_P(QuicPacketCreatorTest, MessageFrameConsumption) { … }
TEST_P(QuicPacketCreatorTest, GetGuaranteedLargestMessagePayload) { … }
TEST_P(QuicPacketCreatorTest, GetCurrentLargestMessagePayload) { … }
TEST_P(QuicPacketCreatorTest, PacketTransmissionType) { … }
TEST_P(QuicPacketCreatorTest,
PacketBytesRetransmitted_AddFrame_Retransmission) { … }
TEST_P(QuicPacketCreatorTest,
PacketBytesRetransmitted_AddFrame_NotRetransmission) { … }
TEST_P(QuicPacketCreatorTest, PacketBytesRetransmitted_AddFrame_MixedFrames) { … }
TEST_P(QuicPacketCreatorTest,
PacketBytesRetransmitted_CreateAndSerializeStreamFrame_Retransmission) { … }
TEST_P(
QuicPacketCreatorTest,
PacketBytesRetransmitted_CreateAndSerializeStreamFrame_NotRetransmission) { … }
TEST_P(QuicPacketCreatorTest, RetryToken) { … }
TEST_P(QuicPacketCreatorTest, GetConnectionId) { … }
TEST_P(QuicPacketCreatorTest, ClientConnectionId) { … }
TEST_P(QuicPacketCreatorTest, CoalesceStreamFrames) { … }
TEST_P(QuicPacketCreatorTest, SaveNonRetransmittableFrames) { … }
TEST_P(QuicPacketCreatorTest, SerializeCoalescedPacket) { … }
TEST_P(QuicPacketCreatorTest, SoftMaxPacketLength) { … }
TEST_P(QuicPacketCreatorTest,
ChangingEncryptionLevelRemovesSoftMaxPacketLength) { … }
TEST_P(QuicPacketCreatorTest, MinPayloadLength) { … }
TEST_P(QuicPacketCreatorTest, PadWhenAlmostMaxLength) { … }
TEST_P(QuicPacketCreatorTest, MorePendingPaddingThanBytesFree) { … }
class MockDelegate : public QuicPacketCreator::DelegateInterface { … };
struct PacketContents { … };
class MultiplePacketsTestPacketCreator : public QuicPacketCreator { … };
class QuicPacketCreatorMultiplePacketsTest : public QuicTest { … };
TEST_F(QuicPacketCreatorMultiplePacketsTest, AddControlFrame_NotWritable) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
WrongEncryptionLevelForStreamDataFastPath) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, AddControlFrame_OnlyAckWritable) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
AddControlFrame_WritableAndShouldNotFlush) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
AddControlFrame_NotWritableBatchThenFlush) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
AddControlFrame_WritableAndShouldFlush) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, ConsumeCryptoData) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
ConsumeCryptoDataCheckShouldGeneratePacket) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
ConsumeDataAdjustWriteLengthAfterBundledData) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
ConsumeDataDoesNotAdjustWriteLengthAfterBundledData) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, ConsumeData_NotWritable) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
ConsumeData_WritableAndShouldNotFlush) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
ConsumeData_WritableAndShouldFlush) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, ConsumeData_Handshake) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
ConsumeData_Handshake_PaddingDisabled) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, ConsumeData_EmptyData) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
ConsumeDataMultipleTimes_WritableAndShouldNotFlush) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, ConsumeData_BatchOperations) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
ConsumeData_FramesPreviouslyQueued) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, ConsumeDataFastPath) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, ConsumeDataLarge) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, ConsumeDataLargeSendAckFalse) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, ConsumeDataLargeSendAckTrue) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, NotWritableThenBatchOperations) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, NotWritableThenBatchOperations2) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, PacketTransmissionType) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, TestConnectionIdLength) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, SetMaxPacketLength_Initial) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, SetMaxPacketLength_Middle) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
SetMaxPacketLength_MidpacketFlush) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
GenerateConnectivityProbingPacket) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
GenerateMtuDiscoveryPacket_Simple) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
GenerateMtuDiscoveryPacket_SurroundedByData) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
ConnectionCloseFrameLargerThanPacketSize) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
RandomPaddingAfterFinSingleStreamSinglePacket) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
RandomPaddingAfterFinSingleStreamMultiplePackets) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
RandomPaddingAfterFinMultipleStreamsMultiplePackets) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, AddMessageFrame) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, ConnectionId) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest, ExtraPaddingNeeded) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
PeerAddressContextWithSameAddress) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
PeerAddressContextWithDifferentAddress) { … }
TEST_F(QuicPacketCreatorMultiplePacketsTest,
NestedPeerAddressContextWithDifferentAddress) { … }
}
}
}