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/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "net/spdy/spdy_framer.h" | 10 #include "net/spdy/spdy_framer.h" |
(...skipping 1651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1662 CONTROL_FLAG_FIN, | 1662 CONTROL_FLAG_FIN, |
1663 false, // compress | 1663 false, // compress |
1664 &headers)); | 1664 &headers)); |
1665 CompareFrame(kDescription, | 1665 CompareFrame(kDescription, |
1666 *frame, | 1666 *frame, |
1667 IsSpdy2() ? kV2FrameData : kV3FrameData, | 1667 IsSpdy2() ? kV2FrameData : kV3FrameData, |
1668 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); | 1668 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); |
1669 } | 1669 } |
1670 } | 1670 } |
1671 | 1671 |
| 1672 // TODO(phajdan.jr): Clean up after we no longer need |
| 1673 // to workaround http://crbug.com/139744. |
| 1674 #if !defined(USE_SYSTEM_ZLIB) |
1672 TEST_P(SpdyFramerTest, CreateSynStreamCompressed) { | 1675 TEST_P(SpdyFramerTest, CreateSynStreamCompressed) { |
1673 SpdyFramer framer(spdy_version_); | 1676 SpdyFramer framer(spdy_version_); |
1674 framer.set_enable_compression(true); | 1677 framer.set_enable_compression(true); |
1675 | 1678 |
1676 { | 1679 { |
1677 const char kDescription[] = | 1680 const char kDescription[] = |
1678 "SYN_STREAM frame, low pri, no FIN"; | 1681 "SYN_STREAM frame, low pri, no FIN"; |
1679 | 1682 |
1680 SpdyHeaderBlock headers; | 1683 SpdyHeaderBlock headers; |
1681 headers["bar"] = "foo"; | 1684 headers["bar"] = "foo"; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 0, // credential slot | 1728 0, // credential slot |
1726 CONTROL_FLAG_NONE, | 1729 CONTROL_FLAG_NONE, |
1727 true, // compress | 1730 true, // compress |
1728 &headers)); | 1731 &headers)); |
1729 CompareFrame(kDescription, | 1732 CompareFrame(kDescription, |
1730 *frame, | 1733 *frame, |
1731 IsSpdy2() ? kV2FrameData : kV3FrameData, | 1734 IsSpdy2() ? kV2FrameData : kV3FrameData, |
1732 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); | 1735 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); |
1733 } | 1736 } |
1734 } | 1737 } |
| 1738 #endif // !defined(USE_SYSTEM_ZLIB) |
1735 | 1739 |
1736 TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { | 1740 TEST_P(SpdyFramerTest, CreateSynReplyUncompressed) { |
1737 SpdyFramer framer(spdy_version_); | 1741 SpdyFramer framer(spdy_version_); |
1738 framer.set_enable_compression(false); | 1742 framer.set_enable_compression(false); |
1739 | 1743 |
1740 { | 1744 { |
1741 const char kDescription[] = "SYN_REPLY frame, no FIN"; | 1745 const char kDescription[] = "SYN_REPLY frame, no FIN"; |
1742 | 1746 |
1743 SpdyHeaderBlock headers; | 1747 SpdyHeaderBlock headers; |
1744 headers["bar"] = "foo"; | 1748 headers["bar"] = "foo"; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1850 }; | 1854 }; |
1851 scoped_ptr<SpdyFrame> frame(framer.CreateSynReply( | 1855 scoped_ptr<SpdyFrame> frame(framer.CreateSynReply( |
1852 0x7fffffff, CONTROL_FLAG_FIN, false, &headers)); | 1856 0x7fffffff, CONTROL_FLAG_FIN, false, &headers)); |
1853 CompareFrame(kDescription, | 1857 CompareFrame(kDescription, |
1854 *frame, | 1858 *frame, |
1855 IsSpdy2() ? kV2FrameData : kV3FrameData, | 1859 IsSpdy2() ? kV2FrameData : kV3FrameData, |
1856 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); | 1860 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); |
1857 } | 1861 } |
1858 } | 1862 } |
1859 | 1863 |
| 1864 // TODO(phajdan.jr): Clean up after we no longer need |
| 1865 // to workaround http://crbug.com/139744. |
| 1866 #if !defined(USE_SYSTEM_ZLIB) |
1860 TEST_P(SpdyFramerTest, CreateSynReplyCompressed) { | 1867 TEST_P(SpdyFramerTest, CreateSynReplyCompressed) { |
1861 SpdyFramer framer(spdy_version_); | 1868 SpdyFramer framer(spdy_version_); |
1862 framer.set_enable_compression(true); | 1869 framer.set_enable_compression(true); |
1863 | 1870 |
1864 { | 1871 { |
1865 const char kDescription[] = "SYN_REPLY frame, no FIN"; | 1872 const char kDescription[] = "SYN_REPLY frame, no FIN"; |
1866 | 1873 |
1867 SpdyHeaderBlock headers; | 1874 SpdyHeaderBlock headers; |
1868 headers["bar"] = "foo"; | 1875 headers["bar"] = "foo"; |
1869 headers["foo"] = "bar"; | 1876 headers["foo"] = "bar"; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 0xff, | 1910 0xff, |
1904 }; | 1911 }; |
1905 scoped_ptr<SpdyFrame> frame(framer.CreateSynReply( | 1912 scoped_ptr<SpdyFrame> frame(framer.CreateSynReply( |
1906 1, CONTROL_FLAG_NONE, true, &headers)); | 1913 1, CONTROL_FLAG_NONE, true, &headers)); |
1907 CompareFrame(kDescription, | 1914 CompareFrame(kDescription, |
1908 *frame, | 1915 *frame, |
1909 IsSpdy2() ? kV2FrameData : kV3FrameData, | 1916 IsSpdy2() ? kV2FrameData : kV3FrameData, |
1910 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); | 1917 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); |
1911 } | 1918 } |
1912 } | 1919 } |
| 1920 #endif // !defined(USE_SYSTEM_ZLIB) |
1913 | 1921 |
1914 TEST_P(SpdyFramerTest, CreateRstStream) { | 1922 TEST_P(SpdyFramerTest, CreateRstStream) { |
1915 SpdyFramer framer(spdy_version_); | 1923 SpdyFramer framer(spdy_version_); |
1916 | 1924 |
1917 { | 1925 { |
1918 const char kDescription[] = "RST_STREAM frame"; | 1926 const char kDescription[] = "RST_STREAM frame"; |
1919 const unsigned char kFrameData[] = { | 1927 const unsigned char kFrameData[] = { |
1920 0x80, spdy_version_, 0x00, 0x03, | 1928 0x80, spdy_version_, 0x00, 0x03, |
1921 0x00, 0x00, 0x00, 0x08, | 1929 0x00, 0x00, 0x00, 0x08, |
1922 0x00, 0x00, 0x00, 0x01, | 1930 0x00, 0x00, 0x00, 0x01, |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2242 }; | 2250 }; |
2243 scoped_ptr<SpdyFrame> frame(framer.CreateHeaders( | 2251 scoped_ptr<SpdyFrame> frame(framer.CreateHeaders( |
2244 0x7fffffff, CONTROL_FLAG_FIN, false, &headers)); | 2252 0x7fffffff, CONTROL_FLAG_FIN, false, &headers)); |
2245 CompareFrame(kDescription, | 2253 CompareFrame(kDescription, |
2246 *frame, | 2254 *frame, |
2247 IsSpdy2() ? kV2FrameData : kV3FrameData, | 2255 IsSpdy2() ? kV2FrameData : kV3FrameData, |
2248 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); | 2256 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); |
2249 } | 2257 } |
2250 } | 2258 } |
2251 | 2259 |
| 2260 // TODO(phajdan.jr): Clean up after we no longer need |
| 2261 // to workaround http://crbug.com/139744. |
| 2262 #if !defined(USE_SYSTEM_ZLIB) |
2252 TEST_P(SpdyFramerTest, CreateHeadersCompressed) { | 2263 TEST_P(SpdyFramerTest, CreateHeadersCompressed) { |
2253 SpdyFramer framer(spdy_version_); | 2264 SpdyFramer framer(spdy_version_); |
2254 framer.set_enable_compression(true); | 2265 framer.set_enable_compression(true); |
2255 | 2266 |
2256 { | 2267 { |
2257 const char kDescription[] = "HEADERS frame, no FIN"; | 2268 const char kDescription[] = "HEADERS frame, no FIN"; |
2258 | 2269 |
2259 SpdyHeaderBlock headers; | 2270 SpdyHeaderBlock headers; |
2260 headers["bar"] = "foo"; | 2271 headers["bar"] = "foo"; |
2261 headers["foo"] = "bar"; | 2272 headers["foo"] = "bar"; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2295 0xff, | 2306 0xff, |
2296 }; | 2307 }; |
2297 scoped_ptr<SpdyFrame> frame(framer.CreateHeaders( | 2308 scoped_ptr<SpdyFrame> frame(framer.CreateHeaders( |
2298 1, CONTROL_FLAG_NONE, true, &headers)); | 2309 1, CONTROL_FLAG_NONE, true, &headers)); |
2299 CompareFrame(kDescription, | 2310 CompareFrame(kDescription, |
2300 *frame, | 2311 *frame, |
2301 IsSpdy2() ? kV2FrameData : kV3FrameData, | 2312 IsSpdy2() ? kV2FrameData : kV3FrameData, |
2302 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); | 2313 IsSpdy2() ? arraysize(kV2FrameData) : arraysize(kV3FrameData)); |
2303 } | 2314 } |
2304 } | 2315 } |
| 2316 #endif // !defined(USE_SYSTEM_ZLIB) |
2305 | 2317 |
2306 TEST_P(SpdyFramerTest, CreateWindowUpdate) { | 2318 TEST_P(SpdyFramerTest, CreateWindowUpdate) { |
2307 SpdyFramer framer(spdy_version_); | 2319 SpdyFramer framer(spdy_version_); |
2308 | 2320 |
2309 { | 2321 { |
2310 const char kDescription[] = "WINDOW_UPDATE frame"; | 2322 const char kDescription[] = "WINDOW_UPDATE frame"; |
2311 const unsigned char kFrameData[] = { | 2323 const unsigned char kFrameData[] = { |
2312 0x80, spdy_version_, 0x00, 0x09, | 2324 0x80, spdy_version_, 0x00, 0x09, |
2313 0x00, 0x00, 0x00, 0x08, | 2325 0x00, 0x00, 0x00, 0x08, |
2314 0x00, 0x00, 0x00, 0x01, | 2326 0x00, 0x00, 0x00, 0x01, |
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3171 const uint32 kWireFormat = htonl(IsSpdy2() ? 0x04030201 : 0x01020304); | 3183 const uint32 kWireFormat = htonl(IsSpdy2() ? 0x04030201 : 0x01020304); |
3172 | 3184 |
3173 SettingsFlagsAndId id_and_flags = | 3185 SettingsFlagsAndId id_and_flags = |
3174 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); | 3186 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); |
3175 EXPECT_EQ(kId, id_and_flags.id()); | 3187 EXPECT_EQ(kId, id_and_flags.id()); |
3176 EXPECT_EQ(kFlags, id_and_flags.flags()); | 3188 EXPECT_EQ(kFlags, id_and_flags.flags()); |
3177 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); | 3189 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); |
3178 } | 3190 } |
3179 | 3191 |
3180 } // namespace net | 3192 } // namespace net |
OLD | NEW |