| 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_METHOD0(IsCryptoHandshakeConfirmed, bool()); |
| 490 |
| 491 using QuicSession::ActivateStream; |
| 492 |
| 493 // Returns a QuicConsumedData that indicates all of |data| (and |fin| if set) |
| 494 // has been consumed. |
| 495 static QuicConsumedData ConsumeAllData( |
| 496 QuicStreamId id, |
| 497 const QuicIOVector& data, |
| 498 QuicStreamOffset offset, |
| 499 bool fin, |
| 500 QuicAckListenerInterface* ack_notifier_delegate); |
| 501 |
| 502 private: |
| 503 std::unique_ptr<QuicCryptoStream> crypto_stream_; |
| 504 |
| 505 DISALLOW_COPY_AND_ASSIGN(MockQuicSession); |
| 506 }; |
| 507 |
| 454 class MockQuicSpdySession : public QuicSpdySession { | 508 class MockQuicSpdySession : public QuicSpdySession { |
| 455 public: | 509 public: |
| 456 explicit MockQuicSpdySession(QuicConnection* connection); | 510 explicit MockQuicSpdySession(QuicConnection* connection); |
| 457 ~MockQuicSpdySession() override; | 511 ~MockQuicSpdySession() override; |
| 458 | 512 |
| 459 QuicCryptoStream* GetCryptoStream() override { return crypto_stream_.get(); } | 513 QuicCryptoStream* GetCryptoStream() override { return crypto_stream_.get(); } |
| 460 | 514 |
| 461 // From QuicSession. | 515 // From QuicSession. |
| 462 MOCK_METHOD3(OnConnectionClosed, | 516 MOCK_METHOD3(OnConnectionClosed, |
| 463 void(QuicErrorCode error, | 517 void(QuicErrorCode error, |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 821 TestQuicSpdyServerSession** server_session); | 875 TestQuicSpdyServerSession** server_session); |
| 822 | 876 |
| 823 // Helper to generate client side stream ids, generalizes | 877 // Helper to generate client side stream ids, generalizes |
| 824 // kClientDataStreamId1 etc. above. | 878 // kClientDataStreamId1 etc. above. |
| 825 QuicStreamId QuicClientDataStreamId(int i); | 879 QuicStreamId QuicClientDataStreamId(int i); |
| 826 | 880 |
| 827 } // namespace test | 881 } // namespace test |
| 828 } // namespace net | 882 } // namespace net |
| 829 | 883 |
| 830 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 884 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| OLD | NEW |