| 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 <string> | 10 #include <string> |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 scoped_ptr<QuicVersionNegotiationPacket> version_negotiation_packet_; | 168 scoped_ptr<QuicVersionNegotiationPacket> version_negotiation_packet_; |
| 169 | 169 |
| 170 DISALLOW_COPY_AND_ASSIGN(FramerVisitorCapturingFrames); | 170 DISALLOW_COPY_AND_ASSIGN(FramerVisitorCapturingFrames); |
| 171 }; | 171 }; |
| 172 | 172 |
| 173 class MockConnectionVisitor : public QuicConnectionVisitorInterface { | 173 class MockConnectionVisitor : public QuicConnectionVisitorInterface { |
| 174 public: | 174 public: |
| 175 MockConnectionVisitor(); | 175 MockConnectionVisitor(); |
| 176 virtual ~MockConnectionVisitor(); | 176 virtual ~MockConnectionVisitor(); |
| 177 | 177 |
| 178 MOCK_METHOD4(OnPacket, bool(const IPEndPoint& self_address, | 178 MOCK_METHOD1(OnStreamFrames, bool(const std::vector<QuicStreamFrame>& frame)); |
| 179 const IPEndPoint& peer_address, | |
| 180 const QuicPacketHeader& header, | |
| 181 const std::vector<QuicStreamFrame>& frame)); | |
| 182 MOCK_METHOD1(OnRstStream, void(const QuicRstStreamFrame& frame)); | 179 MOCK_METHOD1(OnRstStream, void(const QuicRstStreamFrame& frame)); |
| 183 MOCK_METHOD1(OnGoAway, void(const QuicGoAwayFrame& frame)); | 180 MOCK_METHOD1(OnGoAway, void(const QuicGoAwayFrame& frame)); |
| 184 MOCK_METHOD2(ConnectionClose, void(QuicErrorCode error, bool from_peer)); | 181 MOCK_METHOD2(ConnectionClose, void(QuicErrorCode error, bool from_peer)); |
| 185 MOCK_METHOD1(OnAck, void(const SequenceNumberSet& acked_packets)); | |
| 186 MOCK_METHOD0(OnCanWrite, bool()); | 182 MOCK_METHOD0(OnCanWrite, bool()); |
| 183 MOCK_CONST_METHOD0(HasPendingHandshake, bool()); |
| 187 MOCK_METHOD1(OnSuccessfulVersionNegotiation, | 184 MOCK_METHOD1(OnSuccessfulVersionNegotiation, |
| 188 void(const QuicVersion& version)); | 185 void(const QuicVersion& version)); |
| 189 | 186 |
| 190 private: | 187 private: |
| 191 DISALLOW_COPY_AND_ASSIGN(MockConnectionVisitor); | 188 DISALLOW_COPY_AND_ASSIGN(MockConnectionVisitor); |
| 192 }; | 189 }; |
| 193 | 190 |
| 194 class MockHelper : public QuicConnectionHelperInterface { | 191 class MockHelper : public QuicConnectionHelperInterface { |
| 195 public: | 192 public: |
| 196 MockHelper(); | 193 MockHelper(); |
| 197 virtual ~MockHelper(); | 194 virtual ~MockHelper(); |
| 198 | 195 |
| 199 MOCK_METHOD1(SetConnection, void(QuicConnection* connection)); | 196 MOCK_METHOD1(SetConnection, void(QuicConnection* connection)); |
| 200 const QuicClock* GetClock() const; | 197 const QuicClock* GetClock() const; |
| 201 QuicRandom* GetRandomGenerator(); | 198 QuicRandom* GetRandomGenerator(); |
| 202 void AdvanceTime(QuicTime::Delta delta); | 199 void AdvanceTime(QuicTime::Delta delta); |
| 203 MOCK_METHOD2(WritePacketToWire, int(const QuicEncryptedPacket& packet, | 200 MOCK_METHOD2(WritePacketToWire, int(const QuicEncryptedPacket& packet, |
| 204 int* error)); | 201 int* error)); |
| 205 MOCK_METHOD0(IsWriteBlockedDataBuffered, bool()); | 202 MOCK_METHOD0(IsWriteBlockedDataBuffered, bool()); |
| 206 MOCK_METHOD1(IsWriteBlocked, bool(int)); | 203 MOCK_METHOD1(IsWriteBlocked, bool(int stream_id)); |
| 207 virtual QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate); | 204 virtual QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate); |
| 208 | 205 |
| 209 private: | 206 private: |
| 210 MockClock clock_; | 207 MockClock clock_; |
| 211 MockRandom random_generator_; | 208 MockRandom random_generator_; |
| 212 }; | 209 }; |
| 213 | 210 |
| 214 class MockConnection : public QuicConnection { | 211 class MockConnection : public QuicConnection { |
| 215 public: | 212 public: |
| 216 // Uses a MockHelper. | 213 // Uses a MockHelper. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 230 const QuicEncryptedPacket& packet)); | 227 const QuicEncryptedPacket& packet)); |
| 231 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error)); | 228 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error)); |
| 232 MOCK_METHOD2(SendConnectionCloseWithDetails, void(QuicErrorCode error, | 229 MOCK_METHOD2(SendConnectionCloseWithDetails, void(QuicErrorCode error, |
| 233 const string& details)); | 230 const string& details)); |
| 234 MOCK_METHOD2(SendRstStream, void(QuicStreamId id, | 231 MOCK_METHOD2(SendRstStream, void(QuicStreamId id, |
| 235 QuicRstStreamErrorCode error)); | 232 QuicRstStreamErrorCode error)); |
| 236 MOCK_METHOD3(SendGoAway, void(QuicErrorCode error, | 233 MOCK_METHOD3(SendGoAway, void(QuicErrorCode error, |
| 237 QuicStreamId last_good_stream_id, | 234 QuicStreamId last_good_stream_id, |
| 238 const string& reason)); | 235 const string& reason)); |
| 239 MOCK_METHOD0(OnCanWrite, bool()); | 236 MOCK_METHOD0(OnCanWrite, bool()); |
| 237 MOCK_CONST_METHOD0(HasPendingHandshake, bool()); |
| 240 | 238 |
| 241 void ProcessUdpPacketInternal(const IPEndPoint& self_address, | 239 void ProcessUdpPacketInternal(const IPEndPoint& self_address, |
| 242 const IPEndPoint& peer_address, | 240 const IPEndPoint& peer_address, |
| 243 const QuicEncryptedPacket& packet) { | 241 const QuicEncryptedPacket& packet) { |
| 244 QuicConnection::ProcessUdpPacket(self_address, peer_address, packet); | 242 QuicConnection::ProcessUdpPacket(self_address, peer_address, packet); |
| 245 } | 243 } |
| 246 | 244 |
| 247 virtual bool OnProtocolVersionMismatch(QuicVersion version) OVERRIDE { | 245 virtual bool OnProtocolVersionMismatch(QuicVersion version) OVERRIDE { |
| 248 return false; | 246 return false; |
| 249 } | 247 } |
| 250 | 248 |
| 251 private: | 249 private: |
| 252 const bool has_mock_helper_; | 250 const bool has_mock_helper_; |
| 253 | 251 |
| 254 DISALLOW_COPY_AND_ASSIGN(MockConnection); | 252 DISALLOW_COPY_AND_ASSIGN(MockConnection); |
| 255 }; | 253 }; |
| 256 | 254 |
| 257 class PacketSavingConnection : public MockConnection { | 255 class PacketSavingConnection : public MockConnection { |
| 258 public: | 256 public: |
| 259 PacketSavingConnection(QuicGuid guid, IPEndPoint address, bool is_server); | 257 PacketSavingConnection(QuicGuid guid, IPEndPoint address, bool is_server); |
| 260 virtual ~PacketSavingConnection(); | 258 virtual ~PacketSavingConnection(); |
| 261 | 259 |
| 262 virtual bool SendOrQueuePacket( | 260 virtual bool SendOrQueuePacket( |
| 263 EncryptionLevel level, | 261 EncryptionLevel level, |
| 264 QuicPacketSequenceNumber sequence_number, | 262 QuicPacketSequenceNumber sequence_number, |
| 265 QuicPacket* packet, | 263 QuicPacket* packet, |
| 266 QuicPacketEntropyHash entropy_hash, | 264 QuicPacketEntropyHash entropy_hash, |
| 267 HasRetransmittableData has_retransmittable_data) OVERRIDE; | 265 HasRetransmittableData has_retransmittable_data, |
| 266 Force forced) OVERRIDE; |
| 268 | 267 |
| 269 std::vector<QuicPacket*> packets_; | 268 std::vector<QuicPacket*> packets_; |
| 270 std::vector<QuicEncryptedPacket*> encrypted_packets_; | 269 std::vector<QuicEncryptedPacket*> encrypted_packets_; |
| 271 | 270 |
| 272 private: | 271 private: |
| 273 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection); | 272 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection); |
| 274 }; | 273 }; |
| 275 | 274 |
| 276 class MockSession : public QuicSession { | 275 class MockSession : public QuicSession { |
| 277 public: | 276 public: |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 MockAckNotifierDelegate(); | 374 MockAckNotifierDelegate(); |
| 376 virtual ~MockAckNotifierDelegate(); | 375 virtual ~MockAckNotifierDelegate(); |
| 377 | 376 |
| 378 MOCK_METHOD0(OnAckNotification, void()); | 377 MOCK_METHOD0(OnAckNotification, void()); |
| 379 }; | 378 }; |
| 380 | 379 |
| 381 } // namespace test | 380 } // namespace test |
| 382 } // namespace net | 381 } // namespace net |
| 383 | 382 |
| 384 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 383 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| OLD | NEW |