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 5737 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5748 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(altsvc_ir)); | 5748 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(altsvc_ir)); |
5749 framer.ProcessInput(frame->data(), framer.GetAltSvcMinimumSize() + | 5749 framer.ProcessInput(frame->data(), framer.GetAltSvcMinimumSize() + |
5750 altsvc_ir.protocol_id().length() + | 5750 altsvc_ir.protocol_id().length() + |
5751 altsvc_ir.host().length()); | 5751 altsvc_ir.host().length()); |
5752 | 5752 |
5753 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 5753 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
5754 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) | 5754 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) |
5755 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 5755 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
5756 } | 5756 } |
5757 | 5757 |
| 5758 TEST_P(SpdyFramerTest, OnAltSvcEmptyProtocolId) { |
| 5759 if (spdy_version_ <= SPDY3) { |
| 5760 return; |
| 5761 } |
| 5762 |
| 5763 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; |
| 5764 SpdyFramer framer(spdy_version_); |
| 5765 framer.set_visitor(&visitor); |
| 5766 |
| 5767 EXPECT_CALL(visitor, OnError(testing::Eq(&framer))); |
| 5768 |
| 5769 SpdyAltSvcIR altsvc_ir(1); |
| 5770 altsvc_ir.set_max_age(10); |
| 5771 altsvc_ir.set_port(443); |
| 5772 altsvc_ir.set_host("h1"); |
| 5773 altsvc_ir.set_origin("o1"); |
| 5774 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(altsvc_ir)); |
| 5775 framer.ProcessInput(frame->data(), framer.GetAltSvcMinimumSize() + |
| 5776 altsvc_ir.protocol_id().length() + |
| 5777 altsvc_ir.host().length()); |
| 5778 |
| 5779 EXPECT_EQ(SpdyFramer::SPDY_ERROR, framer.state()); |
| 5780 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, framer.error_code()) |
| 5781 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
| 5782 } |
| 5783 |
5758 TEST_P(SpdyFramerTest, OnAltSvcBadLengths) { | 5784 TEST_P(SpdyFramerTest, OnAltSvcBadLengths) { |
5759 if (spdy_version_ <= SPDY3) { | 5785 if (spdy_version_ <= SPDY3) { |
5760 return; | 5786 return; |
5761 } | 5787 } |
5762 | 5788 |
5763 const unsigned char kType = static_cast<unsigned char>( | 5789 const unsigned char kType = static_cast<unsigned char>( |
5764 SpdyConstants::SerializeFrameType(spdy_version_, ALTSVC)); | 5790 SpdyConstants::SerializeFrameType(spdy_version_, ALTSVC)); |
5765 { | 5791 { |
5766 TestSpdyVisitor visitor(spdy_version_); | 5792 TestSpdyVisitor visitor(spdy_version_); |
5767 SpdyFramer framer(spdy_version_); | 5793 SpdyFramer framer(spdy_version_); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5957 TestSpdyVisitor visitor(spdy_version_); | 5983 TestSpdyVisitor visitor(spdy_version_); |
5958 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); | 5984 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); |
5959 | 5985 |
5960 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); | 5986 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); |
5961 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, | 5987 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, |
5962 visitor.framer_.error_code()) | 5988 visitor.framer_.error_code()) |
5963 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); | 5989 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); |
5964 } | 5990 } |
5965 | 5991 |
5966 } // namespace net | 5992 } // namespace net |
OLD | NEW |