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

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

Issue 429453003: Create a visitor which can allow using both a trace... visitor and the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Use_1350_byte_packet_71837432
Patch Set: fixed comments Created 6 years, 4 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/quic_connection.cc ('k') | no next file » | 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/quic_connection.h" 5 #include "net/quic/quic_connection.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 2103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2114 // Don't send missing packet 1. 2114 // Don't send missing packet 1.
2115 ProcessFecPacket(2, 1, true, !kEntropyFlag, NULL); 2115 ProcessFecPacket(2, 1, true, !kEntropyFlag, NULL);
2116 // Entropy flag should be false, so entropy should be 0. 2116 // Entropy flag should be false, so entropy should be 0.
2117 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2)); 2117 EXPECT_EQ(0u, QuicConnectionPeer::ReceivedEntropyHash(&connection_, 2));
2118 } 2118 }
2119 2119
2120 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingSeqNumLengths) { 2120 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingSeqNumLengths) {
2121 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2121 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2122 2122
2123 // Set up a debug visitor to the connection. 2123 // Set up a debug visitor to the connection.
2124 scoped_ptr<FecQuicConnectionDebugVisitor> 2124 FecQuicConnectionDebugVisitor* fec_visitor =
2125 fec_visitor(new FecQuicConnectionDebugVisitor); 2125 new FecQuicConnectionDebugVisitor();
2126 connection_.set_debug_visitor(fec_visitor.get()); 2126 connection_.set_debug_visitor(fec_visitor);
2127 2127
2128 QuicPacketSequenceNumber fec_packet = 0; 2128 QuicPacketSequenceNumber fec_packet = 0;
2129 QuicSequenceNumberLength lengths[] = {PACKET_6BYTE_SEQUENCE_NUMBER, 2129 QuicSequenceNumberLength lengths[] = {PACKET_6BYTE_SEQUENCE_NUMBER,
2130 PACKET_4BYTE_SEQUENCE_NUMBER, 2130 PACKET_4BYTE_SEQUENCE_NUMBER,
2131 PACKET_2BYTE_SEQUENCE_NUMBER, 2131 PACKET_2BYTE_SEQUENCE_NUMBER,
2132 PACKET_1BYTE_SEQUENCE_NUMBER}; 2132 PACKET_1BYTE_SEQUENCE_NUMBER};
2133 // For each sequence number length size, revive a packet and check sequence 2133 // For each sequence number length size, revive a packet and check sequence
2134 // number length in the revived packet. 2134 // number length in the revived packet.
2135 for (size_t i = 0; i < arraysize(lengths); ++i) { 2135 for (size_t i = 0; i < arraysize(lengths); ++i) {
2136 // Set sequence_number_length_ (for data and FEC packets). 2136 // Set sequence_number_length_ (for data and FEC packets).
2137 sequence_number_length_ = lengths[i]; 2137 sequence_number_length_ = lengths[i];
2138 fec_packet += 2; 2138 fec_packet += 2;
2139 // Don't send missing packet, but send fec packet right after it. 2139 // Don't send missing packet, but send fec packet right after it.
2140 ProcessFecPacket(fec_packet, fec_packet - 1, true, !kEntropyFlag, NULL); 2140 ProcessFecPacket(fec_packet, fec_packet - 1, true, !kEntropyFlag, NULL);
2141 // Sequence number length in the revived header should be the same as 2141 // Sequence number length in the revived header should be the same as
2142 // in the original data/fec packet headers. 2142 // in the original data/fec packet headers.
2143 EXPECT_EQ(sequence_number_length_, fec_visitor->revived_header(). 2143 EXPECT_EQ(sequence_number_length_, fec_visitor->revived_header().
2144 public_header.sequence_number_length); 2144 public_header.sequence_number_length);
2145 } 2145 }
2146 } 2146 }
2147 2147
2148 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingConnectionIdLengths) { 2148 TEST_P(QuicConnectionTest, ReviveMissingPacketWithVaryingConnectionIdLengths) {
2149 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2149 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2150 2150
2151 // Set up a debug visitor to the connection. 2151 // Set up a debug visitor to the connection.
2152 scoped_ptr<FecQuicConnectionDebugVisitor> 2152 FecQuicConnectionDebugVisitor* fec_visitor =
2153 fec_visitor(new FecQuicConnectionDebugVisitor); 2153 new FecQuicConnectionDebugVisitor();
2154 connection_.set_debug_visitor(fec_visitor.get()); 2154 connection_.set_debug_visitor(fec_visitor);
2155 2155
2156 QuicPacketSequenceNumber fec_packet = 0; 2156 QuicPacketSequenceNumber fec_packet = 0;
2157 QuicConnectionIdLength lengths[] = {PACKET_8BYTE_CONNECTION_ID, 2157 QuicConnectionIdLength lengths[] = {PACKET_8BYTE_CONNECTION_ID,
2158 PACKET_4BYTE_CONNECTION_ID, 2158 PACKET_4BYTE_CONNECTION_ID,
2159 PACKET_1BYTE_CONNECTION_ID, 2159 PACKET_1BYTE_CONNECTION_ID,
2160 PACKET_0BYTE_CONNECTION_ID}; 2160 PACKET_0BYTE_CONNECTION_ID};
2161 // For each connection id length size, revive a packet and check connection 2161 // For each connection id length size, revive a packet and check connection
2162 // id length in the revived packet. 2162 // id length in the revived packet.
2163 for (size_t i = 0; i < arraysize(lengths); ++i) { 2163 for (size_t i = 0; i < arraysize(lengths); ++i) {
2164 // Set connection id length (for data and FEC packets). 2164 // Set connection id length (for data and FEC packets).
(...skipping 1776 matching lines...) Expand 10 before | Expand all | Expand 10 after
3941 MOCK_METHOD1(OnVersionNegotiationPacket, 3941 MOCK_METHOD1(OnVersionNegotiationPacket,
3942 void(const QuicVersionNegotiationPacket&)); 3942 void(const QuicVersionNegotiationPacket&));
3943 3943
3944 MOCK_METHOD2(OnRevivedPacket, 3944 MOCK_METHOD2(OnRevivedPacket,
3945 void(const QuicPacketHeader&, StringPiece payload)); 3945 void(const QuicPacketHeader&, StringPiece payload));
3946 }; 3946 };
3947 3947
3948 TEST_P(QuicConnectionTest, OnPacketHeaderDebugVisitor) { 3948 TEST_P(QuicConnectionTest, OnPacketHeaderDebugVisitor) {
3949 QuicPacketHeader header; 3949 QuicPacketHeader header;
3950 3950
3951 scoped_ptr<MockQuicConnectionDebugVisitor> 3951 MockQuicConnectionDebugVisitor* debug_visitor =
3952 debug_visitor(new StrictMock<MockQuicConnectionDebugVisitor>); 3952 new MockQuicConnectionDebugVisitor();
3953 connection_.set_debug_visitor(debug_visitor.get()); 3953 connection_.set_debug_visitor(debug_visitor);
3954 EXPECT_CALL(*debug_visitor, OnPacketHeader(Ref(header))).Times(1); 3954 EXPECT_CALL(*debug_visitor, OnPacketHeader(Ref(header))).Times(1);
3955 connection_.OnPacketHeader(header); 3955 connection_.OnPacketHeader(header);
3956 } 3956 }
3957 3957
3958 TEST_P(QuicConnectionTest, Pacing) { 3958 TEST_P(QuicConnectionTest, Pacing) {
3959 ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true); 3959 ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true);
3960 3960
3961 TestConnection server(connection_id_, IPEndPoint(), helper_.get(), 3961 TestConnection server(connection_id_, IPEndPoint(), helper_.get(),
3962 writer_.get(), true, version()); 3962 writer_.get(), true, version());
3963 TestConnection client(connection_id_, IPEndPoint(), helper_.get(), 3963 TestConnection client(connection_id_, IPEndPoint(), helper_.get(),
(...skipping 21 matching lines...) Expand all
3985 QuicBlockedFrame blocked; 3985 QuicBlockedFrame blocked;
3986 blocked.stream_id = 3; 3986 blocked.stream_id = 3;
3987 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 3987 EXPECT_CALL(visitor_, OnBlockedFrames(_));
3988 ProcessFramePacket(QuicFrame(&blocked)); 3988 ProcessFramePacket(QuicFrame(&blocked));
3989 EXPECT_TRUE(ack_alarm->IsSet()); 3989 EXPECT_TRUE(ack_alarm->IsSet());
3990 } 3990 }
3991 3991
3992 } // namespace 3992 } // namespace
3993 } // namespace test 3993 } // namespace test
3994 } // namespace net 3994 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698