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/spdy_framer.h" | 5 #include "net/spdy/spdy_framer.h" |
6 | 6 |
7 #include <stdlib.h> | 7 #include <stdlib.h> |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 framer.set_enable_compression(false); | 992 framer.set_enable_compression(false); |
993 scoped_ptr<SpdyFrame> control_frame(frame.take()); | 993 scoped_ptr<SpdyFrame> control_frame(frame.take()); |
994 | 994 |
995 TestSpdyVisitor visitor(spdy_version_); | 995 TestSpdyVisitor visitor(spdy_version_); |
996 visitor.use_compression_ = false; | 996 visitor.use_compression_ = false; |
997 visitor.SimulateInFramer( | 997 visitor.SimulateInFramer( |
998 reinterpret_cast<unsigned char*>(control_frame->data()), | 998 reinterpret_cast<unsigned char*>(control_frame->data()), |
999 control_frame->size()); | 999 control_frame->size()); |
1000 | 1000 |
1001 EXPECT_THAT(visitor.headers_, | 1001 EXPECT_THAT(visitor.headers_, |
1002 testing::ElementsAre(testing::Pair("name", value))); | 1002 testing::ElementsAre(testing::Pair("name", StringPiece(value)))); |
1003 } | 1003 } |
1004 | 1004 |
1005 TEST_P(SpdyFramerTest, BasicCompression) { | 1005 TEST_P(SpdyFramerTest, BasicCompression) { |
1006 if (spdy_version_ > SPDY3) { | 1006 if (spdy_version_ > SPDY3) { |
1007 // Deflate compression doesn't apply to HPACK. | 1007 // Deflate compression doesn't apply to HPACK. |
1008 return; | 1008 return; |
1009 } | 1009 } |
1010 scoped_ptr<TestSpdyVisitor> visitor(new TestSpdyVisitor(spdy_version_)); | 1010 scoped_ptr<TestSpdyVisitor> visitor(new TestSpdyVisitor(spdy_version_)); |
1011 SpdyFramer framer(spdy_version_); | 1011 SpdyFramer framer(spdy_version_); |
1012 framer.set_debug_visitor(visitor.get()); | 1012 framer.set_debug_visitor(visitor.get()); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 SpdyFramerTestUtil::DecompressFrame(&framer, *frame2)); | 1056 SpdyFramerTestUtil::DecompressFrame(&framer, *frame2)); |
1057 size_t uncompressed_size4 = | 1057 size_t uncompressed_size4 = |
1058 frame4->size() - framer.GetSynStreamMinimumSize(); | 1058 frame4->size() - framer.GetSynStreamMinimumSize(); |
1059 size_t compressed_size4 = | 1059 size_t compressed_size4 = |
1060 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize(); | 1060 visitor->last_frame_len_ - framer.GetSynStreamMinimumSize(); |
1061 if (IsSpdy2()) { | 1061 if (IsSpdy2()) { |
1062 EXPECT_EQ(139u, uncompressed_size4); | 1062 EXPECT_EQ(139u, uncompressed_size4); |
1063 #if defined(USE_SYSTEM_ZLIB) | 1063 #if defined(USE_SYSTEM_ZLIB) |
1064 EXPECT_EQ(149u, compressed_size4); | 1064 EXPECT_EQ(149u, compressed_size4); |
1065 #else // !defined(USE_SYSTEM_ZLIB) | 1065 #else // !defined(USE_SYSTEM_ZLIB) |
1066 EXPECT_EQ(101u, compressed_size4); | 1066 EXPECT_EQ(99u, compressed_size4); |
1067 #endif // !defined(USE_SYSTEM_ZLIB) | 1067 #endif // !defined(USE_SYSTEM_ZLIB) |
1068 } else { | 1068 } else { |
1069 EXPECT_EQ(165u, uncompressed_size4); | 1069 EXPECT_EQ(165u, uncompressed_size4); |
1070 #if defined(USE_SYSTEM_ZLIB) | 1070 #if defined(USE_SYSTEM_ZLIB) |
1071 EXPECT_EQ(175u, compressed_size4); | 1071 EXPECT_EQ(175u, compressed_size4); |
1072 #else // !defined(USE_SYSTEM_ZLIB) | 1072 #else // !defined(USE_SYSTEM_ZLIB) |
1073 EXPECT_EQ(102u, compressed_size4); | 1073 EXPECT_EQ(99u, compressed_size4); |
1074 #endif // !defined(USE_SYSTEM_ZLIB) | 1074 #endif // !defined(USE_SYSTEM_ZLIB) |
1075 } | 1075 } |
1076 | 1076 |
1077 EXPECT_EQ(uncompressed_size1, uncompressed_size2); | 1077 EXPECT_EQ(uncompressed_size1, uncompressed_size2); |
1078 EXPECT_EQ(uncompressed_size1, uncompressed_size4); | 1078 EXPECT_EQ(uncompressed_size1, uncompressed_size4); |
1079 EXPECT_EQ(compressed_size2, compressed_size4); | 1079 EXPECT_EQ(compressed_size2, compressed_size4); |
1080 | 1080 |
1081 // Expect frames 3 & 4 to be the same. | 1081 // Expect frames 3 & 4 to be the same. |
1082 CompareFrames("Uncompressed SYN_STREAM", *frame3, *frame4); | 1082 CompareFrames("Uncompressed SYN_STREAM", *frame3, *frame4); |
1083 | 1083 |
(...skipping 5058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6142 | 6142 |
6143 EXPECT_EQ(1, visitor->data_frame_count_); | 6143 EXPECT_EQ(1, visitor->data_frame_count_); |
6144 EXPECT_EQ(strlen(four_score), static_cast<unsigned>(visitor->data_bytes_)); | 6144 EXPECT_EQ(strlen(four_score), static_cast<unsigned>(visitor->data_bytes_)); |
6145 EXPECT_EQ(0, visitor->headers_frame_count_); | 6145 EXPECT_EQ(0, visitor->headers_frame_count_); |
6146 } | 6146 } |
6147 } | 6147 } |
6148 | 6148 |
6149 } // namespace test | 6149 } // namespace test |
6150 | 6150 |
6151 } // namespace net | 6151 } // namespace net |
OLD | NEW |