Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(147)

Side by Side Diff: net/spdy/core/hpack/hpack_decoder_test.cc

Issue 2895993003: Misc cleanup in net/spdy/core. (Closed)
Patch Set: Rebase. Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "net/spdy/core/hpack/hpack_decoder.h" 5 #include "net/spdy/core/hpack/hpack_decoder.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "net/spdy/chromium/spdy_flags.h" 10 #include "net/spdy/chromium/spdy_flags.h"
11 #include "net/spdy/core/hpack/hpack_encoder.h" 11 #include "net/spdy/core/hpack/hpack_encoder.h"
12 #include "net/spdy/core/hpack/hpack_input_stream.h" 12 #include "net/spdy/core/hpack/hpack_input_stream.h"
13 #include "net/spdy/core/hpack/hpack_output_stream.h" 13 #include "net/spdy/core/hpack/hpack_output_stream.h"
14 #include "net/spdy/core/spdy_protocol.h" 14 #include "net/spdy/core/spdy_protocol.h"
15 #include "net/spdy/core/spdy_test_utils.h" 15 #include "net/spdy/core/spdy_test_utils.h"
16 #include "testing/gmock/include/gmock/gmock.h" 16 #include "testing/gmock/include/gmock/gmock.h"
17 #include "testing/gtest/include/gtest/gtest.h" 17 #include "testing/gtest/include/gtest/gtest.h"
18 18
19 namespace net { 19 namespace net {
20 namespace test { 20 namespace test {
21 21
22 class HpackDecoderPeer { 22 class HpackDecoderPeer {
23 public: 23 public:
24 explicit HpackDecoderPeer(HpackDecoder* decoder) : decoder_(decoder) {} 24 explicit HpackDecoderPeer(HpackDecoder* decoder) : decoder_(decoder) {}
25 25
26 void HandleHeaderRepresentation(SpdyStringPiece name, SpdyStringPiece value) { 26 void HandleHeaderRepresentation(SpdyStringPiece name, SpdyStringPiece value) {
27 decoder_->HandleHeaderRepresentation(name, value); 27 decoder_->HandleHeaderRepresentation(name, value);
28 } 28 }
29
29 bool DecodeNextName(HpackInputStream* in, SpdyStringPiece* out) { 30 bool DecodeNextName(HpackInputStream* in, SpdyStringPiece* out) {
30 return decoder_->DecodeNextName(in, out); 31 return decoder_->DecodeNextName(in, out);
31 } 32 }
33
32 HpackHeaderTable* header_table() { return &decoder_->header_table_; } 34 HpackHeaderTable* header_table() { return &decoder_->header_table_; }
33 35
34 bool DecodeNextStringLiteral(HpackInputStream* in, 36 bool DecodeNextStringLiteral(HpackInputStream* in,
35 bool is_header_key, 37 bool is_header_key,
36 SpdyStringPiece* str) { 38 SpdyStringPiece* str) {
37 return decoder_->DecodeNextStringLiteral(in, is_header_key, str); 39 return decoder_->DecodeNextStringLiteral(in, is_header_key, str);
38 } 40 }
39 41
40 const SpdyString& headers_block_buffer() const { 42 const SpdyString& headers_block_buffer() const {
41 return decoder_->headers_block_buffer_; 43 return decoder_->headers_block_buffer_;
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 // | Huffman encoded: 643 // | Huffman encoded:
642 // 25a8 49e9 5ba9 7d7f | %.I.[.}. 644 // 25a8 49e9 5ba9 7d7f | %.I.[.}.
643 // | Decoded: 645 // | Decoded:
644 // | custom-key 646 // | custom-key
645 // 89 | Literal value (len = 12) 647 // 89 | Literal value (len = 12)
646 // | Huffman encoded: 648 // | Huffman encoded:
647 // 25a8 49e9 5bb8 e8b4 bf | %.I.[.... 649 // 25a8 49e9 5bb8 e8b4 bf | %.I.[....
648 // | Decoded: 650 // | Decoded:
649 // | custom-value 651 // | custom-value
650 // | -> custom-key: custom-value 652 // | -> custom-key: custom-value
651 SpdyString third = a2b_hex( 653 SpdyString third =
652 "828785bf408825a849e95ba97d7f89" 654 a2b_hex("828785bf408825a849e95ba97d7f8925a849e95bb8e8b4bf");
653 "25a849e95bb8e8b4bf");
654 const SpdyHeaderBlock& third_header_set = DecodeBlockExpectingSuccess(third); 655 const SpdyHeaderBlock& third_header_set = DecodeBlockExpectingSuccess(third);
655 656
656 EXPECT_THAT(third_header_set, 657 EXPECT_THAT(third_header_set,
657 ElementsAre(Pair(":method", "GET"), Pair(":scheme", "https"), 658 ElementsAre(Pair(":method", "GET"), Pair(":scheme", "https"),
658 Pair(":path", "/index.html"), 659 Pair(":path", "/index.html"),
659 Pair(":authority", "www.example.com"), 660 Pair(":authority", "www.example.com"),
660 Pair("custom-key", "custom-value"))); 661 Pair("custom-key", "custom-value")));
661 662
662 expectEntry(62, 54, "custom-key", "custom-value"); 663 expectEntry(62, 54, "custom-key", "custom-value");
663 expectEntry(63, 53, "cache-control", "no-cache"); 664 expectEntry(63, 53, "cache-control", "no-cache");
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;" 844 "foo=ASDJKHQKBZXOQWEOPIUAXQWEOIU;"
844 " max-age=3600; version=1"); 845 " max-age=3600; version=1");
845 expectEntry(63, 52, "content-encoding", "gzip"); 846 expectEntry(63, 52, "content-encoding", "gzip");
846 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT"); 847 expectEntry(64, 65, "date", "Mon, 21 Oct 2013 20:13:22 GMT");
847 EXPECT_EQ(215u, decoder_peer_.header_table()->size()); 848 EXPECT_EQ(215u, decoder_peer_.header_table()->size());
848 } 849 }
849 850
850 } // namespace 851 } // namespace
851 } // namespace test 852 } // namespace test
852 } // namespace net 853 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698