OLD | NEW |
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/core/quic_connection.h" | 5 #include "net/quic/core/quic_connection.h" |
6 | 6 |
7 #include <errno.h> | 7 #include <errno.h> |
8 #include <memory> | 8 #include <memory> |
9 #include <ostream> | 9 #include <ostream> |
10 #include <utility> | 10 #include <utility> |
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
727 .WillRepeatedly(Return(QuicBandwidth::Zero())); | 727 .WillRepeatedly(Return(QuicBandwidth::Zero())); |
728 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) | 728 ON_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
729 .WillByDefault(Return(true)); | 729 .WillByDefault(Return(true)); |
730 EXPECT_CALL(*send_algorithm_, HasReliableBandwidthEstimate()) | 730 EXPECT_CALL(*send_algorithm_, HasReliableBandwidthEstimate()) |
731 .Times(AnyNumber()); | 731 .Times(AnyNumber()); |
732 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) | 732 EXPECT_CALL(*send_algorithm_, BandwidthEstimate()) |
733 .Times(AnyNumber()) | 733 .Times(AnyNumber()) |
734 .WillRepeatedly(Return(QuicBandwidth::Zero())); | 734 .WillRepeatedly(Return(QuicBandwidth::Zero())); |
735 EXPECT_CALL(*send_algorithm_, InSlowStart()).Times(AnyNumber()); | 735 EXPECT_CALL(*send_algorithm_, InSlowStart()).Times(AnyNumber()); |
736 EXPECT_CALL(*send_algorithm_, InRecovery()).Times(AnyNumber()); | 736 EXPECT_CALL(*send_algorithm_, InRecovery()).Times(AnyNumber()); |
| 737 EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(AnyNumber()); |
737 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).Times(AnyNumber()); | 738 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).Times(AnyNumber()); |
738 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); | 739 EXPECT_CALL(visitor_, HasPendingHandshake()).Times(AnyNumber()); |
739 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); | 740 EXPECT_CALL(visitor_, OnCanWrite()).Times(AnyNumber()); |
740 EXPECT_CALL(visitor_, PostProcessAfterData()).Times(AnyNumber()); | 741 EXPECT_CALL(visitor_, PostProcessAfterData()).Times(AnyNumber()); |
741 EXPECT_CALL(visitor_, HasOpenDynamicStreams()) | 742 EXPECT_CALL(visitor_, HasOpenDynamicStreams()) |
742 .WillRepeatedly(Return(false)); | 743 .WillRepeatedly(Return(false)); |
743 EXPECT_CALL(visitor_, OnCongestionWindowChange(_)).Times(AnyNumber()); | 744 EXPECT_CALL(visitor_, OnCongestionWindowChange(_)).Times(AnyNumber()); |
744 | 745 |
745 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) | 746 EXPECT_CALL(*loss_algorithm_, GetLossTimeout()) |
746 .WillRepeatedly(Return(QuicTime::Zero())); | 747 .WillRepeatedly(Return(QuicTime::Zero())); |
(...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1937 EXPECT_FALSE(ack_alarm->IsSet()); | 1938 EXPECT_FALSE(ack_alarm->IsSet()); |
1938 } | 1939 } |
1939 | 1940 |
1940 TEST_P(QuicConnectionTest, OnCanWrite) { | 1941 TEST_P(QuicConnectionTest, OnCanWrite) { |
1941 // Visitor's OnCanWrite will send data, but will have more pending writes. | 1942 // Visitor's OnCanWrite will send data, but will have more pending writes. |
1942 EXPECT_CALL(visitor_, OnCanWrite()) | 1943 EXPECT_CALL(visitor_, OnCanWrite()) |
1943 .WillOnce(DoAll(IgnoreResult(InvokeWithoutArgs( | 1944 .WillOnce(DoAll(IgnoreResult(InvokeWithoutArgs( |
1944 &connection_, &TestConnection::SendStreamData3)), | 1945 &connection_, &TestConnection::SendStreamData3)), |
1945 IgnoreResult(InvokeWithoutArgs( | 1946 IgnoreResult(InvokeWithoutArgs( |
1946 &connection_, &TestConnection::SendStreamData5)))); | 1947 &connection_, &TestConnection::SendStreamData5)))); |
1947 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).WillOnce(Return(true)); | 1948 { |
| 1949 InSequence seq; |
| 1950 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).WillOnce(Return(true)); |
| 1951 EXPECT_CALL(visitor_, WillingAndAbleToWrite()) |
| 1952 .WillRepeatedly(Return(false)); |
| 1953 } |
| 1954 |
1948 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _)) | 1955 EXPECT_CALL(*send_algorithm_, TimeUntilSend(_, _)) |
1949 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero())); | 1956 .WillRepeatedly(testing::Return(QuicTime::Delta::Zero())); |
1950 | 1957 |
1951 connection_.OnCanWrite(); | 1958 connection_.OnCanWrite(); |
1952 | 1959 |
1953 // Parse the last packet and ensure it's the two stream frames from | 1960 // Parse the last packet and ensure it's the two stream frames from |
1954 // two different streams. | 1961 // two different streams. |
1955 EXPECT_EQ(2u, writer_->frame_count()); | 1962 EXPECT_EQ(2u, writer_->frame_count()); |
1956 EXPECT_EQ(2u, writer_->stream_frames().size()); | 1963 EXPECT_EQ(2u, writer_->stream_frames().size()); |
1957 EXPECT_EQ(kClientDataStreamId1, writer_->stream_frames()[0]->stream_id); | 1964 EXPECT_EQ(kClientDataStreamId1, writer_->stream_frames()[0]->stream_id); |
(...skipping 3020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4978 // close packet. | 4985 // close packet. |
4979 FLAGS_quic_close_connection_on_packet_too_large = true; | 4986 FLAGS_quic_close_connection_on_packet_too_large = true; |
4980 AlwaysGetPacketTooLarge(); | 4987 AlwaysGetPacketTooLarge(); |
4981 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); | 4988 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)).Times(2); |
4982 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, | 4989 EXPECT_CALL(visitor_, OnConnectionClosed(QUIC_PACKET_WRITE_ERROR, _, |
4983 ConnectionCloseSource::FROM_SELF)) | 4990 ConnectionCloseSource::FROM_SELF)) |
4984 .Times(1); | 4991 .Times(1); |
4985 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); | 4992 connection_.SendStreamDataWithString(3, "foo", 0, !kFin, nullptr); |
4986 } | 4993 } |
4987 | 4994 |
| 4995 // Verify that if connection has no outstanding data, it notifies the send |
| 4996 // algorithm after the write. |
| 4997 TEST_P(QuicConnectionTest, SendDataAndBecomeApplicationLimited) { |
| 4998 FLAGS_quic_enable_app_limited_check = true; |
| 4999 |
| 5000 EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(1); |
| 5001 { |
| 5002 InSequence seq; |
| 5003 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).WillRepeatedly(Return(true)); |
| 5004 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 5005 .WillOnce(Return(true)); |
| 5006 EXPECT_CALL(visitor_, WillingAndAbleToWrite()) |
| 5007 .WillRepeatedly(Return(false)); |
| 5008 } |
| 5009 |
| 5010 connection_.SendStreamData3(); |
| 5011 } |
| 5012 |
| 5013 // Verify that the connection does not become app-limited if there is |
| 5014 // outstanding data to send after the write. |
| 5015 TEST_P(QuicConnectionTest, NotBecomeApplicationLimitedIfMoreDataAvailable) { |
| 5016 FLAGS_quic_enable_app_limited_check = true; |
| 5017 |
| 5018 EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(0); |
| 5019 { |
| 5020 InSequence seq; |
| 5021 EXPECT_CALL(*send_algorithm_, OnPacketSent(_, _, _, _, _)) |
| 5022 .WillOnce(Return(true)); |
| 5023 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).WillRepeatedly(Return(true)); |
| 5024 } |
| 5025 |
| 5026 connection_.SendStreamData3(); |
| 5027 } |
| 5028 |
| 5029 // Verify that the connection does not become app-limited after blocked write |
| 5030 // even if there is outstanding data to send after the write. |
| 5031 TEST_P(QuicConnectionTest, NotBecomeApplicationLimitedDueToWriteBlock) { |
| 5032 FLAGS_quic_enable_app_limited_check = true; |
| 5033 |
| 5034 EXPECT_CALL(*send_algorithm_, OnApplicationLimited(_)).Times(0); |
| 5035 EXPECT_CALL(visitor_, WillingAndAbleToWrite()).WillRepeatedly(Return(true)); |
| 5036 BlockOnNextWrite(); |
| 5037 |
| 5038 connection_.SendStreamData3(); |
| 5039 } |
| 5040 |
4988 } // namespace | 5041 } // namespace |
4989 } // namespace test | 5042 } // namespace test |
4990 } // namespace net | 5043 } // namespace net |
OLD | NEW |