| 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/reliable_quic_stream.h" | 5 #include "net/quic/reliable_quic_stream.h" |
| 6 | 6 |
| 7 #include "net/quic/quic_ack_notifier.h" | 7 #include "net/quic/quic_ack_notifier.h" |
| 8 #include "net/quic/quic_connection.h" | 8 #include "net/quic/quic_connection.h" |
| 9 #include "net/quic/quic_flags.h" | 9 #include "net/quic/quic_flags.h" |
| 10 #include "net/quic/quic_utils.h" | 10 #include "net/quic/quic_utils.h" |
| 11 #include "net/quic/quic_write_blocked_list.h" | 11 #include "net/quic/quic_write_blocked_list.h" |
| 12 #include "net/quic/spdy_utils.h" | 12 #include "net/quic/spdy_utils.h" |
| 13 #include "net/quic/test_tools/quic_config_peer.h" | 13 #include "net/quic/test_tools/quic_config_peer.h" |
| 14 #include "net/quic/test_tools/quic_connection_peer.h" |
| 14 #include "net/quic/test_tools/quic_flow_controller_peer.h" | 15 #include "net/quic/test_tools/quic_flow_controller_peer.h" |
| 15 #include "net/quic/test_tools/quic_session_peer.h" | 16 #include "net/quic/test_tools/quic_session_peer.h" |
| 16 #include "net/quic/test_tools/quic_test_utils.h" | 17 #include "net/quic/test_tools/quic_test_utils.h" |
| 17 #include "net/quic/test_tools/reliable_quic_stream_peer.h" | 18 #include "net/quic/test_tools/reliable_quic_stream_peer.h" |
| 18 #include "net/test/gtest_util.h" | 19 #include "net/test/gtest_util.h" |
| 19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 20 #include "testing/gmock_mutant.h" | 21 #include "testing/gmock_mutant.h" |
| 21 | 22 |
| 22 using base::StringPiece; | 23 using base::StringPiece; |
| 23 using std::min; | 24 using std::min; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 SpdyHeaderBlock headers_; | 144 SpdyHeaderBlock headers_; |
| 144 QuicWriteBlockedList* write_blocked_list_; | 145 QuicWriteBlockedList* write_blocked_list_; |
| 145 uint32 initial_flow_control_window_bytes_; | 146 uint32 initial_flow_control_window_bytes_; |
| 146 QuicTime::Delta zero_; | 147 QuicTime::Delta zero_; |
| 147 QuicVersionVector supported_versions_; | 148 QuicVersionVector supported_versions_; |
| 148 }; | 149 }; |
| 149 | 150 |
| 150 TEST_F(ReliableQuicStreamTest, WriteAllData) { | 151 TEST_F(ReliableQuicStreamTest, WriteAllData) { |
| 151 Initialize(kShouldProcessData); | 152 Initialize(kShouldProcessData); |
| 152 | 153 |
| 153 connection_->options()->max_packet_length = | 154 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( |
| 154 1 + QuicPacketCreator::StreamFramePacketOverhead( | 155 connection_->version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
| 155 connection_->version(), PACKET_8BYTE_CONNECTION_ID, | 156 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP); |
| 156 !kIncludeVersion, PACKET_6BYTE_SEQUENCE_NUMBER, 0u, | 157 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length( |
| 157 NOT_IN_FEC_GROUP); | 158 length); |
| 158 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _)) | 159 |
| 159 .WillOnce(Return(QuicConsumedData(kDataLen, true))); | 160 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _)).WillOnce( |
| 161 Return(QuicConsumedData(kDataLen, true))); |
| 160 stream_->WriteOrBufferData(kData1, false, NULL); | 162 stream_->WriteOrBufferData(kData1, false, NULL); |
| 161 EXPECT_FALSE(HasWriteBlockedStreams()); | 163 EXPECT_FALSE(HasWriteBlockedStreams()); |
| 162 } | 164 } |
| 163 | 165 |
| 164 TEST_F(ReliableQuicStreamTest, NoBlockingIfNoDataOrFin) { | 166 TEST_F(ReliableQuicStreamTest, NoBlockingIfNoDataOrFin) { |
| 165 Initialize(kShouldProcessData); | 167 Initialize(kShouldProcessData); |
| 166 | 168 |
| 167 // Write no data and no fin. If we consume nothing we should not be write | 169 // Write no data and no fin. If we consume nothing we should not be write |
| 168 // blocked. | 170 // blocked. |
| 169 EXPECT_DFATAL(stream_->WriteOrBufferData(StringPiece(), false, NULL), ""); | 171 EXPECT_DFATAL(stream_->WriteOrBufferData(StringPiece(), false, NULL), ""); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _)) | 204 EXPECT_CALL(*session_, WritevData(kHeadersStreamId, _, _, _, _)) |
| 203 .WillOnce(Return(QuicConsumedData(0, false))); | 205 .WillOnce(Return(QuicConsumedData(0, false))); |
| 204 stream_->WriteOrBufferData(StringPiece(), true, NULL); | 206 stream_->WriteOrBufferData(StringPiece(), true, NULL); |
| 205 ASSERT_EQ(1u, write_blocked_list_->NumBlockedStreams()); | 207 ASSERT_EQ(1u, write_blocked_list_->NumBlockedStreams()); |
| 206 } | 208 } |
| 207 | 209 |
| 208 TEST_F(ReliableQuicStreamTest, WriteOrBufferData) { | 210 TEST_F(ReliableQuicStreamTest, WriteOrBufferData) { |
| 209 Initialize(kShouldProcessData); | 211 Initialize(kShouldProcessData); |
| 210 | 212 |
| 211 EXPECT_FALSE(HasWriteBlockedStreams()); | 213 EXPECT_FALSE(HasWriteBlockedStreams()); |
| 212 connection_->options()->max_packet_length = | 214 size_t length = 1 + QuicPacketCreator::StreamFramePacketOverhead( |
| 213 1 + QuicPacketCreator::StreamFramePacketOverhead( | 215 connection_->version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, |
| 214 connection_->version(), PACKET_8BYTE_CONNECTION_ID, !kIncludeVersion, | 216 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP); |
| 215 PACKET_6BYTE_SEQUENCE_NUMBER, 0u, NOT_IN_FEC_GROUP); | 217 QuicConnectionPeer::GetPacketCreator(connection_)->set_max_packet_length( |
| 218 length); |
| 219 |
| 216 EXPECT_CALL(*session_, WritevData(_, _, _, _, _)).WillOnce( | 220 EXPECT_CALL(*session_, WritevData(_, _, _, _, _)).WillOnce( |
| 217 Return(QuicConsumedData(kDataLen - 1, false))); | 221 Return(QuicConsumedData(kDataLen - 1, false))); |
| 218 stream_->WriteOrBufferData(kData1, false, NULL); | 222 stream_->WriteOrBufferData(kData1, false, NULL); |
| 219 EXPECT_TRUE(HasWriteBlockedStreams()); | 223 EXPECT_TRUE(HasWriteBlockedStreams()); |
| 220 | 224 |
| 221 // Queue a bytes_consumed write. | 225 // Queue a bytes_consumed write. |
| 222 stream_->WriteOrBufferData(kData2, false, NULL); | 226 stream_->WriteOrBufferData(kData2, false, NULL); |
| 223 | 227 |
| 224 // Make sure we get the tail of the first write followed by the bytes_consumed | 228 // Make sure we get the tail of the first write followed by the bytes_consumed |
| 225 InSequence s; | 229 InSequence s; |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 | 553 |
| 550 // Handle the acks. | 554 // Handle the acks. |
| 551 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); | 555 proxy_delegate->OnAckNotification(1, 2, 3, 4, zero_); |
| 552 EXPECT_CALL(*delegate, OnAckNotification(11, 22, 33, 44, zero_)); | 556 EXPECT_CALL(*delegate, OnAckNotification(11, 22, 33, 44, zero_)); |
| 553 proxy_delegate->OnAckNotification(10, 20, 30, 40, zero_); | 557 proxy_delegate->OnAckNotification(10, 20, 30, 40, zero_); |
| 554 } | 558 } |
| 555 | 559 |
| 556 } // namespace | 560 } // namespace |
| 557 } // namespace test | 561 } // namespace test |
| 558 } // namespace net | 562 } // namespace net |
| OLD | NEW |