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

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

Issue 515003003: Remove PacketType from QUIC because the QUEUED type is not used and the (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dont_send_SCUP_message_74132773
Patch Set: 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.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 2724 matching lines...) Expand 10 before | Expand all | Expand 10 after
2735 EXPECT_EQ(default_timeout.Add(QuicTime::Delta::FromMilliseconds(5)), 2735 EXPECT_EQ(default_timeout.Add(QuicTime::Delta::FromMilliseconds(5)),
2736 clock_.ApproximateNow()); 2736 clock_.ApproximateNow());
2737 connection_.GetTimeoutAlarm()->Fire(); 2737 connection_.GetTimeoutAlarm()->Fire();
2738 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet()); 2738 EXPECT_FALSE(connection_.GetTimeoutAlarm()->IsSet());
2739 EXPECT_FALSE(connection_.connected()); 2739 EXPECT_FALSE(connection_.connected());
2740 } 2740 }
2741 2741
2742 TEST_P(QuicConnectionTest, SendScheduler) { 2742 TEST_P(QuicConnectionTest, SendScheduler) {
2743 // 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.
2744 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); 2744 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2745 EXPECT_CALL(*send_algorithm_,
2746 TimeUntilSend(_, _, _)).WillOnce(
2747 testing::Return(QuicTime::Delta::Zero()));
2748 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)); 2745 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
2749 connection_.SendPacket( 2746 connection_.SendPacket(
2750 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); 2747 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2751 EXPECT_EQ(0u, connection_.NumQueuedPackets()); 2748 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2752 } 2749 }
2753 2750
2754 TEST_P(QuicConnectionTest, SendSchedulerDelay) { 2751 TEST_P(QuicConnectionTest, SendSchedulerEAGAIN) {
2755 // Test that if we send a packet with a delay, it ends up queued.
2756 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag); 2752 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2757 EXPECT_CALL(*send_algorithm_, 2753 BlockOnNextWrite();
2758 TimeUntilSend(_, _, _)).WillOnce(
2759 testing::Return(QuicTime::Delta::FromMicroseconds(1)));
2760 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 1, _, _)).Times(0); 2754 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 1, _, _)).Times(0);
2761 connection_.SendPacket( 2755 connection_.SendPacket(
2762 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA); 2756 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2763 EXPECT_EQ(1u, connection_.NumQueuedPackets()); 2757 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2764 } 2758 }
2765 2759
2766 TEST_P(QuicConnectionTest, SendSchedulerEAGAIN) {
2767 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2768 BlockOnNextWrite();
2769 EXPECT_CALL(*send_algorithm_,
2770 TimeUntilSend(_, _, _)).WillOnce(
2771 testing::Return(QuicTime::Delta::Zero()));
2772 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 1, _, _)).Times(0);
2773 connection_.SendPacket(
2774 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2775 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2776 }
2777
2778 TEST_P(QuicConnectionTest, SendSchedulerDelayThenSend) {
2779 // Test that if we send a packet with a delay, it ends up queued.
2780 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2781 EXPECT_CALL(*send_algorithm_,
2782 TimeUntilSend(_, _, _)).WillOnce(
2783 testing::Return(QuicTime::Delta::FromMicroseconds(1)));
2784 connection_.SendPacket(
2785 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2786 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2787
2788 // Advance the clock to fire the alarm, and configure the scheduler
2789 // to permit the packet to be sent.
2790 EXPECT_CALL(*send_algorithm_,
2791 TimeUntilSend(_, _, _)).WillRepeatedly(
2792 testing::Return(QuicTime::Delta::Zero()));
2793 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(1));
2794 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
2795 connection_.GetSendAlarm()->Fire();
2796 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2797 }
2798
2799 TEST_P(QuicConnectionTest, SendSchedulerDelayThenRetransmit) {
2800 CongestionUnblockWrites();
2801 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, 1, _, _));
2802 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, NULL);
2803 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2804 // Advance the time for retransmission of lost packet.
2805 clock_.AdvanceTime(QuicTime::Delta::FromMilliseconds(501));
2806 // Test that if we send a retransmit with a delay, it ends up queued in the
2807 // sent packet manager, but not yet serialized.
2808 EXPECT_CALL(*send_algorithm_, OnRetransmissionTimeout(true));
2809 CongestionBlockWrites();
2810 connection_.GetRetransmissionAlarm()->Fire();
2811 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2812
2813 // Advance the clock to fire the alarm, and configure the scheduler
2814 // to permit the packet to be sent.
2815 CongestionUnblockWrites();
2816
2817 // Ensure the scheduler is notified this is a retransmit.
2818 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _));
2819 clock_.AdvanceTime(QuicTime::Delta::FromMicroseconds(1));
2820 connection_.GetSendAlarm()->Fire();
2821 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2822 }
2823
2824 TEST_P(QuicConnectionTest, SendSchedulerDelayAndQueue) {
2825 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2826 EXPECT_CALL(*send_algorithm_,
2827 TimeUntilSend(_, _, _)).WillOnce(
2828 testing::Return(QuicTime::Delta::FromMicroseconds(1)));
2829 connection_.SendPacket(
2830 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2831 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2832
2833 // Attempt to send another packet and make sure that it gets queued.
2834 packet = ConstructDataPacket(2, 0, !kEntropyFlag);
2835 connection_.SendPacket(
2836 ENCRYPTION_NONE, 2, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2837 EXPECT_EQ(2u, connection_.NumQueuedPackets());
2838 }
2839
2840 TEST_P(QuicConnectionTest, SendSchedulerDelayThenAckAndSend) {
2841 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2842 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2843 EXPECT_CALL(*send_algorithm_,
2844 TimeUntilSend(_, _, _)).WillOnce(
2845 testing::Return(QuicTime::Delta::FromMicroseconds(10)));
2846 connection_.SendPacket(
2847 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2848 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2849
2850 // Now send non-retransmitting information, that we're not going to
2851 // retransmit 3. The far end should stop waiting for it.
2852 QuicAckFrame frame = InitAckFrame(0);
2853 EXPECT_CALL(*send_algorithm_,
2854 TimeUntilSend(_, _, _)).WillRepeatedly(
2855 testing::Return(QuicTime::Delta::Zero()));
2856 EXPECT_CALL(*send_algorithm_,
2857 OnPacketSent(_, _, _, _, _));
2858 ProcessAckPacket(&frame);
2859
2860 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2861 // Ensure alarm is not set
2862 EXPECT_FALSE(connection_.GetSendAlarm()->IsSet());
2863 }
2864
2865 TEST_P(QuicConnectionTest, SendSchedulerDelayThenAckAndHold) {
2866 EXPECT_CALL(visitor_, OnSuccessfulVersionNegotiation(_));
2867 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2868 EXPECT_CALL(*send_algorithm_,
2869 TimeUntilSend(_, _, _)).WillOnce(
2870 testing::Return(QuicTime::Delta::FromMicroseconds(10)));
2871 connection_.SendPacket(
2872 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2873 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2874
2875 // Now send non-retransmitting information, that we're not going to
2876 // retransmit 3. The far end should stop waiting for it.
2877 QuicAckFrame frame = InitAckFrame(0);
2878 EXPECT_CALL(*send_algorithm_,
2879 TimeUntilSend(_, _, _)).WillOnce(
2880 testing::Return(QuicTime::Delta::FromMicroseconds(1)));
2881 ProcessAckPacket(&frame);
2882
2883 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2884 }
2885
2886 TEST_P(QuicConnectionTest, SendSchedulerDelayThenOnCanWrite) {
2887 // TODO(ianswett): This test is unrealistic, because we would not serialize
2888 // new data if the send algorithm said not to.
2889 QuicPacket* packet = ConstructDataPacket(1, 0, !kEntropyFlag);
2890 CongestionBlockWrites();
2891 connection_.SendPacket(
2892 ENCRYPTION_NONE, 1, packet, kTestEntropyHash, HAS_RETRANSMITTABLE_DATA);
2893 EXPECT_EQ(1u, connection_.NumQueuedPackets());
2894
2895 // OnCanWrite should send the packet, because it won't consult the send
2896 // algorithm for queued packets.
2897 connection_.OnCanWrite();
2898 EXPECT_EQ(0u, connection_.NumQueuedPackets());
2899 }
2900
2901 TEST_P(QuicConnectionTest, TestQueueLimitsOnSendStreamData) { 2760 TEST_P(QuicConnectionTest, TestQueueLimitsOnSendStreamData) {
2902 // All packets carry version info till version is negotiated. 2761 // All packets carry version info till version is negotiated.
2903 size_t payload_length; 2762 size_t payload_length;
2904 size_t length = GetPacketLengthForOneStream( 2763 size_t length = GetPacketLengthForOneStream(
2905 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER, 2764 connection_.version(), kIncludeVersion, PACKET_1BYTE_SEQUENCE_NUMBER,
2906 NOT_IN_FEC_GROUP, &payload_length); 2765 NOT_IN_FEC_GROUP, &payload_length);
2907 QuicConnectionPeer::GetPacketCreator(&connection_)->set_max_packet_length( 2766 QuicConnectionPeer::GetPacketCreator(&connection_)->set_max_packet_length(
2908 length); 2767 length);
2909 2768
2910 // Queue the first packet. 2769 // Queue the first packet.
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
4004 QuicBlockedFrame blocked; 3863 QuicBlockedFrame blocked;
4005 blocked.stream_id = 3; 3864 blocked.stream_id = 3;
4006 EXPECT_CALL(visitor_, OnBlockedFrames(_)); 3865 EXPECT_CALL(visitor_, OnBlockedFrames(_));
4007 ProcessFramePacket(QuicFrame(&blocked)); 3866 ProcessFramePacket(QuicFrame(&blocked));
4008 EXPECT_TRUE(ack_alarm->IsSet()); 3867 EXPECT_TRUE(ack_alarm->IsSet());
4009 } 3868 }
4010 3869
4011 } // namespace 3870 } // namespace
4012 } // namespace test 3871 } // namespace test
4013 } // namespace net 3872 } // 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