| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include <string> |
| 6 |
| 7 #include "net/quic/quic_spdy_compressor.h" |
| 8 #include "net/quic/quic_spdy_decompressor.h" |
| 9 #include "net/quic/spdy_utils.h" |
| 10 #include "net/quic/test_tools/quic_test_utils.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 |
| 13 using std::string; |
| 14 |
| 15 namespace net { |
| 16 namespace test { |
| 17 namespace { |
| 18 |
| 19 class QuicSpdyDecompressorTest : public ::testing::Test { |
| 20 protected: |
| 21 QuicSpdyDecompressor decompressor_; |
| 22 QuicSpdyCompressor compressor_; |
| 23 TestDecompressorVisitor visitor_; |
| 24 }; |
| 25 |
| 26 TEST_F(QuicSpdyDecompressorTest, Decompress) { |
| 27 SpdyHeaderBlock headers; |
| 28 headers[":host"] = "www.google.com"; |
| 29 headers[":path"] = "/index.hml"; |
| 30 headers[":scheme"] = "https"; |
| 31 |
| 32 EXPECT_EQ(1u, decompressor_.current_header_id()); |
| 33 string compressed_headers = compressor_.CompressHeaders(headers).substr(4); |
| 34 EXPECT_EQ(compressed_headers.length(), |
| 35 decompressor_.DecompressData(compressed_headers, &visitor_)); |
| 36 |
| 37 EXPECT_EQ(SpdyUtils::SerializeUncompressedHeaders(headers), visitor_.data()); |
| 38 EXPECT_EQ(2u, decompressor_.current_header_id()); |
| 39 } |
| 40 |
| 41 TEST_F(QuicSpdyDecompressorTest, DecompressAndIgnoreTrailingData) { |
| 42 SpdyHeaderBlock headers; |
| 43 headers[":host"] = "www.google.com"; |
| 44 headers[":path"] = "/index.hml"; |
| 45 headers[":scheme"] = "https"; |
| 46 |
| 47 string compressed_headers = compressor_.CompressHeaders(headers).substr(4); |
| 48 EXPECT_EQ(compressed_headers.length(), |
| 49 decompressor_.DecompressData(compressed_headers + "abc123", |
| 50 &visitor_)); |
| 51 |
| 52 EXPECT_EQ(SpdyUtils::SerializeUncompressedHeaders(headers), visitor_.data()); |
| 53 } |
| 54 |
| 55 } // namespace |
| 56 } // namespace test |
| 57 } // namespace net |
| OLD | NEW |