| 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_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 7 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| 8 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 8 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 public: | 37 public: |
| 38 SimpleRandom() : seed_(0) {} | 38 SimpleRandom() : seed_(0) {} |
| 39 | 39 |
| 40 // Returns a random number in the range [0, kuint64max]. | 40 // Returns a random number in the range [0, kuint64max]. |
| 41 uint64 RandUint64(); | 41 uint64 RandUint64(); |
| 42 | 42 |
| 43 void set_seed(uint64 seed) { seed_ = seed; } | 43 void set_seed(uint64 seed) { seed_ = seed; } |
| 44 | 44 |
| 45 private: | 45 private: |
| 46 uint64 seed_; | 46 uint64 seed_; |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(SimpleRandom); |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 class MockConnection : public QuicConnection { | 51 class MockConnection : public QuicConnection { |
| 50 public: | 52 public: |
| 51 // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123. | 53 // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123. |
| 52 explicit MockConnection(bool is_server); | 54 explicit MockConnection(bool is_server); |
| 53 | 55 |
| 54 // Uses a MockHelper, ConnectionId of 42. | 56 // Uses a MockHelper, ConnectionId of 42. |
| 55 MockConnection(IPEndPoint address, bool is_server); | 57 MockConnection(IPEndPoint address, bool is_server); |
| 56 | 58 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 111 |
| 110 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); | 112 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); |
| 111 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); | 113 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); |
| 112 | 114 |
| 113 void SetCryptoStream(QuicCryptoStream* stream); | 115 void SetCryptoStream(QuicCryptoStream* stream); |
| 114 | 116 |
| 115 virtual QuicCryptoStream* GetCryptoStream() OVERRIDE; | 117 virtual QuicCryptoStream* GetCryptoStream() OVERRIDE; |
| 116 | 118 |
| 117 private: | 119 private: |
| 118 QuicCryptoStream* crypto_stream_; | 120 QuicCryptoStream* crypto_stream_; |
| 121 |
| 119 DISALLOW_COPY_AND_ASSIGN(TestSession); | 122 DISALLOW_COPY_AND_ASSIGN(TestSession); |
| 120 }; | 123 }; |
| 121 | 124 |
| 122 class MockPacketWriter : public QuicPacketWriter { | 125 class MockPacketWriter : public QuicPacketWriter { |
| 123 public: | 126 public: |
| 124 MockPacketWriter(); | 127 MockPacketWriter(); |
| 125 virtual ~MockPacketWriter(); | 128 virtual ~MockPacketWriter(); |
| 126 | 129 |
| 127 MOCK_METHOD4(WritePacket, | 130 MOCK_METHOD4(WritePacket, |
| 128 WriteResult(const char* buffer, | 131 WriteResult(const char* buffer, |
| 129 size_t buf_len, | 132 size_t buf_len, |
| 130 const IPAddressNumber& self_address, | 133 const IPAddressNumber& self_address, |
| 131 const IPEndPoint& peer_address)); | 134 const IPEndPoint& peer_address)); |
| 132 MOCK_CONST_METHOD0(IsWriteBlockedDataBuffered, bool()); | 135 MOCK_CONST_METHOD0(IsWriteBlockedDataBuffered, bool()); |
| 133 MOCK_CONST_METHOD0(IsWriteBlocked, bool()); | 136 MOCK_CONST_METHOD0(IsWriteBlocked, bool()); |
| 134 MOCK_METHOD0(SetWritable, void()); | 137 MOCK_METHOD0(SetWritable, void()); |
| 138 |
| 139 private: |
| 140 DISALLOW_COPY_AND_ASSIGN(MockPacketWriter); |
| 135 }; | 141 }; |
| 136 | 142 |
| 137 class MockQuicServerSessionVisitor : public QuicServerSessionVisitor { | 143 class MockQuicServerSessionVisitor : public QuicServerSessionVisitor { |
| 138 public: | 144 public: |
| 139 MockQuicServerSessionVisitor(); | 145 MockQuicServerSessionVisitor(); |
| 140 virtual ~MockQuicServerSessionVisitor(); | 146 virtual ~MockQuicServerSessionVisitor(); |
| 141 MOCK_METHOD2(OnConnectionClosed, void(QuicConnectionId connection_id, | 147 MOCK_METHOD2(OnConnectionClosed, void(QuicConnectionId connection_id, |
| 142 QuicErrorCode error)); | 148 QuicErrorCode error)); |
| 143 MOCK_METHOD1(OnWriteBlocked, void(QuicBlockedWriterInterface* writer)); | 149 MOCK_METHOD1(OnWriteBlocked, void(QuicBlockedWriterInterface* writer)); |
| 150 |
| 151 private: |
| 152 DISALLOW_COPY_AND_ASSIGN(MockQuicServerSessionVisitor); |
| 144 }; | 153 }; |
| 145 | 154 |
| 146 class MockAckNotifierDelegate : public QuicAckNotifier::DelegateInterface { | 155 class MockAckNotifierDelegate : public QuicAckNotifier::DelegateInterface { |
| 147 public: | 156 public: |
| 148 MockAckNotifierDelegate(); | 157 MockAckNotifierDelegate(); |
| 149 | 158 |
| 150 MOCK_METHOD5(OnAckNotification, void(int num_original_packets, | 159 MOCK_METHOD5(OnAckNotification, void(int num_original_packets, |
| 151 int num_original_bytes, | 160 int num_original_bytes, |
| 152 int num_retransmitted_packets, | 161 int num_retransmitted_packets, |
| 153 int num_retransmitted_bytes, | 162 int num_retransmitted_bytes, |
| 154 QuicTime::Delta delta_largest_observed)); | 163 QuicTime::Delta delta_largest_observed)); |
| 155 | 164 |
| 156 protected: | 165 protected: |
| 157 // Object is ref counted. | 166 // Object is ref counted. |
| 158 virtual ~MockAckNotifierDelegate(); | 167 virtual ~MockAckNotifierDelegate(); |
| 168 |
| 169 DISALLOW_COPY_AND_ASSIGN(MockAckNotifierDelegate); |
| 159 }; | 170 }; |
| 160 | 171 |
| 161 } // namespace test | 172 } // namespace test |
| 162 } // namespace tools | 173 } // namespace tools |
| 163 } // namespace net | 174 } // namespace net |
| 164 | 175 |
| 165 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 176 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| OLD | NEW |