| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/tools/quic/quic_spdy_client_stream.h" | 5 #include "net/tools/quic/quic_spdy_client_stream.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "net/quic/core/quic_utils.h" | 10 #include "net/quic/core/quic_utils.h" |
| 11 #include "net/quic/core/spdy_utils.h" | 11 #include "net/quic/core/spdy_utils.h" |
| 12 #include "net/quic/platform/api/quic_logging.h" | 12 #include "net/quic/platform/api/quic_logging.h" |
| 13 #include "net/quic/platform/api/quic_socket_address.h" | 13 #include "net/quic/platform/api/quic_socket_address.h" |
| 14 #include "net/quic/platform/api/quic_test.h" | 14 #include "net/quic/platform/api/quic_test.h" |
| 15 #include "net/quic/platform/api/quic_text_utils.h" | 15 #include "net/quic/platform/api/quic_text_utils.h" |
| 16 #include "net/quic/test_tools/crypto_test_utils.h" | 16 #include "net/quic/test_tools/crypto_test_utils.h" |
| 17 #include "net/quic/test_tools/quic_spdy_session_peer.h" | |
| 18 #include "net/quic/test_tools/quic_test_utils.h" | 17 #include "net/quic/test_tools/quic_test_utils.h" |
| 19 #include "net/tools/quic/quic_client_session.h" | 18 #include "net/tools/quic/quic_client_session.h" |
| 20 | 19 |
| 21 using base::IntToString; | 20 using base::IntToString; |
| 22 using std::string; | 21 using std::string; |
| 23 using testing::StrictMock; | 22 using testing::StrictMock; |
| 24 using testing::TestWithParam; | 23 using testing::TestWithParam; |
| 25 | 24 |
| 26 namespace net { | 25 namespace net { |
| 27 namespace test { | 26 namespace test { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 57 : connection_(new StrictMock<MockQuicConnection>(&helper_, | 56 : connection_(new StrictMock<MockQuicConnection>(&helper_, |
| 58 &alarm_factory_, | 57 &alarm_factory_, |
| 59 Perspective::IS_CLIENT)), | 58 Perspective::IS_CLIENT)), |
| 60 session_(connection_, &push_promise_index_), | 59 session_(connection_, &push_promise_index_), |
| 61 body_("hello world") { | 60 body_("hello world") { |
| 62 session_.Initialize(); | 61 session_.Initialize(); |
| 63 | 62 |
| 64 headers_[":status"] = "200"; | 63 headers_[":status"] = "200"; |
| 65 headers_["content-length"] = "11"; | 64 headers_["content-length"] = "11"; |
| 66 | 65 |
| 67 stream_.reset(new QuicSpdyClientStream( | 66 stream_.reset(new QuicSpdyClientStream(kClientDataStreamId1, &session_)); |
| 68 QuicSpdySessionPeer::GetNthClientInitiatedStreamId(session_, 0), | |
| 69 &session_)); | |
| 70 stream_visitor_.reset(new StreamVisitor()); | 67 stream_visitor_.reset(new StreamVisitor()); |
| 71 stream_->set_visitor(stream_visitor_.get()); | 68 stream_->set_visitor(stream_visitor_.get()); |
| 72 } | 69 } |
| 73 | 70 |
| 74 class StreamVisitor : public QuicSpdyClientStream::Visitor { | 71 class StreamVisitor : public QuicSpdyClientStream::Visitor { |
| 75 void OnClose(QuicSpdyStream* stream) override { | 72 void OnClose(QuicSpdyStream* stream) override { |
| 76 QUIC_DVLOG(1) << "stream " << stream->id(); | 73 QUIC_DVLOG(1) << "stream " << stream->id(); |
| 77 } | 74 } |
| 78 }; | 75 }; |
| 79 | 76 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 stream_->OnStreamFrame( | 148 stream_->OnStreamFrame( |
| 152 QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, large_body)); | 149 QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, large_body)); |
| 153 | 150 |
| 154 EXPECT_NE(QUIC_STREAM_NO_ERROR, stream_->stream_error()); | 151 EXPECT_NE(QUIC_STREAM_NO_ERROR, stream_->stream_error()); |
| 155 } | 152 } |
| 156 | 153 |
| 157 TEST_F(QuicSpdyClientStreamTest, TestNoBidirectionalStreaming) { | 154 TEST_F(QuicSpdyClientStreamTest, TestNoBidirectionalStreaming) { |
| 158 if (FLAGS_quic_reloadable_flag_quic_always_enable_bidi_streaming) { | 155 if (FLAGS_quic_reloadable_flag_quic_always_enable_bidi_streaming) { |
| 159 return; | 156 return; |
| 160 } | 157 } |
| 161 QuicStreamFrame frame( | 158 QuicStreamFrame frame(kClientDataStreamId1, false, 3, QuicStringPiece("asd")); |
| 162 QuicSpdySessionPeer::GetNthClientInitiatedStreamId(session_, 0), false, 3, | |
| 163 QuicStringPiece("asd")); | |
| 164 | 159 |
| 165 EXPECT_FALSE(stream_->write_side_closed()); | 160 EXPECT_FALSE(stream_->write_side_closed()); |
| 166 stream_->OnStreamFrame(frame); | 161 stream_->OnStreamFrame(frame); |
| 167 EXPECT_TRUE(stream_->write_side_closed()); | 162 EXPECT_TRUE(stream_->write_side_closed()); |
| 168 } | 163 } |
| 169 | 164 |
| 170 TEST_F(QuicSpdyClientStreamTest, ReceivingTrailers) { | 165 TEST_F(QuicSpdyClientStreamTest, ReceivingTrailers) { |
| 171 // Test that receiving trailing headers, containing a final offset, results in | 166 // Test that receiving trailing headers, containing a final offset, results in |
| 172 // the stream being closed at that byte offset. | 167 // the stream being closed at that byte offset. |
| 173 // Send headers as usual. | 168 // Send headers as usual. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 194 stream_->OnStreamFrame( | 189 stream_->OnStreamFrame( |
| 195 QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, body_)); | 190 QuicStreamFrame(stream_->id(), /*fin=*/false, /*offset=*/0, body_)); |
| 196 if (FLAGS_quic_reloadable_flag_quic_always_enable_bidi_streaming) { | 191 if (FLAGS_quic_reloadable_flag_quic_always_enable_bidi_streaming) { |
| 197 EXPECT_TRUE(stream_->reading_stopped()); | 192 EXPECT_TRUE(stream_->reading_stopped()); |
| 198 } | 193 } |
| 199 } | 194 } |
| 200 | 195 |
| 201 } // namespace | 196 } // namespace |
| 202 } // namespace test | 197 } // namespace test |
| 203 } // namespace net | 198 } // namespace net |
| OLD | NEW |