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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
| 13 #include "base/basictypes.h" |
13 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
14 #include "net/quic/congestion_control/loss_detection_interface.h" | 15 #include "net/quic/congestion_control/loss_detection_interface.h" |
15 #include "net/quic/congestion_control/send_algorithm_interface.h" | 16 #include "net/quic/congestion_control/send_algorithm_interface.h" |
16 #include "net/quic/quic_ack_notifier.h" | 17 #include "net/quic/quic_ack_notifier.h" |
17 #include "net/quic/quic_client_session_base.h" | 18 #include "net/quic/quic_client_session_base.h" |
18 #include "net/quic/quic_connection.h" | 19 #include "net/quic/quic_connection.h" |
19 #include "net/quic/quic_dispatcher.h" | 20 #include "net/quic/quic_dispatcher.h" |
20 #include "net/quic/quic_framer.h" | 21 #include "net/quic/quic_framer.h" |
21 #include "net/quic/quic_per_connection_packet_writer.h" | 22 #include "net/quic/quic_per_connection_packet_writer.h" |
22 #include "net/quic/quic_sent_packet_manager.h" | 23 #include "net/quic/quic_sent_packet_manager.h" |
23 #include "net/quic/quic_session.h" | 24 #include "net/quic/quic_session.h" |
24 #include "net/quic/test_tools/mock_clock.h" | 25 #include "net/quic/test_tools/mock_clock.h" |
25 #include "net/quic/test_tools/mock_random.h" | 26 #include "net/quic/test_tools/mock_random.h" |
26 #include "net/spdy/spdy_framer.h" | 27 #include "net/spdy/spdy_framer.h" |
27 #include "testing/gmock/include/gmock/gmock.h" | 28 #include "testing/gmock/include/gmock/gmock.h" |
28 | 29 |
29 namespace net { | 30 namespace net { |
30 | 31 |
31 namespace test { | 32 namespace test { |
32 | 33 |
33 static const QuicConnectionId kTestConnectionId = 42; | 34 static const QuicConnectionId kTestConnectionId = 42; |
34 static const int kTestPort = 123; | 35 static const uint16 kTestPort = 123; |
35 static const uint32 kInitialStreamFlowControlWindowForTest = | 36 static const uint32 kInitialStreamFlowControlWindowForTest = |
36 32 * 1024; // 32 KB | 37 32 * 1024; // 32 KB |
37 static const uint32 kInitialSessionFlowControlWindowForTest = | 38 static const uint32 kInitialSessionFlowControlWindowForTest = |
38 64 * 1024; // 64 KB | 39 64 * 1024; // 64 KB |
39 | 40 |
40 // Data stream IDs start at 5: the crypto stream is 1, headers stream is 3. | 41 // Data stream IDs start at 5: the crypto stream is 1, headers stream is 3. |
41 static const QuicStreamId kClientDataStreamId1 = 5; | 42 static const QuicStreamId kClientDataStreamId1 = 5; |
42 static const QuicStreamId kClientDataStreamId2 = 7; | 43 static const QuicStreamId kClientDataStreamId2 = 7; |
43 static const QuicStreamId kClientDataStreamId3 = 9; | 44 static const QuicStreamId kClientDataStreamId3 = 9; |
44 static const QuicStreamId kClientDataStreamId4 = 11; | 45 static const QuicStreamId kClientDataStreamId4 = 11; |
(...skipping 98 matching lines...) Loading... |
143 | 144 |
144 private: | 145 private: |
145 uint64 seed_; | 146 uint64 seed_; |
146 | 147 |
147 DISALLOW_COPY_AND_ASSIGN(SimpleRandom); | 148 DISALLOW_COPY_AND_ASSIGN(SimpleRandom); |
148 }; | 149 }; |
149 | 150 |
150 class MockFramerVisitor : public QuicFramerVisitorInterface { | 151 class MockFramerVisitor : public QuicFramerVisitorInterface { |
151 public: | 152 public: |
152 MockFramerVisitor(); | 153 MockFramerVisitor(); |
153 virtual ~MockFramerVisitor(); | 154 ~MockFramerVisitor() override; |
154 | 155 |
155 MOCK_METHOD1(OnError, void(QuicFramer* framer)); | 156 MOCK_METHOD1(OnError, void(QuicFramer* framer)); |
156 // The constructor sets this up to return false by default. | 157 // The constructor sets this up to return false by default. |
157 MOCK_METHOD1(OnProtocolVersionMismatch, bool(QuicVersion version)); | 158 MOCK_METHOD1(OnProtocolVersionMismatch, bool(QuicVersion version)); |
158 MOCK_METHOD0(OnPacket, void()); | 159 MOCK_METHOD0(OnPacket, void()); |
159 MOCK_METHOD1(OnPublicResetPacket, void(const QuicPublicResetPacket& header)); | 160 MOCK_METHOD1(OnPublicResetPacket, void(const QuicPublicResetPacket& header)); |
160 MOCK_METHOD1(OnVersionNegotiationPacket, | 161 MOCK_METHOD1(OnVersionNegotiationPacket, |
161 void(const QuicVersionNegotiationPacket& packet)); | 162 void(const QuicVersionNegotiationPacket& packet)); |
162 MOCK_METHOD0(OnRevivedPacket, void()); | 163 MOCK_METHOD0(OnRevivedPacket, void()); |
163 // The constructor sets this up to return true by default. | 164 // The constructor sets this up to return true by default. |
(...skipping 54 matching lines...) Loading... |
218 bool OnBlockedFrame(const QuicBlockedFrame& frame) override; | 219 bool OnBlockedFrame(const QuicBlockedFrame& frame) override; |
219 void OnPacketComplete() override {} | 220 void OnPacketComplete() override {} |
220 | 221 |
221 private: | 222 private: |
222 DISALLOW_COPY_AND_ASSIGN(NoOpFramerVisitor); | 223 DISALLOW_COPY_AND_ASSIGN(NoOpFramerVisitor); |
223 }; | 224 }; |
224 | 225 |
225 class MockConnectionVisitor : public QuicConnectionVisitorInterface { | 226 class MockConnectionVisitor : public QuicConnectionVisitorInterface { |
226 public: | 227 public: |
227 MockConnectionVisitor(); | 228 MockConnectionVisitor(); |
228 virtual ~MockConnectionVisitor(); | 229 ~MockConnectionVisitor() override; |
229 | 230 |
230 MOCK_METHOD1(OnStreamFrames, void(const std::vector<QuicStreamFrame>& frame)); | 231 MOCK_METHOD1(OnStreamFrames, void(const std::vector<QuicStreamFrame>& frame)); |
231 MOCK_METHOD1(OnWindowUpdateFrames, | 232 MOCK_METHOD1(OnWindowUpdateFrames, |
232 void(const std::vector<QuicWindowUpdateFrame>& frame)); | 233 void(const std::vector<QuicWindowUpdateFrame>& frame)); |
233 MOCK_METHOD1(OnBlockedFrames, | 234 MOCK_METHOD1(OnBlockedFrames, |
234 void(const std::vector<QuicBlockedFrame>& frame)); | 235 void(const std::vector<QuicBlockedFrame>& frame)); |
235 MOCK_METHOD1(OnRstStream, void(const QuicRstStreamFrame& frame)); | 236 MOCK_METHOD1(OnRstStream, void(const QuicRstStreamFrame& frame)); |
236 MOCK_METHOD1(OnGoAway, void(const QuicGoAwayFrame& frame)); | 237 MOCK_METHOD1(OnGoAway, void(const QuicGoAwayFrame& frame)); |
237 MOCK_METHOD2(OnConnectionClosed, void(QuicErrorCode error, bool from_peer)); | 238 MOCK_METHOD2(OnConnectionClosed, void(QuicErrorCode error, bool from_peer)); |
238 MOCK_METHOD0(OnWriteBlocked, void()); | 239 MOCK_METHOD0(OnWriteBlocked, void()); |
(...skipping 47 matching lines...) Loading... |
286 | 287 |
287 // Uses a MockHelper, ConnectionId of 42. | 288 // Uses a MockHelper, ConnectionId of 42. |
288 MockConnection(IPEndPoint address, bool is_server); | 289 MockConnection(IPEndPoint address, bool is_server); |
289 | 290 |
290 // Uses a MockHelper, and 127.0.0.1:123 | 291 // Uses a MockHelper, and 127.0.0.1:123 |
291 MockConnection(QuicConnectionId connection_id, bool is_server); | 292 MockConnection(QuicConnectionId connection_id, bool is_server); |
292 | 293 |
293 // Uses a Mock helper, ConnectionId of 42, and 127.0.0.1:123. | 294 // Uses a Mock helper, ConnectionId of 42, and 127.0.0.1:123. |
294 MockConnection(bool is_server, const QuicVersionVector& supported_versions); | 295 MockConnection(bool is_server, const QuicVersionVector& supported_versions); |
295 | 296 |
296 virtual ~MockConnection(); | 297 ~MockConnection() override; |
297 | 298 |
298 // If the constructor that uses a MockHelper has been used then this method | 299 // If the constructor that uses a MockHelper has been used then this method |
299 // will advance the time of the MockClock. | 300 // will advance the time of the MockClock. |
300 void AdvanceTime(QuicTime::Delta delta); | 301 void AdvanceTime(QuicTime::Delta delta); |
301 | 302 |
302 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address, | 303 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address, |
303 const IPEndPoint& peer_address, | 304 const IPEndPoint& peer_address, |
304 const QuicEncryptedPacket& packet)); | 305 const QuicEncryptedPacket& packet)); |
305 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error)); | 306 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error)); |
306 MOCK_METHOD2(SendConnectionCloseWithDetails, void(QuicErrorCode error, | 307 MOCK_METHOD2(SendConnectionCloseWithDetails, void(QuicErrorCode error, |
(...skipping 10 matching lines...) Loading... |
317 MOCK_METHOD2(SendWindowUpdate, void(QuicStreamId id, | 318 MOCK_METHOD2(SendWindowUpdate, void(QuicStreamId id, |
318 QuicStreamOffset byte_offset)); | 319 QuicStreamOffset byte_offset)); |
319 MOCK_METHOD0(OnCanWrite, void()); | 320 MOCK_METHOD0(OnCanWrite, void()); |
320 | 321 |
321 void ProcessUdpPacketInternal(const IPEndPoint& self_address, | 322 void ProcessUdpPacketInternal(const IPEndPoint& self_address, |
322 const IPEndPoint& peer_address, | 323 const IPEndPoint& peer_address, |
323 const QuicEncryptedPacket& packet) { | 324 const QuicEncryptedPacket& packet) { |
324 QuicConnection::ProcessUdpPacket(self_address, peer_address, packet); | 325 QuicConnection::ProcessUdpPacket(self_address, peer_address, packet); |
325 } | 326 } |
326 | 327 |
327 virtual bool OnProtocolVersionMismatch(QuicVersion version) override { | 328 bool OnProtocolVersionMismatch(QuicVersion version) override { |
328 return false; | 329 return false; |
329 } | 330 } |
330 | 331 |
331 private: | 332 private: |
332 scoped_ptr<QuicConnectionHelperInterface> helper_; | 333 scoped_ptr<QuicConnectionHelperInterface> helper_; |
333 | 334 |
334 DISALLOW_COPY_AND_ASSIGN(MockConnection); | 335 DISALLOW_COPY_AND_ASSIGN(MockConnection); |
335 }; | 336 }; |
336 | 337 |
337 class PacketSavingConnection : public MockConnection { | 338 class PacketSavingConnection : public MockConnection { |
(...skipping 10 matching lines...) Loading... |
348 std::vector<QuicPacket*> packets_; | 349 std::vector<QuicPacket*> packets_; |
349 std::vector<QuicEncryptedPacket*> encrypted_packets_; | 350 std::vector<QuicEncryptedPacket*> encrypted_packets_; |
350 | 351 |
351 private: | 352 private: |
352 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection); | 353 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection); |
353 }; | 354 }; |
354 | 355 |
355 class MockSession : public QuicSession { | 356 class MockSession : public QuicSession { |
356 public: | 357 public: |
357 explicit MockSession(QuicConnection* connection); | 358 explicit MockSession(QuicConnection* connection); |
358 virtual ~MockSession(); | 359 ~MockSession() override; |
359 MOCK_METHOD2(OnConnectionClosed, void(QuicErrorCode error, bool from_peer)); | 360 MOCK_METHOD2(OnConnectionClosed, void(QuicErrorCode error, bool from_peer)); |
360 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); | 361 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); |
361 MOCK_METHOD0(GetCryptoStream, QuicCryptoStream*()); | 362 MOCK_METHOD0(GetCryptoStream, QuicCryptoStream*()); |
362 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); | 363 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); |
363 MOCK_METHOD6(WritevData, | 364 MOCK_METHOD6(WritevData, |
364 QuicConsumedData(QuicStreamId id, | 365 QuicConsumedData(QuicStreamId id, |
365 const IOVector& data, | 366 const IOVector& data, |
366 QuicStreamOffset offset, | 367 QuicStreamOffset offset, |
367 bool fin, | 368 bool fin, |
368 FecProtection fec_protection, | 369 FecProtection fec_protection, |
(...skipping 12 matching lines...) Loading... |
381 | 382 |
382 using QuicSession::ActivateStream; | 383 using QuicSession::ActivateStream; |
383 | 384 |
384 private: | 385 private: |
385 DISALLOW_COPY_AND_ASSIGN(MockSession); | 386 DISALLOW_COPY_AND_ASSIGN(MockSession); |
386 }; | 387 }; |
387 | 388 |
388 class TestSession : public QuicSession { | 389 class TestSession : public QuicSession { |
389 public: | 390 public: |
390 TestSession(QuicConnection* connection, const QuicConfig& config); | 391 TestSession(QuicConnection* connection, const QuicConfig& config); |
391 virtual ~TestSession(); | 392 ~TestSession() override; |
392 | 393 |
393 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); | 394 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); |
394 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); | 395 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); |
395 | 396 |
396 void SetCryptoStream(QuicCryptoStream* stream); | 397 void SetCryptoStream(QuicCryptoStream* stream); |
397 | 398 |
398 virtual QuicCryptoStream* GetCryptoStream() override; | 399 QuicCryptoStream* GetCryptoStream() override; |
399 | 400 |
400 private: | 401 private: |
401 QuicCryptoStream* crypto_stream_; | 402 QuicCryptoStream* crypto_stream_; |
402 | 403 |
403 DISALLOW_COPY_AND_ASSIGN(TestSession); | 404 DISALLOW_COPY_AND_ASSIGN(TestSession); |
404 }; | 405 }; |
405 | 406 |
406 class TestClientSession : public QuicClientSessionBase { | 407 class TestClientSession : public QuicClientSessionBase { |
407 public: | 408 public: |
408 TestClientSession(QuicConnection* connection, const QuicConfig& config); | 409 TestClientSession(QuicConnection* connection, const QuicConfig& config); |
409 virtual ~TestClientSession(); | 410 ~TestClientSession() override; |
410 | 411 |
411 // QuicClientSessionBase | 412 // QuicClientSessionBase |
412 MOCK_METHOD1(OnProofValid, | 413 MOCK_METHOD1(OnProofValid, |
413 void(const QuicCryptoClientConfig::CachedState& cached)); | 414 void(const QuicCryptoClientConfig::CachedState& cached)); |
414 MOCK_METHOD1(OnProofVerifyDetailsAvailable, | 415 MOCK_METHOD1(OnProofVerifyDetailsAvailable, |
415 void(const ProofVerifyDetails& verify_details)); | 416 void(const ProofVerifyDetails& verify_details)); |
416 | 417 |
417 // TestClientSession | 418 // TestClientSession |
418 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); | 419 MOCK_METHOD1(CreateIncomingDataStream, QuicDataStream*(QuicStreamId id)); |
419 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); | 420 MOCK_METHOD0(CreateOutgoingDataStream, QuicDataStream*()); |
420 | 421 |
421 void SetCryptoStream(QuicCryptoStream* stream); | 422 void SetCryptoStream(QuicCryptoStream* stream); |
422 | 423 |
423 virtual QuicCryptoStream* GetCryptoStream() override; | 424 QuicCryptoStream* GetCryptoStream() override; |
424 | 425 |
425 private: | 426 private: |
426 QuicCryptoStream* crypto_stream_; | 427 QuicCryptoStream* crypto_stream_; |
427 | 428 |
428 DISALLOW_COPY_AND_ASSIGN(TestClientSession); | 429 DISALLOW_COPY_AND_ASSIGN(TestClientSession); |
429 }; | 430 }; |
430 | 431 |
431 class MockPacketWriter : public QuicPacketWriter { | 432 class MockPacketWriter : public QuicPacketWriter { |
432 public: | 433 public: |
433 MockPacketWriter(); | 434 MockPacketWriter(); |
434 virtual ~MockPacketWriter(); | 435 ~MockPacketWriter() override; |
435 | 436 |
436 MOCK_METHOD4(WritePacket, | 437 MOCK_METHOD4(WritePacket, |
437 WriteResult(const char* buffer, | 438 WriteResult(const char* buffer, |
438 size_t buf_len, | 439 size_t buf_len, |
439 const IPAddressNumber& self_address, | 440 const IPAddressNumber& self_address, |
440 const IPEndPoint& peer_address)); | 441 const IPEndPoint& peer_address)); |
441 MOCK_CONST_METHOD0(IsWriteBlockedDataBuffered, bool()); | 442 MOCK_CONST_METHOD0(IsWriteBlockedDataBuffered, bool()); |
442 MOCK_CONST_METHOD0(IsWriteBlocked, bool()); | 443 MOCK_CONST_METHOD0(IsWriteBlocked, bool()); |
443 MOCK_METHOD0(SetWritable, void()); | 444 MOCK_METHOD0(SetWritable, void()); |
444 | 445 |
445 private: | 446 private: |
446 DISALLOW_COPY_AND_ASSIGN(MockPacketWriter); | 447 DISALLOW_COPY_AND_ASSIGN(MockPacketWriter); |
447 }; | 448 }; |
448 | 449 |
449 class MockSendAlgorithm : public SendAlgorithmInterface { | 450 class MockSendAlgorithm : public SendAlgorithmInterface { |
450 public: | 451 public: |
451 MockSendAlgorithm(); | 452 MockSendAlgorithm(); |
452 virtual ~MockSendAlgorithm(); | 453 ~MockSendAlgorithm() override; |
453 | 454 |
454 MOCK_METHOD3(SetFromConfig, void(const QuicConfig& config, | 455 MOCK_METHOD3(SetFromConfig, void(const QuicConfig& config, |
455 bool is_server, | 456 bool is_server, |
456 bool using_pacing)); | 457 bool using_pacing)); |
457 MOCK_METHOD1(SetNumEmulatedConnections, void(int num_connections)); | 458 MOCK_METHOD1(SetNumEmulatedConnections, void(int num_connections)); |
458 MOCK_METHOD1(SetMaxPacketSize, void(QuicByteCount max_packet_size)); | 459 MOCK_METHOD1(SetMaxPacketSize, void(QuicByteCount max_packet_size)); |
459 MOCK_METHOD2(OnIncomingQuicCongestionFeedbackFrame, | 460 MOCK_METHOD2(OnIncomingQuicCongestionFeedbackFrame, |
460 void(const QuicCongestionFeedbackFrame&, | 461 void(const QuicCongestionFeedbackFrame&, |
461 QuicTime feedback_receive_time)); | 462 QuicTime feedback_receive_time)); |
462 MOCK_METHOD4(OnCongestionEvent, void(bool rtt_updated, | 463 MOCK_METHOD4(OnCongestionEvent, void(bool rtt_updated, |
(...skipping 12 matching lines...) Loading... |
475 MOCK_CONST_METHOD0(PacingRate, QuicBandwidth(void)); | 476 MOCK_CONST_METHOD0(PacingRate, QuicBandwidth(void)); |
476 MOCK_CONST_METHOD0(BandwidthEstimate, QuicBandwidth(void)); | 477 MOCK_CONST_METHOD0(BandwidthEstimate, QuicBandwidth(void)); |
477 MOCK_CONST_METHOD0(HasReliableBandwidthEstimate, bool()); | 478 MOCK_CONST_METHOD0(HasReliableBandwidthEstimate, bool()); |
478 MOCK_METHOD1(OnRttUpdated, void(QuicPacketSequenceNumber)); | 479 MOCK_METHOD1(OnRttUpdated, void(QuicPacketSequenceNumber)); |
479 MOCK_CONST_METHOD0(RetransmissionDelay, QuicTime::Delta(void)); | 480 MOCK_CONST_METHOD0(RetransmissionDelay, QuicTime::Delta(void)); |
480 MOCK_CONST_METHOD0(GetCongestionWindow, QuicByteCount()); | 481 MOCK_CONST_METHOD0(GetCongestionWindow, QuicByteCount()); |
481 MOCK_CONST_METHOD0(InSlowStart, bool()); | 482 MOCK_CONST_METHOD0(InSlowStart, bool()); |
482 MOCK_CONST_METHOD0(InRecovery, bool()); | 483 MOCK_CONST_METHOD0(InRecovery, bool()); |
483 MOCK_CONST_METHOD0(GetSlowStartThreshold, QuicByteCount()); | 484 MOCK_CONST_METHOD0(GetSlowStartThreshold, QuicByteCount()); |
484 MOCK_CONST_METHOD0(GetCongestionControlType, CongestionControlType()); | 485 MOCK_CONST_METHOD0(GetCongestionControlType, CongestionControlType()); |
| 486 MOCK_METHOD1(ResumeConnectionState, void(const CachedNetworkParameters&)); |
485 | 487 |
486 private: | 488 private: |
487 DISALLOW_COPY_AND_ASSIGN(MockSendAlgorithm); | 489 DISALLOW_COPY_AND_ASSIGN(MockSendAlgorithm); |
488 }; | 490 }; |
489 | 491 |
490 class MockLossAlgorithm : public LossDetectionInterface { | 492 class MockLossAlgorithm : public LossDetectionInterface { |
491 public: | 493 public: |
492 MockLossAlgorithm(); | 494 MockLossAlgorithm(); |
493 virtual ~MockLossAlgorithm(); | 495 ~MockLossAlgorithm() override; |
494 | 496 |
495 MOCK_CONST_METHOD0(GetLossDetectionType, LossDetectionType()); | 497 MOCK_CONST_METHOD0(GetLossDetectionType, LossDetectionType()); |
496 MOCK_METHOD4(DetectLostPackets, | 498 MOCK_METHOD4(DetectLostPackets, |
497 SequenceNumberSet(const QuicUnackedPacketMap& unacked_packets, | 499 SequenceNumberSet(const QuicUnackedPacketMap& unacked_packets, |
498 const QuicTime& time, | 500 const QuicTime& time, |
499 QuicPacketSequenceNumber largest_observed, | 501 QuicPacketSequenceNumber largest_observed, |
500 const RttStats& rtt_stats)); | 502 const RttStats& rtt_stats)); |
501 MOCK_CONST_METHOD0(GetLossTimeout, QuicTime()); | 503 MOCK_CONST_METHOD0(GetLossTimeout, QuicTime()); |
502 | 504 |
503 private: | 505 private: |
504 DISALLOW_COPY_AND_ASSIGN(MockLossAlgorithm); | 506 DISALLOW_COPY_AND_ASSIGN(MockLossAlgorithm); |
505 }; | 507 }; |
506 | 508 |
507 class TestEntropyCalculator : | 509 class TestEntropyCalculator : |
508 public QuicReceivedEntropyHashCalculatorInterface { | 510 public QuicReceivedEntropyHashCalculatorInterface { |
509 public: | 511 public: |
510 TestEntropyCalculator(); | 512 TestEntropyCalculator(); |
511 ~TestEntropyCalculator() override; | 513 ~TestEntropyCalculator() override; |
512 | 514 |
513 QuicPacketEntropyHash EntropyHash( | 515 QuicPacketEntropyHash EntropyHash( |
514 QuicPacketSequenceNumber sequence_number) const override; | 516 QuicPacketSequenceNumber sequence_number) const override; |
515 | 517 |
516 private: | 518 private: |
517 DISALLOW_COPY_AND_ASSIGN(TestEntropyCalculator); | 519 DISALLOW_COPY_AND_ASSIGN(TestEntropyCalculator); |
518 }; | 520 }; |
519 | 521 |
520 class MockEntropyCalculator : public TestEntropyCalculator { | 522 class MockEntropyCalculator : public TestEntropyCalculator { |
521 public: | 523 public: |
522 MockEntropyCalculator(); | 524 MockEntropyCalculator(); |
523 virtual ~MockEntropyCalculator(); | 525 ~MockEntropyCalculator() override; |
524 | 526 |
525 MOCK_CONST_METHOD1( | 527 MOCK_CONST_METHOD1( |
526 EntropyHash, | 528 EntropyHash, |
527 QuicPacketEntropyHash(QuicPacketSequenceNumber sequence_number)); | 529 QuicPacketEntropyHash(QuicPacketSequenceNumber sequence_number)); |
528 | 530 |
529 private: | 531 private: |
530 DISALLOW_COPY_AND_ASSIGN(MockEntropyCalculator); | 532 DISALLOW_COPY_AND_ASSIGN(MockEntropyCalculator); |
531 }; | 533 }; |
532 | 534 |
533 class MockAckNotifierDelegate : public QuicAckNotifier::DelegateInterface { | 535 class MockAckNotifierDelegate : public QuicAckNotifier::DelegateInterface { |
534 public: | 536 public: |
535 MockAckNotifierDelegate(); | 537 MockAckNotifierDelegate(); |
536 | 538 |
537 MOCK_METHOD5(OnAckNotification, void(int num_original_packets, | 539 MOCK_METHOD5(OnAckNotification, void(int num_original_packets, |
538 int num_original_bytes, | 540 int num_original_bytes, |
539 int num_retransmitted_packets, | 541 int num_retransmitted_packets, |
540 int num_retransmitted_bytes, | 542 int num_retransmitted_bytes, |
541 QuicTime::Delta delta_largest_observed)); | 543 QuicTime::Delta delta_largest_observed)); |
542 | 544 |
543 protected: | 545 protected: |
544 // Object is ref counted. | 546 // Object is ref counted. |
545 virtual ~MockAckNotifierDelegate(); | 547 ~MockAckNotifierDelegate() override; |
546 | 548 |
547 private: | 549 private: |
548 DISALLOW_COPY_AND_ASSIGN(MockAckNotifierDelegate); | 550 DISALLOW_COPY_AND_ASSIGN(MockAckNotifierDelegate); |
549 }; | 551 }; |
550 | 552 |
551 class MockNetworkChangeVisitor : | 553 class MockNetworkChangeVisitor : |
552 public QuicSentPacketManager::NetworkChangeVisitor { | 554 public QuicSentPacketManager::NetworkChangeVisitor { |
553 public: | 555 public: |
554 MockNetworkChangeVisitor(); | 556 MockNetworkChangeVisitor(); |
555 virtual ~MockNetworkChangeVisitor(); | 557 ~MockNetworkChangeVisitor() override; |
556 | 558 |
557 MOCK_METHOD0(OnCongestionWindowChange, void()); | 559 MOCK_METHOD0(OnCongestionWindowChange, void()); |
558 | 560 |
559 private: | 561 private: |
560 DISALLOW_COPY_AND_ASSIGN(MockNetworkChangeVisitor); | 562 DISALLOW_COPY_AND_ASSIGN(MockNetworkChangeVisitor); |
561 }; | 563 }; |
562 | 564 |
563 // Creates per-connection packet writers that register themselves with the | 565 // Creates per-connection packet writers that register themselves with the |
564 // TestWriterFactory on each write so that TestWriterFactory::OnPacketSent can | 566 // TestWriterFactory on each write so that TestWriterFactory::OnPacketSent can |
565 // be routed to the appropriate QuicConnection. | 567 // be routed to the appropriate QuicConnection. |
(...skipping 30 matching lines...) Loading... |
596 // clears the pointer to it to prevent use-after-free. | 598 // clears the pointer to it to prevent use-after-free. |
597 void Unregister(PerConnectionPacketWriter* writer); | 599 void Unregister(PerConnectionPacketWriter* writer); |
598 | 600 |
599 PerConnectionPacketWriter* current_writer_; | 601 PerConnectionPacketWriter* current_writer_; |
600 }; | 602 }; |
601 | 603 |
602 } // namespace test | 604 } // namespace test |
603 } // namespace net | 605 } // namespace net |
604 | 606 |
605 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 607 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
OLD | NEW |