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 <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "net/quic/core/crypto/crypto_framer.h" | 10 #include "net/quic/core/crypto/crypto_framer.h" |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 .WillByDefault( | 327 .WillByDefault( |
328 Invoke(this, &PacketSavingConnection::QuicConnection_OnError)); | 328 Invoke(this, &PacketSavingConnection::QuicConnection_OnError)); |
329 } | 329 } |
330 | 330 |
331 MockQuicConnection::~MockQuicConnection() {} | 331 MockQuicConnection::~MockQuicConnection() {} |
332 | 332 |
333 void MockQuicConnection::AdvanceTime(QuicTime::Delta delta) { | 333 void MockQuicConnection::AdvanceTime(QuicTime::Delta delta) { |
334 static_cast<MockQuicConnectionHelper*>(helper())->AdvanceTime(delta); | 334 static_cast<MockQuicConnectionHelper*>(helper())->AdvanceTime(delta); |
335 } | 335 } |
336 | 336 |
| 337 bool MockQuicConnection::OnProtocolVersionMismatch(QuicVersion version) { |
| 338 return false; |
| 339 } |
| 340 |
337 PacketSavingConnection::PacketSavingConnection(MockQuicConnectionHelper* helper, | 341 PacketSavingConnection::PacketSavingConnection(MockQuicConnectionHelper* helper, |
338 MockAlarmFactory* alarm_factory, | 342 MockAlarmFactory* alarm_factory, |
339 Perspective perspective) | 343 Perspective perspective) |
340 : MockQuicConnection(helper, alarm_factory, perspective) {} | 344 : MockQuicConnection(helper, alarm_factory, perspective) {} |
341 | 345 |
342 PacketSavingConnection::PacketSavingConnection( | 346 PacketSavingConnection::PacketSavingConnection( |
343 MockQuicConnectionHelper* helper, | 347 MockQuicConnectionHelper* helper, |
344 MockAlarmFactory* alarm_factory, | 348 MockAlarmFactory* alarm_factory, |
345 Perspective perspective, | 349 Perspective perspective, |
346 const QuicVersionVector& supported_versions) | 350 const QuicVersionVector& supported_versions) |
(...skipping 19 matching lines...) Expand all Loading... |
366 crypto_stream_.reset(new QuicCryptoStream(this)); | 370 crypto_stream_.reset(new QuicCryptoStream(this)); |
367 Initialize(); | 371 Initialize(); |
368 ON_CALL(*this, WritevData(_, _, _, _, _, _)) | 372 ON_CALL(*this, WritevData(_, _, _, _, _, _)) |
369 .WillByDefault(testing::Return(QuicConsumedData(0, false))); | 373 .WillByDefault(testing::Return(QuicConsumedData(0, false))); |
370 } | 374 } |
371 | 375 |
372 MockQuicSession::~MockQuicSession() { | 376 MockQuicSession::~MockQuicSession() { |
373 delete connection(); | 377 delete connection(); |
374 } | 378 } |
375 | 379 |
| 380 QuicCryptoStream* MockQuicSession::GetMutableCryptoStream() { |
| 381 return crypto_stream_.get(); |
| 382 } |
| 383 |
| 384 const QuicCryptoStream* MockQuicSession::GetCryptoStream() const { |
| 385 return crypto_stream_.get(); |
| 386 } |
| 387 |
376 // static | 388 // static |
377 QuicConsumedData MockQuicSession::ConsumeAllData( | 389 QuicConsumedData MockQuicSession::ConsumeAllData( |
378 QuicStream* /*stream*/, | 390 QuicStream* /*stream*/, |
379 QuicStreamId /*id*/, | 391 QuicStreamId /*id*/, |
380 const QuicIOVector& data, | 392 const QuicIOVector& data, |
381 QuicStreamOffset /*offset*/, | 393 QuicStreamOffset /*offset*/, |
382 StreamSendingState state, | 394 StreamSendingState state, |
383 const QuicReferenceCountedPointer< | 395 const QuicReferenceCountedPointer< |
384 QuicAckListenerInterface>& /*ack_listener*/) { | 396 QuicAckListenerInterface>& /*ack_listener*/) { |
385 return QuicConsumedData(data.total_length, state != NO_FIN); | 397 return QuicConsumedData(data.total_length, state != NO_FIN); |
386 } | 398 } |
387 | 399 |
388 MockQuicSpdySession::MockQuicSpdySession(QuicConnection* connection) | 400 MockQuicSpdySession::MockQuicSpdySession(QuicConnection* connection) |
389 : QuicSpdySession(connection, nullptr, DefaultQuicConfig()) { | 401 : QuicSpdySession(connection, nullptr, DefaultQuicConfig()) { |
390 crypto_stream_.reset(new QuicCryptoStream(this)); | 402 crypto_stream_.reset(new QuicCryptoStream(this)); |
391 Initialize(); | 403 Initialize(); |
392 ON_CALL(*this, WritevData(_, _, _, _, _, _)) | 404 ON_CALL(*this, WritevData(_, _, _, _, _, _)) |
393 .WillByDefault(testing::Return(QuicConsumedData(0, false))); | 405 .WillByDefault(testing::Return(QuicConsumedData(0, false))); |
394 } | 406 } |
395 | 407 |
396 MockQuicSpdySession::~MockQuicSpdySession() { | 408 MockQuicSpdySession::~MockQuicSpdySession() { |
397 delete connection(); | 409 delete connection(); |
398 } | 410 } |
399 | 411 |
| 412 QuicCryptoStream* MockQuicSpdySession::GetMutableCryptoStream() { |
| 413 return crypto_stream_.get(); |
| 414 } |
| 415 |
| 416 const QuicCryptoStream* MockQuicSpdySession::GetCryptoStream() const { |
| 417 return crypto_stream_.get(); |
| 418 } |
| 419 |
| 420 size_t MockQuicSpdySession::WriteHeaders( |
| 421 QuicStreamId id, |
| 422 SpdyHeaderBlock headers, |
| 423 bool fin, |
| 424 SpdyPriority priority, |
| 425 QuicReferenceCountedPointer<QuicAckListenerInterface> ack_listener) { |
| 426 write_headers_ = std::move(headers); |
| 427 return WriteHeadersMock(id, write_headers_, fin, priority, ack_listener); |
| 428 } |
| 429 |
400 TestQuicSpdyServerSession::TestQuicSpdyServerSession( | 430 TestQuicSpdyServerSession::TestQuicSpdyServerSession( |
401 QuicConnection* connection, | 431 QuicConnection* connection, |
402 const QuicConfig& config, | 432 const QuicConfig& config, |
403 const QuicCryptoServerConfig* crypto_config, | 433 const QuicCryptoServerConfig* crypto_config, |
404 QuicCompressedCertsCache* compressed_certs_cache) | 434 QuicCompressedCertsCache* compressed_certs_cache) |
405 : QuicServerSessionBase(config, | 435 : QuicServerSessionBase(config, |
406 connection, | 436 connection, |
407 &visitor_, | 437 &visitor_, |
408 &helper_, | 438 &helper_, |
409 crypto_config, | 439 crypto_config, |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
607 QuicPacketNumber packet_number, | 637 QuicPacketNumber packet_number, |
608 const string& data, | 638 const string& data, |
609 QuicConnectionIdLength connection_id_length, | 639 QuicConnectionIdLength connection_id_length, |
610 QuicPacketNumberLength packet_number_length, | 640 QuicPacketNumberLength packet_number_length, |
611 QuicVersionVector* versions, | 641 QuicVersionVector* versions, |
612 Perspective perspective) { | 642 Perspective perspective) { |
613 QuicPacketHeader header; | 643 QuicPacketHeader header; |
614 header.public_header.connection_id = connection_id; | 644 header.public_header.connection_id = connection_id; |
615 header.public_header.connection_id_length = connection_id_length; | 645 header.public_header.connection_id_length = connection_id_length; |
616 header.public_header.version_flag = version_flag; | 646 header.public_header.version_flag = version_flag; |
617 header.public_header.multipath_flag = false; | |
618 header.public_header.reset_flag = reset_flag; | 647 header.public_header.reset_flag = reset_flag; |
619 header.public_header.packet_number_length = packet_number_length; | 648 header.public_header.packet_number_length = packet_number_length; |
620 header.packet_number = packet_number; | 649 header.packet_number = packet_number; |
621 QuicStreamFrame stream_frame(1, false, 0, QuicStringPiece(data)); | 650 QuicStreamFrame stream_frame(1, false, 0, QuicStringPiece(data)); |
622 QuicFrame frame(&stream_frame); | 651 QuicFrame frame(&stream_frame); |
623 QuicFrames frames; | 652 QuicFrames frames; |
624 frames.push_back(frame); | 653 frames.push_back(frame); |
625 QuicFramer framer( | 654 QuicFramer framer( |
626 versions != nullptr ? *versions : CurrentSupportedVersions(), | 655 versions != nullptr ? *versions : CurrentSupportedVersions(), |
627 QuicTime::Zero(), perspective); | 656 QuicTime::Zero(), perspective); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 QuicStreamId GetNthClientInitiatedStreamId(QuicVersion version, int n) { | 874 QuicStreamId GetNthClientInitiatedStreamId(QuicVersion version, int n) { |
846 return 5 + NextStreamId(version) * n; | 875 return 5 + NextStreamId(version) * n; |
847 } | 876 } |
848 | 877 |
849 QuicStreamId GetNthServerInitiatedStreamId(QuicVersion version, int n) { | 878 QuicStreamId GetNthServerInitiatedStreamId(QuicVersion version, int n) { |
850 return 2 + NextStreamId(version) * n; | 879 return 2 + NextStreamId(version) * n; |
851 } | 880 } |
852 | 881 |
853 } // namespace test | 882 } // namespace test |
854 } // namespace net | 883 } // namespace net |
OLD | NEW |