OLD | NEW |
| (Empty) |
1 // Copyright 2016 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 #ifndef NET_HTTP2_HPACK_DECODER_HPACK_STRING_COLLECTOR_H_ | |
6 #define NET_HTTP2_HPACK_DECODER_HPACK_STRING_COLLECTOR_H_ | |
7 | |
8 // Supports tests of decoding HPACK strings. | |
9 | |
10 #include <stddef.h> | |
11 | |
12 #include <iosfwd> | |
13 #include <string> | |
14 | |
15 #include "base/strings/string_piece.h" | |
16 #include "net/http2/hpack/decoder/hpack_string_decoder_listener.h" | |
17 #include "testing/gtest/include/gtest/gtest.h" | |
18 | |
19 namespace net { | |
20 namespace test { | |
21 | |
22 // Records the callbacks associated with a decoding a string; must | |
23 // call Clear() between decoding successive strings. | |
24 struct HpackStringCollector : public HpackStringDecoderListener { | |
25 enum CollectorState { | |
26 kGenesis, | |
27 kStarted, | |
28 kEnded, | |
29 }; | |
30 | |
31 HpackStringCollector(); | |
32 HpackStringCollector(const std::string& str, bool huffman); | |
33 | |
34 void Clear(); | |
35 bool IsClear() const; | |
36 bool IsInProgress() const; | |
37 bool HasEnded() const; | |
38 | |
39 void OnStringStart(bool huffman, size_t length) override; | |
40 void OnStringData(const char* data, size_t length) override; | |
41 void OnStringEnd() override; | |
42 | |
43 ::testing::AssertionResult Collected(base::StringPiece str, | |
44 bool is_huffman_encoded) const; | |
45 | |
46 std::string ToString() const; | |
47 | |
48 std::string s; | |
49 size_t len; | |
50 bool huffman_encoded; | |
51 CollectorState state; | |
52 }; | |
53 | |
54 bool operator==(const HpackStringCollector& a, const HpackStringCollector& b); | |
55 | |
56 bool operator!=(const HpackStringCollector& a, const HpackStringCollector& b); | |
57 | |
58 std::ostream& operator<<(std::ostream& out, const HpackStringCollector& v); | |
59 | |
60 } // namespace test | |
61 } // namespace net | |
62 | |
63 #endif // NET_HTTP2_HPACK_DECODER_HPACK_STRING_COLLECTOR_H_ | |
OLD | NEW |