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 2894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2905 } | 2905 } |
2906 | 2906 |
2907 TEST_P(SpdyFramerTest, SerializeBlocked) { | 2907 TEST_P(SpdyFramerTest, SerializeBlocked) { |
2908 if (spdy_version_ <= SPDY3) { | 2908 if (spdy_version_ <= SPDY3) { |
2909 return; | 2909 return; |
2910 } | 2910 } |
2911 | 2911 |
2912 SpdyFramer framer(spdy_version_); | 2912 SpdyFramer framer(spdy_version_); |
2913 | 2913 |
2914 const char kDescription[] = "BLOCKED frame"; | 2914 const char kDescription[] = "BLOCKED frame"; |
2915 const char kType = static_cast<unsigned char>( | 2915 const unsigned char kType = static_cast<unsigned char>( |
2916 SpdyConstants::SerializeFrameType(spdy_version_, BLOCKED)); | 2916 SpdyConstants::SerializeFrameType(spdy_version_, BLOCKED)); |
2917 const unsigned char kFrameData[] = { | 2917 const unsigned char kFrameData[] = { |
2918 0x00, 0x00, kType, 0x00, | 2918 0x00, 0x00, kType, 0x00, |
2919 0x00, 0x00, 0x00, 0x00, | 2919 0x00, 0x00, 0x00, 0x00, |
2920 }; | 2920 }; |
2921 SpdyBlockedIR blocked_ir(0); | 2921 SpdyBlockedIR blocked_ir(0); |
2922 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); | 2922 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); |
2923 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); | 2923 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); |
2924 } | 2924 } |
2925 | 2925 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2971 } | 2971 } |
2972 | 2972 |
2973 TEST_P(SpdyFramerTest, CreateAltSvc) { | 2973 TEST_P(SpdyFramerTest, CreateAltSvc) { |
2974 if (spdy_version_ <= SPDY3) { | 2974 if (spdy_version_ <= SPDY3) { |
2975 return; | 2975 return; |
2976 } | 2976 } |
2977 | 2977 |
2978 SpdyFramer framer(spdy_version_); | 2978 SpdyFramer framer(spdy_version_); |
2979 | 2979 |
2980 const char kDescription[] = "ALTSVC frame"; | 2980 const char kDescription[] = "ALTSVC frame"; |
2981 const char kType = static_cast<unsigned char>( | 2981 const unsigned char kType = static_cast<unsigned char>( |
2982 SpdyConstants::SerializeFrameType(spdy_version_, ALTSVC)); | 2982 SpdyConstants::SerializeFrameType(spdy_version_, ALTSVC)); |
2983 const unsigned char kFrameData[] = { | 2983 const unsigned char kFrameData[] = { |
2984 0x00, 0x17, kType, 0x00, | 2984 0x00, 0x17, kType, 0x00, |
2985 0x00, 0x00, 0x00, 0x03, | 2985 0x00, 0x00, 0x00, 0x03, |
2986 0x00, 0x00, 0x00, 0x05, | 2986 0x00, 0x00, 0x00, 0x05, |
2987 0x01, 0xbb, 0x00, 0x04, // Port = 443 | 2987 0x01, 0xbb, 0x00, 0x04, // Port = 443 |
2988 'p', 'i', 'd', '1', // Protocol-ID | 2988 'p', 'i', 'd', '1', // Protocol-ID |
2989 0x04, 'h', 'o', 's', | 2989 0x04, 'h', 'o', 's', |
2990 't', 'o', 'r', 'i', | 2990 't', 'o', 'r', 'i', |
2991 'g', 'i', 'n', | 2991 'g', 'i', 'n', |
(...skipping 2225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5217 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 5217 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
5218 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) | 5218 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) |
5219 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 5219 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
5220 } | 5220 } |
5221 | 5221 |
5222 TEST_P(SpdyFramerTest, OnAltSvcBadLengths) { | 5222 TEST_P(SpdyFramerTest, OnAltSvcBadLengths) { |
5223 if (spdy_version_ <= SPDY3) { | 5223 if (spdy_version_ <= SPDY3) { |
5224 return; | 5224 return; |
5225 } | 5225 } |
5226 | 5226 |
5227 const char kType = static_cast<unsigned char>( | 5227 const unsigned char kType = static_cast<unsigned char>( |
5228 SpdyConstants::SerializeFrameType(spdy_version_, ALTSVC)); | 5228 SpdyConstants::SerializeFrameType(spdy_version_, ALTSVC)); |
5229 { | 5229 { |
5230 TestSpdyVisitor visitor(spdy_version_); | 5230 TestSpdyVisitor visitor(spdy_version_); |
5231 SpdyFramer framer(spdy_version_); | 5231 SpdyFramer framer(spdy_version_); |
5232 framer.set_visitor(&visitor); | 5232 framer.set_visitor(&visitor); |
5233 | 5233 |
5234 const unsigned char kFrameDataLargePIDLen[] = { | 5234 const unsigned char kFrameDataLargePIDLen[] = { |
5235 0x00, 0x17, kType, 0x00, | 5235 0x00, 0x17, kType, 0x00, |
5236 0x00, 0x00, 0x00, 0x03, | 5236 0x00, 0x00, 0x00, 0x03, |
5237 0x00, 0x00, 0x00, 0x05, | 5237 0x00, 0x00, 0x00, 0x05, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5390 TestSpdyVisitor visitor(spdy_version_); | 5390 TestSpdyVisitor visitor(spdy_version_); |
5391 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); | 5391 visitor.SimulateInFramer(kFrameData, sizeof(kFrameData)); |
5392 | 5392 |
5393 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); | 5393 EXPECT_EQ(SpdyFramer::SPDY_ERROR, visitor.framer_.state()); |
5394 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, | 5394 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, |
5395 visitor.framer_.error_code()) | 5395 visitor.framer_.error_code()) |
5396 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); | 5396 << SpdyFramer::ErrorCodeToString(visitor.framer_.error_code()); |
5397 } | 5397 } |
5398 | 5398 |
5399 } // namespace net | 5399 } // namespace net |
OLD | NEW |