| 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 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 // Upper limit on versions we support. | 35 // Upper limit on versions we support. |
| 36 QuicVersion QuicVersionMax(); | 36 QuicVersion QuicVersionMax(); |
| 37 | 37 |
| 38 // Lower limit on versions we support. | 38 // Lower limit on versions we support. |
| 39 QuicVersion QuicVersionMin(); | 39 QuicVersion QuicVersionMin(); |
| 40 | 40 |
| 41 // Returns an address for 127.0.0.1. | 41 // Returns an address for 127.0.0.1. |
| 42 IPAddressNumber Loopback4(); | 42 IPAddressNumber Loopback4(); |
| 43 | 43 |
| 44 // Create an encrypted packet for testing. |
| 45 QuicEncryptedPacket* ConstructEncryptedPacket( |
| 46 QuicConnectionId connection_id, |
| 47 bool version_flag, |
| 48 bool reset_flag, |
| 49 QuicPacketSequenceNumber sequence_number, |
| 50 const std::string& data); |
| 51 |
| 44 void CompareCharArraysWithHexError(const std::string& description, | 52 void CompareCharArraysWithHexError(const std::string& description, |
| 45 const char* actual, | 53 const char* actual, |
| 46 const int actual_len, | 54 const int actual_len, |
| 47 const char* expected, | 55 const char* expected, |
| 48 const int expected_len); | 56 const int expected_len); |
| 49 | 57 |
| 50 bool DecodeHexString(const base::StringPiece& hex, std::string* bytes); | 58 bool DecodeHexString(const base::StringPiece& hex, std::string* bytes); |
| 51 | 59 |
| 52 // Returns the length of a QuicPacket that is capable of holding either a | 60 // Returns the length of a QuicPacket that is capable of holding either a |
| 53 // stream frame or a minimal ack frame. Sets |*payload_length| to the number | 61 // stream frame or a minimal ack frame. Sets |*payload_length| to the number |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 // If the constructor that uses a MockHelper has been used then this method | 297 // If the constructor that uses a MockHelper has been used then this method |
| 290 // will advance the time of the MockClock. | 298 // will advance the time of the MockClock. |
| 291 void AdvanceTime(QuicTime::Delta delta); | 299 void AdvanceTime(QuicTime::Delta delta); |
| 292 | 300 |
| 293 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address, | 301 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address, |
| 294 const IPEndPoint& peer_address, | 302 const IPEndPoint& peer_address, |
| 295 const QuicEncryptedPacket& packet)); | 303 const QuicEncryptedPacket& packet)); |
| 296 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error)); | 304 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error)); |
| 297 MOCK_METHOD2(SendConnectionCloseWithDetails, void(QuicErrorCode error, | 305 MOCK_METHOD2(SendConnectionCloseWithDetails, void(QuicErrorCode error, |
| 298 const string& details)); | 306 const string& details)); |
| 307 MOCK_METHOD2(SendConnectionClosePacket, void(QuicErrorCode error, |
| 308 const string& details)); |
| 299 MOCK_METHOD3(SendRstStream, void(QuicStreamId id, | 309 MOCK_METHOD3(SendRstStream, void(QuicStreamId id, |
| 300 QuicRstStreamErrorCode error, | 310 QuicRstStreamErrorCode error, |
| 301 QuicStreamOffset bytes_written)); | 311 QuicStreamOffset bytes_written)); |
| 302 MOCK_METHOD3(SendGoAway, void(QuicErrorCode error, | 312 MOCK_METHOD3(SendGoAway, void(QuicErrorCode error, |
| 303 QuicStreamId last_good_stream_id, | 313 QuicStreamId last_good_stream_id, |
| 304 const string& reason)); | 314 const string& reason)); |
| 305 MOCK_METHOD1(SendBlocked, void(QuicStreamId id)); | 315 MOCK_METHOD1(SendBlocked, void(QuicStreamId id)); |
| 306 MOCK_METHOD2(SendWindowUpdate, void(QuicStreamId id, | 316 MOCK_METHOD2(SendWindowUpdate, void(QuicStreamId id, |
| 307 QuicStreamOffset byte_offset)); | 317 QuicStreamOffset byte_offset)); |
| 308 MOCK_METHOD0(OnCanWrite, void()); | 318 MOCK_METHOD0(OnCanWrite, void()); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 bool(QuicTime sent_time, QuicPacketSequenceNumber, QuicByteCount, | 435 bool(QuicTime sent_time, QuicPacketSequenceNumber, QuicByteCount, |
| 426 TransmissionType, HasRetransmittableData)); | 436 TransmissionType, HasRetransmittableData)); |
| 427 MOCK_METHOD1(OnRetransmissionTimeout, void(bool)); | 437 MOCK_METHOD1(OnRetransmissionTimeout, void(bool)); |
| 428 MOCK_METHOD2(OnPacketAbandoned, void(QuicPacketSequenceNumber sequence_number, | 438 MOCK_METHOD2(OnPacketAbandoned, void(QuicPacketSequenceNumber sequence_number, |
| 429 QuicByteCount abandoned_bytes)); | 439 QuicByteCount abandoned_bytes)); |
| 430 MOCK_METHOD4(TimeUntilSend, QuicTime::Delta(QuicTime now, TransmissionType, | 440 MOCK_METHOD4(TimeUntilSend, QuicTime::Delta(QuicTime now, TransmissionType, |
| 431 HasRetransmittableData, | 441 HasRetransmittableData, |
| 432 IsHandshake)); | 442 IsHandshake)); |
| 433 MOCK_CONST_METHOD0(BandwidthEstimate, QuicBandwidth(void)); | 443 MOCK_CONST_METHOD0(BandwidthEstimate, QuicBandwidth(void)); |
| 434 MOCK_METHOD1(UpdateRtt, void(QuicTime::Delta rtt_sample)); | 444 MOCK_METHOD1(UpdateRtt, void(QuicTime::Delta rtt_sample)); |
| 435 MOCK_CONST_METHOD0(SmoothedRtt, QuicTime::Delta(void)); | |
| 436 MOCK_CONST_METHOD0(RetransmissionDelay, QuicTime::Delta(void)); | 445 MOCK_CONST_METHOD0(RetransmissionDelay, QuicTime::Delta(void)); |
| 437 MOCK_CONST_METHOD0(GetCongestionWindow, QuicByteCount()); | 446 MOCK_CONST_METHOD0(GetCongestionWindow, QuicByteCount()); |
| 438 | 447 |
| 439 private: | 448 private: |
| 440 DISALLOW_COPY_AND_ASSIGN(MockSendAlgorithm); | 449 DISALLOW_COPY_AND_ASSIGN(MockSendAlgorithm); |
| 441 }; | 450 }; |
| 442 | 451 |
| 443 class MockLossAlgorithm : public LossDetectionInterface { | 452 class MockLossAlgorithm : public LossDetectionInterface { |
| 444 public: | 453 public: |
| 445 MockLossAlgorithm(); | 454 MockLossAlgorithm(); |
| 446 virtual ~MockLossAlgorithm(); | 455 virtual ~MockLossAlgorithm(); |
| 447 | 456 |
| 448 MOCK_METHOD5(DetectLostPackets, | 457 MOCK_METHOD4(DetectLostPackets, |
| 449 SequenceNumberSet(const QuicUnackedPacketMap& unacked_packets, | 458 SequenceNumberSet(const QuicUnackedPacketMap& unacked_packets, |
| 450 const QuicTime& time, | 459 const QuicTime& time, |
| 451 QuicPacketSequenceNumber largest_observed, | 460 QuicPacketSequenceNumber largest_observed, |
| 452 QuicTime::Delta srtt, | 461 const RttStats& rtt_stats)); |
| 453 QuicTime::Delta latest_rtt)); | |
| 454 MOCK_CONST_METHOD0(GetLossTimeout, QuicTime()); | 462 MOCK_CONST_METHOD0(GetLossTimeout, QuicTime()); |
| 455 }; | 463 }; |
| 456 | 464 |
| 457 class TestEntropyCalculator : | 465 class TestEntropyCalculator : |
| 458 public QuicReceivedEntropyHashCalculatorInterface { | 466 public QuicReceivedEntropyHashCalculatorInterface { |
| 459 public: | 467 public: |
| 460 TestEntropyCalculator(); | 468 TestEntropyCalculator(); |
| 461 virtual ~TestEntropyCalculator(); | 469 virtual ~TestEntropyCalculator(); |
| 462 | 470 |
| 463 virtual QuicPacketEntropyHash EntropyHash( | 471 virtual QuicPacketEntropyHash EntropyHash( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 482 | 490 |
| 483 protected: | 491 protected: |
| 484 // Object is ref counted. | 492 // Object is ref counted. |
| 485 virtual ~MockAckNotifierDelegate(); | 493 virtual ~MockAckNotifierDelegate(); |
| 486 }; | 494 }; |
| 487 | 495 |
| 488 } // namespace test | 496 } // namespace test |
| 489 } // namespace net | 497 } // namespace net |
| 490 | 498 |
| 491 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 499 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| OLD | NEW |