blob: 058aab447356e1f365af6b659c24139ca37e93b7 [file] [log] [blame]
[email protected]8b37a092012-10-18 21:53:491// 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
3// found in the LICENSE file.
4
5#include "net/quic/test_tools/quic_test_utils.h"
[email protected]9c0b1352012-11-04 00:03:276
[email protected]701bc892013-01-17 04:51:547#include "base/stl_util.h"
[email protected]8b37a092012-10-18 21:53:498#include "net/quic/crypto/crypto_framer.h"
[email protected]6f54ab32013-03-02 17:43:359#include "net/quic/crypto/crypto_handshake.h"
[email protected]872edd9e2013-01-16 08:51:1510#include "net/quic/crypto/crypto_utils.h"
[email protected]5351cc4b2013-03-03 07:22:4111#include "net/quic/crypto/null_encrypter.h"
[email protected]4df69842013-02-27 06:32:1612#include "net/quic/crypto/quic_decrypter.h"
13#include "net/quic/crypto/quic_encrypter.h"
[email protected]a57e0272013-04-26 07:31:4714#include "net/quic/quic_framer.h"
[email protected]5351cc4b2013-03-03 07:22:4115#include "net/quic/quic_packet_creator.h"
[email protected]cbd731e2013-10-24 00:20:3916#include "net/quic/test_tools/quic_connection_peer.h"
[email protected]c244c5a12013-05-07 20:55:0417#include "net/spdy/spdy_frame_builder.h"
[email protected]8b37a092012-10-18 21:53:4918
[email protected]c244c5a12013-05-07 20:55:0419using base::StringPiece;
[email protected]8b37a092012-10-18 21:53:4920using std::max;
21using std::min;
22using std::string;
[email protected]cff7b7b2013-01-11 08:49:0723using testing::_;
[email protected]8b37a092012-10-18 21:53:4924
25namespace net {
26namespace test {
[email protected]965dbe62013-08-09 21:34:3127namespace {
28
29// No-op alarm implementation used by MockHelper.
30class TestAlarm : public QuicAlarm {
31 public:
32 explicit TestAlarm(QuicAlarm::Delegate* delegate)
33 : QuicAlarm(delegate) {
34 }
35
36 virtual void SetImpl() OVERRIDE {}
37 virtual void CancelImpl() OVERRIDE {}
38};
39
40} // namespace
[email protected]8b37a092012-10-18 21:53:4941
42MockFramerVisitor::MockFramerVisitor() {
43 // By default, we want to accept packets.
[email protected]14e8106c2013-03-14 16:25:3344 ON_CALL(*this, OnProtocolVersionMismatch(_))
45 .WillByDefault(testing::Return(false));
46
47 // By default, we want to accept packets.
[email protected]ec86d5462013-11-17 16:04:4948 ON_CALL(*this, OnUnauthenticatedHeader(_))
49 .WillByDefault(testing::Return(true));
50
[email protected]cff7b7b2013-01-11 08:49:0751 ON_CALL(*this, OnPacketHeader(_))
[email protected]8b37a092012-10-18 21:53:4952 .WillByDefault(testing::Return(true));
[email protected]a57e0272013-04-26 07:31:4753
54 ON_CALL(*this, OnStreamFrame(_))
55 .WillByDefault(testing::Return(true));
56
57 ON_CALL(*this, OnAckFrame(_))
58 .WillByDefault(testing::Return(true));
59
60 ON_CALL(*this, OnCongestionFeedbackFrame(_))
61 .WillByDefault(testing::Return(true));
62
63 ON_CALL(*this, OnRstStreamFrame(_))
64 .WillByDefault(testing::Return(true));
65
66 ON_CALL(*this, OnConnectionCloseFrame(_))
67 .WillByDefault(testing::Return(true));
68
69 ON_CALL(*this, OnGoAwayFrame(_))
70 .WillByDefault(testing::Return(true));
[email protected]8b37a092012-10-18 21:53:4971}
72
[email protected]044ac2b2012-11-13 21:41:0673MockFramerVisitor::~MockFramerVisitor() {
74}
[email protected]8b37a092012-10-18 21:53:4975
[email protected]48878092013-07-26 14:51:5676bool NoOpFramerVisitor::OnProtocolVersionMismatch(QuicVersion version) {
[email protected]14e8106c2013-03-14 16:25:3377 return false;
78}
79
[email protected]ec86d5462013-11-17 16:04:4980bool NoOpFramerVisitor::OnUnauthenticatedHeader(
81 const QuicPacketHeader& header) {
82 return true;
83}
84
[email protected]8b37a092012-10-18 21:53:4985bool NoOpFramerVisitor::OnPacketHeader(const QuicPacketHeader& header) {
86 return true;
87}
88
[email protected]a57e0272013-04-26 07:31:4789bool NoOpFramerVisitor::OnStreamFrame(const QuicStreamFrame& frame) {
90 return true;
91}
92
93bool NoOpFramerVisitor::OnAckFrame(const QuicAckFrame& frame) {
94 return true;
95}
96
97bool NoOpFramerVisitor::OnCongestionFeedbackFrame(
98 const QuicCongestionFeedbackFrame& frame) {
99 return true;
100}
101
102bool NoOpFramerVisitor::OnRstStreamFrame(
103 const QuicRstStreamFrame& frame) {
104 return true;
105}
106
107bool NoOpFramerVisitor::OnConnectionCloseFrame(
108 const QuicConnectionCloseFrame& frame) {
109 return true;
110}
111
112bool NoOpFramerVisitor::OnGoAwayFrame(const QuicGoAwayFrame& frame) {
113 return true;
114}
115
[email protected]9db443912013-02-25 05:27:03116FramerVisitorCapturingFrames::FramerVisitorCapturingFrames() : frame_count_(0) {
[email protected]134e5c32012-12-12 19:20:36117}
118
[email protected]9db443912013-02-25 05:27:03119FramerVisitorCapturingFrames::~FramerVisitorCapturingFrames() {
[email protected]583bcbcf2013-10-28 01:51:15120 STLDeleteElements(&stream_data_);
[email protected]26f3f8e2012-12-13 21:07:19121}
122
[email protected]9db443912013-02-25 05:27:03123bool FramerVisitorCapturingFrames::OnPacketHeader(
[email protected]4e6f0ed2012-11-02 22:15:38124 const QuicPacketHeader& header) {
125 header_ = header;
[email protected]9db443912013-02-25 05:27:03126 frame_count_ = 0;
[email protected]4e6f0ed2012-11-02 22:15:38127 return true;
128}
129
[email protected]a57e0272013-04-26 07:31:47130bool FramerVisitorCapturingFrames::OnStreamFrame(const QuicStreamFrame& frame) {
[email protected]583bcbcf2013-10-28 01:51:15131 // Make a copy of the frame and store a copy of underlying string, since
132 // frame.data may not exist outside this callback.
[email protected]5dafdb62013-11-14 01:24:26133 stream_data_.push_back(frame.GetDataAsString());
[email protected]583bcbcf2013-10-28 01:51:15134 QuicStreamFrame frame_copy = frame;
[email protected]5dafdb62013-11-14 01:24:26135 frame_copy.data.Clear();
136 frame_copy.data.Append(const_cast<char*>(stream_data_.back()->data()),
137 stream_data_.back()->size());
[email protected]583bcbcf2013-10-28 01:51:15138 stream_frames_.push_back(frame_copy);
[email protected]9db443912013-02-25 05:27:03139 ++frame_count_;
[email protected]a57e0272013-04-26 07:31:47140 return true;
[email protected]26f3f8e2012-12-13 21:07:19141}
142
[email protected]a57e0272013-04-26 07:31:47143bool FramerVisitorCapturingFrames::OnAckFrame(const QuicAckFrame& frame) {
[email protected]9db443912013-02-25 05:27:03144 ack_.reset(new QuicAckFrame(frame));
145 ++frame_count_;
[email protected]a57e0272013-04-26 07:31:47146 return true;
[email protected]9db443912013-02-25 05:27:03147}
148
[email protected]a57e0272013-04-26 07:31:47149bool FramerVisitorCapturingFrames::OnCongestionFeedbackFrame(
[email protected]26f3f8e2012-12-13 21:07:19150 const QuicCongestionFeedbackFrame& frame) {
151 feedback_.reset(new QuicCongestionFeedbackFrame(frame));
[email protected]9db443912013-02-25 05:27:03152 ++frame_count_;
[email protected]a57e0272013-04-26 07:31:47153 return true;
[email protected]9db443912013-02-25 05:27:03154}
155
[email protected]a57e0272013-04-26 07:31:47156bool FramerVisitorCapturingFrames::OnRstStreamFrame(
[email protected]9db443912013-02-25 05:27:03157 const QuicRstStreamFrame& frame) {
158 rst_.reset(new QuicRstStreamFrame(frame));
159 ++frame_count_;
[email protected]a57e0272013-04-26 07:31:47160 return true;
[email protected]9db443912013-02-25 05:27:03161}
162
[email protected]a57e0272013-04-26 07:31:47163bool FramerVisitorCapturingFrames::OnConnectionCloseFrame(
[email protected]9db443912013-02-25 05:27:03164 const QuicConnectionCloseFrame& frame) {
165 close_.reset(new QuicConnectionCloseFrame(frame));
166 ++frame_count_;
[email protected]a57e0272013-04-26 07:31:47167 return true;
[email protected]9db443912013-02-25 05:27:03168}
169
[email protected]a57e0272013-04-26 07:31:47170bool FramerVisitorCapturingFrames::OnGoAwayFrame(const QuicGoAwayFrame& frame) {
[email protected]9db443912013-02-25 05:27:03171 goaway_.reset(new QuicGoAwayFrame(frame));
172 ++frame_count_;
[email protected]a57e0272013-04-26 07:31:47173 return true;
[email protected]4e6f0ed2012-11-02 22:15:38174}
175
[email protected]14e8106c2013-03-14 16:25:33176void FramerVisitorCapturingFrames::OnVersionNegotiationPacket(
177 const QuicVersionNegotiationPacket& packet) {
178 version_negotiation_packet_.reset(new QuicVersionNegotiationPacket(packet));
179 frame_count_ = 0;
180}
181
[email protected]fee17f72013-02-03 07:47:41182FramerVisitorCapturingPublicReset::FramerVisitorCapturingPublicReset() {
183}
184
185FramerVisitorCapturingPublicReset::~FramerVisitorCapturingPublicReset() {
186}
187
188void FramerVisitorCapturingPublicReset::OnPublicResetPacket(
189 const QuicPublicResetPacket& public_reset) {
190 public_reset_packet_ = public_reset;
191}
192
[email protected]8d659e22013-01-19 04:26:10193MockConnectionVisitor::MockConnectionVisitor() {
194}
195
196MockConnectionVisitor::~MockConnectionVisitor() {
197}
198
[email protected]9c0b1352012-11-04 00:03:27199MockHelper::MockHelper() {
200}
201
202MockHelper::~MockHelper() {
203}
204
[email protected]97693d12012-11-16 16:05:00205const QuicClock* MockHelper::GetClock() const {
[email protected]9c0b1352012-11-04 00:03:27206 return &clock_;
207}
208
[email protected]9558c5d32012-12-22 00:08:14209QuicRandom* MockHelper::GetRandomGenerator() {
210 return &random_generator_;
211}
212
[email protected]965dbe62013-08-09 21:34:31213QuicAlarm* MockHelper::CreateAlarm(QuicAlarm::Delegate* delegate) {
214 return new TestAlarm(delegate);
215}
216
[email protected]fe053f92013-04-23 20:18:55217void MockHelper::AdvanceTime(QuicTime::Delta delta) {
218 clock_.AdvanceTime(delta);
219}
220
[email protected]14e8106c2013-03-14 16:25:33221MockConnection::MockConnection(QuicGuid guid,
222 IPEndPoint address,
223 bool is_server)
[email protected]2532de12013-05-09 12:29:33224 : QuicConnection(guid, address, new testing::NiceMock<MockHelper>(),
[email protected]cbd731e2013-10-24 00:20:39225 new testing::NiceMock<MockPacketWriter>(),
[email protected]b007e632013-10-28 08:39:25226 is_server, QuicSupportedVersions()),
[email protected]cbd731e2013-10-24 00:20:39227 has_mock_helper_(true),
[email protected]2cfc6bb82013-10-27 03:40:44228 writer_(QuicConnectionPeer::GetWriter(this)),
229 helper_(helper()) {
[email protected]044ac2b2012-11-13 21:41:06230}
231
[email protected]872edd9e2013-01-16 08:51:15232MockConnection::MockConnection(QuicGuid guid,
233 IPEndPoint address,
[email protected]14e8106c2013-03-14 16:25:33234 QuicConnectionHelperInterface* helper,
[email protected]cbd731e2013-10-24 00:20:39235 QuicPacketWriter* writer,
[email protected]14e8106c2013-03-14 16:25:33236 bool is_server)
[email protected]cbd731e2013-10-24 00:20:39237 : QuicConnection(guid, address, helper, writer, is_server,
[email protected]b007e632013-10-28 08:39:25238 QuicSupportedVersions()),
[email protected]fe053f92013-04-23 20:18:55239 has_mock_helper_(false) {
[email protected]872edd9e2013-01-16 08:51:15240}
241
[email protected]044ac2b2012-11-13 21:41:06242MockConnection::~MockConnection() {
243}
244
[email protected]fe053f92013-04-23 20:18:55245void MockConnection::AdvanceTime(QuicTime::Delta delta) {
246 CHECK(has_mock_helper_) << "Cannot advance time unless a MockClock is being"
247 " used";
248 static_cast<MockHelper*>(helper())->AdvanceTime(delta);
249}
250
[email protected]044ac2b2012-11-13 21:41:06251PacketSavingConnection::PacketSavingConnection(QuicGuid guid,
[email protected]14e8106c2013-03-14 16:25:33252 IPEndPoint address,
253 bool is_server)
254 : MockConnection(guid, address, is_server) {
[email protected]044ac2b2012-11-13 21:41:06255}
256
257PacketSavingConnection::~PacketSavingConnection() {
[email protected]701bc892013-01-17 04:51:54258 STLDeleteElements(&packets_);
[email protected]2532de12013-05-09 12:29:33259 STLDeleteElements(&encrypted_packets_);
[email protected]044ac2b2012-11-13 21:41:06260}
261
[email protected]fee17f72013-02-03 07:47:41262bool PacketSavingConnection::SendOrQueuePacket(
[email protected]8ba81212013-05-03 13:11:48263 EncryptionLevel level,
[email protected]ec86d5462013-11-17 16:04:49264 const SerializedPacket& packet,
265 TransmissionType transmission_type) {
266 packets_.push_back(packet.packet);
[email protected]2532de12013-05-09 12:29:33267 QuicEncryptedPacket* encrypted =
[email protected]ec86d5462013-11-17 16:04:49268 framer_.EncryptPacket(level, packet.sequence_number, *packet.packet);
[email protected]2532de12013-05-09 12:29:33269 encrypted_packets_.push_back(encrypted);
[email protected]044ac2b2012-11-13 21:41:06270 return true;
271}
272
273MockSession::MockSession(QuicConnection* connection, bool is_server)
[email protected]b064310782013-05-30 21:12:17274 : QuicSession(connection, DefaultQuicConfig(), is_server) {
[email protected]24e5bc52013-09-18 15:36:58275 ON_CALL(*this, WritevData(_, _, _, _, _))
[email protected]cff7b7b2013-01-11 08:49:07276 .WillByDefault(testing::Return(QuicConsumedData(0, false)));
[email protected]044ac2b2012-11-13 21:41:06277}
278
279MockSession::~MockSession() {
280}
281
[email protected]899951652013-05-16 12:52:39282TestSession::TestSession(QuicConnection* connection,
283 const QuicConfig& config,
284 bool is_server)
285 : QuicSession(connection, config, is_server),
[email protected]2532de12013-05-09 12:29:33286 crypto_stream_(NULL) {
287}
288
[email protected]b064310782013-05-30 21:12:17289TestSession::~TestSession() {}
[email protected]2532de12013-05-09 12:29:33290
291void TestSession::SetCryptoStream(QuicCryptoStream* stream) {
292 crypto_stream_ = stream;
293}
294
295QuicCryptoStream* TestSession::GetCryptoStream() {
296 return crypto_stream_;
297}
298
[email protected]cbd731e2013-10-24 00:20:39299MockPacketWriter::MockPacketWriter() {
300}
301
302MockPacketWriter::~MockPacketWriter() {
303}
304
[email protected]fee17f72013-02-03 07:47:41305MockSendAlgorithm::MockSendAlgorithm() {
[email protected]8d659e22013-01-19 04:26:10306}
307
[email protected]fee17f72013-02-03 07:47:41308MockSendAlgorithm::~MockSendAlgorithm() {
[email protected]8d659e22013-01-19 04:26:10309}
310
[email protected]97cf3022013-09-05 14:30:16311MockAckNotifierDelegate::MockAckNotifierDelegate() {
312}
313
314MockAckNotifierDelegate::~MockAckNotifierDelegate() {
315}
316
[email protected]8b37a092012-10-18 21:53:49317namespace {
318
319string HexDumpWithMarks(const char* data, int length,
320 const bool* marks, int mark_length) {
321 static const char kHexChars[] = "0123456789abcdef";
322 static const int kColumns = 4;
323
324 const int kSizeLimit = 1024;
325 if (length > kSizeLimit || mark_length > kSizeLimit) {
326 LOG(ERROR) << "Only dumping first " << kSizeLimit << " bytes.";
327 length = min(length, kSizeLimit);
328 mark_length = min(mark_length, kSizeLimit);
329 }
330
331 string hex;
332 for (const char* row = data; length > 0;
333 row += kColumns, length -= kColumns) {
334 for (const char *p = row; p < row + 4; ++p) {
335 if (p < row + length) {
336 const bool mark =
337 (marks && (p - data) < mark_length && marks[p - data]);
338 hex += mark ? '*' : ' ';
339 hex += kHexChars[(*p & 0xf0) >> 4];
340 hex += kHexChars[*p & 0x0f];
341 hex += mark ? '*' : ' ';
342 } else {
343 hex += " ";
344 }
345 }
346 hex = hex + " ";
347
348 for (const char *p = row; p < row + 4 && p < row + length; ++p)
349 hex += (*p >= 0x20 && *p <= 0x7f) ? (*p) : '.';
350
351 hex = hex + '\n';
352 }
353 return hex;
354}
355
356} // namespace
357
[email protected]b007e632013-10-28 08:39:25358QuicVersion QuicVersionMax() { return QuicSupportedVersions().front(); }
359
360QuicVersion QuicVersionMin() { return QuicSupportedVersions().back(); }
361
[email protected]8b37a092012-10-18 21:53:49362void CompareCharArraysWithHexError(
363 const string& description,
364 const char* actual,
365 const int actual_len,
366 const char* expected,
367 const int expected_len) {
[email protected]b007e632013-10-28 08:39:25368 EXPECT_EQ(actual_len, expected_len);
[email protected]8b37a092012-10-18 21:53:49369 const int min_len = min(actual_len, expected_len);
370 const int max_len = max(actual_len, expected_len);
[email protected]4356f0f2013-04-07 00:58:17371 scoped_ptr<bool[]> marks(new bool[max_len]);
[email protected]8b37a092012-10-18 21:53:49372 bool identical = (actual_len == expected_len);
373 for (int i = 0; i < min_len; ++i) {
374 if (actual[i] != expected[i]) {
375 marks[i] = true;
376 identical = false;
377 } else {
378 marks[i] = false;
379 }
380 }
381 for (int i = min_len; i < max_len; ++i) {
382 marks[i] = true;
383 }
384 if (identical) return;
385 ADD_FAILURE()
386 << "Description:\n"
387 << description
388 << "\n\nExpected:\n"
389 << HexDumpWithMarks(expected, expected_len, marks.get(), max_len)
390 << "\nActual:\n"
391 << HexDumpWithMarks(actual, actual_len, marks.get(), max_len);
392}
393
[email protected]d3d15bf2013-01-30 02:51:54394static QuicPacket* ConstructPacketFromHandshakeMessage(
395 QuicGuid guid,
[email protected]14e8106c2013-03-14 16:25:33396 const CryptoHandshakeMessage& message,
397 bool should_include_version) {
[email protected]8b37a092012-10-18 21:53:49398 CryptoFramer crypto_framer;
[email protected]dc2cc742012-10-21 13:56:13399 scoped_ptr<QuicData> data(crypto_framer.ConstructHandshakeMessage(message));
[email protected]b007e632013-10-28 08:39:25400 QuicFramer quic_framer(QuicSupportedVersions(), QuicTime::Zero(), false);
[email protected]8b37a092012-10-18 21:53:49401
402 QuicPacketHeader header;
[email protected]c995c572013-01-18 05:43:20403 header.public_header.guid = guid;
[email protected]9db443912013-02-25 05:27:03404 header.public_header.reset_flag = false;
[email protected]14e8106c2013-03-14 16:25:33405 header.public_header.version_flag = should_include_version;
[email protected]8b37a092012-10-18 21:53:49406 header.packet_sequence_number = 1;
[email protected]9db443912013-02-25 05:27:03407 header.entropy_flag = false;
408 header.entropy_hash = 0;
409 header.fec_flag = false;
[email protected]8b37a092012-10-18 21:53:49410 header.fec_group = 0;
411
[email protected]be24ab22012-10-22 03:01:52412 QuicStreamFrame stream_frame(kCryptoStreamId, false, 0,
[email protected]5dafdb62013-11-14 01:24:26413 MakeIOVector(data->AsStringPiece()));
[email protected]8b37a092012-10-18 21:53:49414
[email protected]be24ab22012-10-22 03:01:52415 QuicFrame frame(&stream_frame);
416 QuicFrames frames;
417 frames.push_back(frame);
[email protected]3e60db82013-08-05 19:43:06418 return quic_framer.BuildUnsizedDataPacket(header, frames).packet;
[email protected]8b37a092012-10-18 21:53:49419}
420
[email protected]2532de12013-05-09 12:29:33421QuicPacket* ConstructHandshakePacket(QuicGuid guid, QuicTag tag) {
[email protected]d3d15bf2013-01-30 02:51:54422 CryptoHandshakeMessage message;
[email protected]ccc66e8a2013-03-26 08:26:14423 message.set_tag(tag);
[email protected]14e8106c2013-03-14 16:25:33424 return ConstructPacketFromHandshakeMessage(guid, message, false);
[email protected]d3d15bf2013-01-30 02:51:54425}
426
[email protected]ea825e02013-08-21 18:12:45427size_t GetPacketLengthForOneStream(
428 QuicVersion version,
429 bool include_version,
430 QuicSequenceNumberLength sequence_number_length,
431 InFecGroup is_in_fec_group,
432 size_t* payload_length) {
[email protected]f62262b2013-07-05 20:57:30433 *payload_length = 1;
434 const size_t stream_length =
[email protected]5dafdb62013-11-14 01:24:26435 NullEncrypter().GetCiphertextSize(*payload_length) +
[email protected]b064310782013-05-30 21:12:17436 QuicPacketCreator::StreamFramePacketOverhead(
[email protected]3e60db82013-08-05 19:43:06437 version, PACKET_8BYTE_GUID, include_version,
[email protected]ea825e02013-08-21 18:12:45438 sequence_number_length, is_in_fec_group);
[email protected]5dafdb62013-11-14 01:24:26439 const size_t ack_length = NullEncrypter().GetCiphertextSize(
[email protected]8e01c062013-10-31 07:35:31440 QuicFramer::GetMinAckFrameSize(
441 version, sequence_number_length, PACKET_1BYTE_SEQUENCE_NUMBER)) +
[email protected]25c31dc2013-06-05 17:56:04442 GetPacketHeaderSize(PACKET_8BYTE_GUID, include_version,
[email protected]ea825e02013-08-21 18:12:45443 sequence_number_length, is_in_fec_group);
[email protected]f62262b2013-07-05 20:57:30444 if (stream_length < ack_length) {
445 *payload_length = 1 + ack_length - stream_length;
446 }
447
[email protected]5dafdb62013-11-14 01:24:26448 return NullEncrypter().GetCiphertextSize(*payload_length) +
[email protected]f62262b2013-07-05 20:57:30449 QuicPacketCreator::StreamFramePacketOverhead(
[email protected]3e60db82013-08-05 19:43:06450 version, PACKET_8BYTE_GUID, include_version,
[email protected]ea825e02013-08-21 18:12:45451 sequence_number_length, is_in_fec_group);
[email protected]5351cc4b2013-03-03 07:22:41452}
453
[email protected]ea2ab47b2013-08-13 00:44:11454// Size in bytes of the stream frame fields for an arbitrary StreamID and
455// offset and the last frame in a packet.
[email protected]3e60db82013-08-05 19:43:06456size_t GetMinStreamFrameSize(QuicVersion version) {
[email protected]ea2ab47b2013-08-13 00:44:11457 return kQuicFrameTypeSize + kQuicMaxStreamIdSize + kQuicMaxStreamOffsetSize;
[email protected]3e60db82013-08-05 19:43:06458}
459
[email protected]8e01c062013-10-31 07:35:31460TestEntropyCalculator::TestEntropyCalculator() { }
461
462TestEntropyCalculator::~TestEntropyCalculator() { }
463
[email protected]48878092013-07-26 14:51:56464QuicPacketEntropyHash TestEntropyCalculator::EntropyHash(
[email protected]9db443912013-02-25 05:27:03465 QuicPacketSequenceNumber sequence_number) const {
466 return 1u;
467}
468
[email protected]8e01c062013-10-31 07:35:31469MockEntropyCalculator::MockEntropyCalculator() { }
470
471MockEntropyCalculator::~MockEntropyCalculator() { }
472
[email protected]b064310782013-05-30 21:12:17473QuicConfig DefaultQuicConfig() {
474 QuicConfig config;
475 config.SetDefaults();
476 return config;
477}
478
[email protected]c244c5a12013-05-07 20:55:04479bool TestDecompressorVisitor::OnDecompressedData(StringPiece data) {
480 data.AppendToString(&data_);
481 return true;
482}
483
[email protected]899951652013-05-16 12:52:39484void TestDecompressorVisitor::OnDecompressionError() {
485 error_ = true;
486}
487
[email protected]8b37a092012-10-18 21:53:49488} // namespace test
[email protected]8b37a092012-10-18 21:53:49489} // namespace net