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 // Common utilities for Quic tests | 5 // Common utilities for Quic tests |
6 | 6 |
7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
9 | 9 |
10 #include <cstdint> | 10 #include <cstdint> |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 void QuicConnection_OnError(QuicFramer* framer) { | 419 void QuicConnection_OnError(QuicFramer* framer) { |
420 QuicConnection::OnError(framer); | 420 QuicConnection::OnError(framer); |
421 } | 421 } |
422 | 422 |
423 void ReallyProcessUdpPacket(const QuicSocketAddress& self_address, | 423 void ReallyProcessUdpPacket(const QuicSocketAddress& self_address, |
424 const QuicSocketAddress& peer_address, | 424 const QuicSocketAddress& peer_address, |
425 const QuicReceivedPacket& packet) { | 425 const QuicReceivedPacket& packet) { |
426 QuicConnection::ProcessUdpPacket(self_address, peer_address, packet); | 426 QuicConnection::ProcessUdpPacket(self_address, peer_address, packet); |
427 } | 427 } |
428 | 428 |
429 bool OnProtocolVersionMismatch(QuicVersion version) override { return false; } | 429 bool OnProtocolVersionMismatch(QuicVersion version) override; |
430 | 430 |
431 void ReallySendGoAway(QuicErrorCode error, | 431 void ReallySendGoAway(QuicErrorCode error, |
432 QuicStreamId last_good_stream_id, | 432 QuicStreamId last_good_stream_id, |
433 const std::string& reason) { | 433 const std::string& reason) { |
434 QuicConnection::SendGoAway(error, last_good_stream_id, reason); | 434 QuicConnection::SendGoAway(error, last_good_stream_id, reason); |
435 } | 435 } |
436 | 436 |
437 private: | 437 private: |
438 DISALLOW_COPY_AND_ASSIGN(MockQuicConnection); | 438 DISALLOW_COPY_AND_ASSIGN(MockQuicConnection); |
439 }; | 439 }; |
(...skipping 18 matching lines...) Expand all Loading... |
458 private: | 458 private: |
459 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection); | 459 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection); |
460 }; | 460 }; |
461 | 461 |
462 class MockQuicSession : public QuicSession { | 462 class MockQuicSession : public QuicSession { |
463 public: | 463 public: |
464 // Takes ownership of |connection|. | 464 // Takes ownership of |connection|. |
465 explicit MockQuicSession(QuicConnection* connection); | 465 explicit MockQuicSession(QuicConnection* connection); |
466 ~MockQuicSession() override; | 466 ~MockQuicSession() override; |
467 | 467 |
468 QuicCryptoStream* GetMutableCryptoStream() override { | 468 QuicCryptoStream* GetMutableCryptoStream() override; |
469 return crypto_stream_.get(); | 469 const QuicCryptoStream* GetCryptoStream() const override; |
470 } | |
471 | |
472 const QuicCryptoStream* GetCryptoStream() const override { | |
473 return crypto_stream_.get(); | |
474 } | |
475 | 470 |
476 MOCK_METHOD3(OnConnectionClosed, | 471 MOCK_METHOD3(OnConnectionClosed, |
477 void(QuicErrorCode error, | 472 void(QuicErrorCode error, |
478 const std::string& error_details, | 473 const std::string& error_details, |
479 ConnectionCloseSource source)); | 474 ConnectionCloseSource source)); |
480 MOCK_METHOD1(CreateIncomingDynamicStream, QuicStream*(QuicStreamId id)); | 475 MOCK_METHOD1(CreateIncomingDynamicStream, QuicStream*(QuicStreamId id)); |
481 MOCK_METHOD1(CreateOutgoingDynamicStream, QuicStream*(SpdyPriority priority)); | 476 MOCK_METHOD1(CreateOutgoingDynamicStream, QuicStream*(SpdyPriority priority)); |
482 MOCK_METHOD1(MaybeCreateIncomingDynamicStream, QuicStream*(QuicStreamId id)); | 477 MOCK_METHOD1(MaybeCreateIncomingDynamicStream, QuicStream*(QuicStreamId id)); |
483 MOCK_METHOD1(MaybeCreateOutgoingDynamicStream, | 478 MOCK_METHOD1(MaybeCreateOutgoingDynamicStream, |
484 QuicStream*(SpdyPriority priority)); | 479 QuicStream*(SpdyPriority priority)); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 | 520 |
526 DISALLOW_COPY_AND_ASSIGN(MockQuicSession); | 521 DISALLOW_COPY_AND_ASSIGN(MockQuicSession); |
527 }; | 522 }; |
528 | 523 |
529 class MockQuicSpdySession : public QuicSpdySession { | 524 class MockQuicSpdySession : public QuicSpdySession { |
530 public: | 525 public: |
531 // Takes ownership of |connection|. | 526 // Takes ownership of |connection|. |
532 explicit MockQuicSpdySession(QuicConnection* connection); | 527 explicit MockQuicSpdySession(QuicConnection* connection); |
533 ~MockQuicSpdySession() override; | 528 ~MockQuicSpdySession() override; |
534 | 529 |
535 QuicCryptoStream* GetMutableCryptoStream() override { | 530 QuicCryptoStream* GetMutableCryptoStream() override; |
536 return crypto_stream_.get(); | 531 const QuicCryptoStream* GetCryptoStream() const override; |
537 } | |
538 const QuicCryptoStream* GetCryptoStream() const override { | |
539 return crypto_stream_.get(); | |
540 } | |
541 const SpdyHeaderBlock& GetWriteHeaders() { return write_headers_; } | 532 const SpdyHeaderBlock& GetWriteHeaders() { return write_headers_; } |
542 | 533 |
543 // From QuicSession. | 534 // From QuicSession. |
544 MOCK_METHOD3(OnConnectionClosed, | 535 MOCK_METHOD3(OnConnectionClosed, |
545 void(QuicErrorCode error, | 536 void(QuicErrorCode error, |
546 const std::string& error_details, | 537 const std::string& error_details, |
547 ConnectionCloseSource source)); | 538 ConnectionCloseSource source)); |
548 MOCK_METHOD1(CreateIncomingDynamicStream, QuicSpdyStream*(QuicStreamId id)); | 539 MOCK_METHOD1(CreateIncomingDynamicStream, QuicSpdyStream*(QuicStreamId id)); |
549 MOCK_METHOD1(CreateOutgoingDynamicStream, | 540 MOCK_METHOD1(CreateOutgoingDynamicStream, |
550 QuicSpdyStream*(SpdyPriority priority)); | 541 QuicSpdyStream*(SpdyPriority priority)); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
589 QuicStreamId promised_stream_id, | 580 QuicStreamId promised_stream_id, |
590 size_t frame_len, | 581 size_t frame_len, |
591 const QuicHeaderList& header_list)); | 582 const QuicHeaderList& header_list)); |
592 // Methods taking non-copyable types like SpdyHeaderBlock by value cannot be | 583 // Methods taking non-copyable types like SpdyHeaderBlock by value cannot be |
593 // mocked directly. | 584 // mocked directly. |
594 size_t WriteHeaders(QuicStreamId id, | 585 size_t WriteHeaders(QuicStreamId id, |
595 SpdyHeaderBlock headers, | 586 SpdyHeaderBlock headers, |
596 bool fin, | 587 bool fin, |
597 SpdyPriority priority, | 588 SpdyPriority priority, |
598 QuicReferenceCountedPointer<QuicAckListenerInterface> | 589 QuicReferenceCountedPointer<QuicAckListenerInterface> |
599 ack_listener) override { | 590 ack_listener) override; |
600 write_headers_ = std::move(headers); | |
601 return WriteHeadersMock(id, write_headers_, fin, priority, ack_listener); | |
602 } | |
603 MOCK_METHOD5( | 591 MOCK_METHOD5( |
604 WriteHeadersMock, | 592 WriteHeadersMock, |
605 size_t(QuicStreamId id, | 593 size_t(QuicStreamId id, |
606 const SpdyHeaderBlock& headers, | 594 const SpdyHeaderBlock& headers, |
607 bool fin, | 595 bool fin, |
608 SpdyPriority priority, | 596 SpdyPriority priority, |
609 const QuicReferenceCountedPointer<QuicAckListenerInterface>& | 597 const QuicReferenceCountedPointer<QuicAckListenerInterface>& |
610 ack_listener)); | 598 ack_listener)); |
611 MOCK_METHOD1(OnHeadersHeadOfLineBlocking, void(QuicTime::Delta delta)); | 599 MOCK_METHOD1(OnHeadersHeadOfLineBlocking, void(QuicTime::Delta delta)); |
612 MOCK_METHOD4( | 600 MOCK_METHOD4( |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 // Utilities that will adapt stream ids when http stream pairs are | 999 // Utilities that will adapt stream ids when http stream pairs are |
1012 // enabled. | 1000 // enabled. |
1013 QuicStreamId NextStreamId(QuicVersion version); | 1001 QuicStreamId NextStreamId(QuicVersion version); |
1014 QuicStreamId GetNthClientInitiatedStreamId(QuicVersion version, int n); | 1002 QuicStreamId GetNthClientInitiatedStreamId(QuicVersion version, int n); |
1015 QuicStreamId GetNthServerInitiatedStreamId(QuicVersion version, int n); | 1003 QuicStreamId GetNthServerInitiatedStreamId(QuicVersion version, int n); |
1016 | 1004 |
1017 } // namespace test | 1005 } // namespace test |
1018 } // namespace net | 1006 } // namespace net |
1019 | 1007 |
1020 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 1008 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
OLD | NEW |