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

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

Issue 1667583004: Landing Recent QUIC changes until 01/31/2016 05:22 UTC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@Final_0203
Patch Set: Rebase Created 4 years, 10 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_packet_creator_test.cc ('k') | net/quic/quic_protocol.h » ('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/quic_packet_generator.h" 5 #include "net/quic/quic_packet_generator.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "net/quic/crypto/crypto_protocol.h" 10 #include "net/quic/crypto/crypto_protocol.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 generator_(42, &framer_, &random_, &buffer_allocator_, &delegate_), 117 generator_(42, &framer_, &random_, &buffer_allocator_, &delegate_),
118 creator_(QuicPacketGeneratorPeer::GetPacketCreator(&generator_)) { 118 creator_(QuicPacketGeneratorPeer::GetPacketCreator(&generator_)) {
119 generator_.set_fec_send_policy(GetParam()); 119 generator_.set_fec_send_policy(GetParam());
120 // TODO(ianswett): Fix this test so it uses a non-null encrypter. 120 // TODO(ianswett): Fix this test so it uses a non-null encrypter.
121 FLAGS_quic_never_write_unencrypted_data = false; 121 FLAGS_quic_never_write_unencrypted_data = false;
122 FLAGS_quic_no_unencrypted_fec = false; 122 FLAGS_quic_no_unencrypted_fec = false;
123 } 123 }
124 124
125 ~QuicPacketGeneratorTest() override { 125 ~QuicPacketGeneratorTest() override {
126 for (SerializedPacket& packet : packets_) { 126 for (SerializedPacket& packet : packets_) {
127 delete[] packet.encrypted_buffer;
127 QuicUtils::ClearSerializedPacket(&packet); 128 QuicUtils::ClearSerializedPacket(&packet);
128 } 129 }
129 } 130 }
130 131
131 void SavePacket(SerializedPacket* packet) { 132 void SavePacket(SerializedPacket* packet) {
133 packet->encrypted_buffer = QuicUtils::CopyBuffer(*packet);
132 packets_.push_back(*packet); 134 packets_.push_back(*packet);
133 ASSERT_FALSE(packet->packet->owns_buffer()); 135 packet->encrypted_buffer = nullptr;
134 scoped_ptr<QuicEncryptedPacket> encrypted_deleter(packets_.back().packet);
135 packets_.back().packet = packets_.back().packet->Clone();
136 packet->retransmittable_frames.clear(); 136 packet->retransmittable_frames.clear();
137 } 137 }
138 138
139 protected: 139 protected:
140 QuicRstStreamFrame* CreateRstStreamFrame() { 140 QuicRstStreamFrame* CreateRstStreamFrame() {
141 return new QuicRstStreamFrame(1, QUIC_STREAM_NO_ERROR, 0); 141 return new QuicRstStreamFrame(1, QUIC_STREAM_NO_ERROR, 0);
142 } 142 }
143 143
144 QuicGoAwayFrame* CreateGoAwayFrame() { 144 QuicGoAwayFrame* CreateGoAwayFrame() {
145 return new QuicGoAwayFrame(QUIC_NO_ERROR, 1, string()); 145 return new QuicGoAwayFrame(QUIC_NO_ERROR, 1, string());
(...skipping 12 matching lines...) Expand all
158 contents.num_mtu_discovery_frames + num_retransmittable_frames; 158 contents.num_mtu_discovery_frames + num_retransmittable_frames;
159 159
160 if (num_retransmittable_frames == 0) { 160 if (num_retransmittable_frames == 0) {
161 ASSERT_TRUE(packet.retransmittable_frames.empty()); 161 ASSERT_TRUE(packet.retransmittable_frames.empty());
162 } else { 162 } else {
163 ASSERT_FALSE(packet.retransmittable_frames.empty()); 163 ASSERT_FALSE(packet.retransmittable_frames.empty());
164 EXPECT_EQ(num_retransmittable_frames, 164 EXPECT_EQ(num_retransmittable_frames,
165 packet.retransmittable_frames.size()); 165 packet.retransmittable_frames.size());
166 } 166 }
167 167
168 ASSERT_TRUE(packet.packet != nullptr); 168 ASSERT_TRUE(packet.encrypted_buffer != nullptr);
169 ASSERT_TRUE(simple_framer_.ProcessPacket(*packet.packet)); 169 ASSERT_TRUE(simple_framer_.ProcessPacket(
170 QuicEncryptedPacket(packet.encrypted_buffer, packet.encrypted_length)));
170 EXPECT_EQ(num_frames, simple_framer_.num_frames()); 171 EXPECT_EQ(num_frames, simple_framer_.num_frames());
171 EXPECT_EQ(contents.num_ack_frames, simple_framer_.ack_frames().size()); 172 EXPECT_EQ(contents.num_ack_frames, simple_framer_.ack_frames().size());
172 EXPECT_EQ(contents.num_connection_close_frames, 173 EXPECT_EQ(contents.num_connection_close_frames,
173 simple_framer_.connection_close_frames().size()); 174 simple_framer_.connection_close_frames().size());
174 EXPECT_EQ(contents.num_goaway_frames, 175 EXPECT_EQ(contents.num_goaway_frames,
175 simple_framer_.goaway_frames().size()); 176 simple_framer_.goaway_frames().size());
176 EXPECT_EQ(contents.num_rst_stream_frames, 177 EXPECT_EQ(contents.num_rst_stream_frames,
177 simple_framer_.rst_stream_frames().size()); 178 simple_framer_.rst_stream_frames().size());
178 EXPECT_EQ(contents.num_stream_frames, 179 EXPECT_EQ(contents.num_stream_frames,
179 simple_framer_.stream_frames().size()); 180 simple_framer_.stream_frames().size());
180 EXPECT_EQ(contents.num_stop_waiting_frames, 181 EXPECT_EQ(contents.num_stop_waiting_frames,
181 simple_framer_.stop_waiting_frames().size()); 182 simple_framer_.stop_waiting_frames().size());
182 EXPECT_EQ(contents.fec_group, simple_framer_.header().fec_group); 183 EXPECT_EQ(contents.fec_group, simple_framer_.header().fec_group);
183 184
184 // From the receiver's perspective, MTU discovery frames are ping frames. 185 // From the receiver's perspective, MTU discovery frames are ping frames.
185 EXPECT_EQ(contents.num_ping_frames + contents.num_mtu_discovery_frames, 186 EXPECT_EQ(contents.num_ping_frames + contents.num_mtu_discovery_frames,
186 simple_framer_.ping_frames().size()); 187 simple_framer_.ping_frames().size());
187 } 188 }
188 189
189 void CheckPacketHasSingleStreamFrame(size_t packet_index) { 190 void CheckPacketHasSingleStreamFrame(size_t packet_index) {
190 ASSERT_GT(packets_.size(), packet_index); 191 ASSERT_GT(packets_.size(), packet_index);
191 const SerializedPacket& packet = packets_[packet_index]; 192 const SerializedPacket& packet = packets_[packet_index];
192 ASSERT_FALSE(packet.retransmittable_frames.empty()); 193 ASSERT_FALSE(packet.retransmittable_frames.empty());
193 EXPECT_EQ(1u, packet.retransmittable_frames.size()); 194 EXPECT_EQ(1u, packet.retransmittable_frames.size());
194 ASSERT_TRUE(packet.packet != nullptr); 195 ASSERT_TRUE(packet.encrypted_buffer != nullptr);
195 ASSERT_TRUE(simple_framer_.ProcessPacket(*packet.packet)); 196 ASSERT_TRUE(simple_framer_.ProcessPacket(
197 QuicEncryptedPacket(packet.encrypted_buffer, packet.encrypted_length)));
196 EXPECT_EQ(1u, simple_framer_.num_frames()); 198 EXPECT_EQ(1u, simple_framer_.num_frames());
197 EXPECT_EQ(1u, simple_framer_.stream_frames().size()); 199 EXPECT_EQ(1u, simple_framer_.stream_frames().size());
198 } 200 }
199 201
200 void CheckAllPacketsHaveSingleStreamFrame() { 202 void CheckAllPacketsHaveSingleStreamFrame() {
201 for (size_t i = 0; i < packets_.size(); i++) { 203 for (size_t i = 0; i < packets_.size(); i++) {
202 CheckPacketHasSingleStreamFrame(i); 204 CheckPacketHasSingleStreamFrame(i);
203 } 205 }
204 } 206 }
205 207
206 void CheckPacketIsFec(size_t packet_index, QuicPacketNumber fec_group) { 208 void CheckPacketIsFec(size_t packet_index, QuicPacketNumber fec_group) {
207 ASSERT_GT(packets_.size(), packet_index); 209 ASSERT_GT(packets_.size(), packet_index);
208 const SerializedPacket& packet = packets_[packet_index]; 210 const SerializedPacket& packet = packets_[packet_index];
209 ASSERT_TRUE(packet.retransmittable_frames.empty()); 211 ASSERT_TRUE(packet.retransmittable_frames.empty());
210 ASSERT_TRUE(packet.packet != nullptr); 212 ASSERT_TRUE(packet.encrypted_buffer != nullptr);
211 ASSERT_TRUE(simple_framer_.ProcessPacket(*packet.packet)); 213 ASSERT_TRUE(simple_framer_.ProcessPacket(
214 QuicEncryptedPacket(packet.encrypted_buffer, packet.encrypted_length)));
212 EXPECT_TRUE(simple_framer_.header().fec_flag); 215 EXPECT_TRUE(simple_framer_.header().fec_flag);
213 } 216 }
214 217
215 QuicIOVector CreateData(size_t len) { 218 QuicIOVector CreateData(size_t len) {
216 data_array_.reset(new char[len]); 219 data_array_.reset(new char[len]);
217 memset(data_array_.get(), '?', len); 220 memset(data_array_.get(), '?', len);
218 iov_.iov_base = data_array_.get(); 221 iov_.iov_base = data_array_.get();
219 iov_.iov_len = len; 222 iov_.iov_len = len;
220 return QuicIOVector(&iov_, 1, len); 223 return QuicIOVector(&iov_, 1, len);
221 } 224 }
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 kCryptoStreamId, MakeIOVector("foo"), 0, false, MAY_FEC_PROTECT, nullptr); 411 kCryptoStreamId, MakeIOVector("foo"), 0, false, MAY_FEC_PROTECT, nullptr);
409 EXPECT_EQ(3u, consumed.bytes_consumed); 412 EXPECT_EQ(3u, consumed.bytes_consumed);
410 EXPECT_FALSE(generator_.HasQueuedFrames()); 413 EXPECT_FALSE(generator_.HasQueuedFrames());
411 414
412 PacketContents contents; 415 PacketContents contents;
413 contents.num_stream_frames = 1; 416 contents.num_stream_frames = 1;
414 CheckPacketContains(contents, 0); 417 CheckPacketContains(contents, 0);
415 418
416 ASSERT_EQ(1u, packets_.size()); 419 ASSERT_EQ(1u, packets_.size());
417 ASSERT_EQ(kDefaultMaxPacketSize, generator_.GetMaxPacketLength()); 420 ASSERT_EQ(kDefaultMaxPacketSize, generator_.GetMaxPacketLength());
418 EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].packet->length()); 421 EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].encrypted_length);
419 } 422 }
420 423
421 TEST_P(QuicPacketGeneratorTest, ConsumeData_EmptyData) { 424 TEST_P(QuicPacketGeneratorTest, ConsumeData_EmptyData) {
422 EXPECT_DFATAL(generator_.ConsumeData(kHeadersStreamId, MakeIOVector(""), 0, 425 EXPECT_DFATAL(generator_.ConsumeData(kHeadersStreamId, MakeIOVector(""), 0,
423 false, MAY_FEC_PROTECT, nullptr), 426 false, MAY_FEC_PROTECT, nullptr),
424 "Attempt to consume empty data without FIN."); 427 "Attempt to consume empty data without FIN.");
425 } 428 }
426 429
427 TEST_P(QuicPacketGeneratorTest, 430 TEST_P(QuicPacketGeneratorTest,
428 ConsumeDataMultipleTimes_WritableAndShouldNotFlush) { 431 ConsumeDataMultipleTimes_WritableAndShouldNotFlush) {
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after
1408 /*fin=*/true, MAY_FEC_PROTECT, nullptr); 1411 /*fin=*/true, MAY_FEC_PROTECT, nullptr);
1409 EXPECT_EQ(data_len, consumed.bytes_consumed); 1412 EXPECT_EQ(data_len, consumed.bytes_consumed);
1410 EXPECT_TRUE(consumed.fin_consumed); 1413 EXPECT_TRUE(consumed.fin_consumed);
1411 EXPECT_FALSE(generator_.HasQueuedFrames()); 1414 EXPECT_FALSE(generator_.HasQueuedFrames());
1412 1415
1413 // We expect three packets, and first two of them have to be of packet_len 1416 // We expect three packets, and first two of them have to be of packet_len
1414 // size. We check multiple packets (instead of just one) because we want to 1417 // size. We check multiple packets (instead of just one) because we want to
1415 // ensure that |max_packet_length_| does not get changed incorrectly by the 1418 // ensure that |max_packet_length_| does not get changed incorrectly by the
1416 // generator after first packet is serialized. 1419 // generator after first packet is serialized.
1417 ASSERT_EQ(3u, packets_.size()); 1420 ASSERT_EQ(3u, packets_.size());
1418 EXPECT_EQ(packet_len, packets_[0].packet->length()); 1421 EXPECT_EQ(packet_len, packets_[0].encrypted_length);
1419 EXPECT_EQ(packet_len, packets_[1].packet->length()); 1422 EXPECT_EQ(packet_len, packets_[1].encrypted_length);
1420 CheckAllPacketsHaveSingleStreamFrame(); 1423 CheckAllPacketsHaveSingleStreamFrame();
1421 } 1424 }
1422 1425
1423 // Test whether SetMaxPacketLength() works in the situation when we first write 1426 // Test whether SetMaxPacketLength() works in the situation when we first write
1424 // data, then change packet size, then write data again. 1427 // data, then change packet size, then write data again.
1425 TEST_P(QuicPacketGeneratorTest, SetMaxPacketLength_Middle) { 1428 TEST_P(QuicPacketGeneratorTest, SetMaxPacketLength_Middle) {
1426 delegate_.SetCanWriteAnything(); 1429 delegate_.SetCanWriteAnything();
1427 1430
1428 // We send enough data to overflow default packet length, but not the altered 1431 // We send enough data to overflow default packet length, but not the altered
1429 // one. 1432 // one.
(...skipping 26 matching lines...) Expand all
1456 consumed = generator_.ConsumeData(kHeadersStreamId, CreateData(data_len), 1459 consumed = generator_.ConsumeData(kHeadersStreamId, CreateData(data_len),
1457 2 + data_len, 1460 2 + data_len,
1458 /*fin=*/true, MAY_FEC_PROTECT, nullptr); 1461 /*fin=*/true, MAY_FEC_PROTECT, nullptr);
1459 EXPECT_EQ(data_len, consumed.bytes_consumed); 1462 EXPECT_EQ(data_len, consumed.bytes_consumed);
1460 EXPECT_TRUE(consumed.fin_consumed); 1463 EXPECT_TRUE(consumed.fin_consumed);
1461 EXPECT_FALSE(generator_.HasQueuedFrames()); 1464 EXPECT_FALSE(generator_.HasQueuedFrames());
1462 1465
1463 // We expect first data chunk to get fragmented, but the second one to fit 1466 // We expect first data chunk to get fragmented, but the second one to fit
1464 // into a single packet. 1467 // into a single packet.
1465 ASSERT_EQ(3u, packets_.size()); 1468 ASSERT_EQ(3u, packets_.size());
1466 EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].packet->length()); 1469 EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].encrypted_length);
1467 EXPECT_LE(kDefaultMaxPacketSize, packets_[2].packet->length()); 1470 EXPECT_LE(kDefaultMaxPacketSize, packets_[2].encrypted_length);
1468 CheckAllPacketsHaveSingleStreamFrame(); 1471 CheckAllPacketsHaveSingleStreamFrame();
1469 } 1472 }
1470 1473
1471 // Test whether SetMaxPacketLength() works correctly when we change the packet 1474 // Test whether SetMaxPacketLength() works correctly when we change the packet
1472 // size in the middle of the batched packet. 1475 // size in the middle of the batched packet.
1473 TEST_P(QuicPacketGeneratorTest, SetMaxPacketLength_Midpacket) { 1476 TEST_P(QuicPacketGeneratorTest, SetMaxPacketLength_Midpacket) {
1474 delegate_.SetCanWriteAnything(); 1477 delegate_.SetCanWriteAnything();
1475 generator_.StartBatchOperations(); 1478 generator_.StartBatchOperations();
1476 1479
1477 size_t first_write_len = kDefaultMaxPacketSize / 2; 1480 size_t first_write_len = kDefaultMaxPacketSize / 2;
(...skipping 30 matching lines...) Expand all
1508 generator_.ConsumeData(kHeadersStreamId, CreateData(second_write_len), 1511 generator_.ConsumeData(kHeadersStreamId, CreateData(second_write_len),
1509 /*offset=*/2 + first_write_len, 1512 /*offset=*/2 + first_write_len,
1510 /*fin=*/true, MAY_FEC_PROTECT, nullptr); 1513 /*fin=*/true, MAY_FEC_PROTECT, nullptr);
1511 EXPECT_EQ(second_write_len, consumed.bytes_consumed); 1514 EXPECT_EQ(second_write_len, consumed.bytes_consumed);
1512 EXPECT_TRUE(consumed.fin_consumed); 1515 EXPECT_TRUE(consumed.fin_consumed);
1513 EXPECT_TRUE(generator_.HasQueuedFrames()); 1516 EXPECT_TRUE(generator_.HasQueuedFrames());
1514 1517
1515 // We expect the first packet to contain two frames, and to not reflect the 1518 // We expect the first packet to contain two frames, and to not reflect the
1516 // packet size change. 1519 // packet size change.
1517 ASSERT_EQ(1u, packets_.size()); 1520 ASSERT_EQ(1u, packets_.size());
1518 EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].packet->length()); 1521 EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].encrypted_length);
1519 1522
1520 PacketContents contents; 1523 PacketContents contents;
1521 contents.num_stream_frames = 2; 1524 contents.num_stream_frames = 2;
1522 CheckPacketContains(contents, 0); 1525 CheckPacketContains(contents, 0);
1523 } 1526 }
1524 1527
1525 // Test whether SetMaxPacketLength() works correctly when we force the change of 1528 // Test whether SetMaxPacketLength() works correctly when we force the change of
1526 // the packet size in the middle of the batched packet. 1529 // the packet size in the middle of the batched packet.
1527 TEST_P(QuicPacketGeneratorTest, SetMaxPacketLength_MidpacketFlush) { 1530 TEST_P(QuicPacketGeneratorTest, SetMaxPacketLength_MidpacketFlush) {
1528 delegate_.SetCanWriteAnything(); 1531 delegate_.SetCanWriteAnything();
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 generator_.ConsumeData(kHeadersStreamId, CreateData(second_write_len), 1571 generator_.ConsumeData(kHeadersStreamId, CreateData(second_write_len),
1569 /*offset=*/2 + first_write_len, 1572 /*offset=*/2 + first_write_len,
1570 /*fin=*/true, MAY_FEC_PROTECT, nullptr); 1573 /*fin=*/true, MAY_FEC_PROTECT, nullptr);
1571 EXPECT_EQ(second_write_len, consumed.bytes_consumed); 1574 EXPECT_EQ(second_write_len, consumed.bytes_consumed);
1572 EXPECT_TRUE(consumed.fin_consumed); 1575 EXPECT_TRUE(consumed.fin_consumed);
1573 EXPECT_TRUE(generator_.HasQueuedFrames()); 1576 EXPECT_TRUE(generator_.HasQueuedFrames());
1574 1577
1575 // We expect the first packet to be underfilled, and the second packet be up 1578 // We expect the first packet to be underfilled, and the second packet be up
1576 // to the new max packet size. 1579 // to the new max packet size.
1577 ASSERT_EQ(2u, packets_.size()); 1580 ASSERT_EQ(2u, packets_.size());
1578 EXPECT_GT(kDefaultMaxPacketSize, packets_[0].packet->length()); 1581 EXPECT_GT(kDefaultMaxPacketSize, packets_[0].encrypted_length);
1579 EXPECT_EQ(packet_len, packets_[1].packet->length()); 1582 EXPECT_EQ(packet_len, packets_[1].encrypted_length);
1580 1583
1581 CheckAllPacketsHaveSingleStreamFrame(); 1584 CheckAllPacketsHaveSingleStreamFrame();
1582 } 1585 }
1583 1586
1584 // Test sending an MTU probe, without any surrounding data. 1587 // Test sending an MTU probe, without any surrounding data.
1585 TEST_P(QuicPacketGeneratorTest, GenerateMtuDiscoveryPacket_Simple) { 1588 TEST_P(QuicPacketGeneratorTest, GenerateMtuDiscoveryPacket_Simple) {
1586 delegate_.SetCanWriteAnything(); 1589 delegate_.SetCanWriteAnything();
1587 1590
1588 const size_t target_mtu = kDefaultMaxPacketSize + 100; 1591 const size_t target_mtu = kDefaultMaxPacketSize + 100;
1589 static_assert(target_mtu < kMaxPacketSize, 1592 static_assert(target_mtu < kMaxPacketSize,
1590 "The MTU probe used by the test exceeds maximum packet size"); 1593 "The MTU probe used by the test exceeds maximum packet size");
1591 1594
1592 EXPECT_CALL(delegate_, OnSerializedPacket(_)) 1595 EXPECT_CALL(delegate_, OnSerializedPacket(_))
1593 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket)); 1596 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket));
1594 1597
1595 generator_.GenerateMtuDiscoveryPacket(target_mtu, nullptr); 1598 generator_.GenerateMtuDiscoveryPacket(target_mtu, nullptr);
1596 1599
1597 EXPECT_FALSE(generator_.HasQueuedFrames()); 1600 EXPECT_FALSE(generator_.HasQueuedFrames());
1598 ASSERT_EQ(1u, packets_.size()); 1601 ASSERT_EQ(1u, packets_.size());
1599 EXPECT_EQ(target_mtu, packets_[0].packet->length()); 1602 EXPECT_EQ(target_mtu, packets_[0].encrypted_length);
1600 1603
1601 PacketContents contents; 1604 PacketContents contents;
1602 contents.num_mtu_discovery_frames = 1; 1605 contents.num_mtu_discovery_frames = 1;
1603 CheckPacketContains(contents, 0); 1606 CheckPacketContains(contents, 0);
1604 } 1607 }
1605 1608
1606 // Test sending an MTU probe. Surround it with data, to ensure that it resets 1609 // Test sending an MTU probe. Surround it with data, to ensure that it resets
1607 // the MTU to the value before the probe was sent. 1610 // the MTU to the value before the probe was sent.
1608 TEST_P(QuicPacketGeneratorTest, GenerateMtuDiscoveryPacket_SurroundedByData) { 1611 TEST_P(QuicPacketGeneratorTest, GenerateMtuDiscoveryPacket_SurroundedByData) {
1609 delegate_.SetCanWriteAnything(); 1612 delegate_.SetCanWriteAnything();
(...skipping 26 matching lines...) Expand all
1636 1639
1637 // Send data after the MTU probe. 1640 // Send data after the MTU probe.
1638 consumed = generator_.ConsumeData(kHeadersStreamId, CreateData(data_len), 1641 consumed = generator_.ConsumeData(kHeadersStreamId, CreateData(data_len),
1639 /*offset=*/2 + data_len, 1642 /*offset=*/2 + data_len,
1640 /*fin=*/true, MAY_FEC_PROTECT, nullptr); 1643 /*fin=*/true, MAY_FEC_PROTECT, nullptr);
1641 EXPECT_EQ(data_len, consumed.bytes_consumed); 1644 EXPECT_EQ(data_len, consumed.bytes_consumed);
1642 EXPECT_TRUE(consumed.fin_consumed); 1645 EXPECT_TRUE(consumed.fin_consumed);
1643 EXPECT_FALSE(generator_.HasQueuedFrames()); 1646 EXPECT_FALSE(generator_.HasQueuedFrames());
1644 1647
1645 ASSERT_EQ(5u, packets_.size()); 1648 ASSERT_EQ(5u, packets_.size());
1646 EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].packet->length()); 1649 EXPECT_EQ(kDefaultMaxPacketSize, packets_[0].encrypted_length);
1647 EXPECT_EQ(target_mtu, packets_[2].packet->length()); 1650 EXPECT_EQ(target_mtu, packets_[2].encrypted_length);
1648 EXPECT_EQ(kDefaultMaxPacketSize, packets_[3].packet->length()); 1651 EXPECT_EQ(kDefaultMaxPacketSize, packets_[3].encrypted_length);
1649 1652
1650 PacketContents probe_contents; 1653 PacketContents probe_contents;
1651 probe_contents.num_mtu_discovery_frames = 1; 1654 probe_contents.num_mtu_discovery_frames = 1;
1652 1655
1653 CheckPacketHasSingleStreamFrame(0); 1656 CheckPacketHasSingleStreamFrame(0);
1654 CheckPacketHasSingleStreamFrame(1); 1657 CheckPacketHasSingleStreamFrame(1);
1655 CheckPacketContains(probe_contents, 2); 1658 CheckPacketContains(probe_contents, 2);
1656 CheckPacketHasSingleStreamFrame(3); 1659 CheckPacketHasSingleStreamFrame(3);
1657 CheckPacketHasSingleStreamFrame(4); 1660 CheckPacketHasSingleStreamFrame(4);
1658 } 1661 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1708 EXPECT_CALL(delegate_, OnSerializedPacket(_)) 1711 EXPECT_CALL(delegate_, OnSerializedPacket(_))
1709 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket)); 1712 .WillOnce(Invoke(this, &QuicPacketGeneratorTest::SavePacket));
1710 generator_.FlushAllQueuedFrames(); 1713 generator_.FlushAllQueuedFrames();
1711 EXPECT_FALSE(generator_.HasQueuedFrames()); 1714 EXPECT_FALSE(generator_.HasQueuedFrames());
1712 generator_.SetCurrentPath(kTestPathId1, 1, 0); 1715 generator_.SetCurrentPath(kTestPathId1, 1, 0);
1713 EXPECT_EQ(kTestPathId1, QuicPacketCreatorPeer::GetCurrentPath(creator_)); 1716 EXPECT_EQ(kTestPathId1, QuicPacketCreatorPeer::GetCurrentPath(creator_));
1714 } 1717 }
1715 1718
1716 } // namespace test 1719 } // namespace test
1717 } // namespace net 1720 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_packet_creator_test.cc ('k') | net/quic/quic_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698