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/spdy/buffered_spdy_framer.h" | 5 #include "net/spdy/buffered_spdy_framer.h" |
6 | 6 |
7 #include "net/spdy/spdy_test_util_common.h" | 7 #include "net/spdy/spdy_test_util_common.h" |
8 #include "testing/platform_test.h" | 8 #include "testing/platform_test.h" |
9 | 9 |
10 namespace net { | 10 namespace net { |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 TestBufferedSpdyVisitor visitor(spdy_version()); | 219 TestBufferedSpdyVisitor visitor(spdy_version()); |
220 | 220 |
221 visitor.SimulateInFramer( | 221 visitor.SimulateInFramer( |
222 reinterpret_cast<unsigned char*>(control_frame->data()), | 222 reinterpret_cast<unsigned char*>(control_frame->data()), |
223 control_frame->size()); | 223 control_frame->size()); |
224 EXPECT_EQ(0, visitor.error_count_); | 224 EXPECT_EQ(0, visitor.error_count_); |
225 EXPECT_EQ(2, visitor.setting_count_); | 225 EXPECT_EQ(2, visitor.setting_count_); |
226 } | 226 } |
227 | 227 |
228 TEST_P(BufferedSpdyFramerTest, ReadSynStreamHeaderBlock) { | 228 TEST_P(BufferedSpdyFramerTest, ReadSynStreamHeaderBlock) { |
| 229 if (spdy_version() > SPDY3) { |
| 230 // SYN_STREAM not supported in SPDY>3. |
| 231 return; |
| 232 } |
229 SpdyHeaderBlock headers; | 233 SpdyHeaderBlock headers; |
230 headers["aa"] = "vv"; | 234 headers["aa"] = "vv"; |
231 headers["bb"] = "ww"; | 235 headers["bb"] = "ww"; |
232 BufferedSpdyFramer framer(spdy_version(), true); | 236 BufferedSpdyFramer framer(spdy_version(), true); |
233 scoped_ptr<SpdyFrame> control_frame( | 237 scoped_ptr<SpdyFrame> control_frame( |
234 framer.CreateSynStream(1, // stream_id | 238 framer.CreateSynStream(1, // stream_id |
235 0, // associated_stream_id | 239 0, // associated_stream_id |
236 1, // priority | 240 1, // priority |
237 CONTROL_FLAG_NONE, | 241 CONTROL_FLAG_NONE, |
238 &headers)); | 242 &headers)); |
239 EXPECT_TRUE(control_frame.get() != NULL); | 243 EXPECT_TRUE(control_frame.get() != NULL); |
240 | 244 |
241 TestBufferedSpdyVisitor visitor(spdy_version()); | 245 TestBufferedSpdyVisitor visitor(spdy_version()); |
242 visitor.SimulateInFramer( | 246 visitor.SimulateInFramer( |
243 reinterpret_cast<unsigned char*>(control_frame.get()->data()), | 247 reinterpret_cast<unsigned char*>(control_frame.get()->data()), |
244 control_frame.get()->size()); | 248 control_frame.get()->size()); |
245 EXPECT_EQ(0, visitor.error_count_); | 249 EXPECT_EQ(0, visitor.error_count_); |
246 EXPECT_EQ(1, visitor.syn_frame_count_); | 250 EXPECT_EQ(1, visitor.syn_frame_count_); |
247 EXPECT_EQ(0, visitor.syn_reply_frame_count_); | 251 EXPECT_EQ(0, visitor.syn_reply_frame_count_); |
248 EXPECT_EQ(0, visitor.headers_frame_count_); | 252 EXPECT_EQ(0, visitor.headers_frame_count_); |
249 EXPECT_EQ(0, visitor.push_promise_frame_count_); | 253 EXPECT_EQ(0, visitor.push_promise_frame_count_); |
250 EXPECT_TRUE(CompareHeaderBlocks(&headers, &visitor.headers_)); | 254 EXPECT_TRUE(CompareHeaderBlocks(&headers, &visitor.headers_)); |
251 } | 255 } |
252 | 256 |
253 TEST_P(BufferedSpdyFramerTest, ReadSynReplyHeaderBlock) { | 257 TEST_P(BufferedSpdyFramerTest, ReadSynReplyHeaderBlock) { |
254 if (spdy_version() > SPDY3) { | 258 if (spdy_version() > SPDY3) { |
| 259 // SYN_REPLY not supported in SPDY>3. |
255 return; | 260 return; |
256 } | 261 } |
257 SpdyHeaderBlock headers; | 262 SpdyHeaderBlock headers; |
258 headers["alpha"] = "beta"; | 263 headers["alpha"] = "beta"; |
259 headers["gamma"] = "delta"; | 264 headers["gamma"] = "delta"; |
260 BufferedSpdyFramer framer(spdy_version(), true); | 265 BufferedSpdyFramer framer(spdy_version(), true); |
261 scoped_ptr<SpdyFrame> control_frame( | 266 scoped_ptr<SpdyFrame> control_frame( |
262 framer.CreateSynReply(1, // stream_id | 267 framer.CreateSynReply(1, // stream_id |
263 CONTROL_FLAG_NONE, | 268 CONTROL_FLAG_NONE, |
264 &headers)); | 269 &headers)); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 EXPECT_EQ(0, visitor.syn_frame_count_); | 328 EXPECT_EQ(0, visitor.syn_frame_count_); |
324 EXPECT_EQ(0, visitor.syn_reply_frame_count_); | 329 EXPECT_EQ(0, visitor.syn_reply_frame_count_); |
325 EXPECT_EQ(0, visitor.headers_frame_count_); | 330 EXPECT_EQ(0, visitor.headers_frame_count_); |
326 EXPECT_EQ(1, visitor.push_promise_frame_count_); | 331 EXPECT_EQ(1, visitor.push_promise_frame_count_); |
327 EXPECT_TRUE(CompareHeaderBlocks(&headers, &visitor.headers_)); | 332 EXPECT_TRUE(CompareHeaderBlocks(&headers, &visitor.headers_)); |
328 EXPECT_EQ(1u, visitor.header_stream_id_); | 333 EXPECT_EQ(1u, visitor.header_stream_id_); |
329 EXPECT_EQ(2u, visitor.promised_stream_id_); | 334 EXPECT_EQ(2u, visitor.promised_stream_id_); |
330 } | 335 } |
331 | 336 |
332 } // namespace net | 337 } // namespace net |
OLD | NEW |