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 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 | 674 |
675 // Version of SPDY protocol to be used. | 675 // Version of SPDY protocol to be used. |
676 unsigned char spdy_version_; | 676 unsigned char spdy_version_; |
677 }; | 677 }; |
678 | 678 |
679 // All tests are run with two different SPDY versions: SPDY/2 and SPDY/3. | 679 // All tests are run with two different SPDY versions: SPDY/2 and SPDY/3. |
680 INSTANTIATE_TEST_CASE_P(SpdyFramerTests, | 680 INSTANTIATE_TEST_CASE_P(SpdyFramerTests, |
681 SpdyFramerTest, | 681 SpdyFramerTest, |
682 ::testing::Values(SPDY2, SPDY3)); | 682 ::testing::Values(SPDY2, SPDY3)); |
683 | 683 |
684 TEST_P(SpdyFramerTest, IsCompressible) { | |
685 SpdyFramer framer(spdy_version_); | |
686 for (SpdyControlType type = SYN_STREAM; | |
687 type < NUM_CONTROL_FRAME_TYPES; | |
688 type = static_cast<SpdyControlType>(type + 1)) { | |
689 SpdyFrameBuilder frame(type, CONTROL_FLAG_NONE, spdy_version_, 1024); | |
690 scoped_ptr<SpdyControlFrame> control_frame( | |
691 reinterpret_cast<SpdyControlFrame*>(frame.take())); | |
692 EXPECT_EQ(control_frame->has_header_block(), | |
693 framer.IsCompressible(*control_frame)) | |
694 << "Frame type: " << type; | |
695 } | |
696 } | |
697 | |
698 // Test that we can encode and decode a SpdyHeaderBlock in serialized form. | 684 // Test that we can encode and decode a SpdyHeaderBlock in serialized form. |
699 TEST_P(SpdyFramerTest, HeaderBlockInBuffer) { | 685 TEST_P(SpdyFramerTest, HeaderBlockInBuffer) { |
700 SpdyHeaderBlock headers; | 686 SpdyHeaderBlock headers; |
701 headers["alpha"] = "beta"; | 687 headers["alpha"] = "beta"; |
702 headers["gamma"] = "charlie"; | 688 headers["gamma"] = "charlie"; |
703 SpdyFramer framer(spdy_version_); | 689 SpdyFramer framer(spdy_version_); |
704 | 690 |
705 // Encode the header block into a SynStream frame. | 691 // Encode the header block into a SynStream frame. |
706 scoped_ptr<SpdyFrame> frame( | 692 scoped_ptr<SpdyFrame> frame( |
707 framer.CreateSynStream(1, // stream id | 693 framer.CreateSynStream(1, // stream id |
(...skipping 2914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3622 arraysize(kV2FrameData)); | 3608 arraysize(kV2FrameData)); |
3623 } else { | 3609 } else { |
3624 framer.ProcessInput(reinterpret_cast<const char*>(kV3FrameData), | 3610 framer.ProcessInput(reinterpret_cast<const char*>(kV3FrameData), |
3625 arraysize(kV3FrameData)); | 3611 arraysize(kV3FrameData)); |
3626 } | 3612 } |
3627 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); | 3613 EXPECT_EQ(SpdyFramer::SPDY_RESET, framer.state()); |
3628 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()); | 3614 EXPECT_EQ(SpdyFramer::SPDY_NO_ERROR, framer.error_code()); |
3629 } | 3615 } |
3630 | 3616 |
3631 } // namespace net | 3617 } // namespace net |
OLD | NEW |