Home | History | Annotate | Download | only in quic
      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 QuicSpdyCompressorTest : public ::testing::Test {
     20  protected:
     21   TestDecompressorVisitor visitor_;
     22 };
     23 
     24 TEST_F(QuicSpdyCompressorTest, Compress) {
     25   QuicSpdyCompressor compressor;
     26   QuicSpdyDecompressor decompressor;
     27 
     28   SpdyHeaderBlock headers;
     29   headers[":host"] = "www.google.com";
     30   headers[":path"] = "/index.hml";
     31   headers[":scheme"] = "https";
     32 
     33   string compressed_headers = compressor.CompressHeaders(headers);
     34   EXPECT_EQ('\1', compressed_headers[0]);
     35   EXPECT_EQ('\0', compressed_headers[1]);
     36   EXPECT_EQ('\0', compressed_headers[2]);
     37   EXPECT_EQ('\0', compressed_headers[3]);
     38   string compressed_data = compressed_headers.substr(4);
     39   decompressor.DecompressData(compressed_data, &visitor_);
     40   EXPECT_EQ(SpdyUtils::SerializeUncompressedHeaders(headers),
     41             visitor_.data());
     42 }
     43 
     44 }  // namespace
     45 }  // namespace test
     46 }  // namespace net
     47