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 1476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 EXPECT_EQ(0, visitor.headers_frame_count_); | 1487 EXPECT_EQ(0, visitor.headers_frame_count_); |
1488 EXPECT_EQ(arraysize(bytes), static_cast<unsigned>(visitor.data_bytes_)); | 1488 EXPECT_EQ(arraysize(bytes), static_cast<unsigned>(visitor.data_bytes_)); |
1489 EXPECT_EQ(0, visitor.fin_frame_count_); | 1489 EXPECT_EQ(0, visitor.fin_frame_count_); |
1490 EXPECT_EQ(0, visitor.fin_flag_count_); | 1490 EXPECT_EQ(0, visitor.fin_flag_count_); |
1491 EXPECT_EQ(1, visitor.zero_length_data_frame_count_); | 1491 EXPECT_EQ(1, visitor.zero_length_data_frame_count_); |
1492 EXPECT_EQ(1, visitor.data_frame_count_); | 1492 EXPECT_EQ(1, visitor.data_frame_count_); |
1493 } | 1493 } |
1494 | 1494 |
1495 TEST_P(SpdyFramerTest, WindowUpdateFrame) { | 1495 TEST_P(SpdyFramerTest, WindowUpdateFrame) { |
1496 SpdyFramer framer(spdy_version_); | 1496 SpdyFramer framer(spdy_version_); |
1497 scoped_ptr<SpdyWindowUpdateControlFrame> window_update_frame( | 1497 scoped_ptr<SpdyFrame> window_update_frame( |
1498 framer.CreateWindowUpdate(1, 0x12345678)); | 1498 framer.CreateWindowUpdate(1, 0x12345678)); |
1499 | 1499 |
1500 const unsigned char expected_data_frame[] = { | 1500 const unsigned char expected_data_frame[] = { |
1501 0x80, spdy_version_, 0x00, 0x09, | 1501 0x80, spdy_version_, 0x00, 0x09, |
1502 0x00, 0x00, 0x00, 0x08, | 1502 0x00, 0x00, 0x00, 0x08, |
1503 0x00, 0x00, 0x00, 0x01, | 1503 0x00, 0x00, 0x00, 0x01, |
1504 0x12, 0x34, 0x56, 0x78 | 1504 0x12, 0x34, 0x56, 0x78 |
1505 }; | 1505 }; |
1506 | 1506 |
1507 EXPECT_EQ(16u, window_update_frame->size()); | 1507 EXPECT_EQ(framer.GetWindowUpdateSize(), arraysize(expected_data_frame)); |
| 1508 EXPECT_EQ(framer.GetWindowUpdateSize(), |
| 1509 window_update_frame->length() + SpdyFrame::kHeaderSize); |
1508 EXPECT_EQ(0, | 1510 EXPECT_EQ(0, |
1509 memcmp(window_update_frame->data(), expected_data_frame, 16)); | 1511 memcmp(window_update_frame->data(), |
| 1512 expected_data_frame, |
| 1513 framer.GetWindowUpdateSize())); |
1510 } | 1514 } |
1511 | 1515 |
1512 TEST_P(SpdyFramerTest, CreateDataFrame) { | 1516 TEST_P(SpdyFramerTest, CreateDataFrame) { |
1513 SpdyFramer framer(spdy_version_); | 1517 SpdyFramer framer(spdy_version_); |
1514 | 1518 |
1515 { | 1519 { |
1516 const char kDescription[] = "'hello' data frame, no FIN"; | 1520 const char kDescription[] = "'hello' data frame, no FIN"; |
1517 const unsigned char kFrameData[] = { | 1521 const unsigned char kFrameData[] = { |
1518 0x00, 0x00, 0x00, 0x01, | 1522 0x00, 0x00, 0x00, 0x01, |
1519 0x00, 0x00, 0x00, 0x05, | 1523 0x00, 0x00, 0x00, 0x05, |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2383 SpdyFramer framer(spdy_version_); | 2387 SpdyFramer framer(spdy_version_); |
2384 | 2388 |
2385 { | 2389 { |
2386 const char kDescription[] = "WINDOW_UPDATE frame"; | 2390 const char kDescription[] = "WINDOW_UPDATE frame"; |
2387 const unsigned char kFrameData[] = { | 2391 const unsigned char kFrameData[] = { |
2388 0x80, spdy_version_, 0x00, 0x09, | 2392 0x80, spdy_version_, 0x00, 0x09, |
2389 0x00, 0x00, 0x00, 0x08, | 2393 0x00, 0x00, 0x00, 0x08, |
2390 0x00, 0x00, 0x00, 0x01, | 2394 0x00, 0x00, 0x00, 0x01, |
2391 0x00, 0x00, 0x00, 0x01, | 2395 0x00, 0x00, 0x00, 0x01, |
2392 }; | 2396 }; |
2393 scoped_ptr<SpdyWindowUpdateControlFrame> frame( | 2397 scoped_ptr<SpdyFrame> frame( |
2394 framer.CreateWindowUpdate(1, 1)); | 2398 framer.CreateWindowUpdate(1, 1)); |
2395 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); | 2399 CompareFrame(kDescription, *frame, kFrameData, arraysize(kFrameData)); |
2396 } | 2400 } |
2397 | 2401 |
2398 { | 2402 { |
2399 const char kDescription[] = "WINDOW_UPDATE frame with max stream ID"; | 2403 const char kDescription[] = "WINDOW_UPDATE frame with max stream ID"; |
2400 const unsigned char kFrameData[] = { | 2404 const unsigned char kFrameData[] = { |
2401 0x80, spdy_version_, 0x00, 0x09, | 2405 0x80, spdy_version_, 0x00, 0x09, |
2402 0x00, 0x00, 0x00, 0x08, | 2406 0x00, 0x00, 0x00, 0x08, |
2403 0x7f, 0xff, 0xff, 0xff, | 2407 0x7f, 0xff, 0xff, 0xff, |
(...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2860 visitor.SimulateInFramer(kV2FrameData, sizeof(kV2FrameData)); | 2864 visitor.SimulateInFramer(kV2FrameData, sizeof(kV2FrameData)); |
2861 } else { | 2865 } else { |
2862 visitor.SimulateInFramer(kV3FrameData, sizeof(kV3FrameData)); | 2866 visitor.SimulateInFramer(kV3FrameData, sizeof(kV3FrameData)); |
2863 } | 2867 } |
2864 EXPECT_EQ(1, visitor.error_count_); | 2868 EXPECT_EQ(1, visitor.error_count_); |
2865 EXPECT_EQ(1, visitor.setting_count_); | 2869 EXPECT_EQ(1, visitor.setting_count_); |
2866 } | 2870 } |
2867 | 2871 |
2868 TEST_P(SpdyFramerTest, ReadWindowUpdate) { | 2872 TEST_P(SpdyFramerTest, ReadWindowUpdate) { |
2869 SpdyFramer framer(spdy_version_); | 2873 SpdyFramer framer(spdy_version_); |
2870 scoped_ptr<SpdyWindowUpdateControlFrame> control_frame( | 2874 scoped_ptr<SpdyFrame> control_frame( |
2871 framer.CreateWindowUpdate(1, 2)); | 2875 framer.CreateWindowUpdate(1, 2)); |
2872 TestSpdyVisitor visitor(spdy_version_); | 2876 TestSpdyVisitor visitor(spdy_version_); |
2873 visitor.SimulateInFramer( | 2877 visitor.SimulateInFramer( |
2874 reinterpret_cast<unsigned char*>(control_frame->data()), | 2878 reinterpret_cast<unsigned char*>(control_frame->data()), |
2875 control_frame->length() + SpdyControlFrame::kHeaderSize); | 2879 control_frame->length() + SpdyControlFrame::kHeaderSize); |
2876 EXPECT_EQ(1, visitor.last_window_update_stream_); | 2880 EXPECT_EQ(1, visitor.last_window_update_stream_); |
2877 EXPECT_EQ(2, visitor.last_window_update_delta_); | 2881 EXPECT_EQ(2, visitor.last_window_update_delta_); |
2878 } | 2882 } |
2879 | 2883 |
2880 TEST_P(SpdyFramerTest, ReadCredentialFrame) { | 2884 TEST_P(SpdyFramerTest, ReadCredentialFrame) { |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3549 const uint32 kWireFormat = htonl(IsSpdy2() ? 0x04030201 : 0x01020304); | 3553 const uint32 kWireFormat = htonl(IsSpdy2() ? 0x04030201 : 0x01020304); |
3550 | 3554 |
3551 SettingsFlagsAndId id_and_flags = | 3555 SettingsFlagsAndId id_and_flags = |
3552 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); | 3556 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); |
3553 EXPECT_EQ(kId, id_and_flags.id()); | 3557 EXPECT_EQ(kId, id_and_flags.id()); |
3554 EXPECT_EQ(kFlags, id_and_flags.flags()); | 3558 EXPECT_EQ(kFlags, id_and_flags.flags()); |
3555 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); | 3559 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); |
3556 } | 3560 } |
3557 | 3561 |
3558 } // namespace net | 3562 } // namespace net |
OLD | NEW |