| 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 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 const char kValue1[] = "value1"; | 1482 const char kValue1[] = "value1"; |
| 1483 const char kValue2[] = "value2"; | 1483 const char kValue2[] = "value2"; |
| 1484 | 1484 |
| 1485 SpdySynStreamIR syn_stream(1); | 1485 SpdySynStreamIR syn_stream(1); |
| 1486 syn_stream.SetHeader(kHeader1, kValue1); | 1486 syn_stream.SetHeader(kHeader1, kValue1); |
| 1487 syn_stream.SetHeader(kHeader2, kValue2); | 1487 syn_stream.SetHeader(kHeader2, kValue2); |
| 1488 scoped_ptr<SpdyFrame> syn_frame(send_framer.SerializeSynStream(syn_stream)); | 1488 scoped_ptr<SpdyFrame> syn_frame(send_framer.SerializeSynStream(syn_stream)); |
| 1489 EXPECT_TRUE(syn_frame.get() != NULL); | 1489 EXPECT_TRUE(syn_frame.get() != NULL); |
| 1490 | 1490 |
| 1491 StringPiece bytes = "this is a test test test test test!"; | 1491 StringPiece bytes = "this is a test test test test test!"; |
| 1492 net::SpdyDataIR data_ir(1, bytes); | 1492 SpdyDataIR data_ir(1, bytes); |
| 1493 data_ir.set_fin(true); | 1493 data_ir.set_fin(true); |
| 1494 scoped_ptr<SpdyFrame> send_frame(send_framer.SerializeData(data_ir)); | 1494 scoped_ptr<SpdyFrame> send_frame(send_framer.SerializeData(data_ir)); |
| 1495 EXPECT_TRUE(send_frame.get() != NULL); | 1495 EXPECT_TRUE(send_frame.get() != NULL); |
| 1496 | 1496 |
| 1497 // Run the inputs through the framer. | 1497 // Run the inputs through the framer. |
| 1498 TestSpdyVisitor visitor(spdy_version_); | 1498 TestSpdyVisitor visitor(spdy_version_); |
| 1499 visitor.use_compression_ = true; | 1499 visitor.use_compression_ = true; |
| 1500 const unsigned char* data; | 1500 const unsigned char* data; |
| 1501 data = reinterpret_cast<const unsigned char*>(syn_frame->data()); | 1501 data = reinterpret_cast<const unsigned char*>(syn_frame->data()); |
| 1502 visitor.SimulateInFramer(data, syn_frame->size()); | 1502 visitor.SimulateInFramer(data, syn_frame->size()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1526 const char kValue1[] = "value1"; | 1526 const char kValue1[] = "value1"; |
| 1527 const char kValue2[] = "value2"; | 1527 const char kValue2[] = "value2"; |
| 1528 | 1528 |
| 1529 SpdySynStreamIR syn_stream(1); | 1529 SpdySynStreamIR syn_stream(1); |
| 1530 syn_stream.SetHeader(kHeader1, kValue1); | 1530 syn_stream.SetHeader(kHeader1, kValue1); |
| 1531 syn_stream.SetHeader(kHeader2, kValue2); | 1531 syn_stream.SetHeader(kHeader2, kValue2); |
| 1532 scoped_ptr<SpdyFrame> syn_frame(send_framer.SerializeSynStream(syn_stream)); | 1532 scoped_ptr<SpdyFrame> syn_frame(send_framer.SerializeSynStream(syn_stream)); |
| 1533 EXPECT_TRUE(syn_frame.get() != NULL); | 1533 EXPECT_TRUE(syn_frame.get() != NULL); |
| 1534 | 1534 |
| 1535 const char bytes[] = "this is a test test test test test!"; | 1535 const char bytes[] = "this is a test test test test test!"; |
| 1536 net::SpdyDataIR data_ir(1, StringPiece(bytes, arraysize(bytes))); | 1536 SpdyDataIR data_ir(1, StringPiece(bytes, arraysize(bytes))); |
| 1537 data_ir.set_fin(true); | 1537 data_ir.set_fin(true); |
| 1538 scoped_ptr<SpdyFrame> send_frame(send_framer.SerializeData(data_ir)); | 1538 scoped_ptr<SpdyFrame> send_frame(send_framer.SerializeData(data_ir)); |
| 1539 EXPECT_TRUE(send_frame.get() != NULL); | 1539 EXPECT_TRUE(send_frame.get() != NULL); |
| 1540 | 1540 |
| 1541 // Run the inputs through the framer. | 1541 // Run the inputs through the framer. |
| 1542 TestSpdyVisitor visitor(spdy_version_); | 1542 TestSpdyVisitor visitor(spdy_version_); |
| 1543 visitor.use_compression_ = true; | 1543 visitor.use_compression_ = true; |
| 1544 const unsigned char* data; | 1544 const unsigned char* data; |
| 1545 data = reinterpret_cast<const unsigned char*>(syn_frame->data()); | 1545 data = reinterpret_cast<const unsigned char*>(syn_frame->data()); |
| 1546 for (size_t idx = 0; idx < syn_frame->size(); ++idx) { | 1546 for (size_t idx = 0; idx < syn_frame->size(); ++idx) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1560 EXPECT_EQ(arraysize(bytes), static_cast<unsigned>(visitor.data_bytes_)); | 1560 EXPECT_EQ(arraysize(bytes), static_cast<unsigned>(visitor.data_bytes_)); |
| 1561 EXPECT_EQ(0, visitor.fin_frame_count_); | 1561 EXPECT_EQ(0, visitor.fin_frame_count_); |
| 1562 EXPECT_EQ(0, visitor.fin_flag_count_); | 1562 EXPECT_EQ(0, visitor.fin_flag_count_); |
| 1563 EXPECT_EQ(1, visitor.zero_length_data_frame_count_); | 1563 EXPECT_EQ(1, visitor.zero_length_data_frame_count_); |
| 1564 EXPECT_EQ(1, visitor.data_frame_count_); | 1564 EXPECT_EQ(1, visitor.data_frame_count_); |
| 1565 } | 1565 } |
| 1566 | 1566 |
| 1567 TEST_P(SpdyFramerTest, WindowUpdateFrame) { | 1567 TEST_P(SpdyFramerTest, WindowUpdateFrame) { |
| 1568 SpdyFramer framer(spdy_version_); | 1568 SpdyFramer framer(spdy_version_); |
| 1569 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( | 1569 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( |
| 1570 net::SpdyWindowUpdateIR(1, 0x12345678))); | 1570 SpdyWindowUpdateIR(1, 0x12345678))); |
| 1571 | 1571 |
| 1572 const char kDescription[] = "WINDOW_UPDATE frame, stream 1, delta 0x12345678"; | 1572 const char kDescription[] = "WINDOW_UPDATE frame, stream 1, delta 0x12345678"; |
| 1573 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1573 const unsigned char kV3FrameData[] = { // Also applies for V2. |
| 1574 0x80, spdy_version_ch_, 0x00, 0x09, | 1574 0x80, spdy_version_ch_, 0x00, 0x09, |
| 1575 0x00, 0x00, 0x00, 0x08, | 1575 0x00, 0x00, 0x00, 0x08, |
| 1576 0x00, 0x00, 0x00, 0x01, | 1576 0x00, 0x00, 0x00, 0x01, |
| 1577 0x12, 0x34, 0x56, 0x78 | 1577 0x12, 0x34, 0x56, 0x78 |
| 1578 }; | 1578 }; |
| 1579 const unsigned char kV4FrameData[] = { | 1579 const unsigned char kV4FrameData[] = { |
| 1580 0x00, 0x04, 0x08, 0x00, | 1580 0x00, 0x04, 0x08, 0x00, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1778 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1778 const unsigned char kV3FrameData[] = { // Also applies for V2. |
| 1779 0x00, 0x00, 0x00, 0x01, | 1779 0x00, 0x00, 0x00, 0x01, |
| 1780 0x00, 0x00, 0x00, 0x01, | 1780 0x00, 0x00, 0x00, 0x01, |
| 1781 0xff | 1781 0xff |
| 1782 }; | 1782 }; |
| 1783 const unsigned char kV4FrameData[] = { | 1783 const unsigned char kV4FrameData[] = { |
| 1784 0x00, 0x01, 0x00, 0x00, | 1784 0x00, 0x01, 0x00, 0x00, |
| 1785 0x00, 0x00, 0x00, 0x01, | 1785 0x00, 0x00, 0x00, 0x01, |
| 1786 0xff | 1786 0xff |
| 1787 }; | 1787 }; |
| 1788 net::SpdyDataIR data_ir(1, StringPiece("\xff", 1)); | 1788 SpdyDataIR data_ir(1, StringPiece("\xff", 1)); |
| 1789 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1789 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
| 1790 if (IsSpdy4()) { | 1790 if (IsSpdy4()) { |
| 1791 CompareFrame( | 1791 CompareFrame( |
| 1792 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1792 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
| 1793 } else { | 1793 } else { |
| 1794 CompareFrame( | 1794 CompareFrame( |
| 1795 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1795 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
| 1796 } | 1796 } |
| 1797 } | 1797 } |
| 1798 | 1798 |
| 1799 { | 1799 { |
| 1800 const char kDescription[] = "'hello' data frame, with FIN"; | 1800 const char kDescription[] = "'hello' data frame, with FIN"; |
| 1801 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1801 const unsigned char kV3FrameData[] = { // Also applies for V2. |
| 1802 0x00, 0x00, 0x00, 0x01, | 1802 0x00, 0x00, 0x00, 0x01, |
| 1803 0x01, 0x00, 0x00, 0x05, | 1803 0x01, 0x00, 0x00, 0x05, |
| 1804 'h', 'e', 'l', 'l', | 1804 'h', 'e', 'l', 'l', |
| 1805 'o' | 1805 'o' |
| 1806 }; | 1806 }; |
| 1807 const unsigned char kV4FrameData[] = { | 1807 const unsigned char kV4FrameData[] = { |
| 1808 0x00, 0x05, 0x00, 0x01, | 1808 0x00, 0x05, 0x00, 0x01, |
| 1809 0x00, 0x00, 0x00, 0x01, | 1809 0x00, 0x00, 0x00, 0x01, |
| 1810 'h', 'e', 'l', 'l', | 1810 'h', 'e', 'l', 'l', |
| 1811 'o' | 1811 'o' |
| 1812 }; | 1812 }; |
| 1813 net::SpdyDataIR data_ir(1, StringPiece("hello", 5)); | 1813 SpdyDataIR data_ir(1, StringPiece("hello", 5)); |
| 1814 data_ir.set_fin(true); | 1814 data_ir.set_fin(true); |
| 1815 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1815 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
| 1816 if (IsSpdy4()) { | 1816 if (IsSpdy4()) { |
| 1817 CompareFrame( | 1817 CompareFrame( |
| 1818 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1818 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
| 1819 } else { | 1819 } else { |
| 1820 CompareFrame( | 1820 CompareFrame( |
| 1821 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1821 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
| 1822 } | 1822 } |
| 1823 } | 1823 } |
| 1824 | 1824 |
| 1825 { | 1825 { |
| 1826 const char kDescription[] = "Empty data frame"; | 1826 const char kDescription[] = "Empty data frame"; |
| 1827 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1827 const unsigned char kV3FrameData[] = { // Also applies for V2. |
| 1828 0x00, 0x00, 0x00, 0x01, | 1828 0x00, 0x00, 0x00, 0x01, |
| 1829 0x00, 0x00, 0x00, 0x00, | 1829 0x00, 0x00, 0x00, 0x00, |
| 1830 }; | 1830 }; |
| 1831 const unsigned char kV4FrameData[] = { | 1831 const unsigned char kV4FrameData[] = { |
| 1832 0x00, 0x00, 0x00, 0x00, | 1832 0x00, 0x00, 0x00, 0x00, |
| 1833 0x00, 0x00, 0x00, 0x01, | 1833 0x00, 0x00, 0x00, 0x01, |
| 1834 }; | 1834 }; |
| 1835 net::SpdyDataIR data_ir(1, StringPiece()); | 1835 SpdyDataIR data_ir(1, StringPiece()); |
| 1836 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1836 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
| 1837 if (IsSpdy4()) { | 1837 if (IsSpdy4()) { |
| 1838 CompareFrame( | 1838 CompareFrame( |
| 1839 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1839 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
| 1840 } else { | 1840 } else { |
| 1841 CompareFrame( | 1841 CompareFrame( |
| 1842 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1842 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
| 1843 } | 1843 } |
| 1844 } | 1844 } |
| 1845 | 1845 |
| 1846 { | 1846 { |
| 1847 const char kDescription[] = "Data frame with max stream ID"; | 1847 const char kDescription[] = "Data frame with max stream ID"; |
| 1848 const unsigned char kV3FrameData[] = { // Also applies for V2. | 1848 const unsigned char kV3FrameData[] = { // Also applies for V2. |
| 1849 0x7f, 0xff, 0xff, 0xff, | 1849 0x7f, 0xff, 0xff, 0xff, |
| 1850 0x01, 0x00, 0x00, 0x05, | 1850 0x01, 0x00, 0x00, 0x05, |
| 1851 'h', 'e', 'l', 'l', | 1851 'h', 'e', 'l', 'l', |
| 1852 'o' | 1852 'o' |
| 1853 }; | 1853 }; |
| 1854 const unsigned char kV4FrameData[] = { | 1854 const unsigned char kV4FrameData[] = { |
| 1855 0x00, 0x05, 0x00, 0x01, | 1855 0x00, 0x05, 0x00, 0x01, |
| 1856 0x7f, 0xff, 0xff, 0xff, | 1856 0x7f, 0xff, 0xff, 0xff, |
| 1857 'h', 'e', 'l', 'l', | 1857 'h', 'e', 'l', 'l', |
| 1858 'o' | 1858 'o' |
| 1859 }; | 1859 }; |
| 1860 net::SpdyDataIR data_ir(0x7fffffff, "hello"); | 1860 SpdyDataIR data_ir(0x7fffffff, "hello"); |
| 1861 data_ir.set_fin(true); | 1861 data_ir.set_fin(true); |
| 1862 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1862 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
| 1863 if (IsSpdy4()) { | 1863 if (IsSpdy4()) { |
| 1864 CompareFrame( | 1864 CompareFrame( |
| 1865 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 1865 kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
| 1866 } else { | 1866 } else { |
| 1867 CompareFrame( | 1867 CompareFrame( |
| 1868 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 1868 kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
| 1869 } | 1869 } |
| 1870 } | 1870 } |
| 1871 | 1871 |
| 1872 if (!IsSpdy4()) { | 1872 if (!IsSpdy4()) { |
| 1873 // This test does not apply to SPDY 4 because the max frame size is smaller | 1873 // This test does not apply to SPDY 4 because the max frame size is smaller |
| 1874 // than 4MB. | 1874 // than 4MB. |
| 1875 const char kDescription[] = "Large data frame"; | 1875 const char kDescription[] = "Large data frame"; |
| 1876 const int kDataSize = 4 * 1024 * 1024; // 4 MB | 1876 const int kDataSize = 4 * 1024 * 1024; // 4 MB |
| 1877 const string kData(kDataSize, 'A'); | 1877 const string kData(kDataSize, 'A'); |
| 1878 const unsigned char kFrameHeader[] = { | 1878 const unsigned char kFrameHeader[] = { |
| 1879 0x00, 0x00, 0x00, 0x01, | 1879 0x00, 0x00, 0x00, 0x01, |
| 1880 0x01, 0x40, 0x00, 0x00, | 1880 0x01, 0x40, 0x00, 0x00, |
| 1881 }; | 1881 }; |
| 1882 | 1882 |
| 1883 const int kFrameSize = arraysize(kFrameHeader) + kDataSize; | 1883 const int kFrameSize = arraysize(kFrameHeader) + kDataSize; |
| 1884 scoped_ptr<unsigned char[]> expected_frame_data( | 1884 scoped_ptr<unsigned char[]> expected_frame_data( |
| 1885 new unsigned char[kFrameSize]); | 1885 new unsigned char[kFrameSize]); |
| 1886 memcpy(expected_frame_data.get(), kFrameHeader, arraysize(kFrameHeader)); | 1886 memcpy(expected_frame_data.get(), kFrameHeader, arraysize(kFrameHeader)); |
| 1887 memset(expected_frame_data.get() + arraysize(kFrameHeader), 'A', kDataSize); | 1887 memset(expected_frame_data.get() + arraysize(kFrameHeader), 'A', kDataSize); |
| 1888 | 1888 |
| 1889 net::SpdyDataIR data_ir(1, StringPiece(kData.data(), kData.size())); | 1889 SpdyDataIR data_ir(1, StringPiece(kData.data(), kData.size())); |
| 1890 data_ir.set_fin(true); | 1890 data_ir.set_fin(true); |
| 1891 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 1891 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
| 1892 CompareFrame(kDescription, *frame, expected_frame_data.get(), kFrameSize); | 1892 CompareFrame(kDescription, *frame, expected_frame_data.get(), kFrameSize); |
| 1893 } | 1893 } |
| 1894 } | 1894 } |
| 1895 | 1895 |
| 1896 TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { | 1896 TEST_P(SpdyFramerTest, CreateSynStreamUncompressed) { |
| 1897 SpdyFramer framer(spdy_version_); | 1897 SpdyFramer framer(spdy_version_); |
| 1898 framer.set_enable_compression(false); | 1898 framer.set_enable_compression(false); |
| 1899 | 1899 |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2353 0x00, 0x00, 0x00, 0x08, | 2353 0x00, 0x00, 0x00, 0x08, |
| 2354 0x00, 0x00, 0x00, 0x01, | 2354 0x00, 0x00, 0x00, 0x01, |
| 2355 0x00, 0x00, 0x00, 0x01, | 2355 0x00, 0x00, 0x00, 0x01, |
| 2356 }; | 2356 }; |
| 2357 const unsigned char kV4FrameData[] = { | 2357 const unsigned char kV4FrameData[] = { |
| 2358 0x00, 0x07, 0x03, 0x00, | 2358 0x00, 0x07, 0x03, 0x00, |
| 2359 0x00, 0x00, 0x00, 0x01, | 2359 0x00, 0x00, 0x00, 0x01, |
| 2360 0x00, 0x00, 0x00, 0x01, | 2360 0x00, 0x00, 0x00, 0x01, |
| 2361 0x52, 0x53, 0x54 | 2361 0x52, 0x53, 0x54 |
| 2362 }; | 2362 }; |
| 2363 net::SpdyRstStreamIR rst_stream(1, RST_STREAM_PROTOCOL_ERROR, "RST"); | 2363 SpdyRstStreamIR rst_stream(1, RST_STREAM_PROTOCOL_ERROR, "RST"); |
| 2364 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); | 2364 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); |
| 2365 if (IsSpdy4()) { | 2365 if (IsSpdy4()) { |
| 2366 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2366 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
| 2367 } else { | 2367 } else { |
| 2368 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2368 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
| 2369 } | 2369 } |
| 2370 } | 2370 } |
| 2371 | 2371 |
| 2372 { | 2372 { |
| 2373 const char kDescription[] = "RST_STREAM frame with max stream ID"; | 2373 const char kDescription[] = "RST_STREAM frame with max stream ID"; |
| 2374 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2374 const unsigned char kV3FrameData[] = { // Also applies for V2. |
| 2375 0x80, spdy_version_ch_, 0x00, 0x03, | 2375 0x80, spdy_version_ch_, 0x00, 0x03, |
| 2376 0x00, 0x00, 0x00, 0x08, | 2376 0x00, 0x00, 0x00, 0x08, |
| 2377 0x7f, 0xff, 0xff, 0xff, | 2377 0x7f, 0xff, 0xff, 0xff, |
| 2378 0x00, 0x00, 0x00, 0x01, | 2378 0x00, 0x00, 0x00, 0x01, |
| 2379 }; | 2379 }; |
| 2380 const unsigned char kV4FrameData[] = { | 2380 const unsigned char kV4FrameData[] = { |
| 2381 0x00, 0x04, 0x03, 0x00, | 2381 0x00, 0x04, 0x03, 0x00, |
| 2382 0x7f, 0xff, 0xff, 0xff, | 2382 0x7f, 0xff, 0xff, 0xff, |
| 2383 0x00, 0x00, 0x00, 0x01, | 2383 0x00, 0x00, 0x00, 0x01, |
| 2384 }; | 2384 }; |
| 2385 net::SpdyRstStreamIR rst_stream(0x7FFFFFFF, | 2385 SpdyRstStreamIR rst_stream(0x7FFFFFFF, |
| 2386 RST_STREAM_PROTOCOL_ERROR, | 2386 RST_STREAM_PROTOCOL_ERROR, |
| 2387 ""); | 2387 ""); |
| 2388 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); | 2388 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); |
| 2389 if (IsSpdy4()) { | 2389 if (IsSpdy4()) { |
| 2390 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2390 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
| 2391 } else { | 2391 } else { |
| 2392 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2392 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
| 2393 } | 2393 } |
| 2394 } | 2394 } |
| 2395 | 2395 |
| 2396 { | 2396 { |
| 2397 const char kDescription[] = "RST_STREAM frame with max status code"; | 2397 const char kDescription[] = "RST_STREAM frame with max status code"; |
| 2398 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2398 const unsigned char kV3FrameData[] = { // Also applies for V2. |
| 2399 0x80, spdy_version_ch_, 0x00, 0x03, | 2399 0x80, spdy_version_ch_, 0x00, 0x03, |
| 2400 0x00, 0x00, 0x00, 0x08, | 2400 0x00, 0x00, 0x00, 0x08, |
| 2401 0x7f, 0xff, 0xff, 0xff, | 2401 0x7f, 0xff, 0xff, 0xff, |
| 2402 0x00, 0x00, 0x00, 0x06, | 2402 0x00, 0x00, 0x00, 0x06, |
| 2403 }; | 2403 }; |
| 2404 const unsigned char kV4FrameData[] = { | 2404 const unsigned char kV4FrameData[] = { |
| 2405 0x00, 0x04, 0x03, 0x00, | 2405 0x00, 0x04, 0x03, 0x00, |
| 2406 0x7f, 0xff, 0xff, 0xff, | 2406 0x7f, 0xff, 0xff, 0xff, |
| 2407 0x00, 0x00, 0x00, 0x06, | 2407 0x00, 0x00, 0x00, 0x06, |
| 2408 }; | 2408 }; |
| 2409 net::SpdyRstStreamIR rst_stream(0x7FFFFFFF, | 2409 SpdyRstStreamIR rst_stream(0x7FFFFFFF, |
| 2410 RST_STREAM_INTERNAL_ERROR, | 2410 RST_STREAM_INTERNAL_ERROR, |
| 2411 ""); | 2411 ""); |
| 2412 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); | 2412 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); |
| 2413 if (IsSpdy4()) { | 2413 if (IsSpdy4()) { |
| 2414 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2414 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
| 2415 } else { | 2415 } else { |
| 2416 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2416 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
| 2417 } | 2417 } |
| 2418 } | 2418 } |
| 2419 } | 2419 } |
| 2420 | 2420 |
| 2421 TEST_P(SpdyFramerTest, CreateSettings) { | 2421 TEST_P(SpdyFramerTest, CreateSettings) { |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2897 0x00, 0x00, 0x00, 0x08, | 2897 0x00, 0x00, 0x00, 0x08, |
| 2898 0x00, 0x00, 0x00, 0x01, | 2898 0x00, 0x00, 0x00, 0x01, |
| 2899 0x00, 0x00, 0x00, 0x01, | 2899 0x00, 0x00, 0x00, 0x01, |
| 2900 }; | 2900 }; |
| 2901 const unsigned char kV4FrameData[] = { | 2901 const unsigned char kV4FrameData[] = { |
| 2902 0x00, 0x04, 0x08, 0x00, | 2902 0x00, 0x04, 0x08, 0x00, |
| 2903 0x00, 0x00, 0x00, 0x01, | 2903 0x00, 0x00, 0x00, 0x01, |
| 2904 0x00, 0x00, 0x00, 0x01, | 2904 0x00, 0x00, 0x00, 0x01, |
| 2905 }; | 2905 }; |
| 2906 scoped_ptr<SpdyFrame> frame( | 2906 scoped_ptr<SpdyFrame> frame( |
| 2907 framer.SerializeWindowUpdate(net::SpdyWindowUpdateIR(1, 1))); | 2907 framer.SerializeWindowUpdate(SpdyWindowUpdateIR(1, 1))); |
| 2908 if (IsSpdy4()) { | 2908 if (IsSpdy4()) { |
| 2909 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2909 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
| 2910 } else { | 2910 } else { |
| 2911 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2911 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
| 2912 } | 2912 } |
| 2913 } | 2913 } |
| 2914 | 2914 |
| 2915 { | 2915 { |
| 2916 const char kDescription[] = "WINDOW_UPDATE frame with max stream ID"; | 2916 const char kDescription[] = "WINDOW_UPDATE frame with max stream ID"; |
| 2917 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2917 const unsigned char kV3FrameData[] = { // Also applies for V2. |
| 2918 0x80, spdy_version_ch_, 0x00, 0x09, | 2918 0x80, spdy_version_ch_, 0x00, 0x09, |
| 2919 0x00, 0x00, 0x00, 0x08, | 2919 0x00, 0x00, 0x00, 0x08, |
| 2920 0x7f, 0xff, 0xff, 0xff, | 2920 0x7f, 0xff, 0xff, 0xff, |
| 2921 0x00, 0x00, 0x00, 0x01, | 2921 0x00, 0x00, 0x00, 0x01, |
| 2922 }; | 2922 }; |
| 2923 const unsigned char kV4FrameData[] = { | 2923 const unsigned char kV4FrameData[] = { |
| 2924 0x00, 0x04, 0x08, 0x00, | 2924 0x00, 0x04, 0x08, 0x00, |
| 2925 0x7f, 0xff, 0xff, 0xff, | 2925 0x7f, 0xff, 0xff, 0xff, |
| 2926 0x00, 0x00, 0x00, 0x01, | 2926 0x00, 0x00, 0x00, 0x01, |
| 2927 }; | 2927 }; |
| 2928 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( | 2928 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( |
| 2929 net::SpdyWindowUpdateIR(0x7FFFFFFF, 1))); | 2929 SpdyWindowUpdateIR(0x7FFFFFFF, 1))); |
| 2930 if (IsSpdy4()) { | 2930 if (IsSpdy4()) { |
| 2931 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2931 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
| 2932 } else { | 2932 } else { |
| 2933 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2933 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
| 2934 } | 2934 } |
| 2935 } | 2935 } |
| 2936 | 2936 |
| 2937 { | 2937 { |
| 2938 const char kDescription[] = "WINDOW_UPDATE frame with max window delta"; | 2938 const char kDescription[] = "WINDOW_UPDATE frame with max window delta"; |
| 2939 const unsigned char kV3FrameData[] = { // Also applies for V2. | 2939 const unsigned char kV3FrameData[] = { // Also applies for V2. |
| 2940 0x80, spdy_version_ch_, 0x00, 0x09, | 2940 0x80, spdy_version_ch_, 0x00, 0x09, |
| 2941 0x00, 0x00, 0x00, 0x08, | 2941 0x00, 0x00, 0x00, 0x08, |
| 2942 0x00, 0x00, 0x00, 0x01, | 2942 0x00, 0x00, 0x00, 0x01, |
| 2943 0x7f, 0xff, 0xff, 0xff, | 2943 0x7f, 0xff, 0xff, 0xff, |
| 2944 }; | 2944 }; |
| 2945 const unsigned char kV4FrameData[] = { | 2945 const unsigned char kV4FrameData[] = { |
| 2946 0x00, 0x04, 0x08, 0x00, | 2946 0x00, 0x04, 0x08, 0x00, |
| 2947 0x00, 0x00, 0x00, 0x01, | 2947 0x00, 0x00, 0x00, 0x01, |
| 2948 0x7f, 0xff, 0xff, 0xff, | 2948 0x7f, 0xff, 0xff, 0xff, |
| 2949 }; | 2949 }; |
| 2950 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( | 2950 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( |
| 2951 net::SpdyWindowUpdateIR(1, 0x7FFFFFFF))); | 2951 SpdyWindowUpdateIR(1, 0x7FFFFFFF))); |
| 2952 if (IsSpdy4()) { | 2952 if (IsSpdy4()) { |
| 2953 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); | 2953 CompareFrame(kDescription, *frame, kV4FrameData, arraysize(kV4FrameData)); |
| 2954 } else { | 2954 } else { |
| 2955 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); | 2955 CompareFrame(kDescription, *frame, kV3FrameData, arraysize(kV3FrameData)); |
| 2956 } | 2956 } |
| 2957 } | 2957 } |
| 2958 } | 2958 } |
| 2959 | 2959 |
| 2960 TEST_P(SpdyFramerTest, SerializeBlocked) { | 2960 TEST_P(SpdyFramerTest, SerializeBlocked) { |
| 2961 if (spdy_version_ < SPDY4) { | 2961 if (spdy_version_ < SPDY4) { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3181 EXPECT_FALSE(visitor.header_buffer_valid_); | 3181 EXPECT_FALSE(visitor.header_buffer_valid_); |
| 3182 EXPECT_EQ(1, visitor.error_count_); | 3182 EXPECT_EQ(1, visitor.error_count_); |
| 3183 EXPECT_EQ(SpdyFramer::SPDY_CONTROL_PAYLOAD_TOO_LARGE, | 3183 EXPECT_EQ(SpdyFramer::SPDY_CONTROL_PAYLOAD_TOO_LARGE, |
| 3184 visitor.framer_.error_code()) | 3184 visitor.framer_.error_code()) |
| 3185 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 3185 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
| 3186 EXPECT_EQ(0, visitor.syn_frame_count_); | 3186 EXPECT_EQ(0, visitor.syn_frame_count_); |
| 3187 EXPECT_EQ(0u, visitor.header_buffer_length_); | 3187 EXPECT_EQ(0u, visitor.header_buffer_length_); |
| 3188 } | 3188 } |
| 3189 | 3189 |
| 3190 TEST_P(SpdyFramerTest, TooLargeHeadersFrameUsesContinuation) { | 3190 TEST_P(SpdyFramerTest, TooLargeHeadersFrameUsesContinuation) { |
| 3191 if (spdy_version_ < net::SPDY4) { | 3191 if (spdy_version_ < SPDY4) { |
| 3192 return; | 3192 return; |
| 3193 } | 3193 } |
| 3194 SpdyFramer framer(spdy_version_); | 3194 SpdyFramer framer(spdy_version_); |
| 3195 framer.set_enable_compression(false); | 3195 framer.set_enable_compression(false); |
| 3196 SpdyHeadersIR headers(1); | 3196 SpdyHeadersIR headers(1); |
| 3197 | 3197 |
| 3198 // Exact payload length will change with HPACK, but this should be long | 3198 // Exact payload length will change with HPACK, but this should be long |
| 3199 // enough to cause an overflow. | 3199 // enough to cause an overflow. |
| 3200 const size_t kBigValueSize = framer.GetControlFrameBufferMaxSize(); | 3200 const size_t kBigValueSize = framer.GetControlFrameBufferMaxSize(); |
| 3201 string big_value(kBigValueSize, 'x'); | 3201 string big_value(kBigValueSize, 'x'); |
| 3202 headers.SetHeader("aa", big_value.c_str()); | 3202 headers.SetHeader("aa", big_value.c_str()); |
| 3203 scoped_ptr<SpdyFrame> control_frame(framer.SerializeHeaders(headers)); | 3203 scoped_ptr<SpdyFrame> control_frame(framer.SerializeHeaders(headers)); |
| 3204 EXPECT_TRUE(control_frame.get() != NULL); | 3204 EXPECT_TRUE(control_frame.get() != NULL); |
| 3205 EXPECT_GT(control_frame->size(), framer.GetControlFrameBufferMaxSize()); | 3205 EXPECT_GT(control_frame->size(), framer.GetControlFrameBufferMaxSize()); |
| 3206 | 3206 |
| 3207 TestSpdyVisitor visitor(spdy_version_); | 3207 TestSpdyVisitor visitor(spdy_version_); |
| 3208 visitor.SimulateInFramer( | 3208 visitor.SimulateInFramer( |
| 3209 reinterpret_cast<unsigned char*>(control_frame->data()), | 3209 reinterpret_cast<unsigned char*>(control_frame->data()), |
| 3210 control_frame->size()); | 3210 control_frame->size()); |
| 3211 EXPECT_TRUE(visitor.header_buffer_valid_); | 3211 EXPECT_TRUE(visitor.header_buffer_valid_); |
| 3212 EXPECT_EQ(0, visitor.error_count_); | 3212 EXPECT_EQ(0, visitor.error_count_); |
| 3213 EXPECT_EQ(1, visitor.headers_frame_count_); | 3213 EXPECT_EQ(1, visitor.headers_frame_count_); |
| 3214 EXPECT_EQ(1, visitor.continuation_count_); | 3214 EXPECT_EQ(1, visitor.continuation_count_); |
| 3215 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); | 3215 EXPECT_EQ(1, visitor.zero_length_control_frame_header_data_count_); |
| 3216 } | 3216 } |
| 3217 | 3217 |
| 3218 TEST_P(SpdyFramerTest, TooLargePushPromiseFrameUsesContinuation) { | 3218 TEST_P(SpdyFramerTest, TooLargePushPromiseFrameUsesContinuation) { |
| 3219 if (spdy_version_ < net::SPDY4) { | 3219 if (spdy_version_ < SPDY4) { |
| 3220 return; | 3220 return; |
| 3221 } | 3221 } |
| 3222 SpdyFramer framer(spdy_version_); | 3222 SpdyFramer framer(spdy_version_); |
| 3223 framer.set_enable_compression(false); | 3223 framer.set_enable_compression(false); |
| 3224 SpdyPushPromiseIR push_promise(1, 2); | 3224 SpdyPushPromiseIR push_promise(1, 2); |
| 3225 | 3225 |
| 3226 // Exact payload length will change with HPACK, but this should be long | 3226 // Exact payload length will change with HPACK, but this should be long |
| 3227 // enough to cause an overflow. | 3227 // enough to cause an overflow. |
| 3228 const size_t kBigValueSize = framer.GetControlFrameBufferMaxSize(); | 3228 const size_t kBigValueSize = framer.GetControlFrameBufferMaxSize(); |
| 3229 string big_value(kBigValueSize, 'x'); | 3229 string big_value(kBigValueSize, 'x'); |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3654 // Send rest of the padding payload. | 3654 // Send rest of the padding payload. |
| 3655 EXPECT_CALL(visitor, OnStreamFrameData(1, NULL, 410, false)); | 3655 EXPECT_CALL(visitor, OnStreamFrameData(1, NULL, 410, false)); |
| 3656 CHECK_EQ(410u, framer.ProcessInput(frame->data() + bytes_consumed, 410)); | 3656 CHECK_EQ(410u, framer.ProcessInput(frame->data() + bytes_consumed, 410)); |
| 3657 CHECK_EQ(framer.state(), SpdyFramer::SPDY_RESET); | 3657 CHECK_EQ(framer.state(), SpdyFramer::SPDY_RESET); |
| 3658 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); | 3658 CHECK_EQ(framer.error_code(), SpdyFramer::SPDY_NO_ERROR); |
| 3659 } | 3659 } |
| 3660 | 3660 |
| 3661 TEST_P(SpdyFramerTest, ReadWindowUpdate) { | 3661 TEST_P(SpdyFramerTest, ReadWindowUpdate) { |
| 3662 SpdyFramer framer(spdy_version_); | 3662 SpdyFramer framer(spdy_version_); |
| 3663 scoped_ptr<SpdyFrame> control_frame( | 3663 scoped_ptr<SpdyFrame> control_frame( |
| 3664 framer.SerializeWindowUpdate(net::SpdyWindowUpdateIR(1, 2))); | 3664 framer.SerializeWindowUpdate(SpdyWindowUpdateIR(1, 2))); |
| 3665 TestSpdyVisitor visitor(spdy_version_); | 3665 TestSpdyVisitor visitor(spdy_version_); |
| 3666 visitor.SimulateInFramer( | 3666 visitor.SimulateInFramer( |
| 3667 reinterpret_cast<unsigned char*>(control_frame->data()), | 3667 reinterpret_cast<unsigned char*>(control_frame->data()), |
| 3668 control_frame->size()); | 3668 control_frame->size()); |
| 3669 EXPECT_EQ(1u, visitor.last_window_update_stream_); | 3669 EXPECT_EQ(1u, visitor.last_window_update_stream_); |
| 3670 EXPECT_EQ(2u, visitor.last_window_update_delta_); | 3670 EXPECT_EQ(2u, visitor.last_window_update_delta_); |
| 3671 } | 3671 } |
| 3672 | 3672 |
| 3673 TEST_P(SpdyFramerTest, ReceiveCredentialFrame) { | 3673 TEST_P(SpdyFramerTest, ReceiveCredentialFrame) { |
| 3674 if (!IsSpdy3()) { | 3674 if (!IsSpdy3()) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3718 't', 0x00, 0x00, 0x00, | 3718 't', 0x00, 0x00, 0x00, |
| 3719 0x0A, 'f', 'i', 'n', | 3719 0x0A, 'f', 'i', 'n', |
| 3720 'a', 'l', ' ', 'c', | 3720 'a', 'l', ' ', 'c', |
| 3721 'e', 'r', 't', | 3721 'e', 'r', 't', |
| 3722 }; | 3722 }; |
| 3723 TestSpdyVisitor visitor(spdy_version_); | 3723 TestSpdyVisitor visitor(spdy_version_); |
| 3724 visitor.use_compression_ = false; | 3724 visitor.use_compression_ = false; |
| 3725 string multiple_frame_data(reinterpret_cast<const char*>(kV3FrameData), | 3725 string multiple_frame_data(reinterpret_cast<const char*>(kV3FrameData), |
| 3726 arraysize(kV3FrameData)); | 3726 arraysize(kV3FrameData)); |
| 3727 scoped_ptr<SpdyFrame> control_frame( | 3727 scoped_ptr<SpdyFrame> control_frame( |
| 3728 framer.SerializeWindowUpdate(net::SpdyWindowUpdateIR(1, 2))); | 3728 framer.SerializeWindowUpdate(SpdyWindowUpdateIR(1, 2))); |
| 3729 multiple_frame_data.append(string(control_frame->data(), | 3729 multiple_frame_data.append(string(control_frame->data(), |
| 3730 control_frame->size())); | 3730 control_frame->size())); |
| 3731 visitor.SimulateInFramer( | 3731 visitor.SimulateInFramer( |
| 3732 reinterpret_cast<unsigned const char*>(multiple_frame_data.data()), | 3732 reinterpret_cast<unsigned const char*>(multiple_frame_data.data()), |
| 3733 multiple_frame_data.length()); | 3733 multiple_frame_data.length()); |
| 3734 EXPECT_EQ(0, visitor.error_count_); | 3734 EXPECT_EQ(0, visitor.error_count_); |
| 3735 EXPECT_EQ(1u, visitor.last_window_update_stream_); | 3735 EXPECT_EQ(1u, visitor.last_window_update_stream_); |
| 3736 EXPECT_EQ(2u, visitor.last_window_update_delta_); | 3736 EXPECT_EQ(2u, visitor.last_window_update_delta_); |
| 3737 } | 3737 } |
| 3738 | 3738 |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4282 return; | 4282 return; |
| 4283 } | 4283 } |
| 4284 | 4284 |
| 4285 for (int flags = 0; flags < 256; ++flags) { | 4285 for (int flags = 0; flags < 256; ++flags) { |
| 4286 SCOPED_TRACE(testing::Message() << "Flags " << flags); | 4286 SCOPED_TRACE(testing::Message() << "Flags " << flags); |
| 4287 | 4287 |
| 4288 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; | 4288 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; |
| 4289 SpdyFramer framer(spdy_version_); | 4289 SpdyFramer framer(spdy_version_); |
| 4290 framer.set_visitor(&visitor); | 4290 framer.set_visitor(&visitor); |
| 4291 | 4291 |
| 4292 net::SpdyDataIR data_ir(1, StringPiece("hello", 5)); | 4292 SpdyDataIR data_ir(1, StringPiece("hello", 5)); |
| 4293 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 4293 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
| 4294 SetFrameFlags(frame.get(), flags, spdy_version_); | 4294 SetFrameFlags(frame.get(), flags, spdy_version_); |
| 4295 | 4295 |
| 4296 if (flags & ~DATA_FLAG_FIN) { | 4296 if (flags & ~DATA_FLAG_FIN) { |
| 4297 EXPECT_CALL(visitor, OnError(_)); | 4297 EXPECT_CALL(visitor, OnError(_)); |
| 4298 } else { | 4298 } else { |
| 4299 EXPECT_CALL(visitor, OnDataFrameHeader(1, 5, flags & DATA_FLAG_FIN)); | 4299 EXPECT_CALL(visitor, OnDataFrameHeader(1, 5, flags & DATA_FLAG_FIN)); |
| 4300 EXPECT_CALL(visitor, OnStreamFrameData(_, _, 5, false)); | 4300 EXPECT_CALL(visitor, OnStreamFrameData(_, _, 5, false)); |
| 4301 if (flags & DATA_FLAG_FIN) { | 4301 if (flags & DATA_FLAG_FIN) { |
| 4302 EXPECT_CALL(visitor, OnStreamFrameData(_, _, 0, true)); | 4302 EXPECT_CALL(visitor, OnStreamFrameData(_, _, 0, true)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 4325 uint8 valid_data_flags = DATA_FLAG_FIN | DATA_FLAG_END_SEGMENT | | 4325 uint8 valid_data_flags = DATA_FLAG_FIN | DATA_FLAG_END_SEGMENT | |
| 4326 DATA_FLAG_PAD_LOW | DATA_FLAG_PAD_HIGH; | 4326 DATA_FLAG_PAD_LOW | DATA_FLAG_PAD_HIGH; |
| 4327 | 4327 |
| 4328 for (int flags = 0; flags < 256; ++flags) { | 4328 for (int flags = 0; flags < 256; ++flags) { |
| 4329 SCOPED_TRACE(testing::Message() << "Flags " << flags); | 4329 SCOPED_TRACE(testing::Message() << "Flags " << flags); |
| 4330 | 4330 |
| 4331 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; | 4331 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; |
| 4332 SpdyFramer framer(spdy_version_); | 4332 SpdyFramer framer(spdy_version_); |
| 4333 framer.set_visitor(&visitor); | 4333 framer.set_visitor(&visitor); |
| 4334 | 4334 |
| 4335 net::SpdyDataIR data_ir(1, StringPiece("hello", 5)); | 4335 SpdyDataIR data_ir(1, StringPiece("hello", 5)); |
| 4336 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); | 4336 scoped_ptr<SpdyFrame> frame(framer.SerializeData(data_ir)); |
| 4337 SetFrameFlags(frame.get(), flags, spdy_version_); | 4337 SetFrameFlags(frame.get(), flags, spdy_version_); |
| 4338 | 4338 |
| 4339 if (flags & ~valid_data_flags) { | 4339 if (flags & ~valid_data_flags) { |
| 4340 EXPECT_CALL(visitor, OnError(_)); | 4340 EXPECT_CALL(visitor, OnError(_)); |
| 4341 } else { | 4341 } else { |
| 4342 EXPECT_CALL(visitor, OnDataFrameHeader(1, 5, flags & DATA_FLAG_FIN)); | 4342 EXPECT_CALL(visitor, OnDataFrameHeader(1, 5, flags & DATA_FLAG_FIN)); |
| 4343 if ((flags & DATA_FLAG_PAD_LOW) || (flags & DATA_FLAG_PAD_HIGH)) { | 4343 if ((flags & DATA_FLAG_PAD_LOW) || (flags & DATA_FLAG_PAD_HIGH)) { |
| 4344 // Expect Error since we don't set pad_high and pad_low in payload. | 4344 // Expect Error since we don't set pad_high and pad_low in payload. |
| 4345 EXPECT_CALL(visitor, OnError(_)); | 4345 EXPECT_CALL(visitor, OnError(_)); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4484 } | 4484 } |
| 4485 | 4485 |
| 4486 TEST_P(SpdyFramerTest, RstStreamFrameFlags) { | 4486 TEST_P(SpdyFramerTest, RstStreamFrameFlags) { |
| 4487 for (int flags = 0; flags < 256; ++flags) { | 4487 for (int flags = 0; flags < 256; ++flags) { |
| 4488 SCOPED_TRACE(testing::Message() << "Flags " << flags); | 4488 SCOPED_TRACE(testing::Message() << "Flags " << flags); |
| 4489 | 4489 |
| 4490 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; | 4490 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; |
| 4491 SpdyFramer framer(spdy_version_); | 4491 SpdyFramer framer(spdy_version_); |
| 4492 framer.set_visitor(&visitor); | 4492 framer.set_visitor(&visitor); |
| 4493 | 4493 |
| 4494 net::SpdyRstStreamIR rst_stream(13, RST_STREAM_CANCEL, ""); | 4494 SpdyRstStreamIR rst_stream(13, RST_STREAM_CANCEL, ""); |
| 4495 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); | 4495 scoped_ptr<SpdyFrame> frame(framer.SerializeRstStream(rst_stream)); |
| 4496 SetFrameFlags(frame.get(), flags, spdy_version_); | 4496 SetFrameFlags(frame.get(), flags, spdy_version_); |
| 4497 | 4497 |
| 4498 if (flags != 0) { | 4498 if (flags != 0) { |
| 4499 EXPECT_CALL(visitor, OnError(_)); | 4499 EXPECT_CALL(visitor, OnError(_)); |
| 4500 } else { | 4500 } else { |
| 4501 EXPECT_CALL(visitor, OnRstStream(13, RST_STREAM_CANCEL)); | 4501 EXPECT_CALL(visitor, OnRstStream(13, RST_STREAM_CANCEL)); |
| 4502 } | 4502 } |
| 4503 | 4503 |
| 4504 framer.ProcessInput(frame->data(), frame->size()); | 4504 framer.ProcessInput(frame->data(), frame->size()); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4729 | 4729 |
| 4730 TEST_P(SpdyFramerTest, WindowUpdateFrameFlags) { | 4730 TEST_P(SpdyFramerTest, WindowUpdateFrameFlags) { |
| 4731 for (int flags = 0; flags < 256; ++flags) { | 4731 for (int flags = 0; flags < 256; ++flags) { |
| 4732 SCOPED_TRACE(testing::Message() << "Flags " << flags); | 4732 SCOPED_TRACE(testing::Message() << "Flags " << flags); |
| 4733 | 4733 |
| 4734 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; | 4734 testing::StrictMock<test::MockSpdyFramerVisitor> visitor; |
| 4735 SpdyFramer framer(spdy_version_); | 4735 SpdyFramer framer(spdy_version_); |
| 4736 framer.set_visitor(&visitor); | 4736 framer.set_visitor(&visitor); |
| 4737 | 4737 |
| 4738 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( | 4738 scoped_ptr<SpdyFrame> frame(framer.SerializeWindowUpdate( |
| 4739 net::SpdyWindowUpdateIR(4, 1024))); | 4739 SpdyWindowUpdateIR(4, 1024))); |
| 4740 SetFrameFlags(frame.get(), flags, spdy_version_); | 4740 SetFrameFlags(frame.get(), flags, spdy_version_); |
| 4741 | 4741 |
| 4742 if (flags != 0) { | 4742 if (flags != 0) { |
| 4743 EXPECT_CALL(visitor, OnError(_)); | 4743 EXPECT_CALL(visitor, OnError(_)); |
| 4744 } else { | 4744 } else { |
| 4745 EXPECT_CALL(visitor, OnWindowUpdate(4, 1024)); | 4745 EXPECT_CALL(visitor, OnWindowUpdate(4, 1024)); |
| 4746 } | 4746 } |
| 4747 | 4747 |
| 4748 framer.ProcessInput(frame->data(), frame->size()); | 4748 framer.ProcessInput(frame->data(), frame->size()); |
| 4749 if (flags != 0) { | 4749 if (flags != 0) { |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5028 SpdyBlockedIR blocked_ir(0); | 5028 SpdyBlockedIR blocked_ir(0); |
| 5029 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); | 5029 scoped_ptr<SpdySerializedFrame> frame(framer.SerializeFrame(blocked_ir)); |
| 5030 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); | 5030 framer.ProcessInput(frame->data(), framer.GetBlockedSize()); |
| 5031 | 5031 |
| 5032 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 5032 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
| 5033 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) | 5033 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()) |
| 5034 << SpdyFramer::ErrorCodeToString(framer.error_code()); | 5034 << SpdyFramer::ErrorCodeToString(framer.error_code()); |
| 5035 } | 5035 } |
| 5036 | 5036 |
| 5037 } // namespace net | 5037 } // namespace net |
| OLD | NEW |