| OLD | NEW |
| 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/hpack_encoder.h" | 5 #include "net/spdy/hpack_encoder.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 | 38 |
| 39 explicit HpackEncoderPeer(HpackEncoder* encoder) | 39 explicit HpackEncoderPeer(HpackEncoder* encoder) |
| 40 : encoder_(encoder) {} | 40 : encoder_(encoder) {} |
| 41 | 41 |
| 42 HpackHeaderTable* table() { | 42 HpackHeaderTable* table() { |
| 43 return &encoder_->header_table_; | 43 return &encoder_->header_table_; |
| 44 } | 44 } |
| 45 HpackHeaderTablePeer table_peer() { | 45 HpackHeaderTablePeer table_peer() { |
| 46 return HpackHeaderTablePeer(table()); | 46 return HpackHeaderTablePeer(table()); |
| 47 } | 47 } |
| 48 bool allow_huffman_compression() { | |
| 49 return encoder_->allow_huffman_compression_; | |
| 50 } | |
| 51 void set_allow_huffman_compression(bool allow) { | 48 void set_allow_huffman_compression(bool allow) { |
| 52 encoder_->allow_huffman_compression_ = allow; | 49 encoder_->allow_huffman_compression_ = allow; |
| 53 } | 50 } |
| 54 void EmitString(StringPiece str) { | 51 void EmitString(StringPiece str) { |
| 55 encoder_->EmitString(str); | 52 encoder_->EmitString(str); |
| 56 } | 53 } |
| 57 void TakeString(string* out) { | 54 void TakeString(string* out) { |
| 58 encoder_->output_stream_.TakeString(out); | 55 encoder_->output_stream_.TakeString(out); |
| 59 } | 56 } |
| 60 void UpdateCharacterCounts(StringPiece str) { | 57 void UpdateCharacterCounts(StringPiece str) { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 expected_.AppendPrefix(kStringLiteralIdentityEncoded); | 143 expected_.AppendPrefix(kStringLiteralIdentityEncoded); |
| 147 expected_.AppendUint32(value.size()); | 144 expected_.AppendUint32(value.size()); |
| 148 expected_.AppendBytes(value); | 145 expected_.AppendBytes(value); |
| 149 } | 146 } |
| 150 void CompareWithExpectedEncoding(const map<string, string>& header_set) { | 147 void CompareWithExpectedEncoding(const map<string, string>& header_set) { |
| 151 string expected_out, actual_out; | 148 string expected_out, actual_out; |
| 152 expected_.TakeString(&expected_out); | 149 expected_.TakeString(&expected_out); |
| 153 EXPECT_TRUE(encoder_.EncodeHeaderSet(header_set, &actual_out)); | 150 EXPECT_TRUE(encoder_.EncodeHeaderSet(header_set, &actual_out)); |
| 154 EXPECT_EQ(expected_out, actual_out); | 151 EXPECT_EQ(expected_out, actual_out); |
| 155 } | 152 } |
| 156 size_t IndexOf(HpackEntry* entry) { | |
| 157 return peer_.table()->IndexOf(entry); | |
| 158 } | |
| 159 size_t IndexOf(const HpackEntry* entry) { | 153 size_t IndexOf(const HpackEntry* entry) { |
| 160 return peer_.table()->IndexOf(entry); | 154 return peer_.table()->IndexOf(entry); |
| 161 } | 155 } |
| 162 | 156 |
| 163 HpackEncoder encoder_; | 157 HpackEncoder encoder_; |
| 164 test::HpackEncoderPeer peer_; | 158 test::HpackEncoderPeer peer_; |
| 165 | 159 |
| 166 const HpackEntry* static_; | 160 const HpackEntry* static_; |
| 167 const HpackEntry* key_1_; | 161 const HpackEntry* key_1_; |
| 168 const HpackEntry* key_2_; | 162 const HpackEntry* key_2_; |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 expected_.AppendUint32(62); | 456 expected_.AppendUint32(62); |
| 463 expected_.AppendPrefix(kStringLiteralIdentityEncoded); | 457 expected_.AppendPrefix(kStringLiteralIdentityEncoded); |
| 464 expected_.AppendUint32(3); | 458 expected_.AppendUint32(3); |
| 465 expected_.AppendBytes("bar"); | 459 expected_.AppendBytes("bar"); |
| 466 CompareWithExpectedEncoding(headers); | 460 CompareWithExpectedEncoding(headers); |
| 467 } | 461 } |
| 468 | 462 |
| 469 } // namespace | 463 } // namespace |
| 470 | 464 |
| 471 } // namespace net | 465 } // namespace net |
| OLD | NEW |