| 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 <stddef.h> | 10 #include <stddef.h> |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 ~PacketSavingConnection() override; | 444 ~PacketSavingConnection() override; |
| 445 | 445 |
| 446 void SendOrQueuePacket(SerializedPacket* packet) override; | 446 void SendOrQueuePacket(SerializedPacket* packet) override; |
| 447 | 447 |
| 448 std::vector<QuicEncryptedPacket*> encrypted_packets_; | 448 std::vector<QuicEncryptedPacket*> encrypted_packets_; |
| 449 | 449 |
| 450 private: | 450 private: |
| 451 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection); | 451 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection); |
| 452 }; | 452 }; |
| 453 | 453 |
| 454 class MockQuicSession : public QuicSession { | |
| 455 public: | |
| 456 explicit MockQuicSession(QuicConnection* connection); | |
| 457 ~MockQuicSession() override; | |
| 458 | |
| 459 QuicCryptoStream* GetCryptoStream() override { return crypto_stream_.get(); } | |
| 460 | |
| 461 MOCK_METHOD3(OnConnectionClosed, | |
| 462 void(QuicErrorCode error, | |
| 463 const std::string& error_details, | |
| 464 ConnectionCloseSource source)); | |
| 465 MOCK_METHOD1(CreateIncomingDynamicStream, | |
| 466 ReliableQuicStream*(QuicStreamId id)); | |
| 467 MOCK_METHOD1(CreateOutgoingDynamicStream, | |
| 468 ReliableQuicStream*(SpdyPriority priority)); | |
| 469 MOCK_METHOD1(ShouldCreateIncomingDynamicStream, bool(QuicStreamId id)); | |
| 470 MOCK_METHOD0(ShouldCreateOutgoingDynamicStream, bool()); | |
| 471 MOCK_METHOD5(WritevData, | |
| 472 QuicConsumedData(QuicStreamId id, | |
| 473 QuicIOVector data, | |
| 474 QuicStreamOffset offset, | |
| 475 bool fin, | |
| 476 QuicAckListenerInterface*)); | |
| 477 | |
| 478 MOCK_METHOD3(SendRstStream, | |
| 479 void(QuicStreamId stream_id, | |
| 480 QuicRstStreamErrorCode error, | |
| 481 QuicStreamOffset bytes_written)); | |
| 482 | |
| 483 MOCK_METHOD2(OnStreamHeaders, | |
| 484 void(QuicStreamId stream_id, base::StringPiece headers_data)); | |
| 485 MOCK_METHOD2(OnStreamHeadersPriority, | |
| 486 void(QuicStreamId stream_id, SpdyPriority priority)); | |
| 487 MOCK_METHOD3(OnStreamHeadersComplete, | |
| 488 void(QuicStreamId stream_id, bool fin, size_t frame_len)); | |
| 489 MOCK_METHOD4(OnStreamHeaderList, | |
| 490 void(QuicStreamId stream_id, | |
| 491 bool fin, | |
| 492 size_t frame_len, | |
| 493 const QuicHeaderList& header_list)); | |
| 494 MOCK_METHOD0(IsCryptoHandshakeConfirmed, bool()); | |
| 495 | |
| 496 using QuicSession::ActivateStream; | |
| 497 | |
| 498 // Returns a QuicConsumedData that indicates all of |data| (and |fin| if set) | |
| 499 // has been consumed. | |
| 500 static QuicConsumedData ConsumeAllData( | |
| 501 QuicStreamId id, | |
| 502 const QuicIOVector& data, | |
| 503 QuicStreamOffset offset, | |
| 504 bool fin, | |
| 505 QuicAckListenerInterface* ack_notifier_delegate); | |
| 506 | |
| 507 private: | |
| 508 std::unique_ptr<QuicCryptoStream> crypto_stream_; | |
| 509 | |
| 510 DISALLOW_COPY_AND_ASSIGN(MockQuicSession); | |
| 511 }; | |
| 512 | |
| 513 class MockQuicSpdySession : public QuicSpdySession { | 454 class MockQuicSpdySession : public QuicSpdySession { |
| 514 public: | 455 public: |
| 515 explicit MockQuicSpdySession(QuicConnection* connection); | 456 explicit MockQuicSpdySession(QuicConnection* connection); |
| 516 ~MockQuicSpdySession() override; | 457 ~MockQuicSpdySession() override; |
| 517 | 458 |
| 518 QuicCryptoStream* GetCryptoStream() override { return crypto_stream_.get(); } | 459 QuicCryptoStream* GetCryptoStream() override { return crypto_stream_.get(); } |
| 519 | 460 |
| 520 // From QuicSession. | 461 // From QuicSession. |
| 521 MOCK_METHOD3(OnConnectionClosed, | 462 MOCK_METHOD3(OnConnectionClosed, |
| 522 void(QuicErrorCode error, | 463 void(QuicErrorCode error, |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 TestQuicSpdyServerSession** server_session); | 821 TestQuicSpdyServerSession** server_session); |
| 881 | 822 |
| 882 // Helper to generate client side stream ids, generalizes | 823 // Helper to generate client side stream ids, generalizes |
| 883 // kClientDataStreamId1 etc. above. | 824 // kClientDataStreamId1 etc. above. |
| 884 QuicStreamId QuicClientDataStreamId(int i); | 825 QuicStreamId QuicClientDataStreamId(int i); |
| 885 | 826 |
| 886 } // namespace test | 827 } // namespace test |
| 887 } // namespace net | 828 } // namespace net |
| 888 | 829 |
| 889 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 830 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| OLD | NEW |