| 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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 ~PacketSavingConnection() override; | 464 ~PacketSavingConnection() override; |
| 465 | 465 |
| 466 void SendOrQueuePacket(SerializedPacket* packet) override; | 466 void SendOrQueuePacket(SerializedPacket* packet) override; |
| 467 | 467 |
| 468 std::vector<QuicEncryptedPacket*> encrypted_packets_; | 468 std::vector<QuicEncryptedPacket*> encrypted_packets_; |
| 469 | 469 |
| 470 private: | 470 private: |
| 471 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection); | 471 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection); |
| 472 }; | 472 }; |
| 473 | 473 |
| 474 class MockQuicSession : public QuicSession { |
| 475 public: |
| 476 explicit MockQuicSession(QuicConnection* connection); |
| 477 ~MockQuicSession() override; |
| 478 |
| 479 QuicCryptoStream* GetCryptoStream() override { return crypto_stream_.get(); } |
| 480 |
| 481 MOCK_METHOD3(OnConnectionClosed, |
| 482 void(QuicErrorCode error, |
| 483 const std::string& error_details, |
| 484 ConnectionCloseSource source)); |
| 485 MOCK_METHOD1(CreateIncomingDynamicStream, |
| 486 ReliableQuicStream*(QuicStreamId id)); |
| 487 MOCK_METHOD1(CreateOutgoingDynamicStream, |
| 488 ReliableQuicStream*(SpdyPriority priority)); |
| 489 MOCK_METHOD1(ShouldCreateIncomingDynamicStream, bool(QuicStreamId id)); |
| 490 MOCK_METHOD0(ShouldCreateOutgoingDynamicStream, bool()); |
| 491 MOCK_METHOD5(WritevData, |
| 492 QuicConsumedData(QuicStreamId id, |
| 493 QuicIOVector data, |
| 494 QuicStreamOffset offset, |
| 495 bool fin, |
| 496 QuicAckListenerInterface*)); |
| 497 |
| 498 MOCK_METHOD3(SendRstStream, |
| 499 void(QuicStreamId stream_id, |
| 500 QuicRstStreamErrorCode error, |
| 501 QuicStreamOffset bytes_written)); |
| 502 |
| 503 MOCK_METHOD2(OnStreamHeaders, |
| 504 void(QuicStreamId stream_id, base::StringPiece headers_data)); |
| 505 MOCK_METHOD2(OnStreamHeadersPriority, |
| 506 void(QuicStreamId stream_id, SpdyPriority priority)); |
| 507 MOCK_METHOD3(OnStreamHeadersComplete, |
| 508 void(QuicStreamId stream_id, bool fin, size_t frame_len)); |
| 509 MOCK_METHOD4(OnStreamHeaderList, |
| 510 void(QuicStreamId stream_id, |
| 511 bool fin, |
| 512 size_t frame_len, |
| 513 const QuicHeaderList& header_list)); |
| 514 MOCK_METHOD0(IsCryptoHandshakeConfirmed, bool()); |
| 515 |
| 516 using QuicSession::ActivateStream; |
| 517 |
| 518 // Returns a QuicConsumedData that indicates all of |data| (and |fin| if set) |
| 519 // has been consumed. |
| 520 static QuicConsumedData ConsumeAllData( |
| 521 QuicStreamId id, |
| 522 const QuicIOVector& data, |
| 523 QuicStreamOffset offset, |
| 524 bool fin, |
| 525 QuicAckListenerInterface* ack_notifier_delegate); |
| 526 |
| 527 private: |
| 528 std::unique_ptr<QuicCryptoStream> crypto_stream_; |
| 529 |
| 530 DISALLOW_COPY_AND_ASSIGN(MockQuicSession); |
| 531 }; |
| 532 |
| 474 class MockQuicSpdySession : public QuicSpdySession { | 533 class MockQuicSpdySession : public QuicSpdySession { |
| 475 public: | 534 public: |
| 476 explicit MockQuicSpdySession(QuicConnection* connection); | 535 explicit MockQuicSpdySession(QuicConnection* connection); |
| 477 ~MockQuicSpdySession() override; | 536 ~MockQuicSpdySession() override; |
| 478 | 537 |
| 479 QuicCryptoStream* GetCryptoStream() override { return crypto_stream_.get(); } | 538 QuicCryptoStream* GetCryptoStream() override { return crypto_stream_.get(); } |
| 480 | 539 |
| 481 // From QuicSession. | 540 // From QuicSession. |
| 482 MOCK_METHOD3(OnConnectionClosed, | 541 MOCK_METHOD3(OnConnectionClosed, |
| 483 void(QuicErrorCode error, | 542 void(QuicErrorCode error, |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 TestQuicSpdyServerSession** server_session); | 912 TestQuicSpdyServerSession** server_session); |
| 854 | 913 |
| 855 // Helper to generate client side stream ids, generalizes | 914 // Helper to generate client side stream ids, generalizes |
| 856 // kClientDataStreamId1 etc. above. | 915 // kClientDataStreamId1 etc. above. |
| 857 QuicStreamId QuicClientDataStreamId(int i); | 916 QuicStreamId QuicClientDataStreamId(int i); |
| 858 | 917 |
| 859 } // namespace test | 918 } // namespace test |
| 860 } // namespace net | 919 } // namespace net |
| 861 | 920 |
| 862 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 921 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| OLD | NEW |