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/quic/quic_headers_stream.h" | 5 #include "net/quic/quic_headers_stream.h" |
6 | 6 |
7 #include "net/quic/quic_utils.h" | 7 #include "net/quic/quic_utils.h" |
8 #include "net/quic/spdy_utils.h" | 8 #include "net/quic/spdy_utils.h" |
9 #include "net/quic/test_tools/quic_connection_peer.h" | 9 #include "net/quic/test_tools/quic_connection_peer.h" |
10 #include "net/quic/test_tools/quic_session_peer.h" | 10 #include "net/quic/test_tools/quic_session_peer.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 body_("hello world"), | 75 body_("hello world"), |
76 framer_(SPDY3) { | 76 framer_(SPDY3) { |
77 headers_[":version"] = "HTTP/1.1"; | 77 headers_[":version"] = "HTTP/1.1"; |
78 headers_[":status"] = "200 Ok"; | 78 headers_[":status"] = "200 Ok"; |
79 headers_["content-length"] = "11"; | 79 headers_["content-length"] = "11"; |
80 framer_.set_visitor(&visitor_); | 80 framer_.set_visitor(&visitor_); |
81 EXPECT_EQ(QUIC_VERSION_13, session_.connection()->version()); | 81 EXPECT_EQ(QUIC_VERSION_13, session_.connection()->version()); |
82 EXPECT_TRUE(headers_stream_ != NULL); | 82 EXPECT_TRUE(headers_stream_ != NULL); |
83 } | 83 } |
84 | 84 |
85 QuicConsumedData SaveIov(const struct iovec* iov, int count) { | 85 QuicConsumedData SaveIov(const IOVector& data) { |
| 86 const iovec* iov = data.iovec(); |
| 87 int count = data.Capacity(); |
86 for (int i = 0 ; i < count; ++i) { | 88 for (int i = 0 ; i < count; ++i) { |
87 saved_data_.append(static_cast<char*>(iov[i].iov_base), iov[i].iov_len); | 89 saved_data_.append(static_cast<char*>(iov[i].iov_base), iov[i].iov_len); |
88 } | 90 } |
89 return QuicConsumedData(saved_data_.length(), false); | 91 return QuicConsumedData(saved_data_.length(), false); |
90 } | 92 } |
91 | 93 |
92 bool SaveHeaderData(const char* data, int len) { | 94 bool SaveHeaderData(const char* data, int len) { |
93 saved_header_data_.append(data, len); | 95 saved_header_data_.append(data, len); |
94 return true; | 96 return true; |
95 } | 97 } |
(...skipping 11 matching lines...) Expand all Loading... |
107 void WriteHeadersAndExpectSynReply(QuicStreamId stream_id, | 109 void WriteHeadersAndExpectSynReply(QuicStreamId stream_id, |
108 bool fin) { | 110 bool fin) { |
109 WriteHeadersAndCheckData(stream_id, fin, 0, SYN_REPLY); | 111 WriteHeadersAndCheckData(stream_id, fin, 0, SYN_REPLY); |
110 } | 112 } |
111 | 113 |
112 void WriteHeadersAndCheckData(QuicStreamId stream_id, | 114 void WriteHeadersAndCheckData(QuicStreamId stream_id, |
113 bool fin, | 115 bool fin, |
114 QuicPriority priority, | 116 QuicPriority priority, |
115 SpdyFrameType type) { | 117 SpdyFrameType type) { |
116 // Write the headers and capture the outgoing data | 118 // Write the headers and capture the outgoing data |
117 EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, _, _, false, NULL)) | 119 EXPECT_CALL(session_, WritevData(kHeadersStreamId, _, _, false, NULL)) |
118 .WillOnce(WithArgs<1, 2>( | 120 .WillOnce(WithArgs<1>(Invoke(this, &QuicHeadersStreamTest::SaveIov))); |
119 Invoke(this, &QuicHeadersStreamTest::SaveIov))); | |
120 headers_stream_->WriteHeaders(stream_id, headers_, fin); | 121 headers_stream_->WriteHeaders(stream_id, headers_, fin); |
121 | 122 |
122 // Parse the outgoing data and check that it matches was was written. | 123 // Parse the outgoing data and check that it matches was was written. |
123 if (type == SYN_STREAM) { | 124 if (type == SYN_STREAM) { |
124 EXPECT_CALL(visitor_, OnSynStream(stream_id, kNoAssociatedStream, 0, | 125 EXPECT_CALL(visitor_, OnSynStream(stream_id, kNoAssociatedStream, 0, |
125 // priority, | 126 // priority, |
126 fin, kNotUnidirectional)); | 127 fin, kNotUnidirectional)); |
127 } else { | 128 } else { |
128 EXPECT_CALL(visitor_, OnSynReply(stream_id, fin)); | 129 EXPECT_CALL(visitor_, OnSynReply(stream_id, fin)); |
129 } | 130 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 QUIC_INVALID_HEADERS_STREAM_DATA, | 308 QUIC_INVALID_HEADERS_STREAM_DATA, |
308 "SPDY WINDOW_UPDATE frame recevied.")) | 309 "SPDY WINDOW_UPDATE frame recevied.")) |
309 .WillOnce(InvokeWithoutArgs(this, | 310 .WillOnce(InvokeWithoutArgs(this, |
310 &QuicHeadersStreamTest::CloseConnection)); | 311 &QuicHeadersStreamTest::CloseConnection)); |
311 headers_stream_->ProcessRawData(frame->data(), frame->size()); | 312 headers_stream_->ProcessRawData(frame->data(), frame->size()); |
312 } | 313 } |
313 | 314 |
314 } // namespace | 315 } // namespace |
315 } // namespace test | 316 } // namespace test |
316 } // namespace net | 317 } // namespace net |
OLD | NEW |