#include "quiche/quic/core/quic_trace_visitor.h"
#include <string>
#include <vector>
#include "quiche/quic/core/quic_constants.h"
#include "quiche/quic/platform/api/quic_test.h"
#include "quiche/quic/test_tools/quic_test_utils.h"
#include "quiche/quic/test_tools/simulator/quic_endpoint.h"
#include "quiche/quic/test_tools/simulator/simulator.h"
#include "quiche/quic/test_tools/simulator/switch.h"
namespace quic::test {
namespace {
const QuicByteCount kTransferSize = …;
const QuicByteCount kTestStreamNumber = …;
const QuicTime::Delta kDelay = …;
class QuicTraceVisitorTest : public QuicTest { … };
TEST_F(…) {
char expected_cid[] = {0, 0, 0, 0, 0, 0, 0, 42};
EXPECT_EQ(…);
}
TEST_F(…) {
std::string version = trace_.protocol_version();
ASSERT_EQ(…);
EXPECT_TRUE(…);
}
TEST_F(…) {
auto sent_packets = AllEventsWithType(quic_trace::PACKET_SENT);
EXPECT_EQ(…);
ASSERT_GT(…);
EXPECT_EQ(…);
EXPECT_EQ(…);
}
TEST_F(…) {
auto sent_packets = AllEventsWithType(quic_trace::PACKET_SENT);
QuicIntervalSet<QuicStreamOffset> offsets;
for (const quic_trace::Event& packet : sent_packets) {
for (const quic_trace::Frame& frame : packet.frames()) {
if (frame.frame_type() != quic_trace::STREAM) {
continue;
}
const quic_trace::StreamFrameInfo& info = frame.stream_frame_info();
if (info.stream_id() != kTestStreamNumber) {
continue;
}
ASSERT_GT(…);
offsets.Add(info.offset(), info.offset() + info.length());
}
}
ASSERT_EQ(…);
EXPECT_EQ(…);
EXPECT_EQ(…);
}
TEST_F(…) {
QuicIntervalSet<QuicPacketNumber> packets;
for (const quic_trace::Event& packet : trace_.events()) {
if (packet.event_type() == quic_trace::PACKET_RECEIVED) {
for (const quic_trace::Frame& frame : packet.frames()) {
if (frame.frame_type() != quic_trace::ACK) {
continue;
}
const quic_trace::AckInfo& info = frame.ack_info();
for (const auto& block : info.acked_packets()) {
packets.Add(QuicPacketNumber(block.first_packet()),
QuicPacketNumber(block.last_packet()) + 1);
}
}
}
if (packet.event_type() == quic_trace::PACKET_LOST) {
packets.Add(QuicPacketNumber(packet.packet_number()),
QuicPacketNumber(packet.packet_number()) + 1);
}
}
ASSERT_EQ(…);
EXPECT_EQ(…);
EXPECT_GT(…);
}
TEST_F(…) {
auto acks = AllEventsWithType(quic_trace::PACKET_RECEIVED);
ASSERT_EQ(…);
ASSERT_EQ(…);
EXPECT_LE(…);
EXPECT_GE(…);
}
TEST_F(…) {
for (const auto& event : trace_.events()) {
switch (event.event_type()) {
case quic_trace::PACKET_SENT:
case quic_trace::PACKET_RECEIVED:
case quic_trace::PACKET_LOST:
ASSERT_TRUE(…);
ASSERT_NE(…);
break;
default:
break;
}
}
}
}
}