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