| Index: net/quic/test_tools/quic_test_utils.cc
|
| diff --git a/net/quic/test_tools/quic_test_utils.cc b/net/quic/test_tools/quic_test_utils.cc
|
| index 5e4d7f5b3d3ed17d67c6d0d255ab59b5a4815c48..ba87a486a1cda16bc01bb150c01db7bd67b7e783 100644
|
| --- a/net/quic/test_tools/quic_test_utils.cc
|
| +++ b/net/quic/test_tools/quic_test_utils.cc
|
| @@ -32,9 +32,7 @@ namespace {
|
| // No-op alarm implementation used by MockHelper.
|
| class TestAlarm : public QuicAlarm {
|
| public:
|
| - explicit TestAlarm(QuicAlarm::Delegate* delegate)
|
| - : QuicAlarm(delegate) {
|
| - }
|
| + explicit TestAlarm(QuicAlarm::Delegate* delegate) : QuicAlarm(delegate) {}
|
|
|
| virtual void SetImpl() OVERRIDE {}
|
| virtual void CancelImpl() OVERRIDE {}
|
| @@ -64,32 +62,25 @@ MockFramerVisitor::MockFramerVisitor() {
|
| ON_CALL(*this, OnUnauthenticatedPublicHeader(_))
|
| .WillByDefault(testing::Return(true));
|
|
|
| - ON_CALL(*this, OnPacketHeader(_))
|
| - .WillByDefault(testing::Return(true));
|
| + ON_CALL(*this, OnPacketHeader(_)).WillByDefault(testing::Return(true));
|
|
|
| - ON_CALL(*this, OnStreamFrame(_))
|
| - .WillByDefault(testing::Return(true));
|
| + ON_CALL(*this, OnStreamFrame(_)).WillByDefault(testing::Return(true));
|
|
|
| - ON_CALL(*this, OnAckFrame(_))
|
| - .WillByDefault(testing::Return(true));
|
| + ON_CALL(*this, OnAckFrame(_)).WillByDefault(testing::Return(true));
|
|
|
| ON_CALL(*this, OnCongestionFeedbackFrame(_))
|
| .WillByDefault(testing::Return(true));
|
|
|
| - ON_CALL(*this, OnStopWaitingFrame(_))
|
| - .WillByDefault(testing::Return(true));
|
| + ON_CALL(*this, OnStopWaitingFrame(_)).WillByDefault(testing::Return(true));
|
|
|
| - ON_CALL(*this, OnPingFrame(_))
|
| - .WillByDefault(testing::Return(true));
|
| + ON_CALL(*this, OnPingFrame(_)).WillByDefault(testing::Return(true));
|
|
|
| - ON_CALL(*this, OnRstStreamFrame(_))
|
| - .WillByDefault(testing::Return(true));
|
| + ON_CALL(*this, OnRstStreamFrame(_)).WillByDefault(testing::Return(true));
|
|
|
| ON_CALL(*this, OnConnectionCloseFrame(_))
|
| .WillByDefault(testing::Return(true));
|
|
|
| - ON_CALL(*this, OnGoAwayFrame(_))
|
| - .WillByDefault(testing::Return(true));
|
| + ON_CALL(*this, OnGoAwayFrame(_)).WillByDefault(testing::Return(true));
|
| }
|
|
|
| MockFramerVisitor::~MockFramerVisitor() {
|
| @@ -126,8 +117,7 @@ bool NoOpFramerVisitor::OnCongestionFeedbackFrame(
|
| return true;
|
| }
|
|
|
| -bool NoOpFramerVisitor::OnStopWaitingFrame(
|
| - const QuicStopWaitingFrame& frame) {
|
| +bool NoOpFramerVisitor::OnStopWaitingFrame(const QuicStopWaitingFrame& frame) {
|
| return true;
|
| }
|
|
|
| @@ -135,8 +125,7 @@ bool NoOpFramerVisitor::OnPingFrame(const QuicPingFrame& frame) {
|
| return true;
|
| }
|
|
|
| -bool NoOpFramerVisitor::OnRstStreamFrame(
|
| - const QuicRstStreamFrame& frame) {
|
| +bool NoOpFramerVisitor::OnRstStreamFrame(const QuicRstStreamFrame& frame) {
|
| return true;
|
| }
|
|
|
| @@ -191,30 +180,32 @@ MockConnection::MockConnection(bool is_server)
|
| IPEndPoint(TestPeerIPAddress(), kTestPort),
|
| new testing::NiceMock<MockHelper>(),
|
| new testing::NiceMock<MockPacketWriter>(),
|
| - is_server, QuicSupportedVersions(),
|
| + is_server,
|
| + QuicSupportedVersions(),
|
| kInitialFlowControlWindowForTest),
|
| writer_(QuicConnectionPeer::GetWriter(this)),
|
| helper_(helper()) {
|
| }
|
|
|
| -MockConnection::MockConnection(IPEndPoint address,
|
| - bool is_server)
|
| - : QuicConnection(kTestConnectionId, address,
|
| +MockConnection::MockConnection(IPEndPoint address, bool is_server)
|
| + : QuicConnection(kTestConnectionId,
|
| + address,
|
| new testing::NiceMock<MockHelper>(),
|
| new testing::NiceMock<MockPacketWriter>(),
|
| - is_server, QuicSupportedVersions(),
|
| + is_server,
|
| + QuicSupportedVersions(),
|
| kInitialFlowControlWindowForTest),
|
| writer_(QuicConnectionPeer::GetWriter(this)),
|
| helper_(helper()) {
|
| }
|
|
|
| -MockConnection::MockConnection(QuicConnectionId connection_id,
|
| - bool is_server)
|
| +MockConnection::MockConnection(QuicConnectionId connection_id, bool is_server)
|
| : QuicConnection(connection_id,
|
| IPEndPoint(TestPeerIPAddress(), kTestPort),
|
| new testing::NiceMock<MockHelper>(),
|
| new testing::NiceMock<MockPacketWriter>(),
|
| - is_server, QuicSupportedVersions(),
|
| + is_server,
|
| + QuicSupportedVersions(),
|
| kInitialFlowControlWindowForTest),
|
| writer_(QuicConnectionPeer::GetWriter(this)),
|
| helper_(helper()) {
|
| @@ -226,7 +217,8 @@ MockConnection::MockConnection(bool is_server,
|
| IPEndPoint(TestPeerIPAddress(), kTestPort),
|
| new testing::NiceMock<MockHelper>(),
|
| new testing::NiceMock<MockPacketWriter>(),
|
| - is_server, supported_versions,
|
| + is_server,
|
| + supported_versions,
|
| kInitialFlowControlWindowForTest),
|
| writer_(QuicConnectionPeer::GetWriter(this)),
|
| helper_(helper()) {
|
| @@ -259,8 +251,9 @@ bool PacketSavingConnection::SendOrQueuePacket(
|
| const SerializedPacket& packet,
|
| TransmissionType transmission_type) {
|
| packets_.push_back(packet.packet);
|
| - QuicEncryptedPacket* encrypted = QuicConnectionPeer::GetFramer(this)->
|
| - EncryptPacket(level, packet.sequence_number, *packet.packet);
|
| + QuicEncryptedPacket* encrypted =
|
| + QuicConnectionPeer::GetFramer(this)
|
| + ->EncryptPacket(level, packet.sequence_number, *packet.packet);
|
| encrypted_packets_.push_back(encrypted);
|
| return true;
|
| }
|
| @@ -274,13 +267,12 @@ MockSession::MockSession(QuicConnection* connection)
|
| MockSession::~MockSession() {
|
| }
|
|
|
| -TestSession::TestSession(QuicConnection* connection,
|
| - const QuicConfig& config)
|
| - : QuicSession(connection, config),
|
| - crypto_stream_(NULL) {
|
| +TestSession::TestSession(QuicConnection* connection, const QuicConfig& config)
|
| + : QuicSession(connection, config), crypto_stream_(NULL) {
|
| }
|
|
|
| -TestSession::~TestSession() {}
|
| +TestSession::~TestSession() {
|
| +}
|
|
|
| void TestSession::SetCryptoStream(QuicCryptoStream* stream) {
|
| crypto_stream_ = stream;
|
| @@ -292,12 +284,12 @@ QuicCryptoStream* TestSession::GetCryptoStream() {
|
|
|
| TestClientSession::TestClientSession(QuicConnection* connection,
|
| const QuicConfig& config)
|
| - : QuicClientSessionBase(connection, config),
|
| - crypto_stream_(NULL) {
|
| - EXPECT_CALL(*this, OnProofValid(_)).Times(AnyNumber());
|
| + : QuicClientSessionBase(connection, config), crypto_stream_(NULL) {
|
| + EXPECT_CALL(*this, OnProofValid(_)).Times(AnyNumber());
|
| }
|
|
|
| -TestClientSession::~TestClientSession() {}
|
| +TestClientSession::~TestClientSession() {
|
| +}
|
|
|
| void TestClientSession::SetCryptoStream(QuicCryptoStream* stream) {
|
| crypto_stream_ = stream;
|
| @@ -333,8 +325,10 @@ MockAckNotifierDelegate::~MockAckNotifierDelegate() {
|
|
|
| namespace {
|
|
|
| -string HexDumpWithMarks(const char* data, int length,
|
| - const bool* marks, int mark_length) {
|
| +string HexDumpWithMarks(const char* data,
|
| + int length,
|
| + const bool* marks,
|
| + int mark_length) {
|
| static const char kHexChars[] = "0123456789abcdef";
|
| static const int kColumns = 4;
|
|
|
| @@ -348,7 +342,7 @@ string HexDumpWithMarks(const char* data, int length,
|
| string hex;
|
| for (const char* row = data; length > 0;
|
| row += kColumns, length -= kColumns) {
|
| - for (const char *p = row; p < row + 4; ++p) {
|
| + for (const char* p = row; p < row + 4; ++p) {
|
| if (p < row + length) {
|
| const bool mark =
|
| (marks && (p - data) < mark_length && marks[p - data]);
|
| @@ -362,7 +356,7 @@ string HexDumpWithMarks(const char* data, int length,
|
| }
|
| hex = hex + " ";
|
|
|
| - for (const char *p = row; p < row + 4 && p < row + length; ++p)
|
| + for (const char* p = row; p < row + 4 && p < row + length; ++p)
|
| hex += (*p >= 0x20 && *p <= 0x7f) ? (*p) : '.';
|
|
|
| hex = hex + '\n';
|
| @@ -372,11 +366,17 @@ string HexDumpWithMarks(const char* data, int length,
|
|
|
| } // namespace
|
|
|
| -IPAddressNumber TestPeerIPAddress() { return Loopback4(); }
|
| +IPAddressNumber TestPeerIPAddress() {
|
| + return Loopback4();
|
| +}
|
|
|
| -QuicVersion QuicVersionMax() { return QuicSupportedVersions().front(); }
|
| +QuicVersion QuicVersionMax() {
|
| + return QuicSupportedVersions().front();
|
| +}
|
|
|
| -QuicVersion QuicVersionMin() { return QuicSupportedVersions().back(); }
|
| +QuicVersion QuicVersionMin() {
|
| + return QuicSupportedVersions().back();
|
| +}
|
|
|
| IPAddressNumber Loopback4() {
|
| IPAddressNumber addr;
|
| @@ -418,19 +418,17 @@ QuicEncryptedPacket* ConstructEncryptedPacket(
|
| scoped_ptr<QuicPacket> packet(
|
| framer.BuildUnsizedDataPacket(header, frames).packet);
|
| EXPECT_TRUE(packet != NULL);
|
| - QuicEncryptedPacket* encrypted = framer.EncryptPacket(ENCRYPTION_NONE,
|
| - sequence_number,
|
| - *packet);
|
| + QuicEncryptedPacket* encrypted =
|
| + framer.EncryptPacket(ENCRYPTION_NONE, sequence_number, *packet);
|
| EXPECT_TRUE(encrypted != NULL);
|
| return encrypted;
|
| }
|
|
|
| -void CompareCharArraysWithHexError(
|
| - const string& description,
|
| - const char* actual,
|
| - const int actual_len,
|
| - const char* expected,
|
| - const int expected_len) {
|
| +void CompareCharArraysWithHexError(const string& description,
|
| + const char* actual,
|
| + const int actual_len,
|
| + const char* expected,
|
| + const int expected_len) {
|
| EXPECT_EQ(actual_len, expected_len);
|
| const int min_len = min(actual_len, expected_len);
|
| const int max_len = max(actual_len, expected_len);
|
| @@ -447,14 +445,13 @@ void CompareCharArraysWithHexError(
|
| for (int i = min_len; i < max_len; ++i) {
|
| marks[i] = true;
|
| }
|
| - if (identical) return;
|
| - ADD_FAILURE()
|
| - << "Description:\n"
|
| - << description
|
| - << "\n\nExpected:\n"
|
| - << HexDumpWithMarks(expected, expected_len, marks.get(), max_len)
|
| - << "\nActual:\n"
|
| - << HexDumpWithMarks(actual, actual_len, marks.get(), max_len);
|
| + if (identical)
|
| + return;
|
| + ADD_FAILURE() << "Description:\n" << description << "\n\nExpected:\n"
|
| + << HexDumpWithMarks(
|
| + expected, expected_len, marks.get(), max_len)
|
| + << "\nActual:\n"
|
| + << HexDumpWithMarks(actual, actual_len, marks.get(), max_len);
|
| }
|
|
|
| bool DecodeHexString(const base::StringPiece& hex, std::string* bytes) {
|
| @@ -487,8 +484,8 @@ static QuicPacket* ConstructPacketFromHandshakeMessage(
|
| header.fec_flag = false;
|
| header.fec_group = 0;
|
|
|
| - QuicStreamFrame stream_frame(kCryptoStreamId, false, 0,
|
| - MakeIOVector(data->AsStringPiece()));
|
| + QuicStreamFrame stream_frame(
|
| + kCryptoStreamId, false, 0, MakeIOVector(data->AsStringPiece()));
|
|
|
| QuicFrame frame(&stream_frame);
|
| QuicFrames frames;
|
| @@ -512,36 +509,47 @@ size_t GetPacketLengthForOneStream(
|
| *payload_length = 1;
|
| const size_t stream_length =
|
| NullEncrypter().GetCiphertextSize(*payload_length) +
|
| - QuicPacketCreator::StreamFramePacketOverhead(
|
| - version, PACKET_8BYTE_CONNECTION_ID, include_version,
|
| - sequence_number_length, is_in_fec_group);
|
| - const size_t ack_length = NullEncrypter().GetCiphertextSize(
|
| - QuicFramer::GetMinAckFrameSize(
|
| + QuicPacketCreator::StreamFramePacketOverhead(version,
|
| + PACKET_8BYTE_CONNECTION_ID,
|
| + include_version,
|
| + sequence_number_length,
|
| + is_in_fec_group);
|
| + const size_t ack_length =
|
| + NullEncrypter().GetCiphertextSize(QuicFramer::GetMinAckFrameSize(
|
| version, sequence_number_length, PACKET_1BYTE_SEQUENCE_NUMBER)) +
|
| - GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID, include_version,
|
| - sequence_number_length, is_in_fec_group);
|
| + GetPacketHeaderSize(PACKET_8BYTE_CONNECTION_ID,
|
| + include_version,
|
| + sequence_number_length,
|
| + is_in_fec_group);
|
| if (stream_length < ack_length) {
|
| *payload_length = 1 + ack_length - stream_length;
|
| }
|
|
|
| return NullEncrypter().GetCiphertextSize(*payload_length) +
|
| - QuicPacketCreator::StreamFramePacketOverhead(
|
| - version, PACKET_8BYTE_CONNECTION_ID, include_version,
|
| - sequence_number_length, is_in_fec_group);
|
| + QuicPacketCreator::StreamFramePacketOverhead(
|
| + version,
|
| + PACKET_8BYTE_CONNECTION_ID,
|
| + include_version,
|
| + sequence_number_length,
|
| + is_in_fec_group);
|
| }
|
|
|
| -TestEntropyCalculator::TestEntropyCalculator() { }
|
| +TestEntropyCalculator::TestEntropyCalculator() {
|
| +}
|
|
|
| -TestEntropyCalculator::~TestEntropyCalculator() { }
|
| +TestEntropyCalculator::~TestEntropyCalculator() {
|
| +}
|
|
|
| QuicPacketEntropyHash TestEntropyCalculator::EntropyHash(
|
| QuicPacketSequenceNumber sequence_number) const {
|
| return 1u;
|
| }
|
|
|
| -MockEntropyCalculator::MockEntropyCalculator() { }
|
| +MockEntropyCalculator::MockEntropyCalculator() {
|
| +}
|
|
|
| -MockEntropyCalculator::~MockEntropyCalculator() { }
|
| +MockEntropyCalculator::~MockEntropyCalculator() {
|
| +}
|
|
|
| QuicConfig DefaultQuicConfig() {
|
| QuicConfig config;
|
|
|