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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 headers["cookie"] = "e=ff; a=bb; c=dd"; | 309 headers["cookie"] = "e=ff; a=bb; c=dd"; |
310 CompareWithExpectedEncoding(headers); | 310 CompareWithExpectedEncoding(headers); |
311 } | 311 } |
312 | 312 |
313 TEST_F(HpackEncoderTest, StringsDynamicallySelectHuffmanCoding) { | 313 TEST_F(HpackEncoderTest, StringsDynamicallySelectHuffmanCoding) { |
314 peer_.set_allow_huffman_compression(true); | 314 peer_.set_allow_huffman_compression(true); |
315 | 315 |
316 // Compactable string. Uses Huffman coding. | 316 // Compactable string. Uses Huffman coding. |
317 peer_.EmitString("feedbeef"); | 317 peer_.EmitString("feedbeef"); |
318 expected_.AppendPrefix(kStringLiteralHuffmanEncoded); | 318 expected_.AppendPrefix(kStringLiteralHuffmanEncoded); |
319 expected_.AppendUint32(5); | 319 expected_.AppendUint32(6); |
320 expected_.AppendBytes("\xC4G\v\xC4q"); | 320 expected_.AppendBytes("\xE0\xB5\xD3\xBDk\xE1"); |
321 | 321 |
322 // Non-compactable. Uses identity coding. | 322 // Non-compactable. Uses identity coding. |
323 peer_.EmitString("@@@@@@"); | 323 peer_.EmitString("@@@@@@"); |
324 expected_.AppendPrefix(kStringLiteralIdentityEncoded); | 324 expected_.AppendPrefix(kStringLiteralIdentityEncoded); |
325 expected_.AppendUint32(6); | 325 expected_.AppendUint32(6); |
326 expected_.AppendBytes("@@@@@@"); | 326 expected_.AppendBytes("@@@@@@"); |
327 | 327 |
328 string expected_out, actual_out; | 328 string expected_out, actual_out; |
329 expected_.TakeString(&expected_out); | 329 expected_.TakeString(&expected_out); |
330 peer_.TakeString(&actual_out); | 330 peer_.TakeString(&actual_out); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 expect[static_cast<uint8>('\xff')] = 1; | 440 expect[static_cast<uint8>('\xff')] = 1; |
441 expect[static_cast<uint8>('b')] = 1; | 441 expect[static_cast<uint8>('b')] = 1; |
442 | 442 |
443 EXPECT_EQ(expect, counts); | 443 EXPECT_EQ(expect, counts); |
444 EXPECT_EQ(9u, total_counts); | 444 EXPECT_EQ(9u, total_counts); |
445 } | 445 } |
446 | 446 |
447 } // namespace | 447 } // namespace |
448 | 448 |
449 } // namespace net | 449 } // namespace net |
OLD | NEW |