| 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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 int spdy_version_; | 531 int spdy_version_; |
| 532 }; | 532 }; |
| 533 | 533 |
| 534 | 534 |
| 535 //----------------------------------------------------------------------------- | 535 //----------------------------------------------------------------------------- |
| 536 // All tests are run with two different SPDY versions: SPDY/2 and SPDY/3. | 536 // All tests are run with two different SPDY versions: SPDY/2 and SPDY/3. |
| 537 INSTANTIATE_TEST_CASE_P(SpdyFramerTests, | 537 INSTANTIATE_TEST_CASE_P(SpdyFramerTests, |
| 538 SpdyFramerTest, | 538 SpdyFramerTest, |
| 539 ::testing::Values(SPDY2, SPDY3)); | 539 ::testing::Values(SPDY2, SPDY3)); |
| 540 | 540 |
| 541 TEST_P(SpdyFramerTest, IsCompressible) { |
| 542 SpdyFramer framer(spdy_version_); |
| 543 for (SpdyControlType type = SYN_STREAM; |
| 544 type < NUM_CONTROL_FRAME_TYPES; |
| 545 type = static_cast<SpdyControlType>(type + 1)) { |
| 546 SpdyFrameBuilder frame(type, CONTROL_FLAG_NONE, spdy_version_, 1024); |
| 547 scoped_ptr<SpdyControlFrame> control_frame( |
| 548 reinterpret_cast<SpdyControlFrame*>(frame.take())); |
| 549 EXPECT_EQ(control_frame->has_header_block(), |
| 550 framer.IsCompressible(*control_frame)) |
| 551 << "Frame type: " << type; |
| 552 } |
| 553 } |
| 554 |
| 541 // Test that we can encode and decode a SpdyHeaderBlock in serialized form. | 555 // Test that we can encode and decode a SpdyHeaderBlock in serialized form. |
| 542 TEST_P(SpdyFramerTest, HeaderBlockInBuffer) { | 556 TEST_P(SpdyFramerTest, HeaderBlockInBuffer) { |
| 543 SpdyHeaderBlock headers; | 557 SpdyHeaderBlock headers; |
| 544 headers["alpha"] = "beta"; | 558 headers["alpha"] = "beta"; |
| 545 headers["gamma"] = "charlie"; | 559 headers["gamma"] = "charlie"; |
| 546 SpdyFramer framer(spdy_version_); | 560 SpdyFramer framer(spdy_version_); |
| 547 | 561 |
| 548 // Encode the header block into a SynStream frame. | 562 // Encode the header block into a SynStream frame. |
| 549 scoped_ptr<SpdySynStreamControlFrame> frame( | 563 scoped_ptr<SpdySynStreamControlFrame> frame( |
| 550 framer.CreateSynStream(1, // stream id | 564 framer.CreateSynStream(1, // stream id |
| (...skipping 2115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2666 htonl(IsSpdy2() ? 0x04030201 : 0x01020304); | 2680 htonl(IsSpdy2() ? 0x04030201 : 0x01020304); |
| 2667 | 2681 |
| 2668 SettingsFlagsAndId id_and_flags = | 2682 SettingsFlagsAndId id_and_flags = |
| 2669 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); | 2683 SettingsFlagsAndId::FromWireFormat(spdy_version_, kWireFormat); |
| 2670 EXPECT_EQ(kId, id_and_flags.id()); | 2684 EXPECT_EQ(kId, id_and_flags.id()); |
| 2671 EXPECT_EQ(kFlags, id_and_flags.flags()); | 2685 EXPECT_EQ(kFlags, id_and_flags.flags()); |
| 2672 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); | 2686 EXPECT_EQ(kWireFormat, id_and_flags.GetWireFormat(spdy_version_)); |
| 2673 } | 2687 } |
| 2674 | 2688 |
| 2675 } // namespace net | 2689 } // namespace net |
| OLD | NEW |