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

Side by Side Diff: net/quic/core/quic_connection_test.cc

Issue 2848203002: Add a platform implementation of QuicTest and QuicTestWithParam (Closed)
Patch Set: net/quic/platform/impl/quic_test_impl.cc Created 3 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/core/quic_config_test.cc ('k') | net/quic/core/quic_crypto_client_stream_test.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 #include "net/quic/core/quic_connection.h" 5 #include "net/quic/core/quic_connection.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <memory> 8 #include <memory>
9 #include <ostream> 9 #include <ostream>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "net/base/net_errors.h" 14 #include "net/base/net_errors.h"
15 #include "net/quic/core/congestion_control/loss_detection_interface.h" 15 #include "net/quic/core/congestion_control/loss_detection_interface.h"
16 #include "net/quic/core/congestion_control/send_algorithm_interface.h" 16 #include "net/quic/core/congestion_control/send_algorithm_interface.h"
17 #include "net/quic/core/crypto/null_encrypter.h" 17 #include "net/quic/core/crypto/null_encrypter.h"
18 #include "net/quic/core/crypto/quic_decrypter.h" 18 #include "net/quic/core/crypto/quic_decrypter.h"
19 #include "net/quic/core/crypto/quic_encrypter.h" 19 #include "net/quic/core/crypto/quic_encrypter.h"
20 #include "net/quic/core/quic_packets.h" 20 #include "net/quic/core/quic_packets.h"
21 #include "net/quic/core/quic_simple_buffer_allocator.h" 21 #include "net/quic/core/quic_simple_buffer_allocator.h"
22 #include "net/quic/core/quic_utils.h" 22 #include "net/quic/core/quic_utils.h"
23 #include "net/quic/platform/api/quic_flags.h" 23 #include "net/quic/platform/api/quic_flags.h"
24 #include "net/quic/platform/api/quic_logging.h" 24 #include "net/quic/platform/api/quic_logging.h"
25 #include "net/quic/platform/api/quic_reference_counted.h" 25 #include "net/quic/platform/api/quic_reference_counted.h"
26 #include "net/quic/platform/api/quic_str_cat.h" 26 #include "net/quic/platform/api/quic_str_cat.h"
27 #include "net/quic/platform/api/quic_string_piece.h"
28 #include "net/quic/platform/api/quic_test.h"
27 #include "net/quic/test_tools/mock_clock.h" 29 #include "net/quic/test_tools/mock_clock.h"
28 #include "net/quic/test_tools/mock_random.h" 30 #include "net/quic/test_tools/mock_random.h"
29 #include "net/quic/test_tools/quic_config_peer.h" 31 #include "net/quic/test_tools/quic_config_peer.h"
30 #include "net/quic/test_tools/quic_connection_peer.h" 32 #include "net/quic/test_tools/quic_connection_peer.h"
31 #include "net/quic/test_tools/quic_framer_peer.h" 33 #include "net/quic/test_tools/quic_framer_peer.h"
32 #include "net/quic/test_tools/quic_packet_creator_peer.h" 34 #include "net/quic/test_tools/quic_packet_creator_peer.h"
33 #include "net/quic/test_tools/quic_packet_generator_peer.h" 35 #include "net/quic/test_tools/quic_packet_generator_peer.h"
34 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h" 36 #include "net/quic/test_tools/quic_sent_packet_manager_peer.h"
35 #include "net/quic/test_tools/quic_test_utils.h" 37 #include "net/quic/test_tools/quic_test_utils.h"
36 #include "net/quic/test_tools/simple_quic_framer.h" 38 #include "net/quic/test_tools/simple_quic_framer.h"
37 #include "net/test/gtest_util.h" 39 #include "net/test/gtest_util.h"
38 #include "testing/gmock/include/gmock/gmock.h"
39 #include "testing/gmock_mutant.h" 40 #include "testing/gmock_mutant.h"
40 #include "testing/gtest/include/gtest/gtest.h"
41 41
42 using std::string; 42 using std::string;
43 using testing::AnyNumber; 43 using testing::AnyNumber;
44 using testing::AtLeast; 44 using testing::AtLeast;
45 using testing::DoAll; 45 using testing::DoAll;
46 using testing::InSequence; 46 using testing::InSequence;
47 using testing::Invoke; 47 using testing::Invoke;
48 using testing::InvokeWithoutArgs; 48 using testing::InvokeWithoutArgs;
49 using testing::NiceMock; 49 using testing::NiceMock;
50 using testing::Ref; 50 using testing::Ref;
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 {AckResponse::kDefer, AckResponse::kImmediate}) { 679 {AckResponse::kDefer, AckResponse::kImmediate}) {
680 for (bool stop_waiting : {true, false}) { 680 for (bool stop_waiting : {true, false}) {
681 params.push_back( 681 params.push_back(
682 TestParams(all_supported_versions[i], ack_response, stop_waiting)); 682 TestParams(all_supported_versions[i], ack_response, stop_waiting));
683 } 683 }
684 } 684 }
685 } 685 }
686 return params; 686 return params;
687 } 687 }
688 688
689 class QuicConnectionTest : public ::testing::TestWithParam<TestParams> { 689 class QuicConnectionTest : public QuicTestWithParam<TestParams> {
690 protected: 690 protected:
691 QuicConnectionTest() 691 QuicConnectionTest()
692 : connection_id_(42), 692 : connection_id_(42),
693 framer_(SupportedVersions(version()), 693 framer_(SupportedVersions(version()),
694 QuicTime::Zero(), 694 QuicTime::Zero(),
695 Perspective::IS_CLIENT), 695 Perspective::IS_CLIENT),
696 send_algorithm_(new StrictMock<MockSendAlgorithm>), 696 send_algorithm_(new StrictMock<MockSendAlgorithm>),
697 loss_algorithm_(new MockLossAlgorithm()), 697 loss_algorithm_(new MockLossAlgorithm()),
698 helper_(new TestConnectionHelper(&clock_, &random_generator_)), 698 helper_(new TestConnectionHelper(&clock_, &random_generator_)),
699 alarm_factory_(new TestAlarmFactory()), 699 alarm_factory_(new TestAlarmFactory()),
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1054 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _)) 1054 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
1055 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero())); 1055 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
1056 } 1056 }
1057 1057
1058 void set_perspective(Perspective perspective) { 1058 void set_perspective(Perspective perspective) {
1059 connection_.set_perspective(perspective); 1059 connection_.set_perspective(perspective);
1060 QuicFramerPeer::SetPerspective(&peer_framer_, 1060 QuicFramerPeer::SetPerspective(&peer_framer_,
1061 InvertPerspective(perspective)); 1061 InvertPerspective(perspective));
1062 } 1062 }
1063 1063
1064 QuicFlagSaver flags_; // Save/restore all QUIC flag values.
1065
1066 QuicConnectionId connection_id_; 1064 QuicConnectionId connection_id_;
1067 QuicFramer framer_; 1065 QuicFramer framer_;
1068 1066
1069 MockSendAlgorithm* send_algorithm_; 1067 MockSendAlgorithm* send_algorithm_;
1070 std::unique_ptr<MockLossAlgorithm> loss_algorithm_; 1068 std::unique_ptr<MockLossAlgorithm> loss_algorithm_;
1071 MockClock clock_; 1069 MockClock clock_;
1072 MockRandom random_generator_; 1070 MockRandom random_generator_;
1073 SimpleBufferAllocator buffer_allocator_; 1071 SimpleBufferAllocator buffer_allocator_;
1074 std::unique_ptr<TestConnectionHelper> helper_; 1072 std::unique_ptr<TestConnectionHelper> helper_;
1075 std::unique_ptr<TestAlarmFactory> alarm_factory_; 1073 std::unique_ptr<TestAlarmFactory> alarm_factory_;
(...skipping 4140 matching lines...) Expand 10 before | Expand all | Expand 10 after
5216 error_details, ConnectionCloseSource::FROM_PEER)); 5214 error_details, ConnectionCloseSource::FROM_PEER));
5217 connection_.set_perspective(Perspective::IS_CLIENT); 5215 connection_.set_perspective(Perspective::IS_CLIENT);
5218 connection_.CloseConnection(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, 5216 connection_.CloseConnection(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT,
5219 error_details, 5217 error_details,
5220 ConnectionCloseBehavior::SILENT_CLOSE); 5218 ConnectionCloseBehavior::SILENT_CLOSE);
5221 } 5219 }
5222 5220
5223 } // namespace 5221 } // namespace
5224 } // namespace test 5222 } // namespace test
5225 } // namespace net 5223 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/quic_config_test.cc ('k') | net/quic/core/quic_crypto_client_stream_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698