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 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "net/spdy/spdy_framer.h" | 9 #include "net/spdy/spdy_framer.h" |
10 #include "net/spdy/spdy_protocol.h" | 10 #include "net/spdy/spdy_protocol.h" |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 LOG(ERROR) << "Expected header named '" << it->first | 494 LOG(ERROR) << "Expected header named '" << it->first |
495 << "' to have a value of '" << it->second | 495 << "' to have a value of '" << it->second |
496 << "'. The actual value received was '" << it2->second | 496 << "'. The actual value received was '" << it2->second |
497 << "'." << std::endl; | 497 << "'." << std::endl; |
498 return false; | 498 return false; |
499 } | 499 } |
500 } | 500 } |
501 return true; | 501 return true; |
502 } | 502 } |
503 | 503 |
504 SpdySetting SpdySettingFromWireFormat(uint32 key, uint32 value) { | 504 void AddSpdySettingFromWireFormat(SettingsMap* settings, |
505 return SpdySetting( | 505 uint32 key, |
506 SettingsFlagsAndId::FromWireFormat(spdy_version_, key), | 506 uint32 value) { |
507 value); | 507 SettingsFlagsAndId flags_and_id = |
| 508 SettingsFlagsAndId::FromWireFormat(spdy_version_, key); |
| 509 SpdySettingsIds id = static_cast<SpdySettingsIds>(flags_and_id.id()); |
| 510 SpdySettingsFlags flags = |
| 511 static_cast<SpdySettingsFlags>(flags_and_id.flags()); |
| 512 settings->insert(std::make_pair(id, SettingsFlagsAndValue(flags, value))); |
508 } | 513 } |
509 | 514 |
510 bool IsSpdy2() { return spdy_version_ < 3; } | 515 bool IsSpdy2() { return spdy_version_ < 3; } |
511 | 516 |
512 // Version of SPDY protocol to be used. | 517 // Version of SPDY protocol to be used. |
513 int spdy_version_; | 518 int spdy_version_; |
514 }; | 519 }; |
515 | 520 |
516 | 521 |
517 //----------------------------------------------------------------------------- | 522 //----------------------------------------------------------------------------- |
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1829 } | 1834 } |
1830 } | 1835 } |
1831 | 1836 |
1832 TEST_P(SpdyFramerTest, CreateSettings) { | 1837 TEST_P(SpdyFramerTest, CreateSettings) { |
1833 SpdyFramer framer(spdy_version_); | 1838 SpdyFramer framer(spdy_version_); |
1834 | 1839 |
1835 { | 1840 { |
1836 const char kDescription[] = "Network byte order SETTINGS frame"; | 1841 const char kDescription[] = "Network byte order SETTINGS frame"; |
1837 | 1842 |
1838 uint32 kValue = 0x0a0b0c0d; | 1843 uint32 kValue = 0x0a0b0c0d; |
1839 uint8 kFlags = 0x04; | 1844 SpdySettingsFlags kFlags = static_cast<SpdySettingsFlags>(0x04); |
1840 uint32 kId = 0x030201; | 1845 SpdySettingsIds kId = static_cast<SpdySettingsIds>(0x030201); |
1841 SettingsFlagsAndId idAndFlags(kFlags, kId); | |
1842 | 1846 |
1843 SpdySettings settings; | 1847 SettingsMap settings; |
1844 settings.push_back(SpdySetting(idAndFlags, kValue)); | 1848 settings[kId] = SettingsFlagsAndValue(kFlags, kValue); |
1845 | 1849 |
1846 EXPECT_EQ(kValue, settings.back().second); | 1850 EXPECT_EQ(kFlags, settings[kId].first); |
1847 EXPECT_EQ(kFlags, settings.back().first.flags()); | 1851 EXPECT_EQ(kValue, settings[kId].second); |
1848 EXPECT_EQ(kId, settings.back().first.id()); | |
1849 | 1852 |
1850 const unsigned char kFrameDatav2[] = { | 1853 const unsigned char kFrameDatav2[] = { |
1851 0x80, spdy_version_, 0x00, 0x04, | 1854 0x80, spdy_version_, 0x00, 0x04, |
1852 0x00, 0x00, 0x00, 0x0c, | 1855 0x00, 0x00, 0x00, 0x0c, |
1853 0x00, 0x00, 0x00, 0x01, | 1856 0x00, 0x00, 0x00, 0x01, |
1854 0x01, 0x02, 0x03, 0x04, | 1857 0x01, 0x02, 0x03, 0x04, |
1855 0x0a, 0x0b, 0x0c, 0x0d, | 1858 0x0a, 0x0b, 0x0c, 0x0d, |
1856 }; | 1859 }; |
1857 | 1860 |
1858 const unsigned char kFrameDatav3[] = { | 1861 const unsigned char kFrameDatav3[] = { |
1859 0x80, spdy_version_, 0x00, 0x04, | 1862 0x80, spdy_version_, 0x00, 0x04, |
1860 0x00, 0x00, 0x00, 0x0c, | 1863 0x00, 0x00, 0x00, 0x0c, |
1861 0x00, 0x00, 0x00, 0x01, | 1864 0x00, 0x00, 0x00, 0x01, |
1862 0x04, 0x03, 0x02, 0x01, | 1865 0x04, 0x03, 0x02, 0x01, |
1863 0x0a, 0x0b, 0x0c, 0x0d, | 1866 0x0a, 0x0b, 0x0c, 0x0d, |
1864 }; | 1867 }; |
1865 | 1868 |
1866 scoped_ptr<SpdySettingsControlFrame> frame(framer.CreateSettings(settings)); | 1869 scoped_ptr<SpdySettingsControlFrame> frame(framer.CreateSettings(settings)); |
1867 CompareFrame(kDescription, | 1870 CompareFrame(kDescription, |
1868 *frame, | 1871 *frame, |
1869 (IsSpdy2()) ? kFrameDatav2 : kFrameDatav3, | 1872 (IsSpdy2()) ? kFrameDatav2 : kFrameDatav3, |
1870 arraysize(kFrameDatav3)); // Size is unchanged among versions. | 1873 arraysize(kFrameDatav3)); // Size is unchanged among versions. |
1871 EXPECT_EQ(SpdyFramer::kInvalidStream, | 1874 EXPECT_EQ(SpdyFramer::kInvalidStream, |
1872 SpdyFramer::GetControlFrameStreamId(frame.get())); | 1875 SpdyFramer::GetControlFrameStreamId(frame.get())); |
1873 | 1876 |
1874 // Make sure that ParseSettings also works as advertised. | 1877 // Make sure that ParseSettings also works as advertised. |
1875 SpdySettings parsed_settings; | 1878 SettingsMap parsed_settings; |
1876 EXPECT_TRUE(framer.ParseSettings(frame.get(), &parsed_settings)); | 1879 EXPECT_TRUE(framer.ParseSettings(frame.get(), &parsed_settings)); |
1877 EXPECT_EQ(settings.size(), parsed_settings.size()); | 1880 EXPECT_EQ(settings.size(), parsed_settings.size()); |
1878 EXPECT_EQ(kFlags, parsed_settings.back().first.flags()); | 1881 EXPECT_EQ(kFlags, parsed_settings[kId].first); |
1879 EXPECT_EQ(kId, parsed_settings.back().first.id()); | 1882 EXPECT_EQ(kValue, parsed_settings[kId].second); |
1880 } | 1883 } |
1881 | 1884 |
1882 { | 1885 { |
1883 const char kDescription[] = "Basic SETTINGS frame"; | 1886 const char kDescription[] = "Basic SETTINGS frame"; |
1884 | 1887 |
1885 SpdySettings settings; | 1888 SettingsMap settings; |
1886 settings.push_back( | 1889 AddSpdySettingFromWireFormat( |
1887 SpdySettingFromWireFormat(0x00000000, 0x00000000)); // 1st Setting | 1890 &settings, 0x00000000, 0x00000001); // 1st Setting |
1888 settings.push_back( | 1891 AddSpdySettingFromWireFormat( |
1889 SpdySettingFromWireFormat(0xffffffff, 0x00000001)); // 2nd Setting | 1892 &settings, 0x01000002, 0x00000002); // 2nd Setting |
1890 settings.push_back( | 1893 AddSpdySettingFromWireFormat( |
1891 SpdySettingFromWireFormat(0xff000001, 0x00000002)); // 3rd Setting | 1894 &settings, 0x02000003, 0x00000003); // 3rd Setting |
1892 | 1895 AddSpdySettingFromWireFormat( |
1893 // Duplicates allowed | 1896 &settings, 0x03000004, 0xff000004); // 4th Setting |
1894 settings.push_back( | 1897 AddSpdySettingFromWireFormat( |
1895 SpdySettingFromWireFormat(0x01000002, 0x00000003)); // 4th Setting | 1898 &settings, 0xff000005, 0x00000005); // 5th Setting |
1896 settings.push_back( | 1899 AddSpdySettingFromWireFormat( |
1897 SpdySettingFromWireFormat(0x01000002, 0x00000003)); // 5th Setting | 1900 &settings, 0xffffffff, 0x00000006); // 6th Setting |
1898 | |
1899 settings.push_back( | |
1900 SpdySettingFromWireFormat(0x01000003, 0x000000ff)); // 6th Setting | |
1901 settings.push_back( | |
1902 SpdySettingFromWireFormat(0x01000004, 0xff000001)); // 7th Setting | |
1903 settings.push_back( | |
1904 SpdySettingFromWireFormat(0x01000004, 0xffffffff)); // 8th Setting | |
1905 | 1901 |
1906 const unsigned char kFrameData[] = { | 1902 const unsigned char kFrameData[] = { |
1907 0x80, spdy_version_, 0x00, 0x04, | 1903 0x80, spdy_version_, 0x00, 0x04, |
1908 0x00, 0x00, 0x00, 0x44, | 1904 0x00, 0x00, 0x00, 0x34, |
1909 0x00, 0x00, 0x00, 0x08, | 1905 0x00, 0x00, 0x00, 0x06, |
1910 0x00, 0x00, 0x00, 0x00, // 1st Setting | 1906 0x00, 0x00, 0x00, 0x00, // 1st Setting |
1911 0x00, 0x00, 0x00, 0x00, | |
1912 0xff, 0xff, 0xff, 0xff, // 2nd Setting | |
1913 0x00, 0x00, 0x00, 0x01, | 1907 0x00, 0x00, 0x00, 0x01, |
1914 0x01, 0x00, 0x00, 0xff, // 3rd Setting | 1908 0x02, 0x00, 0x00, 0x01, // 2nd Setting |
1915 0x00, 0x00, 0x00, 0x02, | 1909 0x00, 0x00, 0x00, 0x02, |
1916 0x02, 0x00, 0x00, 0x01, // 4th Setting | 1910 0x03, 0x00, 0x00, 0x02, // 3rd Setting |
1917 0x00, 0x00, 0x00, 0x03, | 1911 0x00, 0x00, 0x00, 0x03, |
1918 0x02, 0x00, 0x00, 0x01, // 5th Setting | 1912 0x04, 0x00, 0x00, 0x03, // 4th Setting |
1919 0x00, 0x00, 0x00, 0x03, | 1913 0xff, 0x00, 0x00, 0x04, |
1920 0x03, 0x00, 0x00, 0x01, // 6th Setting | 1914 0x05, 0x00, 0x00, 0xff, // 5th Setting |
1921 0x00, 0x00, 0x00, 0xff, | 1915 0x00, 0x00, 0x00, 0x05, |
1922 0x04, 0x00, 0x00, 0x01, // 7th Setting | 1916 0xff, 0xff, 0xff, 0xff, // 6th Setting |
1923 0xff, 0x00, 0x00, 0x01, | 1917 0x00, 0x00, 0x00, 0x06, |
1924 0x04, 0x00, 0x00, 0x01, // 8th Setting | |
1925 0xff, 0xff, 0xff, 0xff, | |
1926 }; | 1918 }; |
1927 scoped_ptr<SpdySettingsControlFrame> frame(framer.CreateSettings(settings)); | 1919 scoped_ptr<SpdySettingsControlFrame> frame(framer.CreateSettings(settings)); |
1928 CompareFrame(kDescription, | 1920 CompareFrame(kDescription, |
1929 *frame, | 1921 *frame, |
1930 kFrameData, | 1922 kFrameData, |
1931 arraysize(kFrameData)); | 1923 arraysize(kFrameData)); |
1932 EXPECT_EQ(SpdyFramer::kInvalidStream, | 1924 EXPECT_EQ(SpdyFramer::kInvalidStream, |
1933 SpdyFramer::GetControlFrameStreamId(frame.get())); | 1925 SpdyFramer::GetControlFrameStreamId(frame.get())); |
1934 } | 1926 } |
1935 | 1927 |
1936 { | 1928 { |
1937 const char kDescription[] = "Empty SETTINGS frame"; | 1929 const char kDescription[] = "Empty SETTINGS frame"; |
1938 | 1930 |
1939 SpdySettings settings; | 1931 SettingsMap settings; |
1940 | 1932 |
1941 const unsigned char kFrameData[] = { | 1933 const unsigned char kFrameData[] = { |
1942 0x80, spdy_version_, 0x00, 0x04, | 1934 0x80, spdy_version_, 0x00, 0x04, |
1943 0x00, 0x00, 0x00, 0x04, | 1935 0x00, 0x00, 0x00, 0x04, |
1944 0x00, 0x00, 0x00, 0x00, | 1936 0x00, 0x00, 0x00, 0x00, |
1945 }; | 1937 }; |
1946 scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings)); | 1938 scoped_ptr<SpdyFrame> frame(framer.CreateSettings(settings)); |
1947 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); | 1939 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); |
1948 } | 1940 } |
1949 } | 1941 } |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2299 reinterpret_cast<const unsigned char*>(pad.c_str()), | 2291 reinterpret_cast<const unsigned char*>(pad.c_str()), |
2300 overhead); | 2292 overhead); |
2301 EXPECT_EQ(1, visitor.error_count_); // This generated an error. | 2293 EXPECT_EQ(1, visitor.error_count_); // This generated an error. |
2302 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, | 2294 EXPECT_EQ(SpdyFramer::SPDY_INVALID_CONTROL_FRAME, |
2303 visitor.framer_.error_code()); | 2295 visitor.framer_.error_code()); |
2304 EXPECT_EQ(0, visitor.goaway_count_); // Frame not parsed. | 2296 EXPECT_EQ(0, visitor.goaway_count_); // Frame not parsed. |
2305 } | 2297 } |
2306 | 2298 |
2307 TEST_P(SpdyFramerTest, ReadZeroLenSettingsFrame) { | 2299 TEST_P(SpdyFramerTest, ReadZeroLenSettingsFrame) { |
2308 SpdyFramer framer(spdy_version_); | 2300 SpdyFramer framer(spdy_version_); |
2309 SpdySettings settings; | 2301 SettingsMap settings; |
2310 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); | 2302 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); |
2311 control_frame->set_length(0); | 2303 control_frame->set_length(0); |
2312 TestSpdyVisitor visitor(spdy_version_); | 2304 TestSpdyVisitor visitor(spdy_version_); |
2313 visitor.use_compression_ = false; | 2305 visitor.use_compression_ = false; |
2314 visitor.SimulateInFramer( | 2306 visitor.SimulateInFramer( |
2315 reinterpret_cast<unsigned char*>(control_frame->data()), | 2307 reinterpret_cast<unsigned char*>(control_frame->data()), |
2316 control_frame.get()->length() + SpdyControlFrame::kHeaderSize); | 2308 control_frame.get()->length() + SpdyControlFrame::kHeaderSize); |
2317 // Should generate an error, since zero-len settings frames are unsupported. | 2309 // Should generate an error, since zero-len settings frames are unsupported. |
2318 EXPECT_EQ(1, visitor.error_count_); | 2310 EXPECT_EQ(1, visitor.error_count_); |
2319 } | 2311 } |
2320 | 2312 |
2321 // Tests handling of SETTINGS frames with invalid length. | 2313 // Tests handling of SETTINGS frames with invalid length. |
2322 TEST_P(SpdyFramerTest, ReadBogusLenSettingsFrame) { | 2314 TEST_P(SpdyFramerTest, ReadBogusLenSettingsFrame) { |
2323 SpdyFramer framer(spdy_version_); | 2315 SpdyFramer framer(spdy_version_); |
2324 SpdySettings settings; | 2316 SettingsMap settings; |
2325 // Add a setting to pad the frame so that we don't get a buffer overflow when | 2317 // Add a setting to pad the frame so that we don't get a buffer overflow when |
2326 // calling SimulateInFramer() below. | 2318 // calling SimulateInFramer() below. |
2327 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002)); | 2319 settings[SETTINGS_UPLOAD_BANDWIDTH] = |
| 2320 SettingsFlagsAndValue(SETTINGS_FLAG_NONE, 0x00000002); |
2328 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); | 2321 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); |
2329 control_frame->set_length(5); | 2322 control_frame->set_length(5); |
2330 TestSpdyVisitor visitor(spdy_version_); | 2323 TestSpdyVisitor visitor(spdy_version_); |
2331 visitor.use_compression_ = false; | 2324 visitor.use_compression_ = false; |
2332 visitor.SimulateInFramer( | 2325 visitor.SimulateInFramer( |
2333 reinterpret_cast<unsigned char*>(control_frame->data()), | 2326 reinterpret_cast<unsigned char*>(control_frame->data()), |
2334 control_frame.get()->length() + SpdyControlFrame::kHeaderSize); | 2327 control_frame.get()->length() + SpdyControlFrame::kHeaderSize); |
2335 // Should generate an error, since zero-len settings frames are unsupported. | 2328 // Should generate an error, since zero-len settings frames are unsupported. |
2336 EXPECT_EQ(1, visitor.error_count_); | 2329 EXPECT_EQ(1, visitor.error_count_); |
2337 } | 2330 } |
2338 | 2331 |
2339 // Tests handling of SETTINGS frames larger than the frame buffer size. | 2332 // Tests handling of SETTINGS frames larger than the frame buffer size. |
2340 TEST_P(SpdyFramerTest, ReadLargeSettingsFrame) { | 2333 TEST_P(SpdyFramerTest, ReadLargeSettingsFrame) { |
2341 SpdyFramer framer(spdy_version_); | 2334 SpdyFramer framer(spdy_version_); |
2342 SpdySettings settings; | 2335 SettingsMap settings; |
2343 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002)); | 2336 SpdySettingsFlags flags = SETTINGS_FLAG_NONE; |
2344 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 2), 0x00000003)); | 2337 settings[SETTINGS_UPLOAD_BANDWIDTH] = |
2345 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 3), 0x00000004)); | 2338 SettingsFlagsAndValue(flags, 0x00000002); |
| 2339 settings[SETTINGS_DOWNLOAD_BANDWIDTH] = |
| 2340 SettingsFlagsAndValue(flags, 0x00000003); |
| 2341 settings[SETTINGS_ROUND_TRIP_TIME] = SettingsFlagsAndValue(flags, 0x00000004); |
2346 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); | 2342 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); |
2347 EXPECT_LT(SpdyFramer::kUncompressedControlFrameBufferInitialSize, | 2343 EXPECT_LT(SpdyFramer::kUncompressedControlFrameBufferInitialSize, |
2348 control_frame->length() + SpdyControlFrame::kHeaderSize); | 2344 control_frame->length() + SpdyControlFrame::kHeaderSize); |
2349 TestSpdyVisitor visitor(spdy_version_); | 2345 TestSpdyVisitor visitor(spdy_version_); |
2350 visitor.use_compression_ = false; | 2346 visitor.use_compression_ = false; |
2351 | 2347 |
2352 // Read all at once. | 2348 // Read all at once. |
2353 visitor.SimulateInFramer( | 2349 visitor.SimulateInFramer( |
2354 reinterpret_cast<unsigned char*>(control_frame->data()), | 2350 reinterpret_cast<unsigned char*>(control_frame->data()), |
2355 control_frame->length() + SpdyControlFrame::kHeaderSize); | 2351 control_frame->length() + SpdyControlFrame::kHeaderSize); |
(...skipping 12 matching lines...) Expand all Loading... |
2368 reinterpret_cast<unsigned char*>(control_frame->data() + framed_data), | 2364 reinterpret_cast<unsigned char*>(control_frame->data() + framed_data), |
2369 to_read); | 2365 to_read); |
2370 unframed_data -= to_read; | 2366 unframed_data -= to_read; |
2371 framed_data += to_read; | 2367 framed_data += to_read; |
2372 } | 2368 } |
2373 EXPECT_EQ(0, visitor.error_count_); | 2369 EXPECT_EQ(0, visitor.error_count_); |
2374 EXPECT_EQ(settings.size() * 2, static_cast<unsigned>(visitor.setting_count_)); | 2370 EXPECT_EQ(settings.size() * 2, static_cast<unsigned>(visitor.setting_count_)); |
2375 EXPECT_EQ(2, visitor.settings_frame_count_); | 2371 EXPECT_EQ(2, visitor.settings_frame_count_); |
2376 } | 2372 } |
2377 | 2373 |
2378 // Tests handling of SETTINGS frame with duplicate entries. | |
2379 TEST_P(SpdyFramerTest, ReadDuplicateSettings) { | |
2380 SpdyFramer framer(spdy_version_); | |
2381 SpdySettings settings; | |
2382 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000002)); | |
2383 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000003)); | |
2384 // This last setting should not be processed due to error above. | |
2385 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 3), 0x00000003)); | |
2386 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); | |
2387 TestSpdyVisitor visitor(spdy_version_); | |
2388 visitor.use_compression_ = false; | |
2389 | |
2390 visitor.SimulateInFramer( | |
2391 reinterpret_cast<unsigned char*>(control_frame->data()), | |
2392 control_frame->length() + SpdyControlFrame::kHeaderSize); | |
2393 EXPECT_EQ(1, visitor.error_count_); | |
2394 EXPECT_EQ(1, visitor.setting_count_); | |
2395 EXPECT_EQ(1, visitor.settings_frame_count_); | |
2396 } | |
2397 | |
2398 // Tests handling of SETTINGS frame with entries out of order. | |
2399 TEST_P(SpdyFramerTest, ReadOutOfOrderSettings) { | |
2400 SpdyFramer framer(spdy_version_); | |
2401 SpdySettings settings; | |
2402 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 2), 0x00000002)); | |
2403 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 1), 0x00000003)); | |
2404 // This last setting should not be processed due to error above. | |
2405 settings.push_back(SpdySetting(SettingsFlagsAndId(0, 3), 0x00000003)); | |
2406 scoped_ptr<SpdyFrame> control_frame(framer.CreateSettings(settings)); | |
2407 TestSpdyVisitor visitor(spdy_version_); | |
2408 visitor.use_compression_ = false; | |
2409 | |
2410 visitor.SimulateInFramer( | |
2411 reinterpret_cast<unsigned char*>(control_frame->data()), | |
2412 control_frame->length() + SpdyControlFrame::kHeaderSize); | |
2413 EXPECT_EQ(1, visitor.error_count_); | |
2414 EXPECT_EQ(1, visitor.setting_count_); | |
2415 EXPECT_EQ(1, visitor.settings_frame_count_); | |
2416 } | |
2417 | |
2418 TEST_P(SpdyFramerTest, ReadCredentialFrame) { | 2374 TEST_P(SpdyFramerTest, ReadCredentialFrame) { |
2419 SpdyCredential credential; | 2375 SpdyCredential credential; |
2420 credential.slot = 3; | 2376 credential.slot = 3; |
2421 credential.proof = "proof"; | 2377 credential.proof = "proof"; |
2422 credential.certs.push_back("a cert"); | 2378 credential.certs.push_back("a cert"); |
2423 credential.certs.push_back("another cert"); | 2379 credential.certs.push_back("another cert"); |
2424 credential.certs.push_back("final cert"); | 2380 credential.certs.push_back("final cert"); |
2425 SpdyFramer framer(spdy_version_); | 2381 SpdyFramer framer(spdy_version_); |
2426 scoped_ptr<SpdyFrame> control_frame( | 2382 scoped_ptr<SpdyFrame> control_frame( |
2427 framer.CreateCredentialFrame(credential)); | 2383 framer.CreateCredentialFrame(credential)); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2684 htonl(IsSpdy2() ? 0x04030201 : 0x01020304); | 2640 htonl(IsSpdy2() ? 0x04030201 : 0x01020304); |
2685 | 2641 |
2686 SettingsFlagsAndId id_and_flags = | 2642 SettingsFlagsAndId id_and_flags = |
2687 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); | 2643 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); |
2688 EXPECT_EQ(kId, id_and_flags.id()); | 2644 EXPECT_EQ(kId, id_and_flags.id()); |
2689 EXPECT_EQ(kFlags, id_and_flags.flags()); | 2645 EXPECT_EQ(kFlags, id_and_flags.flags()); |
2690 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); | 2646 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); |
2691 } | 2647 } |
2692 | 2648 |
2693 } // namespace net | 2649 } // namespace net |
OLD | NEW |