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

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

Issue 288313003: Land Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src
Patch Set: implemented rch's comments Created 6 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
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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 DISALLOW_COPY_AND_ASSIGN(TestPacketWriter); 412 DISALLOW_COPY_AND_ASSIGN(TestPacketWriter);
413 }; 413 };
414 414
415 class TestConnection : public QuicConnection { 415 class TestConnection : public QuicConnection {
416 public: 416 public:
417 TestConnection(QuicConnectionId connection_id, 417 TestConnection(QuicConnectionId connection_id,
418 IPEndPoint address, 418 IPEndPoint address,
419 TestConnectionHelper* helper, 419 TestConnectionHelper* helper,
420 TestPacketWriter* writer, 420 TestPacketWriter* writer,
421 bool is_server, 421 bool is_server,
422 QuicVersion version, 422 QuicVersion version)
423 uint32 flow_control_send_window)
424 : QuicConnection(connection_id, address, helper, writer, is_server, 423 : QuicConnection(connection_id, address, helper, writer, is_server,
425 SupportedVersions(version), 424 SupportedVersions(version)),
426 flow_control_send_window),
427 writer_(writer) { 425 writer_(writer) {
428 // Disable tail loss probes for most tests. 426 // Disable tail loss probes for most tests.
429 QuicSentPacketManagerPeer::SetMaxTailLossProbes( 427 QuicSentPacketManagerPeer::SetMaxTailLossProbes(
430 QuicConnectionPeer::GetSentPacketManager(this), 0); 428 QuicConnectionPeer::GetSentPacketManager(this), 0);
431 writer_->set_is_server(is_server); 429 writer_->set_is_server(is_server);
432 } 430 }
433 431
434 void SendAck() { 432 void SendAck() {
435 QuicConnectionPeer::SendAck(this); 433 QuicConnectionPeer::SendAck(this);
436 } 434 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 protected: 579 protected:
582 QuicConnectionTest() 580 QuicConnectionTest()
583 : connection_id_(42), 581 : connection_id_(42),
584 framer_(SupportedVersions(version()), QuicTime::Zero(), false), 582 framer_(SupportedVersions(version()), QuicTime::Zero(), false),
585 creator_(connection_id_, &framer_, &random_generator_, false), 583 creator_(connection_id_, &framer_, &random_generator_, false),
586 send_algorithm_(new StrictMock<MockSendAlgorithm>), 584 send_algorithm_(new StrictMock<MockSendAlgorithm>),
587 loss_algorithm_(new MockLossAlgorithm()), 585 loss_algorithm_(new MockLossAlgorithm()),
588 helper_(new TestConnectionHelper(&clock_, &random_generator_)), 586 helper_(new TestConnectionHelper(&clock_, &random_generator_)),
589 writer_(new TestPacketWriter(version())), 587 writer_(new TestPacketWriter(version())),
590 connection_(connection_id_, IPEndPoint(), helper_.get(), 588 connection_(connection_id_, IPEndPoint(), helper_.get(),
591 writer_.get(), false, version(), 589 writer_.get(), false, version()),
592 kDefaultFlowControlSendWindow),
593 frame1_(1, false, 0, MakeIOVector(data1)), 590 frame1_(1, false, 0, MakeIOVector(data1)),
594 frame2_(1, false, 3, MakeIOVector(data2)), 591 frame2_(1, false, 3, MakeIOVector(data2)),
595 sequence_number_length_(PACKET_6BYTE_SEQUENCE_NUMBER), 592 sequence_number_length_(PACKET_6BYTE_SEQUENCE_NUMBER),
596 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) { 593 connection_id_length_(PACKET_8BYTE_CONNECTION_ID) {
597 connection_.set_visitor(&visitor_); 594 connection_.set_visitor(&visitor_);
598 connection_.SetSendAlgorithm(send_algorithm_); 595 connection_.SetSendAlgorithm(send_algorithm_);
599 connection_.SetLossAlgorithm(loss_algorithm_); 596 connection_.SetLossAlgorithm(loss_algorithm_);
600 framer_.set_received_entropy_calculator(&entropy_calculator_); 597 framer_.set_received_entropy_calculator(&entropy_calculator_);
601 // Simplify tests by not sending feedback unless specifically configured. 598 // Simplify tests by not sending feedback unless specifically configured.
602 SetFeedback(NULL); 599 SetFeedback(NULL);
603 EXPECT_CALL( 600 EXPECT_CALL(
604 *send_algorithm_, TimeUntilSend(_, _, _)).WillRepeatedly(Return( 601 *send_algorithm_, TimeUntilSend(_, _, _)).WillRepeatedly(Return(
605 QuicTime::Delta::Zero())); 602 QuicTime::Delta::Zero()));
606 EXPECT_CALL(*receive_algorithm_, 603 EXPECT_CALL(*receive_algorithm_,
607 RecordIncomingPacket(_, _, _)).Times(AnyNumber()); 604 RecordIncomingPacket(_, _, _)).Times(AnyNumber());
608 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 605 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
609 .Times(AnyNumber()); 606 .Times(AnyNumber());
610 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly( 607 EXPECT_CALL(*send_algorithm_, RetransmissionDelay()).WillRepeatedly(
611 Return(QuicTime::Delta::Zero())); 608 Return(QuicTime::Delta::Zero()));
612 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly( 609 EXPECT_CALL(*send_algorithm_, GetCongestionWindow()).WillRepeatedly(
613 Return(kMaxPacketSize)); 610 Return(kMaxPacketSize));
614 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) 611 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _))
615 .WillByDefault(Return(true)); 612 .WillByDefault(Return(true));
616 EXPECT_CALL(visitor_, HasPendingWrites()).Times(AnyNumber()); 613 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).Times(AnyNumber());
617 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); 614 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber());
618 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); 615 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber());
619 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(false)); 616 EXPECT_CALL(visitor_, HasOpenDataStreams()).WillRepeatedly(Return(false));
620 617
621 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) 618 EXPECT_CALL(*loss_algorithm_, GetLossTimeout())
622 .WillRepeatedly(Return(QuicTime::Zero())); 619 .WillRepeatedly(Return(QuicTime::Zero()));
623 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _)) 620 EXPECT_CALL(*loss_algorithm_, DetectLostPackets(_, _, _, _))
624 .WillRepeatedly(Return(SequenceNumberSet())); 621 .WillRepeatedly(Return(SequenceNumberSet()));
625 } 622 }
626 623
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after
1437 } 1434 }
1438 1435
1439 TEST_P(QuicConnectionTest, FECSending) { 1436 TEST_P(QuicConnectionTest, FECSending) {
1440 // All packets carry version info till version is negotiated. 1437 // All packets carry version info till version is negotiated.
1441 size_t payload_length; 1438 size_t payload_length;
1442 connection_.options()->max_packet_length = 1439 connection_.options()->max_packet_length =
1443 GetPacketLengthForOneStream( 1440 GetPacketLengthForOneStream(
1444 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, 1441 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER,
1445 IN_FEC_GROUP, &payload_length); 1442 IN_FEC_GROUP, &payload_length);
1446 // And send FEC every two packets. 1443 // And send FEC every two packets.
1447 connection_.options()->max_packets_per_fec_group = 2; 1444 EXPECT_TRUE(QuicPacketCreatorPeer::SwitchFecProtectionOn(
1445 QuicConnectionPeer::GetPacketCreator(&connection_), 2));
1448 1446
1449 // Send 4 data packets and 2 FEC packets. 1447 // Send 4 data packets and 2 FEC packets.
1450 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); 1448 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6);
1451 // The first stream frame will consume 2 fewer bytes than the other three. 1449 // The first stream frame will consume 2 fewer bytes than the other three.
1452 const string payload(payload_length * 4 - 6, 'a'); 1450 const string payload(payload_length * 4 - 6, 'a');
1453 connection_.SendStreamDataWithString(1, payload, 0, !kFin, NULL); 1451 connection_.SendStreamDataWithString(1, payload, 0, !kFin, NULL);
1454 // Expect the FEC group to be closed after SendStreamDataWithString. 1452 // Expect the FEC group to be closed after SendStreamDataWithString.
1455 EXPECT_FALSE(creator_.ShouldSendFec(true)); 1453 EXPECT_FALSE(creator_.ShouldSendFec(true));
1456 } 1454 }
1457 1455
1458 TEST_P(QuicConnectionTest, FECQueueing) { 1456 TEST_P(QuicConnectionTest, FECQueueing) {
1459 // All packets carry version info till version is negotiated. 1457 // All packets carry version info till version is negotiated.
1460 size_t payload_length; 1458 size_t payload_length;
1461 connection_.options()->max_packet_length = 1459 connection_.options()->max_packet_length =
1462 GetPacketLengthForOneStream( 1460 GetPacketLengthForOneStream(
1463 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, 1461 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER,
1464 IN_FEC_GROUP, &payload_length); 1462 IN_FEC_GROUP, &payload_length);
1465 // And send FEC every two packets. 1463 // And send FEC every two packets.
1466 connection_.options()->max_packets_per_fec_group = 2; 1464 EXPECT_TRUE(QuicPacketCreatorPeer::SwitchFecProtectionOn(
1465 QuicConnectionPeer::GetPacketCreator(&connection_), 2));
1467 1466
1468 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 1467 EXPECT_EQ(0u, connection_.NumQueuedPackets());
1469 BlockOnNextWrite(); 1468 BlockOnNextWrite();
1470 const string payload(payload_length, 'a'); 1469 const string payload(payload_length, 'a');
1471 connection_.SendStreamDataWithString(1, payload, 0, !kFin, NULL); 1470 connection_.SendStreamDataWithString(1, payload, 0, !kFin, NULL);
1472 EXPECT_FALSE(creator_.ShouldSendFec(true)); 1471 EXPECT_FALSE(creator_.ShouldSendFec(true));
1473 // Expect the first data packet and the fec packet to be queued. 1472 // Expect the first data packet and the fec packet to be queued.
1474 EXPECT_EQ(2u, connection_.NumQueuedPackets()); 1473 EXPECT_EQ(2u, connection_.NumQueuedPackets());
1475 } 1474 }
1476 1475
1477 TEST_P(QuicConnectionTest, AbandonFECFromCongestionWindow) { 1476 TEST_P(QuicConnectionTest, AbandonFECFromCongestionWindow) {
1478 connection_.options()->max_packets_per_fec_group = 1; 1477 EXPECT_TRUE(QuicPacketCreatorPeer::SwitchFecProtectionOn(
1478 QuicConnectionPeer::GetPacketCreator(&connection_), 1));
1479
1479 // 1 Data and 1 FEC packet. 1480 // 1 Data and 1 FEC packet.
1480 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); 1481 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2);
1481 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); 1482 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
1482 1483
1483 const QuicTime::Delta retransmission_time = 1484 const QuicTime::Delta retransmission_time =
1484 QuicTime::Delta::FromMilliseconds(5000); 1485 QuicTime::Delta::FromMilliseconds(5000);
1485 clock_.AdvanceTime(retransmission_time); 1486 clock_.AdvanceTime(retransmission_time);
1486 1487
1487 // Abandon FEC packet and data packet. 1488 // Abandon FEC packet and data packet.
1488 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 1489 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1489 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1); 1490 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(1);
1490 EXPECT_CALL(visitor_, OnCanWrite()); 1491 EXPECT_CALL(visitor_, OnCanWrite());
1491 connection_.OnRetransmissionTimeout(); 1492 connection_.OnRetransmissionTimeout();
1492 } 1493 }
1493 1494
1494 TEST_P(QuicConnectionTest, DontAbandonAckedFEC) { 1495 TEST_P(QuicConnectionTest, DontAbandonAckedFEC) {
1495 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1496 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1496 connection_.options()->max_packets_per_fec_group = 1; 1497 EXPECT_TRUE(QuicPacketCreatorPeer::SwitchFecProtectionOn(
1498 QuicConnectionPeer::GetPacketCreator(&connection_), 1));
1497 1499
1498 // 1 Data and 1 FEC packet. 1500 // 1 Data and 1 FEC packet.
1499 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); 1501 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6);
1500 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); 1502 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
1501 // Send some more data afterwards to ensure early retransmit doesn't trigger. 1503 // Send some more data afterwards to ensure early retransmit doesn't trigger.
1502 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); 1504 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL);
1503 connection_.SendStreamDataWithString(3, "foo", 6, !kFin, NULL); 1505 connection_.SendStreamDataWithString(3, "foo", 6, !kFin, NULL);
1504 1506
1505 QuicAckFrame ack_fec = InitAckFrame(2, 1); 1507 QuicAckFrame ack_fec = InitAckFrame(2, 1);
1506 // Data packet missing. 1508 // Data packet missing.
1507 // TODO(ianswett): Note that this is not a sensible ack, since if the FEC was 1509 // TODO(ianswett): Note that this is not a sensible ack, since if the FEC was
1508 // received, it would cause the covered packet to be acked as well. 1510 // received, it would cause the covered packet to be acked as well.
1509 NackPacket(1, &ack_fec); 1511 NackPacket(1, &ack_fec);
1510 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _)); 1512 EXPECT_CALL(*send_algorithm_, OnCongestionEvent(true, _, _, _));
1511 ProcessAckPacket(&ack_fec); 1513 ProcessAckPacket(&ack_fec);
1512 clock_.AdvanceTime(DefaultRetransmissionTime()); 1514 clock_.AdvanceTime(DefaultRetransmissionTime());
1513 1515
1514 // Don't abandon the acked FEC packet, but it will abandon 2 the subsequent 1516 // Don't abandon the acked FEC packet, but it will abandon 2 the subsequent
1515 // FEC packets. 1517 // FEC packets.
1516 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true)); 1518 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
1517 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3); 1519 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(3);
1518 connection_.GetRetransmissionAlarm()->Fire(); 1520 connection_.GetRetransmissionAlarm()->Fire();
1519 } 1521 }
1520 1522
1521 TEST_P(QuicConnectionTest, AbandonAllFEC) { 1523 TEST_P(QuicConnectionTest, AbandonAllFEC) {
1522 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 1524 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
1523 connection_.options()->max_packets_per_fec_group = 1; 1525 EXPECT_TRUE(QuicPacketCreatorPeer::SwitchFecProtectionOn(
1526 QuicConnectionPeer::GetPacketCreator(&connection_), 1));
1524 1527
1525 // 1 Data and 1 FEC packet. 1528 // 1 Data and 1 FEC packet.
1526 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6); 1529 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(6);
1527 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL); 1530 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
1528 // Send some more data afterwards to ensure early retransmit doesn't trigger. 1531 // Send some more data afterwards to ensure early retransmit doesn't trigger.
1529 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL); 1532 connection_.SendStreamDataWithString(3, "foo", 3, !kFin, NULL);
1530 // Advance the time so not all the FEC packets are abandoned. 1533 // Advance the time so not all the FEC packets are abandoned.
1531 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1)); 1534 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(1));
1532 connection_.SendStreamDataWithString(3, "foo", 6, !kFin, NULL); 1535 connection_.SendStreamDataWithString(3, "foo", 6, !kFin, NULL);
1533 1536
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1638 EXPECT_EQ(1u, writer_->frame_count()); 1641 EXPECT_EQ(1u, writer_->frame_count());
1639 EXPECT_EQ(1u, writer_->stream_frames().size()); 1642 EXPECT_EQ(1u, writer_->stream_frames().size());
1640 EXPECT_EQ(kStreamId3, writer_->stream_frames()[0].stream_id); 1643 EXPECT_EQ(kStreamId3, writer_->stream_frames()[0].stream_id);
1641 } 1644 }
1642 1645
1643 TEST_P(QuicConnectionTest, FramePackingFEC) { 1646 TEST_P(QuicConnectionTest, FramePackingFEC) {
1644 if (version() < QUIC_VERSION_15) { 1647 if (version() < QUIC_VERSION_15) {
1645 return; 1648 return;
1646 } 1649 }
1647 // Enable fec. 1650 // Enable fec.
1648 connection_.options()->max_packets_per_fec_group = 6; 1651 EXPECT_TRUE(QuicPacketCreatorPeer::SwitchFecProtectionOn(
1652 QuicConnectionPeer::GetPacketCreator(&connection_), 6));
1653
1649 // Block the connection. 1654 // Block the connection.
1650 connection_.GetSendAlarm()->Set( 1655 connection_.GetSendAlarm()->Set(
1651 clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(1))); 1656 clock_.ApproximateNow().Add(QuicTime::Delta::FromSeconds(1)));
1652 1657
1653 // Send an ack and two stream frames in 1 packet by queueing them. 1658 // Send an ack and two stream frames in 1 packet by queueing them.
1654 connection_.SendAck(); 1659 connection_.SendAck();
1655 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( 1660 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll(
1656 IgnoreResult(InvokeWithoutArgs(&connection_, 1661 IgnoreResult(InvokeWithoutArgs(&connection_,
1657 &TestConnection::SendStreamData3)), 1662 &TestConnection::SendStreamData3)),
1658 IgnoreResult(InvokeWithoutArgs(&connection_, 1663 IgnoreResult(InvokeWithoutArgs(&connection_,
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 EXPECT_TRUE(writer_->stream_frames()[0].fin); 1776 EXPECT_TRUE(writer_->stream_frames()[0].fin);
1772 } 1777 }
1773 1778
1774 TEST_P(QuicConnectionTest, OnCanWrite) { 1779 TEST_P(QuicConnectionTest, OnCanWrite) {
1775 // Visitor's OnCanWrite will send data, but will have more pending writes. 1780 // Visitor's OnCanWrite will send data, but will have more pending writes.
1776 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll( 1781 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(DoAll(
1777 IgnoreResult(InvokeWithoutArgs(&connection_, 1782 IgnoreResult(InvokeWithoutArgs(&connection_,
1778 &TestConnection::SendStreamData3)), 1783 &TestConnection::SendStreamData3)),
1779 IgnoreResult(InvokeWithoutArgs(&connection_, 1784 IgnoreResult(InvokeWithoutArgs(&connection_,
1780 &TestConnection::SendStreamData5)))); 1785 &TestConnection::SendStreamData5))));
1781 EXPECT_CALL(visitor_, HasPendingWrites()).WillOnce(Return(true)); 1786 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).WillOnce(Return(true));
1782 EXPECT_CALL(*send_algorithm_, 1787 EXPECT_CALL(*send_algorithm_,
1783 TimeUntilSend(_, _, _)).WillRepeatedly( 1788 TimeUntilSend(_, _, _)).WillRepeatedly(
1784 testing::Return(QuicTime::Delta::Zero())); 1789 testing::Return(QuicTime::Delta::Zero()));
1785 1790
1786 connection_.OnCanWrite(); 1791 connection_.OnCanWrite();
1787 1792
1788 // Parse the last packet and ensure it's the two stream frames from 1793 // Parse the last packet and ensure it's the two stream frames from
1789 // two different streams. 1794 // two different streams.
1790 EXPECT_EQ(2u, writer_->frame_count()); 1795 EXPECT_EQ(2u, writer_->frame_count());
1791 EXPECT_EQ(2u, writer_->stream_frames().size()); 1796 EXPECT_EQ(2u, writer_->stream_frames().size());
(...skipping 2149 matching lines...) Expand 10 before | Expand all | Expand 10 after
3941 debug_visitor(new StrictMock<MockQuicConnectionDebugVisitor>); 3946 debug_visitor(new StrictMock<MockQuicConnectionDebugVisitor>);
3942 connection_.set_debug_visitor(debug_visitor.get()); 3947 connection_.set_debug_visitor(debug_visitor.get());
3943 EXPECT_CALL(*debug_visitor, OnPacketHeader(Ref(header))).Times(1); 3948 EXPECT_CALL(*debug_visitor, OnPacketHeader(Ref(header))).Times(1);
3944 connection_.OnPacketHeader(header); 3949 connection_.OnPacketHeader(header);
3945 } 3950 }
3946 3951
3947 TEST_P(QuicConnectionTest, Pacing) { 3952 TEST_P(QuicConnectionTest, Pacing) {
3948 ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true); 3953 ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true);
3949 3954
3950 TestConnection server(connection_id_, IPEndPoint(), helper_.get(), 3955 TestConnection server(connection_id_, IPEndPoint(), helper_.get(),
3951 writer_.get(), true, version(), 3956 writer_.get(), true, version());
3952 kDefaultFlowControlSendWindow);
3953 TestConnection client(connection_id_, IPEndPoint(), helper_.get(), 3957 TestConnection client(connection_id_, IPEndPoint(), helper_.get(),
3954 writer_.get(), false, version(), 3958 writer_.get(), false, version());
3955 kDefaultFlowControlSendWindow);
3956 EXPECT_TRUE(client.sent_packet_manager().using_pacing()); 3959 EXPECT_TRUE(client.sent_packet_manager().using_pacing());
3957 EXPECT_FALSE(server.sent_packet_manager().using_pacing()); 3960 EXPECT_FALSE(server.sent_packet_manager().using_pacing());
3958 } 3961 }
3959 3962
3960 TEST_P(QuicConnectionTest, ControlFramesInstigateAcks) { 3963 TEST_P(QuicConnectionTest, ControlFramesInstigateAcks) {
3961 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 3964 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3962 3965
3963 // Send a WINDOW_UPDATE frame. 3966 // Send a WINDOW_UPDATE frame.
3964 QuicWindowUpdateFrame window_update; 3967 QuicWindowUpdateFrame window_update;
3965 window_update.stream_id = 3; 3968 window_update.stream_id = 3;
3966 window_update.byte_offset = 1234; 3969 window_update.byte_offset = 1234;
3967 EXPECT_CALL(visitor_, OnWindowUpdateFrames(_)); 3970 EXPECT_CALL(visitor_, OnWindowUpdateFrames(_));
3968 ProcessFramePacket(QuicFrame(&window_update)); 3971 ProcessFramePacket(QuicFrame(&window_update));
3969 3972
3970 // Ensure that this has caused the ACK alarm to be set. 3973 // Ensure that this has caused the ACK alarm to be set.
3971 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_); 3974 QuicAlarm* ack_alarm = QuicConnectionPeer::GetAckAlarm(&connection_);
3972 EXPECT_TRUE(ack_alarm->IsSet()); 3975 EXPECT_TRUE(ack_alarm->IsSet());
3973 3976
3974 // Cancel alarm, and try again with BLOCKED frame. 3977 // Cancel alarm, and try again with BLOCKED frame.
3975 ack_alarm->Cancel(); 3978 ack_alarm->Cancel();
3976 QuicBlockedFrame blocked; 3979 QuicBlockedFrame blocked;
3977 blocked.stream_id = 3; 3980 blocked.stream_id = 3;
3978 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 3981 EXPECT_CALL(visitor_, OnBlockedFrames(_));
3979 ProcessFramePacket(QuicFrame(&blocked)); 3982 ProcessFramePacket(QuicFrame(&blocked));
3980 EXPECT_TRUE(ack_alarm->IsSet()); 3983 EXPECT_TRUE(ack_alarm->IsSet());
3981 } 3984 }
3982 3985
3983 TEST_P(QuicConnectionTest, InvalidFlowControlWindow) {
3984 ValueRestore<bool> old_flag(&FLAGS_enable_quic_pacing, true);
3985
3986 const uint32 kSmallerFlowControlWindow = kDefaultFlowControlSendWindow - 1;
3987 TestConnection connection(connection_id_, IPEndPoint(), helper_.get(),
3988 writer_.get(), true, version(),
3989 kSmallerFlowControlWindow);
3990 EXPECT_EQ(kDefaultFlowControlSendWindow,
3991 connection.max_flow_control_receive_window_bytes());
3992 }
3993
3994 } // namespace 3986 } // namespace
3995 } // namespace test 3987 } // namespace test
3996 } // namespace net 3988 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698