| 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/basictypes.h" |
| 14 #include "base/strings/string_piece.h" | 14 #include "base/strings/string_piece.h" |
| 15 #include "net/quic/congestion_control/loss_detection_interface.h" | 15 #include "net/quic/congestion_control/loss_detection_interface.h" |
| 16 #include "net/quic/congestion_control/send_algorithm_interface.h" | 16 #include "net/quic/congestion_control/send_algorithm_interface.h" |
| 17 #include "net/quic/quic_ack_notifier.h" | 17 #include "net/quic/quic_ack_notifier.h" |
| 18 #include "net/quic/quic_client_session_base.h" | 18 #include "net/quic/quic_client_session_base.h" |
| 19 #include "net/quic/quic_connection.h" | 19 #include "net/quic/quic_connection.h" |
| 20 #include "net/quic/quic_dispatcher.h" | 20 #include "net/quic/quic_dispatcher.h" |
| 21 #include "net/quic/quic_framer.h" | 21 #include "net/quic/quic_framer.h" |
| 22 #include "net/quic/quic_per_connection_packet_writer.h" | 22 #include "net/quic/quic_per_connection_packet_writer.h" |
| 23 #include "net/quic/quic_protocol.h" |
| 23 #include "net/quic/quic_sent_packet_manager.h" | 24 #include "net/quic/quic_sent_packet_manager.h" |
| 24 #include "net/quic/quic_session.h" | 25 #include "net/quic/quic_session.h" |
| 25 #include "net/quic/test_tools/mock_clock.h" | 26 #include "net/quic/test_tools/mock_clock.h" |
| 26 #include "net/quic/test_tools/mock_random.h" | 27 #include "net/quic/test_tools/mock_random.h" |
| 27 #include "net/spdy/spdy_framer.h" | 28 #include "net/spdy/spdy_framer.h" |
| 28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
| 29 | 30 |
| 30 namespace net { | 31 namespace net { |
| 31 | 32 |
| 32 namespace test { | 33 namespace test { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 284 |
| 284 QuicPacketWriter* Create(QuicConnection* /*connection*/) const override; | 285 QuicPacketWriter* Create(QuicConnection* /*connection*/) const override; |
| 285 | 286 |
| 286 private: | 287 private: |
| 287 DISALLOW_COPY_AND_ASSIGN(NiceMockPacketWriterFactory); | 288 DISALLOW_COPY_AND_ASSIGN(NiceMockPacketWriterFactory); |
| 288 }; | 289 }; |
| 289 | 290 |
| 290 class MockConnection : public QuicConnection { | 291 class MockConnection : public QuicConnection { |
| 291 public: | 292 public: |
| 292 // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123. | 293 // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123. |
| 293 explicit MockConnection(bool is_server); | 294 explicit MockConnection(Perspective perspective); |
| 294 | 295 |
| 295 // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123. | 296 // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123. |
| 296 MockConnection(bool is_server, bool is_secure); | 297 MockConnection(Perspective perspective, bool is_secure); |
| 297 | 298 |
| 298 // Uses a MockHelper, ConnectionId of 42. | 299 // Uses a MockHelper, ConnectionId of 42. |
| 299 MockConnection(IPEndPoint address, bool is_server); | 300 MockConnection(IPEndPoint address, Perspective perspective); |
| 300 | 301 |
| 301 // Uses a MockHelper, and 127.0.0.1:123 | 302 // Uses a MockHelper, and 127.0.0.1:123 |
| 302 MockConnection(QuicConnectionId connection_id, bool is_server); | 303 MockConnection(QuicConnectionId connection_id, Perspective perspective); |
| 303 | 304 |
| 304 // Uses a Mock helper, ConnectionId of 42, and 127.0.0.1:123. | 305 // Uses a Mock helper, ConnectionId of 42, and 127.0.0.1:123. |
| 305 MockConnection(bool is_server, const QuicVersionVector& supported_versions); | 306 MockConnection(Perspective perspective, |
| 307 const QuicVersionVector& supported_versions); |
| 306 | 308 |
| 307 ~MockConnection() override; | 309 ~MockConnection() override; |
| 308 | 310 |
| 309 // If the constructor that uses a MockHelper has been used then this method | 311 // If the constructor that uses a MockHelper has been used then this method |
| 310 // will advance the time of the MockClock. | 312 // will advance the time of the MockClock. |
| 311 void AdvanceTime(QuicTime::Delta delta); | 313 void AdvanceTime(QuicTime::Delta delta); |
| 312 | 314 |
| 313 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address, | 315 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address, |
| 314 const IPEndPoint& peer_address, | 316 const IPEndPoint& peer_address, |
| 315 const QuicEncryptedPacket& packet)); | 317 const QuicEncryptedPacket& packet)); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 343 } | 345 } |
| 344 | 346 |
| 345 private: | 347 private: |
| 346 scoped_ptr<QuicConnectionHelperInterface> helper_; | 348 scoped_ptr<QuicConnectionHelperInterface> helper_; |
| 347 | 349 |
| 348 DISALLOW_COPY_AND_ASSIGN(MockConnection); | 350 DISALLOW_COPY_AND_ASSIGN(MockConnection); |
| 349 }; | 351 }; |
| 350 | 352 |
| 351 class PacketSavingConnection : public MockConnection { | 353 class PacketSavingConnection : public MockConnection { |
| 352 public: | 354 public: |
| 353 explicit PacketSavingConnection(bool is_server); | 355 explicit PacketSavingConnection(Perspective perspective); |
| 354 | 356 |
| 355 PacketSavingConnection(bool is_server, | 357 PacketSavingConnection(Perspective perspective, |
| 356 const QuicVersionVector& supported_versions); | 358 const QuicVersionVector& supported_versions); |
| 357 | 359 |
| 358 ~PacketSavingConnection() override; | 360 ~PacketSavingConnection() override; |
| 359 | 361 |
| 360 void SendOrQueuePacket(QueuedPacket packet) override; | 362 void SendOrQueuePacket(QueuedPacket packet) override; |
| 361 | 363 |
| 362 std::vector<QuicEncryptedPacket*> encrypted_packets_; | 364 std::vector<QuicEncryptedPacket*> encrypted_packets_; |
| 363 | 365 |
| 364 private: | 366 private: |
| 365 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection); | 367 DISALLOW_COPY_AND_ASSIGN(PacketSavingConnection); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 459 |
| 458 private: | 460 private: |
| 459 DISALLOW_COPY_AND_ASSIGN(MockPacketWriter); | 461 DISALLOW_COPY_AND_ASSIGN(MockPacketWriter); |
| 460 }; | 462 }; |
| 461 | 463 |
| 462 class MockSendAlgorithm : public SendAlgorithmInterface { | 464 class MockSendAlgorithm : public SendAlgorithmInterface { |
| 463 public: | 465 public: |
| 464 MockSendAlgorithm(); | 466 MockSendAlgorithm(); |
| 465 ~MockSendAlgorithm() override; | 467 ~MockSendAlgorithm() override; |
| 466 | 468 |
| 467 MOCK_METHOD3(SetFromConfig, void(const QuicConfig& config, | 469 MOCK_METHOD3(SetFromConfig, |
| 468 bool is_server, | 470 void(const QuicConfig& config, |
| 469 bool using_pacing)); | 471 Perspective perspective, |
| 472 bool using_pacing)); |
| 470 MOCK_METHOD1(SetNumEmulatedConnections, void(int num_connections)); | 473 MOCK_METHOD1(SetNumEmulatedConnections, void(int num_connections)); |
| 471 MOCK_METHOD1(SetMaxPacketSize, void(QuicByteCount max_packet_size)); | 474 MOCK_METHOD1(SetMaxPacketSize, void(QuicByteCount max_packet_size)); |
| 472 MOCK_METHOD4(OnCongestionEvent, void(bool rtt_updated, | 475 MOCK_METHOD4(OnCongestionEvent, void(bool rtt_updated, |
| 473 QuicByteCount bytes_in_flight, | 476 QuicByteCount bytes_in_flight, |
| 474 const CongestionVector& acked_packets, | 477 const CongestionVector& acked_packets, |
| 475 const CongestionVector& lost_packets)); | 478 const CongestionVector& lost_packets)); |
| 476 MOCK_METHOD5(OnPacketSent, | 479 MOCK_METHOD5(OnPacketSent, |
| 477 bool(QuicTime, QuicByteCount, QuicPacketSequenceNumber, | 480 bool(QuicTime, QuicByteCount, QuicPacketSequenceNumber, |
| 478 QuicByteCount, HasRetransmittableData)); | 481 QuicByteCount, HasRetransmittableData)); |
| 479 MOCK_METHOD1(OnRetransmissionTimeout, void(bool)); | 482 MOCK_METHOD1(OnRetransmissionTimeout, void(bool)); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 // clears the pointer to it to prevent use-after-free. | 610 // clears the pointer to it to prevent use-after-free. |
| 608 void Unregister(PerConnectionPacketWriter* writer); | 611 void Unregister(PerConnectionPacketWriter* writer); |
| 609 | 612 |
| 610 PerConnectionPacketWriter* current_writer_; | 613 PerConnectionPacketWriter* current_writer_; |
| 611 }; | 614 }; |
| 612 | 615 |
| 613 } // namespace test | 616 } // namespace test |
| 614 } // namespace net | 617 } // namespace net |
| 615 | 618 |
| 616 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 619 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
| OLD | NEW |