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 <algorithm> | 5 #include <algorithm> |
6 #include <iostream> | 6 #include <iostream> |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 4097 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4108 kPaddingLen + strlen(data_payload), | 4108 kPaddingLen + strlen(data_payload), |
4109 false)); | 4109 false)); |
4110 CHECK_EQ(framer.GetDataFrameMinimumSize(), | 4110 CHECK_EQ(framer.GetDataFrameMinimumSize(), |
4111 framer.ProcessInput(frame->data(), | 4111 framer.ProcessInput(frame->data(), |
4112 framer.GetDataFrameMinimumSize())); | 4112 framer.GetDataFrameMinimumSize())); |
4113 CHECK_EQ(framer.state(), SpdyFramer::SPDY_READ_DATA_FRAME_PADDING_LENGTH); | 4113 CHECK_EQ(framer.state(), SpdyFramer::SPDY_READ_DATA_FRAME_PADDING_LENGTH); |
4114 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); | 4114 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); |
4115 bytes_consumed += framer.GetDataFrameMinimumSize(); | 4115 bytes_consumed += framer.GetDataFrameMinimumSize(); |
4116 | 4116 |
4117 // Send the padding length field. | 4117 // Send the padding length field. |
| 4118 EXPECT_CALL(visitor, OnStreamFrameData(1, nullptr, 1, false)); |
4118 CHECK_EQ(1u, framer.ProcessInput(frame->data() + bytes_consumed, 1)); | 4119 CHECK_EQ(1u, framer.ProcessInput(frame->data() + bytes_consumed, 1)); |
4119 CHECK_EQ(framer.state(), SpdyFramer::SPDY_FORWARD_STREAM_FRAME); | 4120 CHECK_EQ(framer.state(), SpdyFramer::SPDY_FORWARD_STREAM_FRAME); |
4120 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); | 4121 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); |
4121 bytes_consumed += 1; | 4122 bytes_consumed += 1; |
4122 | 4123 |
4123 // Send the first two bytes of the data payload, i.e., "he". | 4124 // Send the first two bytes of the data payload, i.e., "he". |
4124 EXPECT_CALL(visitor, OnStreamFrameData(1, _, 2, false)); | 4125 EXPECT_CALL(visitor, OnStreamFrameData(1, _, 2, false)); |
4125 CHECK_EQ(2u, framer.ProcessInput(frame->data() + bytes_consumed, 2)); | 4126 CHECK_EQ(2u, framer.ProcessInput(frame->data() + bytes_consumed, 2)); |
4126 CHECK_EQ(framer.state(), SpdyFramer::SPDY_FORWARD_STREAM_FRAME); | 4127 CHECK_EQ(framer.state(), SpdyFramer::SPDY_FORWARD_STREAM_FRAME); |
4127 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); | 4128 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); |
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4913 | 4914 |
4914 SpdyDataIR data_ir(1, StringPiece("hello", 5)); | 4915 SpdyDataIR data_ir(1, StringPiece("hello", 5)); |
4915 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 4916 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
4916 SetFrameFlags(frame.get(), flags, spdy_version_); | 4917 SetFrameFlags(frame.get(), flags, spdy_version_); |
4917 | 4918 |
4918 if (flags & ~valid_data_flags) { | 4919 if (flags & ~valid_data_flags) { |
4919 EXPECT_CALL(visitor, OnError(_)); | 4920 EXPECT_CALL(visitor, OnError(_)); |
4920 } else { | 4921 } else { |
4921 EXPECT_CALL(visitor, OnDataFrameHeader(1, 5, flags & DATA_FLAG_FIN)); | 4922 EXPECT_CALL(visitor, OnDataFrameHeader(1, 5, flags & DATA_FLAG_FIN)); |
4922 if (flags & DATA_FLAG_PADDED) { | 4923 if (flags & DATA_FLAG_PADDED) { |
| 4924 EXPECT_CALL(visitor, OnStreamFrameData(_, nullptr, 1, false)); |
4923 // Expect Error since we don't set padded in payload. | 4925 // Expect Error since we don't set padded in payload. |
4924 EXPECT_CALL(visitor, OnError(_)); | 4926 EXPECT_CALL(visitor, OnError(_)); |
4925 } else { | 4927 } else { |
4926 EXPECT_CALL(visitor, OnStreamFrameData(_, _, 5, false)); | 4928 EXPECT_CALL(visitor, OnStreamFrameData(_, _, 5, false)); |
4927 if (flags & DATA_FLAG_FIN) { | 4929 if (flags & DATA_FLAG_FIN) { |
4928 EXPECT_CALL(visitor, OnStreamFrameData(_, _, 0, true)); | 4930 EXPECT_CALL(visitor, OnStreamFrameData(_, _, 0, true)); |
4929 } | 4931 } |
4930 } | 4932 } |
4931 } | 4933 } |
4932 | 4934 |
(...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5935 TestSpdyVisitor visitor(spdy_version_); | 5937 TestSpdyVisitor visitor(spdy_version_); |
5936 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); | 5938 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); |
5937 | 5939 |
5938 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); | 5940 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); |
5939 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, | 5941 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, |
5940 visitor.framer_.error_code()) | 5942 visitor.framer_.error_code()) |
5941 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); | 5943 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); |
5942 } | 5944 } |
5943 | 5945 |
5944 } // namespace net | 5946 } // namespace net |
OLD | NEW |