| 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/test_tools/quic_test_utils.h" | 5 #include "net/quic/test_tools/quic_test_utils.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "net/quic/crypto/crypto_framer.h" | 8 #include "net/quic/crypto/crypto_framer.h" |
| 9 #include "net/quic/crypto/crypto_handshake.h" | 9 #include "net/quic/crypto/crypto_handshake.h" |
| 10 #include "net/quic/crypto/crypto_utils.h" | 10 #include "net/quic/crypto/crypto_utils.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 ON_CALL(*this, OnConnectionCloseFrame(_)) | 48 ON_CALL(*this, OnConnectionCloseFrame(_)) |
| 49 .WillByDefault(testing::Return(true)); | 49 .WillByDefault(testing::Return(true)); |
| 50 | 50 |
| 51 ON_CALL(*this, OnGoAwayFrame(_)) | 51 ON_CALL(*this, OnGoAwayFrame(_)) |
| 52 .WillByDefault(testing::Return(true)); | 52 .WillByDefault(testing::Return(true)); |
| 53 } | 53 } |
| 54 | 54 |
| 55 MockFramerVisitor::~MockFramerVisitor() { | 55 MockFramerVisitor::~MockFramerVisitor() { |
| 56 } | 56 } |
| 57 | 57 |
| 58 bool NoOpFramerVisitor::OnProtocolVersionMismatch(QuicTag version) { | 58 bool NoOpFramerVisitor::OnProtocolVersionMismatch(QuicVersion version) { |
| 59 return false; | 59 return false; |
| 60 } | 60 } |
| 61 | 61 |
| 62 bool NoOpFramerVisitor::OnPacketHeader(const QuicPacketHeader& header) { | 62 bool NoOpFramerVisitor::OnPacketHeader(const QuicPacketHeader& header) { |
| 63 return true; | 63 return true; |
| 64 } | 64 } |
| 65 | 65 |
| 66 bool NoOpFramerVisitor::OnStreamFrame(const QuicStreamFrame& frame) { | 66 bool NoOpFramerVisitor::OnStreamFrame(const QuicStreamFrame& frame) { |
| 67 return true; | 67 return true; |
| 68 } | 68 } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 } | 182 } |
| 183 | 183 |
| 184 void MockHelper::AdvanceTime(QuicTime::Delta delta) { | 184 void MockHelper::AdvanceTime(QuicTime::Delta delta) { |
| 185 clock_.AdvanceTime(delta); | 185 clock_.AdvanceTime(delta); |
| 186 } | 186 } |
| 187 | 187 |
| 188 MockConnection::MockConnection(QuicGuid guid, | 188 MockConnection::MockConnection(QuicGuid guid, |
| 189 IPEndPoint address, | 189 IPEndPoint address, |
| 190 bool is_server) | 190 bool is_server) |
| 191 : QuicConnection(guid, address, new testing::NiceMock<MockHelper>(), | 191 : QuicConnection(guid, address, new testing::NiceMock<MockHelper>(), |
| 192 is_server), | 192 is_server, QuicVersionMax()), |
| 193 has_mock_helper_(true) { | 193 has_mock_helper_(true) { |
| 194 } | 194 } |
| 195 | 195 |
| 196 MockConnection::MockConnection(QuicGuid guid, | 196 MockConnection::MockConnection(QuicGuid guid, |
| 197 IPEndPoint address, | 197 IPEndPoint address, |
| 198 QuicConnectionHelperInterface* helper, | 198 QuicConnectionHelperInterface* helper, |
| 199 bool is_server) | 199 bool is_server) |
| 200 : QuicConnection(guid, address, helper, is_server), | 200 : QuicConnection(guid, address, helper, is_server, QuicVersionMax()), |
| 201 has_mock_helper_(false) { | 201 has_mock_helper_(false) { |
| 202 } | 202 } |
| 203 | 203 |
| 204 MockConnection::~MockConnection() { | 204 MockConnection::~MockConnection() { |
| 205 } | 205 } |
| 206 | 206 |
| 207 void MockConnection::AdvanceTime(QuicTime::Delta delta) { | 207 void MockConnection::AdvanceTime(QuicTime::Delta delta) { |
| 208 CHECK(has_mock_helper_) << "Cannot advance time unless a MockClock is being" | 208 CHECK(has_mock_helper_) << "Cannot advance time unless a MockClock is being" |
| 209 " used"; | 209 " used"; |
| 210 static_cast<MockHelper*>(helper())->AdvanceTime(delta); | 210 static_cast<MockHelper*>(helper())->AdvanceTime(delta); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 actual->data(), actual->length(), | 347 actual->data(), actual->length(), |
| 348 expected->data(), expected->length()); | 348 expected->data(), expected->length()); |
| 349 } | 349 } |
| 350 | 350 |
| 351 static QuicPacket* ConstructPacketFromHandshakeMessage( | 351 static QuicPacket* ConstructPacketFromHandshakeMessage( |
| 352 QuicGuid guid, | 352 QuicGuid guid, |
| 353 const CryptoHandshakeMessage& message, | 353 const CryptoHandshakeMessage& message, |
| 354 bool should_include_version) { | 354 bool should_include_version) { |
| 355 CryptoFramer crypto_framer; | 355 CryptoFramer crypto_framer; |
| 356 scoped_ptr<QuicData> data(crypto_framer.ConstructHandshakeMessage(message)); | 356 scoped_ptr<QuicData> data(crypto_framer.ConstructHandshakeMessage(message)); |
| 357 QuicFramer quic_framer(kQuicVersion1, QuicTime::Zero(), false); | 357 QuicFramer quic_framer(QuicVersionMax(), QuicTime::Zero(), false); |
| 358 | 358 |
| 359 QuicPacketHeader header; | 359 QuicPacketHeader header; |
| 360 header.public_header.guid = guid; | 360 header.public_header.guid = guid; |
| 361 header.public_header.reset_flag = false; | 361 header.public_header.reset_flag = false; |
| 362 header.public_header.version_flag = should_include_version; | 362 header.public_header.version_flag = should_include_version; |
| 363 header.packet_sequence_number = 1; | 363 header.packet_sequence_number = 1; |
| 364 header.entropy_flag = false; | 364 header.entropy_flag = false; |
| 365 header.entropy_hash = 0; | 365 header.entropy_hash = 0; |
| 366 header.fec_flag = false; | 366 header.fec_flag = false; |
| 367 header.fec_group = 0; | 367 header.fec_group = 0; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 396 if (stream_length < ack_length) { | 396 if (stream_length < ack_length) { |
| 397 *payload_length = 1 + ack_length - stream_length; | 397 *payload_length = 1 + ack_length - stream_length; |
| 398 } | 398 } |
| 399 | 399 |
| 400 return NullEncrypter().GetCiphertextSize(*payload_length) + | 400 return NullEncrypter().GetCiphertextSize(*payload_length) + |
| 401 QuicPacketCreator::StreamFramePacketOverhead( | 401 QuicPacketCreator::StreamFramePacketOverhead( |
| 402 PACKET_8BYTE_GUID, include_version, | 402 PACKET_8BYTE_GUID, include_version, |
| 403 PACKET_6BYTE_SEQUENCE_NUMBER, is_in_fec_group); | 403 PACKET_6BYTE_SEQUENCE_NUMBER, is_in_fec_group); |
| 404 } | 404 } |
| 405 | 405 |
| 406 QuicPacketEntropyHash TestEntropyCalculator::ReceivedEntropyHash( | 406 QuicPacketEntropyHash TestEntropyCalculator::EntropyHash( |
| 407 QuicPacketSequenceNumber sequence_number) const { | 407 QuicPacketSequenceNumber sequence_number) const { |
| 408 return 1u; | 408 return 1u; |
| 409 } | 409 } |
| 410 | 410 |
| 411 QuicConfig DefaultQuicConfig() { | 411 QuicConfig DefaultQuicConfig() { |
| 412 QuicConfig config; | 412 QuicConfig config; |
| 413 config.SetDefaults(); | 413 config.SetDefaults(); |
| 414 return config; | 414 return config; |
| 415 } | 415 } |
| 416 | 416 |
| 417 bool TestDecompressorVisitor::OnDecompressedData(StringPiece data) { | 417 bool TestDecompressorVisitor::OnDecompressedData(StringPiece data) { |
| 418 data.AppendToString(&data_); | 418 data.AppendToString(&data_); |
| 419 return true; | 419 return true; |
| 420 } | 420 } |
| 421 | 421 |
| 422 void TestDecompressorVisitor::OnDecompressionError() { | 422 void TestDecompressorVisitor::OnDecompressionError() { |
| 423 error_ = true; | 423 error_ = true; |
| 424 } | 424 } |
| 425 | 425 |
| 426 } // namespace test | 426 } // namespace test |
| 427 } // namespace net | 427 } // namespace net |
| OLD | NEW |