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

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

Issue 1977153002: Rename various MockConnectionFoo classes to MockQuicConnectionFoo. No behavior change. This is cons… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@121576119
Patch Set: Created 4 years, 7 months 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 <stddef.h> 10 #include <stddef.h>
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 bool OnGoAwayFrame(const QuicGoAwayFrame& frame) override; 304 bool OnGoAwayFrame(const QuicGoAwayFrame& frame) override;
305 bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override; 305 bool OnWindowUpdateFrame(const QuicWindowUpdateFrame& frame) override;
306 bool OnBlockedFrame(const QuicBlockedFrame& frame) override; 306 bool OnBlockedFrame(const QuicBlockedFrame& frame) override;
307 bool OnPathCloseFrame(const QuicPathCloseFrame& frame) override; 307 bool OnPathCloseFrame(const QuicPathCloseFrame& frame) override;
308 void OnPacketComplete() override {} 308 void OnPacketComplete() override {}
309 309
310 private: 310 private:
311 DISALLOW_COPY_AND_ASSIGN(NoOpFramerVisitor); 311 DISALLOW_COPY_AND_ASSIGN(NoOpFramerVisitor);
312 }; 312 };
313 313
314 class MockConnectionVisitor : public QuicConnectionVisitorInterface { 314 class MockQuicConnectionVisitor : public QuicConnectionVisitorInterface {
315 public: 315 public:
316 MockConnectionVisitor(); 316 MockQuicConnectionVisitor();
317 ~MockConnectionVisitor() override; 317 ~MockQuicConnectionVisitor() override;
318 318
319 MOCK_METHOD1(OnStreamFrame, void(const QuicStreamFrame& frame)); 319 MOCK_METHOD1(OnStreamFrame, void(const QuicStreamFrame& frame));
320 MOCK_METHOD1(OnWindowUpdateFrame, void(const QuicWindowUpdateFrame& frame)); 320 MOCK_METHOD1(OnWindowUpdateFrame, void(const QuicWindowUpdateFrame& frame));
321 MOCK_METHOD1(OnBlockedFrame, void(const QuicBlockedFrame& frame)); 321 MOCK_METHOD1(OnBlockedFrame, void(const QuicBlockedFrame& frame));
322 MOCK_METHOD1(OnRstStream, void(const QuicRstStreamFrame& frame)); 322 MOCK_METHOD1(OnRstStream, void(const QuicRstStreamFrame& frame));
323 MOCK_METHOD1(OnGoAway, void(const QuicGoAwayFrame& frame)); 323 MOCK_METHOD1(OnGoAway, void(const QuicGoAwayFrame& frame));
324 MOCK_METHOD3(OnConnectionClosed, 324 MOCK_METHOD3(OnConnectionClosed,
325 void(QuicErrorCode error, 325 void(QuicErrorCode error,
326 const std::string& error_details, 326 const std::string& error_details,
327 ConnectionCloseSource source)); 327 ConnectionCloseSource source));
328 MOCK_METHOD0(OnWriteBlocked, void()); 328 MOCK_METHOD0(OnWriteBlocked, void());
329 MOCK_METHOD0(OnCanWrite, void()); 329 MOCK_METHOD0(OnCanWrite, void());
330 MOCK_METHOD1(OnCongestionWindowChange, void(QuicTime now)); 330 MOCK_METHOD1(OnCongestionWindowChange, void(QuicTime now));
331 MOCK_METHOD1(OnConnectionMigration, void(PeerAddressChangeType type)); 331 MOCK_METHOD1(OnConnectionMigration, void(PeerAddressChangeType type));
332 MOCK_METHOD0(OnPathDegrading, void()); 332 MOCK_METHOD0(OnPathDegrading, void());
333 MOCK_CONST_METHOD0(WillingAndAbleToWrite, bool()); 333 MOCK_CONST_METHOD0(WillingAndAbleToWrite, bool());
334 MOCK_CONST_METHOD0(HasPendingHandshake, bool()); 334 MOCK_CONST_METHOD0(HasPendingHandshake, bool());
335 MOCK_CONST_METHOD0(HasOpenDynamicStreams, bool()); 335 MOCK_CONST_METHOD0(HasOpenDynamicStreams, bool());
336 MOCK_METHOD1(OnSuccessfulVersionNegotiation, 336 MOCK_METHOD1(OnSuccessfulVersionNegotiation,
337 void(const QuicVersion& version)); 337 void(const QuicVersion& version));
338 MOCK_METHOD0(OnConfigNegotiated, void()); 338 MOCK_METHOD0(OnConfigNegotiated, void());
339 MOCK_METHOD0(PostProcessAfterData, void()); 339 MOCK_METHOD0(PostProcessAfterData, void());
340 340
341 private: 341 private:
342 DISALLOW_COPY_AND_ASSIGN(MockConnectionVisitor); 342 DISALLOW_COPY_AND_ASSIGN(MockQuicConnectionVisitor);
343 }; 343 };
344 344
345 class MockConnectionHelper : public QuicConnectionHelperInterface { 345 class MockQuicConnectionHelper : public QuicConnectionHelperInterface {
346 public: 346 public:
347 MockConnectionHelper(); 347 MockQuicConnectionHelper();
348 ~MockConnectionHelper() override; 348 ~MockQuicConnectionHelper() override;
349 const QuicClock* GetClock() const override; 349 const QuicClock* GetClock() const override;
350 QuicRandom* GetRandomGenerator() override; 350 QuicRandom* GetRandomGenerator() override;
351 QuicBufferAllocator* GetBufferAllocator() override; 351 QuicBufferAllocator* GetBufferAllocator() override;
352 void AdvanceTime(QuicTime::Delta delta); 352 void AdvanceTime(QuicTime::Delta delta);
353 353
354 private: 354 private:
355 MockClock clock_; 355 MockClock clock_;
356 MockRandom random_generator_; 356 MockRandom random_generator_;
357 SimpleBufferAllocator buffer_allocator_; 357 SimpleBufferAllocator buffer_allocator_;
358 358
359 DISALLOW_COPY_AND_ASSIGN(MockConnectionHelper); 359 DISALLOW_COPY_AND_ASSIGN(MockQuicConnectionHelper);
360 }; 360 };
361 361
362 class MockAlarmFactory : public QuicAlarmFactory { 362 class MockAlarmFactory : public QuicAlarmFactory {
363 public: 363 public:
364 QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) override; 364 QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) override;
365 QuicArenaScopedPtr<QuicAlarm> CreateAlarm( 365 QuicArenaScopedPtr<QuicAlarm> CreateAlarm(
366 QuicArenaScopedPtr<QuicAlarm::Delegate> delegate, 366 QuicArenaScopedPtr<QuicAlarm::Delegate> delegate,
367 QuicConnectionArena* arena) override; 367 QuicConnectionArena* arena) override;
368 368
369 // No-op alarm implementation 369 // No-op alarm implementation
370 class TestAlarm : public QuicAlarm { 370 class TestAlarm : public QuicAlarm {
371 public: 371 public:
372 explicit TestAlarm(QuicArenaScopedPtr<QuicAlarm::Delegate> delegate) 372 explicit TestAlarm(QuicArenaScopedPtr<QuicAlarm::Delegate> delegate)
373 : QuicAlarm(std::move(delegate)) {} 373 : QuicAlarm(std::move(delegate)) {}
374 374
375 void SetImpl() override {} 375 void SetImpl() override {}
376 void CancelImpl() override {} 376 void CancelImpl() override {}
377 377
378 using QuicAlarm::Fire; 378 using QuicAlarm::Fire;
379 }; 379 };
380 380
381 void FireAlarm(QuicAlarm* alarm) { 381 void FireAlarm(QuicAlarm* alarm) {
382 reinterpret_cast<TestAlarm*>(alarm)->Fire(); 382 reinterpret_cast<TestAlarm*>(alarm)->Fire();
383 } 383 }
384 }; 384 };
385 385
386 class MockConnection : public QuicConnection { 386 class MockQuicConnection : public QuicConnection {
387 public: 387 public:
388 // Uses a ConnectionId of 42 and 127.0.0.1:123. 388 // Uses a ConnectionId of 42 and 127.0.0.1:123.
389 MockConnection(MockConnectionHelper* helper, 389 MockQuicConnection(MockQuicConnectionHelper* helper,
390 MockAlarmFactory* alarm_factory, 390 MockAlarmFactory* alarm_factory,
391 Perspective perspective); 391 Perspective perspective);
392 392
393 // Uses a ConnectionId of 42. 393 // Uses a ConnectionId of 42.
394 MockConnection(IPEndPoint address, 394 MockQuicConnection(IPEndPoint address,
395 MockConnectionHelper* helper, 395 MockQuicConnectionHelper* helper,
396 MockAlarmFactory* alarm_factory, 396 MockAlarmFactory* alarm_factory,
397 Perspective perspective); 397 Perspective perspective);
398 398
399 // Uses 127.0.0.1:123. 399 // Uses 127.0.0.1:123.
400 MockConnection(QuicConnectionId connection_id, 400 MockQuicConnection(QuicConnectionId connection_id,
401 MockConnectionHelper* helper, 401 MockQuicConnectionHelper* helper,
402 MockAlarmFactory* alarm_factory, 402 MockAlarmFactory* alarm_factory,
403 Perspective perspective); 403 Perspective perspective);
404 404
405 // Uses a ConnectionId of 42, and 127.0.0.1:123. 405 // Uses a ConnectionId of 42, and 127.0.0.1:123.
406 MockConnection(MockConnectionHelper* helper, 406 MockQuicConnection(MockQuicConnectionHelper* helper,
407 MockAlarmFactory* alarm_factory, 407 MockAlarmFactory* alarm_factory,
408 Perspective perspective, 408 Perspective perspective,
409 const QuicVersionVector& supported_versions); 409 const QuicVersionVector& supported_versions);
410 410
411 MockConnection(QuicConnectionId connection_id, 411 MockQuicConnection(QuicConnectionId connection_id,
412 IPEndPoint address, 412 IPEndPoint address,
413 MockConnectionHelper* helper, 413 MockQuicConnectionHelper* helper,
414 MockAlarmFactory* alarm_factory, 414 MockAlarmFactory* alarm_factory,
415 Perspective perspective, 415 Perspective perspective,
416 const QuicVersionVector& supported_versions); 416 const QuicVersionVector& supported_versions);
417 417
418 ~MockConnection() override; 418 ~MockQuicConnection() override;
419 419
420 // If the constructor that uses a MockConnectionHelper has been used then 420 // If the constructor that uses a MockQuicConnectionHelper has been used then
421 // this method 421 // this method
422 // will advance the time of the MockClock. 422 // will advance the time of the MockClock.
423 void AdvanceTime(QuicTime::Delta delta); 423 void AdvanceTime(QuicTime::Delta delta);
424 424
425 MOCK_METHOD3(ProcessUdpPacket, 425 MOCK_METHOD3(ProcessUdpPacket,
426 void(const IPEndPoint& self_address, 426 void(const IPEndPoint& self_address,
427 const IPEndPoint& peer_address, 427 const IPEndPoint& peer_address,
428 const QuicReceivedPacket& packet)); 428 const QuicReceivedPacket& packet));
429 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error)); 429 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error));
430 MOCK_METHOD3(CloseConnection, 430 MOCK_METHOD3(CloseConnection,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 464
465 bool OnProtocolVersionMismatch(QuicVersion version) override { return false; } 465 bool OnProtocolVersionMismatch(QuicVersion version) override { return false; }
466 466
467 void ReallySendGoAway(QuicErrorCode error, 467 void ReallySendGoAway(QuicErrorCode error,
468 QuicStreamId last_good_stream_id, 468 QuicStreamId last_good_stream_id,
469 const std::string& reason) { 469 const std::string& reason) {
470 QuicConnection::SendGoAway(error, last_good_stream_id, reason); 470 QuicConnection::SendGoAway(error, last_good_stream_id, reason);
471 } 471 }
472 472
473 private: 473 private:
474 DISALLOW_COPY_AND_ASSIGN(MockConnection); 474 DISALLOW_COPY_AND_ASSIGN(MockQuicConnection);
475 }; 475 };
476 476
477 class PacketSavingConnection : public MockConnection { 477 class PacketSavingConnection : public MockQuicConnection {
478 public: 478 public:
479 PacketSavingConnection(MockConnectionHelper* helper, 479 PacketSavingConnection(MockQuicConnectionHelper* helper,
480 MockAlarmFactory* alarm_factory, 480 MockAlarmFactory* alarm_factory,
481 Perspective perspective); 481 Perspective perspective);
482 482
483 PacketSavingConnection(MockConnectionHelper* helper, 483 PacketSavingConnection(MockQuicConnectionHelper* helper,
484 MockAlarmFactory* alarm_factory, 484 MockAlarmFactory* alarm_factory,
485 Perspective perspective, 485 Perspective perspective,
486 const QuicVersionVector& supported_versions); 486 const QuicVersionVector& supported_versions);
487 487
488 ~PacketSavingConnection() override; 488 ~PacketSavingConnection() override;
489 489
490 void SendOrQueuePacket(SerializedPacket* packet) override; 490 void SendOrQueuePacket(SerializedPacket* packet) override;
491 491
492 std::vector<QuicEncryptedPacket*> encrypted_packets_; 492 std::vector<QuicEncryptedPacket*> encrypted_packets_;
493 493
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 883
884 // Creates a client session for testing. 884 // Creates a client session for testing.
885 // 885 //
886 // server_id: The server id associated with this stream. 886 // server_id: The server id associated with this stream.
887 // supports_stateless_rejects: Does this client support stateless rejects. 887 // supports_stateless_rejects: Does this client support stateless rejects.
888 // connection_start_time: The time to set for the connection clock. 888 // connection_start_time: The time to set for the connection clock.
889 // Needed for strike-register nonce verification. The client 889 // Needed for strike-register nonce verification. The client
890 // connection_start_time should be synchronized witht the server 890 // connection_start_time should be synchronized witht the server
891 // start time, otherwise nonce verification will fail. 891 // start time, otherwise nonce verification will fail.
892 // supported_versions: Set of QUIC versions this client supports. 892 // supported_versions: Set of QUIC versions this client supports.
893 // helper: Pointer to the MockConnectionHelper to use for the session. 893 // helper: Pointer to the MockQuicConnectionHelper to use for the session.
894 // crypto_client_config: Pointer to the crypto client config. 894 // crypto_client_config: Pointer to the crypto client config.
895 // client_connection: Pointer reference for newly created 895 // client_connection: Pointer reference for newly created
896 // connection. This object will be owned by the 896 // connection. This object will be owned by the
897 // client_session. 897 // client_session.
898 // client_session: Pointer reference for the newly created client 898 // client_session: Pointer reference for the newly created client
899 // session. The new object will be owned by the caller. 899 // session. The new object will be owned by the caller.
900 void CreateClientSessionForTest(QuicServerId server_id, 900 void CreateClientSessionForTest(QuicServerId server_id,
901 bool supports_stateless_rejects, 901 bool supports_stateless_rejects,
902 QuicTime::Delta connection_start_time, 902 QuicTime::Delta connection_start_time,
903 QuicVersionVector supported_versions, 903 QuicVersionVector supported_versions,
904 MockConnectionHelper* helper, 904 MockQuicConnectionHelper* helper,
905 MockAlarmFactory* alarm_factory, 905 MockAlarmFactory* alarm_factory,
906 QuicCryptoClientConfig* crypto_client_config, 906 QuicCryptoClientConfig* crypto_client_config,
907 PacketSavingConnection** client_connection, 907 PacketSavingConnection** client_connection,
908 TestQuicSpdyClientSession** client_session); 908 TestQuicSpdyClientSession** client_session);
909 909
910 // Creates a server session for testing. 910 // Creates a server session for testing.
911 // 911 //
912 // server_id: The server id associated with this stream. 912 // server_id: The server id associated with this stream.
913 // connection_start_time: The time to set for the connection clock. 913 // connection_start_time: The time to set for the connection clock.
914 // Needed for strike-register nonce verification. The server 914 // Needed for strike-register nonce verification. The server
915 // connection_start_time should be synchronized witht the client 915 // connection_start_time should be synchronized witht the client
916 // start time, otherwise nonce verification will fail. 916 // start time, otherwise nonce verification will fail.
917 // supported_versions: Set of QUIC versions this server supports. 917 // supported_versions: Set of QUIC versions this server supports.
918 // helper: Pointer to the MockConnectionHelper to use for the session. 918 // helper: Pointer to the MockQuicConnectionHelper to use for the session.
919 // crypto_server_config: Pointer to the crypto server config. 919 // crypto_server_config: Pointer to the crypto server config.
920 // server_connection: Pointer reference for newly created 920 // server_connection: Pointer reference for newly created
921 // connection. This object will be owned by the 921 // connection. This object will be owned by the
922 // server_session. 922 // server_session.
923 // server_session: Pointer reference for the newly created server 923 // server_session: Pointer reference for the newly created server
924 // session. The new object will be owned by the caller. 924 // session. The new object will be owned by the caller.
925 void CreateServerSessionForTest( 925 void CreateServerSessionForTest(
926 QuicServerId server_id, 926 QuicServerId server_id,
927 QuicTime::Delta connection_start_time, 927 QuicTime::Delta connection_start_time,
928 QuicVersionVector supported_versions, 928 QuicVersionVector supported_versions,
929 MockConnectionHelper* helper, 929 MockQuicConnectionHelper* helper,
930 MockAlarmFactory* alarm_factory, 930 MockAlarmFactory* alarm_factory,
931 QuicCryptoServerConfig* crypto_server_config, 931 QuicCryptoServerConfig* crypto_server_config,
932 QuicCompressedCertsCache* compressed_certs_cache, 932 QuicCompressedCertsCache* compressed_certs_cache,
933 PacketSavingConnection** server_connection, 933 PacketSavingConnection** server_connection,
934 TestQuicSpdyServerSession** server_session); 934 TestQuicSpdyServerSession** server_session);
935 935
936 // Helper to generate client side stream ids, generalizes 936 // Helper to generate client side stream ids, generalizes
937 // kClientDataStreamId1 etc. above. 937 // kClientDataStreamId1 etc. above.
938 QuicStreamId QuicClientDataStreamId(int i); 938 QuicStreamId QuicClientDataStreamId(int i);
939 939
940 } // namespace test 940 } // namespace test
941 } // namespace net 941 } // namespace net
942 942
943 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ 943 #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