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

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

Issue 2306173003: Add a new QuicFlagSaver class for saving/restoring the values of QUIC flags in tests. (Closed)
Patch Set: Better Created 4 years, 3 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
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>
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _)) 1055 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _))
1056 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero())); 1056 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero()));
1057 } 1057 }
1058 1058
1059 void set_perspective(Perspective perspective) { 1059 void set_perspective(Perspective perspective) {
1060 connection_.set_perspective(perspective); 1060 connection_.set_perspective(perspective);
1061 QuicFramerPeer::SetPerspective(&peer_framer_, 1061 QuicFramerPeer::SetPerspective(&peer_framer_,
1062 InvertPerspective(perspective)); 1062 InvertPerspective(perspective));
1063 } 1063 }
1064 1064
1065 QuicFlagSaver flags_; // Save/restore all QUIC flag values.
1066
1065 QuicConnectionId connection_id_; 1067 QuicConnectionId connection_id_;
1066 QuicFramer framer_; 1068 QuicFramer framer_;
1067 MockEntropyCalculator entropy_calculator_; 1069 MockEntropyCalculator entropy_calculator_;
1068 MockEntropyCalculator peer_entropy_calculator_; 1070 MockEntropyCalculator peer_entropy_calculator_;
1069 1071
1070 MockSendAlgorithm* send_algorithm_; 1072 MockSendAlgorithm* send_algorithm_;
1071 std::unique_ptr<MockLossAlgorithm> loss_algorithm_; 1073 std::unique_ptr<MockLossAlgorithm> loss_algorithm_;
1072 MockClock clock_; 1074 MockClock clock_;
1073 MockRandom random_generator_; 1075 MockRandom random_generator_;
1074 SimpleBufferAllocator buffer_allocator_; 1076 SimpleBufferAllocator buffer_allocator_;
(...skipping 3902 matching lines...) Expand 10 before | Expand all | Expand 10 after
4977 OnConnectionClosed(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA, 4979 OnConnectionClosed(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA,
4978 _, ConnectionCloseSource::FROM_SELF)); 4980 _, ConnectionCloseSource::FROM_SELF));
4979 EXPECT_QUIC_BUG(connection_.SendStreamDataWithString(3, "", 0, kFin, nullptr), 4981 EXPECT_QUIC_BUG(connection_.SendStreamDataWithString(3, "", 0, kFin, nullptr),
4980 "Cannot send stream data without encryption."); 4982 "Cannot send stream data without encryption.");
4981 EXPECT_FALSE(connection_.connected()); 4983 EXPECT_FALSE(connection_.connected());
4982 } 4984 }
4983 4985
4984 TEST_P(QuicConnectionTest, EnableMultipathNegotiation) { 4986 TEST_P(QuicConnectionTest, EnableMultipathNegotiation) {
4985 // Test multipath negotiation during crypto handshake. Multipath is enabled 4987 // Test multipath negotiation during crypto handshake. Multipath is enabled
4986 // when both endpoints enable multipath. 4988 // when both endpoints enable multipath.
4987 ValueRestore<bool> old_flag(&FLAGS_quic_enable_multipath, true); 4989 FLAGS_quic_enable_multipath = true;
4988 EXPECT_TRUE(connection_.connected()); 4990 EXPECT_TRUE(connection_.connected());
4989 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_)); 4991 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_));
4990 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _)); 4992 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
4991 QuicConfig config; 4993 QuicConfig config;
4992 // Enable multipath on server side. 4994 // Enable multipath on server side.
4993 config.SetMultipathEnabled(true); 4995 config.SetMultipathEnabled(true);
4994 4996
4995 // Create a handshake message enables multipath. 4997 // Create a handshake message enables multipath.
4996 CryptoHandshakeMessage msg; 4998 CryptoHandshakeMessage msg;
4997 string error_details; 4999 string error_details;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
5205 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); 5207 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr);
5206 EXPECT_EQ(1u, writer_->frame_count()); 5208 EXPECT_EQ(1u, writer_->frame_count());
5207 EXPECT_FALSE(writer_->connection_close_frames().empty()); 5209 EXPECT_FALSE(writer_->connection_close_frames().empty());
5208 // Ack frame is not bundled in connection close packet. 5210 // Ack frame is not bundled in connection close packet.
5209 EXPECT_TRUE(writer_->ack_frames().empty()); 5211 EXPECT_TRUE(writer_->ack_frames().empty());
5210 } 5212 }
5211 5213
5212 } // namespace 5214 } // namespace
5213 } // namespace test 5215 } // namespace test
5214 } // namespace net 5216 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/crypto/crypto_server_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