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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 framer.CreateSynStream(1, // stream id | 927 framer.CreateSynStream(1, // stream id |
928 0, // associated stream id | 928 0, // associated stream id |
929 1, // priority | 929 1, // priority |
930 0, // credential slot | 930 0, // credential slot |
931 CONTROL_FLAG_NONE, | 931 CONTROL_FLAG_NONE, |
932 true, // compress | 932 true, // compress |
933 &headers)); | 933 &headers)); |
934 if (IsSpdy2()) { | 934 if (IsSpdy2()) { |
935 EXPECT_EQ(139u, visitor->last_uncompressed_size_); | 935 EXPECT_EQ(139u, visitor->last_uncompressed_size_); |
936 #if defined(USE_SYSTEM_ZLIB) | 936 #if defined(USE_SYSTEM_ZLIB) |
937 EXPECT_EQ(93u, visitor->last_compressed_size_); | 937 EXPECT_EQ(155u, visitor->last_compressed_size_); |
938 #else // !defined(USE_SYSTEM_ZLIB) | 938 #else // !defined(USE_SYSTEM_ZLIB) |
939 EXPECT_EQ(135u, visitor->last_compressed_size_); | 939 EXPECT_EQ(135u, visitor->last_compressed_size_); |
940 #endif // !defined(USE_SYSTEM_ZLIB) | 940 #endif // !defined(USE_SYSTEM_ZLIB) |
941 } else { | 941 } else { |
942 EXPECT_EQ(165u, visitor->last_uncompressed_size_); | 942 EXPECT_EQ(165u, visitor->last_uncompressed_size_); |
943 #if defined(USE_SYSTEM_ZLIB) | 943 #if defined(USE_SYSTEM_ZLIB) |
944 EXPECT_EQ(72u, visitor->last_compressed_size_); | 944 EXPECT_EQ(181u, visitor->last_compressed_size_); |
945 #else // !defined(USE_SYSTEM_ZLIB) | 945 #else // !defined(USE_SYSTEM_ZLIB) |
946 EXPECT_EQ(117u, visitor->last_compressed_size_); | 946 EXPECT_EQ(117u, visitor->last_compressed_size_); |
947 #endif // !defined(USE_SYSTEM_ZLIB) | 947 #endif // !defined(USE_SYSTEM_ZLIB) |
948 } | 948 } |
949 scoped_ptr<SpdyFrame> frame2( | 949 scoped_ptr<SpdyFrame> frame2( |
950 framer.CreateSynStream(1, // stream id | 950 framer.CreateSynStream(1, // stream id |
951 0, // associated stream id | 951 0, // associated stream id |
952 1, // priority | 952 1, // priority |
953 0, // credential slot | 953 0, // credential slot |
954 CONTROL_FLAG_NONE, | 954 CONTROL_FLAG_NONE, |
955 true, // compress | 955 true, // compress |
956 &headers)); | 956 &headers)); |
957 | 957 |
958 // Expect the second frame to be more compact than the first. | 958 // Expect the second frame to be more compact than the first. |
959 EXPECT_LE(frame2->size(), frame1->size()); | 959 EXPECT_LE(frame2->size(), frame1->size()); |
960 | 960 |
961 // Decompress the first frame | 961 // Decompress the first frame |
962 scoped_ptr<SpdyFrame> frame3(SpdyFramerTestUtil::DecompressFrame( | 962 scoped_ptr<SpdyFrame> frame3(SpdyFramerTestUtil::DecompressFrame( |
963 &framer, *frame1.get())); | 963 &framer, *frame1.get())); |
964 | 964 |
965 // Decompress the second frame | 965 // Decompress the second frame |
966 visitor.reset(new TestSpdyVisitor(spdy_version_)); | 966 visitor.reset(new TestSpdyVisitor(spdy_version_)); |
967 framer.set_debug_visitor(visitor.get()); | 967 framer.set_debug_visitor(visitor.get()); |
968 scoped_ptr<SpdyFrame> frame4(SpdyFramerTestUtil::DecompressFrame( | 968 scoped_ptr<SpdyFrame> frame4(SpdyFramerTestUtil::DecompressFrame( |
969 &framer, *frame2.get())); | 969 &framer, *frame2.get())); |
970 if (IsSpdy2()) { | 970 if (IsSpdy2()) { |
971 EXPECT_EQ(139u, visitor->last_uncompressed_size_); | 971 EXPECT_EQ(139u, visitor->last_uncompressed_size_); |
972 #if defined(USE_SYSTEM_ZLIB) | 972 #if defined(USE_SYSTEM_ZLIB) |
973 EXPECT_EQ(9u, visitor->last_compressed_size_); | 973 EXPECT_EQ(149u, visitor->last_compressed_size_); |
974 #else // !defined(USE_SYSTEM_ZLIB) | 974 #else // !defined(USE_SYSTEM_ZLIB) |
975 EXPECT_EQ(101u, visitor->last_compressed_size_); | 975 EXPECT_EQ(101u, visitor->last_compressed_size_); |
976 #endif // !defined(USE_SYSTEM_ZLIB) | 976 #endif // !defined(USE_SYSTEM_ZLIB) |
977 } else { | 977 } else { |
978 EXPECT_EQ(165u, visitor->last_uncompressed_size_); | 978 EXPECT_EQ(165u, visitor->last_uncompressed_size_); |
979 #if defined(USE_SYSTEM_ZLIB) | 979 #if defined(USE_SYSTEM_ZLIB) |
980 EXPECT_EQ(9u, visitor->last_compressed_size_); | 980 EXPECT_EQ(175u, visitor->last_compressed_size_); |
981 #else // !defined(USE_SYSTEM_ZLIB) | 981 #else // !defined(USE_SYSTEM_ZLIB) |
982 EXPECT_EQ(102u, visitor->last_compressed_size_); | 982 EXPECT_EQ(102u, visitor->last_compressed_size_); |
983 #endif // !defined(USE_SYSTEM_ZLIB) | 983 #endif // !defined(USE_SYSTEM_ZLIB) |
984 } | 984 } |
985 | 985 |
986 // Expect frames 3 & 4 to be the same. | 986 // Expect frames 3 & 4 to be the same. |
987 CompareFrames("Uncompressed SYN_STREAM", *frame3, *frame4); | 987 CompareFrames("Uncompressed SYN_STREAM", *frame3, *frame4); |
988 | 988 |
989 // Expect frames 3 to be the same as a uncompressed frame created | 989 // Expect frames 3 to be the same as a uncompressed frame created |
990 // from scratch. | 990 // from scratch. |
(...skipping 3142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4133 arraysize(kV3FrameData)); | 4133 arraysize(kV3FrameData)); |
4134 } else { | 4134 } else { |
4135 framer.ProcessInput(reinterpret_cast<const char*>(kV4FrameData), | 4135 framer.ProcessInput(reinterpret_cast<const char*>(kV4FrameData), |
4136 arraysize(kV4FrameData)); | 4136 arraysize(kV4FrameData)); |
4137 } | 4137 } |
4138 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 4138 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
4139 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()); | 4139 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()); |
4140 } | 4140 } |
4141 | 4141 |
4142 } // namespace net | 4142 } // namespace net |
OLD | NEW |