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

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

Issue 515303003: Landing Recent QUIC Changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Bug fix for 409191 Created 6 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
« no previous file with comments | « net/quic/quic_connection_logger.h ('k') | net/quic/quic_crypto_server_stream.cc » ('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_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 715 matching lines...) Expand 10 before | Expand all | Expand 10 after
726 bool entropy_flag, 726 bool entropy_flag,
727 EncryptionLevel level) { 727 EncryptionLevel level) {
728 scoped_ptr<QuicPacket> packet(ConstructDataPacket(number, fec_group, 728 scoped_ptr<QuicPacket> packet(ConstructDataPacket(number, fec_group,
729 entropy_flag)); 729 entropy_flag));
730 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( 730 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(
731 level, number, *packet)); 731 level, number, *packet));
732 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); 732 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
733 return encrypted->length(); 733 return encrypted->length();
734 } 734 }
735 735
736 void ProcessPingPacket(QuicPacketSequenceNumber number) {
737 scoped_ptr<QuicPacket> packet(ConstructPingPacket(number));
738 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(
739 ENCRYPTION_NONE, number, *packet));
740 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
741 }
742
736 void ProcessClosePacket(QuicPacketSequenceNumber number, 743 void ProcessClosePacket(QuicPacketSequenceNumber number,
737 QuicFecGroupNumber fec_group) { 744 QuicFecGroupNumber fec_group) {
738 scoped_ptr<QuicPacket> packet(ConstructClosePacket(number, fec_group)); 745 scoped_ptr<QuicPacket> packet(ConstructClosePacket(number, fec_group));
739 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket( 746 scoped_ptr<QuicEncryptedPacket> encrypted(framer_.EncryptPacket(
740 ENCRYPTION_NONE, number, *packet)); 747 ENCRYPTION_NONE, number, *packet));
741 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted); 748 connection_.ProcessUdpPacket(IPEndPoint(), IPEndPoint(), *encrypted);
742 } 749 }
743 750
744 size_t ProcessFecProtectedPacket(QuicPacketSequenceNumber number, 751 size_t ProcessFecProtectedPacket(QuicPacketSequenceNumber number,
745 bool expect_revival, bool entropy_flag) { 752 bool expect_revival, bool entropy_flag) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
865 872
866 QuicFrames frames; 873 QuicFrames frames;
867 QuicFrame frame(&frame1_); 874 QuicFrame frame(&frame1_);
868 frames.push_back(frame); 875 frames.push_back(frame);
869 QuicPacket* packet = 876 QuicPacket* packet =
870 BuildUnsizedDataPacket(&framer_, header_, frames).packet; 877 BuildUnsizedDataPacket(&framer_, header_, frames).packet;
871 EXPECT_TRUE(packet != NULL); 878 EXPECT_TRUE(packet != NULL);
872 return packet; 879 return packet;
873 } 880 }
874 881
882 QuicPacket* ConstructPingPacket(QuicPacketSequenceNumber number) {
883 header_.public_header.connection_id = connection_id_;
884 header_.packet_sequence_number = number;
885 header_.public_header.reset_flag = false;
886 header_.public_header.version_flag = false;
887 header_.entropy_flag = false;
888 header_.fec_flag = false;
889 header_.is_in_fec_group = NOT_IN_FEC_GROUP;
890 header_.fec_group = 0;
891
892 QuicPingFrame ping;
893
894 QuicFrames frames;
895 QuicFrame frame(&ping);
896 frames.push_back(frame);
897 QuicPacket* packet =
898 BuildUnsizedDataPacket(&framer_, header_, frames).packet;
899 EXPECT_TRUE(packet != NULL);
900 return packet;
901 }
902
875 QuicPacket* ConstructClosePacket(QuicPacketSequenceNumber number, 903 QuicPacket* ConstructClosePacket(QuicPacketSequenceNumber number,
876 QuicFecGroupNumber fec_group) { 904 QuicFecGroupNumber fec_group) {
877 header_.public_header.connection_id = connection_id_; 905 header_.public_header.connection_id = connection_id_;
878 header_.packet_sequence_number = number; 906 header_.packet_sequence_number = number;
879 header_.public_header.reset_flag = false; 907 header_.public_header.reset_flag = false;
880 header_.public_header.version_flag = false; 908 header_.public_header.version_flag = false;
881 header_.entropy_flag = false; 909 header_.entropy_flag = false;
882 header_.fec_flag = false; 910 header_.fec_flag = false;
883 header_.is_in_fec_group = fec_group == 0u ? NOT_IN_FEC_GROUP : IN_FEC_GROUP; 911 header_.is_in_fec_group = fec_group == 0u ? NOT_IN_FEC_GROUP : IN_FEC_GROUP;
884 header_.fec_group = fec_group; 912 header_.fec_group = fec_group;
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after
1365 Return(kMaxPacketSize * 256 * 256 * 256 * 256)); 1393 Return(kMaxPacketSize * 256 * 256 * 256 * 256));
1366 1394
1367 SendStreamDataToPeer(1, "foo", 12, !kFin, &last_packet); 1395 SendStreamDataToPeer(1, "foo", 12, !kFin, &last_packet);
1368 EXPECT_EQ(5u, last_packet); 1396 EXPECT_EQ(5u, last_packet);
1369 EXPECT_EQ(PACKET_6BYTE_SEQUENCE_NUMBER, 1397 EXPECT_EQ(PACKET_6BYTE_SEQUENCE_NUMBER,
1370 creator->next_sequence_number_length()); 1398 creator->next_sequence_number_length());
1371 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER, 1399 EXPECT_EQ(PACKET_4BYTE_SEQUENCE_NUMBER,
1372 writer_->header().public_header.sequence_number_length); 1400 writer_->header().public_header.sequence_number_length);
1373 } 1401 }
1374 1402
1375 TEST_P(QuicConnectionTest, SendingDifferentSequenceNumberLengthsUnackedDelta) { 1403 // TODO(ianswett): Re-enable this test by finding a good way to test different
1404 // sequence number lengths without sending packets with giant gaps.
1405 TEST_P(QuicConnectionTest,
1406 DISABLED_SendingDifferentSequenceNumberLengthsUnackedDelta) {
1376 QuicPacketSequenceNumber last_packet; 1407 QuicPacketSequenceNumber last_packet;
1377 QuicPacketCreator* creator = 1408 QuicPacketCreator* creator =
1378 QuicConnectionPeer::GetPacketCreator(&connection_); 1409 QuicConnectionPeer::GetPacketCreator(&connection_);
1379 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet); 1410 SendStreamDataToPeer(1, "foo", 0, !kFin, &last_packet);
1380 EXPECT_EQ(1u, last_packet); 1411 EXPECT_EQ(1u, last_packet);
1381 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, 1412 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER,
1382 creator->next_sequence_number_length()); 1413 creator->next_sequence_number_length());
1383 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER, 1414 EXPECT_EQ(PACKET_1BYTE_SEQUENCE_NUMBER,
1384 writer_->header().public_header.sequence_number_length); 1415 writer_->header().public_header.sequence_number_length);
1385 1416
(...skipping 1318 matching lines...) Expand 10 before | Expand all | Expand 10 after
2704 EXPECT_EQ(default_timeout.Add(QuicTime::Delta::FromMilliseconds(5)), 2735 EXPECT_EQ(default_timeout.Add(QuicTime::Delta::FromMilliseconds(5)),
2705 clock_.ApproximateNow()); 2736 clock_.ApproximateNow());
2706 connection_.GetTimeoutAlarm()->Fire(); 2737 connection_.GetTimeoutAlarm()->Fire();
2707 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 2738 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
2708 EXPECT_FALSE(connection_.connected()); 2739 EXPECT_FALSE(connection_.connected());
2709 } 2740 }
2710 2741
2711 TEST_P(QuicConnectionTest, SendScheduler) { 2742 TEST_P(QuicConnectionTest, SendScheduler) {
2712 // Test that if we send a packet without delay, it is not queued. 2743 // Test that if we send a packet without delay, it is not queued.
2713 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); 2744 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2714 EXPECT_CALL(*send_algorithm_,
2715 TimeUntilSend(_, _, _)).WillOnce(
2716 testing::Return(QuicTime::Delta::Zero()));
2717 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 2745 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
2718 connection_.SendPacket( 2746 connection_.SendPacket(
2719 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); 2747 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2720 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 2748 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2721 } 2749 }
2722 2750
2723 TEST_P(QuicConnectionTest, SendSchedulerDelay) { 2751 TEST_P(QuicConnectionTest, SendSchedulerEAGAIN) {
2724 // Test that if we send a packet with a delay, it ends up queued.
2725 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); 2752 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2726 EXPECT_CALL(*send_algorithm_, 2753 BlockOnNextWrite();
2727 TimeUntilSend(_, _, _)).WillOnce(
2728 testing::Return(QuicTime::Delta::FromMicroseconds(1)));
2729 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 1, _, _)).Times(0); 2754 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 1, _, _)).Times(0);
2730 connection_.SendPacket( 2755 connection_.SendPacket(
2731 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); 2756 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2732 EXPECT_EQ(1u, connection_.NumQueuedPackets()); 2757 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2733 } 2758 }
2734 2759
2735 TEST_P(QuicConnectionTest, SendSchedulerEAGAIN) {
2736 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2737 BlockOnNextWrite();
2738 EXPECT_CALL(*send_algorithm_,
2739 TimeUntilSend(_, _, _)).WillOnce(
2740 testing::Return(QuicTime::Delta::Zero()));
2741 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 1, _, _)).Times(0);
2742 connection_.SendPacket(
2743 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2744 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2745 }
2746
2747 TEST_P(QuicConnectionTest, SendSchedulerDelayThenSend) {
2748 // Test that if we send a packet with a delay, it ends up queued.
2749 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2750 EXPECT_CALL(*send_algorithm_,
2751 TimeUntilSend(_, _, _)).WillOnce(
2752 testing::Return(QuicTime::Delta::FromMicroseconds(1)));
2753 connection_.SendPacket(
2754 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2755 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2756
2757 // Advance the clock to fire the alarm, and configure the scheduler
2758 // to permit the packet to be sent.
2759 EXPECT_CALL(*send_algorithm_,
2760 TimeUntilSend(_, _, _)).WillRepeatedly(
2761 testing::Return(QuicTime::Delta::Zero()));
2762 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(1));
2763 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
2764 connection_.GetSendAlarm()->Fire();
2765 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2766 }
2767
2768 TEST_P(QuicConnectionTest, SendSchedulerDelayThenRetransmit) {
2769 CongestionUnblockWrites();
2770 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 1, _, _));
2771 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
2772 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2773 // Advance the time for retransmission of lost packet.
2774 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(501));
2775 // Test that if we send a retransmit with a delay, it ends up queued in the
2776 // sent packet manager, but not yet serialized.
2777 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
2778 CongestionBlockWrites();
2779 connection_.GetRetransmissionAlarm()->Fire();
2780 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2781
2782 // Advance the clock to fire the alarm, and configure the scheduler
2783 // to permit the packet to be sent.
2784 CongestionUnblockWrites();
2785
2786 // Ensure the scheduler is notified this is a retransmit.
2787 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
2788 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(1));
2789 connection_.GetSendAlarm()->Fire();
2790 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2791 }
2792
2793 TEST_P(QuicConnectionTest, SendSchedulerDelayAndQueue) {
2794 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2795 EXPECT_CALL(*send_algorithm_,
2796 TimeUntilSend(_, _, _)).WillOnce(
2797 testing::Return(QuicTime::Delta::FromMicroseconds(1)));
2798 connection_.SendPacket(
2799 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2800 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2801
2802 // Attempt to send another packet and make sure that it gets queued.
2803 packet = ConstructDataPacket(2, 0, !kEntropyFlag);
2804 connection_.SendPacket(
2805 ENCRYPTION_NONE, 2, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2806 EXPECT_EQ(2u, connection_.NumQueuedPackets());
2807 }
2808
2809 TEST_P(QuicConnectionTest, SendSchedulerDelayThenAckAndSend) {
2810 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2811 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2812 EXPECT_CALL(*send_algorithm_,
2813 TimeUntilSend(_, _, _)).WillOnce(
2814 testing::Return(QuicTime::Delta::FromMicroseconds(10)));
2815 connection_.SendPacket(
2816 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2817 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2818
2819 // Now send non-retransmitting information, that we're not going to
2820 // retransmit 3. The far end should stop waiting for it.
2821 QuicAckFrame frame = InitAckFrame(0);
2822 EXPECT_CALL(*send_algorithm_,
2823 TimeUntilSend(_, _, _)).WillRepeatedly(
2824 testing::Return(QuicTime::Delta::Zero()));
2825 EXPECT_CALL(*send_algorithm_,
2826 OnPacketSent(_, _, _, _, _));
2827 ProcessAckPacket(&frame);
2828
2829 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2830 // Ensure alarm is not set
2831 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet());
2832 }
2833
2834 TEST_P(QuicConnectionTest, SendSchedulerDelayThenAckAndHold) {
2835 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2836 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2837 EXPECT_CALL(*send_algorithm_,
2838 TimeUntilSend(_, _, _)).WillOnce(
2839 testing::Return(QuicTime::Delta::FromMicroseconds(10)));
2840 connection_.SendPacket(
2841 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2842 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2843
2844 // Now send non-retransmitting information, that we're not going to
2845 // retransmit 3. The far end should stop waiting for it.
2846 QuicAckFrame frame = InitAckFrame(0);
2847 EXPECT_CALL(*send_algorithm_,
2848 TimeUntilSend(_, _, _)).WillOnce(
2849 testing::Return(QuicTime::Delta::FromMicroseconds(1)));
2850 ProcessAckPacket(&frame);
2851
2852 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2853 }
2854
2855 TEST_P(QuicConnectionTest, SendSchedulerDelayThenOnCanWrite) {
2856 // TODO(ianswett): This test is unrealistic, because we would not serialize
2857 // new data if the send algorithm said not to.
2858 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2859 CongestionBlockWrites();
2860 connection_.SendPacket(
2861 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2862 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2863
2864 // OnCanWrite should send the packet, because it won't consult the send
2865 // algorithm for queued packets.
2866 connection_.OnCanWrite();
2867 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2868 }
2869
2870 TEST_P(QuicConnectionTest, TestQueueLimitsOnSendStreamData) { 2760 TEST_P(QuicConnectionTest, TestQueueLimitsOnSendStreamData) {
2871 // All packets carry version info till version is negotiated. 2761 // All packets carry version info till version is negotiated.
2872 size_t payload_length; 2762 size_t payload_length;
2873 size_t length = GetPacketLengthForOneStream( 2763 size_t length = GetPacketLengthForOneStream(
2874 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, 2764 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER,
2875 NOT_IN_FEC_GROUP, &payload_length); 2765 NOT_IN_FEC_GROUP, &payload_length);
2876 QuicConnectionPeer::GetPacketCreator(&connection_)->set_max_packet_length( 2766 QuicConnectionPeer::GetPacketCreator(&connection_)->set_max_packet_length(
2877 length); 2767 length);
2878 2768
2879 // Queue the first packet. 2769 // Queue the first packet.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2960 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2850 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2961 ProcessPacket(1); 2851 ProcessPacket(1);
2962 ProcessPacket(2); 2852 ProcessPacket(2);
2963 // Check that ack is sent and that delayed ack alarm is reset. 2853 // Check that ack is sent and that delayed ack alarm is reset.
2964 EXPECT_EQ(2u, writer_->frame_count()); 2854 EXPECT_EQ(2u, writer_->frame_count());
2965 EXPECT_FALSE(writer_->stop_waiting_frames().empty()); 2855 EXPECT_FALSE(writer_->stop_waiting_frames().empty());
2966 EXPECT_FALSE(writer_->ack_frames().empty()); 2856 EXPECT_FALSE(writer_->ack_frames().empty());
2967 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); 2857 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
2968 } 2858 }
2969 2859
2860 TEST_P(QuicConnectionTest, SendDelayedAckForPing) {
2861 if (version() < QUIC_VERSION_18) {
2862 return;
2863 }
2864 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2865 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
2866 ProcessPingPacket(1);
2867 EXPECT_TRUE(connection_.GetAckAlarm()->IsSet());
2868 }
2869
2970 TEST_P(QuicConnectionTest, NoAckOnOldNacks) { 2870 TEST_P(QuicConnectionTest, NoAckOnOldNacks) {
2971 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2871 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2972 // Drop one packet, triggering a sequence of acks. 2872 // Drop one packet, triggering a sequence of acks.
2973 ProcessPacket(2); 2873 ProcessPacket(2);
2974 size_t frames_per_ack = 2; 2874 size_t frames_per_ack = 2;
2975 EXPECT_EQ(frames_per_ack, writer_->frame_count()); 2875 EXPECT_EQ(frames_per_ack, writer_->frame_count());
2976 EXPECT_FALSE(writer_->ack_frames().empty()); 2876 EXPECT_FALSE(writer_->ack_frames().empty());
2977 writer_->Reset(); 2877 writer_->Reset();
2978 ProcessPacket(3); 2878 ProcessPacket(3);
2979 EXPECT_EQ(frames_per_ack, writer_->frame_count()); 2879 EXPECT_EQ(frames_per_ack, writer_->frame_count());
(...skipping 29 matching lines...) Expand all
3009 TEST_P(QuicConnectionTest, SendDelayedAckOnOutgoingCryptoPacket) { 2909 TEST_P(QuicConnectionTest, SendDelayedAckOnOutgoingCryptoPacket) {
3010 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2910 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3011 ProcessPacket(1); 2911 ProcessPacket(1);
3012 connection_.SendStreamDataWithString(kCryptoStreamId, "foo", 0, !kFin, NULL); 2912 connection_.SendStreamDataWithString(kCryptoStreamId, "foo", 0, !kFin, NULL);
3013 // Check that ack is bundled with outgoing crypto data. 2913 // Check that ack is bundled with outgoing crypto data.
3014 EXPECT_EQ(3u, writer_->frame_count()); 2914 EXPECT_EQ(3u, writer_->frame_count());
3015 EXPECT_FALSE(writer_->ack_frames().empty()); 2915 EXPECT_FALSE(writer_->ack_frames().empty());
3016 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); 2916 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
3017 } 2917 }
3018 2918
2919 TEST_P(QuicConnectionTest, BlockAndBufferOnFirstCHLOPacketOfTwo) {
2920 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2921 ProcessPacket(1);
2922 BlockOnNextWrite();
2923 writer_->set_is_write_blocked_data_buffered(true);
2924 connection_.SendStreamDataWithString(kCryptoStreamId, "foo", 0, !kFin, NULL);
2925 EXPECT_TRUE(writer_->IsWriteBlocked());
2926 EXPECT_FALSE(connection_.HasQueuedData());
2927 connection_.SendStreamDataWithString(kCryptoStreamId, "bar", 3, !kFin, NULL);
2928 EXPECT_TRUE(writer_->IsWriteBlocked());
2929 EXPECT_TRUE(connection_.HasQueuedData());
2930 }
2931
3019 TEST_P(QuicConnectionTest, BundleAckForSecondCHLO) { 2932 TEST_P(QuicConnectionTest, BundleAckForSecondCHLO) {
3020 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_)); 2933 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
3021 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet()); 2934 EXPECT_FALSE(connection_.GetAckAlarm()->IsSet());
3022 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce( 2935 EXPECT_CALL(visitor_, OnCanWrite()).WillOnce(
3023 IgnoreResult(InvokeWithoutArgs(&connection_, 2936 IgnoreResult(InvokeWithoutArgs(&connection_,
3024 &TestConnection::SendCryptoStreamData))); 2937 &TestConnection::SendCryptoStreamData)));
3025 // Process a packet from the crypto stream, which is frame1_'s default. 2938 // Process a packet from the crypto stream, which is frame1_'s default.
3026 // Receiving the CHLO as packet 2 first will cause the connection to 2939 // Receiving the CHLO as packet 2 first will cause the connection to
3027 // immediately send an ack, due to the packet gap. 2940 // immediately send an ack, due to the packet gap.
3028 ProcessPacket(2); 2941 ProcessPacket(2);
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
3963 QuicBlockedFrame blocked; 3876 QuicBlockedFrame blocked;
3964 blocked.stream_id = 3; 3877 blocked.stream_id = 3;
3965 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 3878 EXPECT_CALL(visitor_, OnBlockedFrames(_));
3966 ProcessFramePacket(QuicFrame(&blocked)); 3879 ProcessFramePacket(QuicFrame(&blocked));
3967 EXPECT_TRUE(ack_alarm->IsSet()); 3880 EXPECT_TRUE(ack_alarm->IsSet());
3968 } 3881 }
3969 3882
3970 } // namespace 3883 } // namespace
3971 } // namespace test 3884 } // namespace test
3972 } // namespace net 3885 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_connection_logger.h ('k') | net/quic/quic_crypto_server_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698