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

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

Issue 2747443002: Landing recent QUIC changes until Sun Mar 5 09:18:09 2017 +0000 (Closed)
Patch Set: Created 3 years, 9 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 911 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 QuicStopWaitingFrame* frame, 922 QuicStopWaitingFrame* frame,
923 EncryptionLevel level) { 923 EncryptionLevel level) {
924 return ProcessFramePacketAtLevel(number, QuicFrame(frame), 924 return ProcessFramePacketAtLevel(number, QuicFrame(frame),
925 ENCRYPTION_INITIAL); 925 ENCRYPTION_INITIAL);
926 } 926 }
927 927
928 void ProcessGoAwayPacket(QuicGoAwayFrame* frame) { 928 void ProcessGoAwayPacket(QuicGoAwayFrame* frame) {
929 ProcessFramePacket(QuicFrame(frame)); 929 ProcessFramePacket(QuicFrame(frame));
930 } 930 }
931 931
932 void ProcessPathClosePacket(QuicPathCloseFrame* frame) {
933 ProcessFramePacket(QuicFrame(frame));
934 }
935
936 bool IsMissing(QuicPacketNumber number) { 932 bool IsMissing(QuicPacketNumber number) {
937 return IsAwaitingPacket(*outgoing_ack(), number, 0); 933 return IsAwaitingPacket(*outgoing_ack(), number, 0);
938 } 934 }
939 935
940 QuicPacket* ConstructPacket(QuicPacketHeader header, QuicFrames frames) { 936 QuicPacket* ConstructPacket(QuicPacketHeader header, QuicFrames frames) {
941 QuicPacket* packet = BuildUnsizedDataPacket(&peer_framer_, header, frames); 937 QuicPacket* packet = BuildUnsizedDataPacket(&peer_framer_, header, frames);
942 EXPECT_NE(nullptr, packet); 938 EXPECT_NE(nullptr, packet);
943 return packet; 939 return packet;
944 } 940 }
945 941
(...skipping 3894 matching lines...) Expand 10 before | Expand all | Expand 10 after
4840 4836
4841 MockQuicConnectionDebugVisitor debug_visitor; 4837 MockQuicConnectionDebugVisitor debug_visitor;
4842 connection_.set_debug_visitor(&debug_visitor); 4838 connection_.set_debug_visitor(&debug_visitor);
4843 EXPECT_CALL(debug_visitor, OnPacketHeader(Ref(header))).Times(1); 4839 EXPECT_CALL(debug_visitor, OnPacketHeader(Ref(header))).Times(1);
4844 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)).Times(1); 4840 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)).Times(1);
4845 EXPECT_CALL(debug_visitor, OnSuccessfulVersionNegotiation(_)).Times(1); 4841 EXPECT_CALL(debug_visitor, OnSuccessfulVersionNegotiation(_)).Times(1);
4846 connection_.OnPacketHeader(header); 4842 connection_.OnPacketHeader(header);
4847 } 4843 }
4848 4844
4849 TEST_P(QuicConnectionTest, Pacing) { 4845 TEST_P(QuicConnectionTest, Pacing) {
4850 // static_cast here does not work if using multipath_sent_packet_manager.
4851 FLAGS_quic_reloadable_flag_quic_enable_multipath = false;
4852 TestConnection server(connection_id_, kSelfAddress, helper_.get(), 4846 TestConnection server(connection_id_, kSelfAddress, helper_.get(),
4853 alarm_factory_.get(), writer_.get(), 4847 alarm_factory_.get(), writer_.get(),
4854 Perspective::IS_SERVER, version()); 4848 Perspective::IS_SERVER, version());
4855 TestConnection client(connection_id_, kPeerAddress, helper_.get(), 4849 TestConnection client(connection_id_, kPeerAddress, helper_.get(),
4856 alarm_factory_.get(), writer_.get(), 4850 alarm_factory_.get(), writer_.get(),
4857 Perspective::IS_CLIENT, version()); 4851 Perspective::IS_CLIENT, version());
4858 EXPECT_FALSE(QuicSentPacketManagerPeer::UsingPacing( 4852 EXPECT_FALSE(QuicSentPacketManagerPeer::UsingPacing(
4859 static_cast<const QuicSentPacketManager*>( 4853 static_cast<const QuicSentPacketManager*>(
4860 &client.sent_packet_manager()))); 4854 &client.sent_packet_manager())));
4861 EXPECT_FALSE(QuicSentPacketManagerPeer::UsingPacing( 4855 EXPECT_FALSE(QuicSentPacketManagerPeer::UsingPacing(
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
4972 EXPECT_CALL(visitor_, 4966 EXPECT_CALL(visitor_,
4973 OnConnectionClosed(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA, 4967 OnConnectionClosed(QUIC_ATTEMPT_TO_SEND_UNENCRYPTED_STREAM_DATA,
4974 _, ConnectionCloseSource::FROM_SELF)); 4968 _, ConnectionCloseSource::FROM_SELF));
4975 struct iovec iov; 4969 struct iovec iov;
4976 QuicIOVector data_iov(MakeIOVector("", &iov)); 4970 QuicIOVector data_iov(MakeIOVector("", &iov));
4977 EXPECT_QUIC_BUG(connection_.SendStreamData(3, data_iov, 0, kFin, nullptr), 4971 EXPECT_QUIC_BUG(connection_.SendStreamData(3, data_iov, 0, kFin, nullptr),
4978 "Cannot send stream data without encryption."); 4972 "Cannot send stream data without encryption.");
4979 EXPECT_FALSE(connection_.connected()); 4973 EXPECT_FALSE(connection_.connected());
4980 } 4974 }
4981 4975
4982 TEST_P(QuicConnectionTest, EnableMultipathNegotiation) {
4983 // Test multipath negotiation during crypto handshake. Multipath is enabled
4984 // when both endpoints enable multipath.
4985 FLAGS_quic_reloadable_flag_quic_enable_multipath = true;
4986 EXPECT_TRUE(connection_.connected());
4987 EXPECT_FALSE(QuicConnectionPeer::IsMultipathEnabled(&connection_));
4988 EXPECT_CALL(*send_algorithm_, SetFromConfig(_, _));
4989 QuicConfig config;
4990 // Enable multipath on server side.
4991 config.SetMultipathEnabled(true);
4992
4993 // Create a handshake message enables multipath.
4994 CryptoHandshakeMessage msg;
4995 string error_details;
4996 QuicConfig client_config;
4997 // Enable multipath on client side.
4998 client_config.SetMultipathEnabled(true);
4999 client_config.ToHandshakeMessage(&msg);
5000 const QuicErrorCode error =
5001 config.ProcessPeerHello(msg, CLIENT, &error_details);
5002 EXPECT_EQ(QUIC_NO_ERROR, error);
5003
5004 connection_.SetFromConfig(config);
5005 EXPECT_TRUE(QuicConnectionPeer::IsMultipathEnabled(&connection_));
5006 }
5007
5008 TEST_P(QuicConnectionTest, OnPathDegrading) { 4976 TEST_P(QuicConnectionTest, OnPathDegrading) {
5009 QuicByteCount packet_size; 4977 QuicByteCount packet_size;
5010 const size_t kMinTimeoutsBeforePathDegrading = 2; 4978 const size_t kMinTimeoutsBeforePathDegrading = 2;
5011 4979
5012 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 4980 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
5013 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true))); 4981 .WillOnce(DoAll(SaveArg<3>(&packet_size), Return(true)));
5014 connection_.SendStreamDataWithString(3, "packet", 0, !kFin, nullptr); 4982 connection_.SendStreamDataWithString(3, "packet", 0, !kFin, nullptr);
5015 size_t num_timeouts = 4983 size_t num_timeouts =
5016 kMinTimeoutsBeforePathDegrading + 4984 kMinTimeoutsBeforePathDegrading +
5017 QuicSentPacketManagerPeer::GetMaxTailLossProbes( 4985 QuicSentPacketManagerPeer::GetMaxTailLossProbes(
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
5162 error_details, ConnectionCloseSource::FROM_PEER)); 5130 error_details, ConnectionCloseSource::FROM_PEER));
5163 connection_.set_perspective(Perspective::IS_CLIENT); 5131 connection_.set_perspective(Perspective::IS_CLIENT);
5164 connection_.CloseConnection(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT, 5132 connection_.CloseConnection(QUIC_CRYPTO_HANDSHAKE_STATELESS_REJECT,
5165 error_details, 5133 error_details,
5166 ConnectionCloseBehavior::SILENT_CLOSE); 5134 ConnectionCloseBehavior::SILENT_CLOSE);
5167 } 5135 }
5168 5136
5169 } // namespace 5137 } // namespace
5170 } // namespace test 5138 } // namespace test
5171 } // namespace net 5139 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698