Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: net/quic/test_tools/quic_test_utils.h

Issue 1433433003: Rename MockHelper to the more descriptive (and more consistent with other Mock classes) MockConnect… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@106414015
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.cc ('k') | net/quic/test_tools/quic_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 MOCK_CONST_METHOD0(HasPendingHandshake, bool()); 287 MOCK_CONST_METHOD0(HasPendingHandshake, bool());
288 MOCK_CONST_METHOD0(HasOpenDynamicStreams, bool()); 288 MOCK_CONST_METHOD0(HasOpenDynamicStreams, bool());
289 MOCK_METHOD1(OnSuccessfulVersionNegotiation, 289 MOCK_METHOD1(OnSuccessfulVersionNegotiation,
290 void(const QuicVersion& version)); 290 void(const QuicVersion& version));
291 MOCK_METHOD0(OnConfigNegotiated, void()); 291 MOCK_METHOD0(OnConfigNegotiated, void());
292 292
293 private: 293 private:
294 DISALLOW_COPY_AND_ASSIGN(MockConnectionVisitor); 294 DISALLOW_COPY_AND_ASSIGN(MockConnectionVisitor);
295 }; 295 };
296 296
297 class MockHelper : public QuicConnectionHelperInterface { 297 class MockConnectionHelper : public QuicConnectionHelperInterface {
298 public: 298 public:
299 MockHelper(); 299 MockConnectionHelper();
300 ~MockHelper() override; 300 ~MockConnectionHelper() override;
301 const QuicClock* GetClock() const override; 301 const QuicClock* GetClock() const override;
302 QuicRandom* GetRandomGenerator() override; 302 QuicRandom* GetRandomGenerator() override;
303 QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) override; 303 QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) override;
304 void AdvanceTime(QuicTime::Delta delta); 304 void AdvanceTime(QuicTime::Delta delta);
305 305
306 private: 306 private:
307 MockClock clock_; 307 MockClock clock_;
308 MockRandom random_generator_; 308 MockRandom random_generator_;
309 309
310 DISALLOW_COPY_AND_ASSIGN(MockHelper); 310 DISALLOW_COPY_AND_ASSIGN(MockConnectionHelper);
311 }; 311 };
312 312
313 class NiceMockPacketWriterFactory : public QuicConnection::PacketWriterFactory { 313 class NiceMockPacketWriterFactory : public QuicConnection::PacketWriterFactory {
314 public: 314 public:
315 NiceMockPacketWriterFactory() {} 315 NiceMockPacketWriterFactory() {}
316 ~NiceMockPacketWriterFactory() override {} 316 ~NiceMockPacketWriterFactory() override {}
317 317
318 QuicPacketWriter* Create(QuicConnection* /*connection*/) const override; 318 QuicPacketWriter* Create(QuicConnection* /*connection*/) const override;
319 319
320 private: 320 private:
321 DISALLOW_COPY_AND_ASSIGN(NiceMockPacketWriterFactory); 321 DISALLOW_COPY_AND_ASSIGN(NiceMockPacketWriterFactory);
322 }; 322 };
323 323
324 class MockConnection : public QuicConnection { 324 class MockConnection : public QuicConnection {
325 public: 325 public:
326 // Uses a ConnectionId of 42 and 127.0.0.1:123. 326 // Uses a ConnectionId of 42 and 127.0.0.1:123.
327 MockConnection(MockHelper* helper, Perspective perspective); 327 MockConnection(MockConnectionHelper* helper, Perspective perspective);
328 328
329 // Uses a ConnectionId of 42. 329 // Uses a ConnectionId of 42.
330 MockConnection(IPEndPoint address, 330 MockConnection(IPEndPoint address,
331 MockHelper* helper, 331 MockConnectionHelper* helper,
332 Perspective perspective); 332 Perspective perspective);
333 333
334 // Uses 127.0.0.1:123. 334 // Uses 127.0.0.1:123.
335 MockConnection(QuicConnectionId connection_id, 335 MockConnection(QuicConnectionId connection_id,
336 MockHelper* helper, 336 MockConnectionHelper* helper,
337 Perspective perspective); 337 Perspective perspective);
338 338
339 // Uses a ConnectionId of 42, and 127.0.0.1:123. 339 // Uses a ConnectionId of 42, and 127.0.0.1:123.
340 MockConnection(MockHelper* helper, 340 MockConnection(MockConnectionHelper* helper,
341 Perspective perspective, 341 Perspective perspective,
342 const QuicVersionVector& supported_versions); 342 const QuicVersionVector& supported_versions);
343 343
344 MockConnection(QuicConnectionId connection_id, 344 MockConnection(QuicConnectionId connection_id,
345 IPEndPoint address, 345 IPEndPoint address,
346 MockHelper* helper, 346 MockConnectionHelper* helper,
347 Perspective perspective, 347 Perspective perspective,
348 const QuicVersionVector& supported_versions); 348 const QuicVersionVector& supported_versions);
349 349
350 ~MockConnection() override; 350 ~MockConnection() override;
351 351
352 // If the constructor that uses a MockHelper has been used then this method 352 // If the constructor that uses a MockConnectionHelper has been used then
353 // this method
353 // will advance the time of the MockClock. 354 // will advance the time of the MockClock.
354 void AdvanceTime(QuicTime::Delta delta); 355 void AdvanceTime(QuicTime::Delta delta);
355 356
356 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address, 357 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address,
357 const IPEndPoint& peer_address, 358 const IPEndPoint& peer_address,
358 const QuicEncryptedPacket& packet)); 359 const QuicEncryptedPacket& packet));
359 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error)); 360 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error));
360 MOCK_METHOD2(SendConnectionCloseWithDetails, 361 MOCK_METHOD2(SendConnectionCloseWithDetails,
361 void(QuicErrorCode error, const std::string& details)); 362 void(QuicErrorCode error, const std::string& details));
362 MOCK_METHOD2(SendConnectionClosePacket, 363 MOCK_METHOD2(SendConnectionClosePacket,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 const std::string& reason) { 398 const std::string& reason) {
398 QuicConnection::SendGoAway(error, last_good_stream_id, reason); 399 QuicConnection::SendGoAway(error, last_good_stream_id, reason);
399 } 400 }
400 401
401 private: 402 private:
402 DISALLOW_COPY_AND_ASSIGN(MockConnection); 403 DISALLOW_COPY_AND_ASSIGN(MockConnection);
403 }; 404 };
404 405
405 class PacketSavingConnection : public MockConnection { 406 class PacketSavingConnection : public MockConnection {
406 public: 407 public:
407 PacketSavingConnection(MockHelper* helper, Perspective perspective); 408 PacketSavingConnection(MockConnectionHelper* helper, Perspective perspective);
408 409
409 PacketSavingConnection(MockHelper* helper, 410 PacketSavingConnection(MockConnectionHelper* helper,
410 Perspective perspective, 411 Perspective perspective,
411 const QuicVersionVector& supported_versions); 412 const QuicVersionVector& supported_versions);
412 413
413 ~PacketSavingConnection() override; 414 ~PacketSavingConnection() override;
414 415
415 void SendOrQueuePacket(QueuedPacket packet) override; 416 void SendOrQueuePacket(QueuedPacket packet) override;
416 417
417 std::vector<QuicEncryptedPacket*> encrypted_packets_; 418 std::vector<QuicEncryptedPacket*> encrypted_packets_;
418 419
419 private: 420 private:
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 }; 724 };
724 725
725 // Creates a client session for testing. 726 // Creates a client session for testing.
726 // 727 //
727 // server_id: The server id associated with this stream. 728 // server_id: The server id associated with this stream.
728 // supports_stateless_rejects: Does this client support stateless rejects. 729 // supports_stateless_rejects: Does this client support stateless rejects.
729 // connection_start_time: The time to set for the connection clock. 730 // connection_start_time: The time to set for the connection clock.
730 // Needed for strike-register nonce verification. The client 731 // Needed for strike-register nonce verification. The client
731 // connection_start_time should be synchronized witht the server 732 // connection_start_time should be synchronized witht the server
732 // start time, otherwise nonce verification will fail. 733 // start time, otherwise nonce verification will fail.
733 // helper: Pointer to the MockHelper to use for the session. 734 // helper: Pointer to the MockConnectionHelper to use for the session.
734 // crypto_client_config: Pointer to the crypto client config. 735 // crypto_client_config: Pointer to the crypto client config.
735 // client_connection: Pointer reference for newly created 736 // client_connection: Pointer reference for newly created
736 // connection. This object will be owned by the 737 // connection. This object will be owned by the
737 // client_session. 738 // client_session.
738 // client_session: Pointer reference for the newly created client 739 // client_session: Pointer reference for the newly created client
739 // session. The new object will be owned by the caller. 740 // session. The new object will be owned by the caller.
740 void CreateClientSessionForTest(QuicServerId server_id, 741 void CreateClientSessionForTest(QuicServerId server_id,
741 bool supports_stateless_rejects, 742 bool supports_stateless_rejects,
742 QuicTime::Delta connection_start_time, 743 QuicTime::Delta connection_start_time,
743 MockHelper* helper, 744 MockConnectionHelper* helper,
744 QuicCryptoClientConfig* crypto_client_config, 745 QuicCryptoClientConfig* crypto_client_config,
745 PacketSavingConnection** client_connection, 746 PacketSavingConnection** client_connection,
746 TestQuicSpdyClientSession** client_session); 747 TestQuicSpdyClientSession** client_session);
747 748
748 // Creates a server session for testing. 749 // Creates a server session for testing.
749 // 750 //
750 // server_id: The server id associated with this stream. 751 // server_id: The server id associated with this stream.
751 // connection_start_time: The time to set for the connection clock. 752 // connection_start_time: The time to set for the connection clock.
752 // Needed for strike-register nonce verification. The server 753 // Needed for strike-register nonce verification. The server
753 // connection_start_time should be synchronized witht the client 754 // connection_start_time should be synchronized witht the client
754 // start time, otherwise nonce verification will fail. 755 // start time, otherwise nonce verification will fail.
755 // helper: Pointer to the MockHelper to use for the session. 756 // helper: Pointer to the MockConnectionHelper to use for the session.
756 // crypto_server_config: Pointer to the crypto server config. 757 // crypto_server_config: Pointer to the crypto server config.
757 // server_connection: Pointer reference for newly created 758 // server_connection: Pointer reference for newly created
758 // connection. This object will be owned by the 759 // connection. This object will be owned by the
759 // server_session. 760 // server_session.
760 // server_session: Pointer reference for the newly created server 761 // server_session: Pointer reference for the newly created server
761 // session. The new object will be owned by the caller. 762 // session. The new object will be owned by the caller.
762 void CreateServerSessionForTest(QuicServerId server_id, 763 void CreateServerSessionForTest(QuicServerId server_id,
763 QuicTime::Delta connection_start_time, 764 QuicTime::Delta connection_start_time,
764 MockHelper* helper, 765 MockConnectionHelper* helper,
765 QuicCryptoServerConfig* crypto_server_config, 766 QuicCryptoServerConfig* crypto_server_config,
766 PacketSavingConnection** server_connection, 767 PacketSavingConnection** server_connection,
767 TestQuicSpdyServerSession** server_session); 768 TestQuicSpdyServerSession** server_session);
768 769
769 // Helper to generate client side stream ids, generalizes 770 // Helper to generate client side stream ids, generalizes
770 // kClientDataStreamId1 etc. above. 771 // kClientDataStreamId1 etc. above.
771 QuicStreamId QuicClientDataStreamId(int i); 772 QuicStreamId QuicClientDataStreamId(int i);
772 773
773 } // namespace test 774 } // namespace test
774 } // namespace net 775 } // namespace net
775 776
776 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ 777 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « net/quic/test_tools/crypto_test_utils.cc ('k') | net/quic/test_tools/quic_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698