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

Side by Side Diff: net/spdy/spdy_test_utils.h

Issue 2832973003: Split net/spdy into core and chromium subdirectories. (Closed)
Patch Set: Fix some more build rules. Created 3 years, 8 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
« no previous file with comments | « net/spdy/spdy_test_util_common.cc ('k') | net/spdy/spdy_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 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_SPDY_SPDY_TEST_UTILS_H_
6 #define NET_SPDY_SPDY_TEST_UTILS_H_
7
8 #include <stddef.h>
9 #include <stdint.h>
10
11 #include <map>
12 #include <memory>
13
14 #include "net/spdy/platform/api/spdy_string.h"
15 #include "net/spdy/platform/api/spdy_string_piece.h"
16 #include "net/spdy/server_push_delegate.h"
17 #include "net/spdy/spdy_bug_tracker.h"
18 #include "net/spdy/spdy_header_block.h"
19 #include "net/spdy/spdy_headers_handler_interface.h"
20 #include "net/spdy/spdy_protocol.h"
21 #include "net/test/gtest_util.h"
22
23 #define EXPECT_SPDY_BUG EXPECT_DFATAL
24
25 namespace net {
26
27 class HashValue;
28 class TransportSecurityState;
29
30 inline bool operator==(SpdyStringPiece x,
31 const SpdyHeaderBlock::ValueProxy& y) {
32 return x == y.as_string();
33 }
34
35 namespace test {
36
37 SpdyString HexDumpWithMarks(const unsigned char* data,
38 int length,
39 const bool* marks,
40 int mark_length);
41
42 void CompareCharArraysWithHexError(const SpdyString& description,
43 const unsigned char* actual,
44 const int actual_len,
45 const unsigned char* expected,
46 const int expected_len);
47
48 void SetFrameFlags(SpdySerializedFrame* frame, uint8_t flags);
49
50 void SetFrameLength(SpdySerializedFrame* frame, size_t length);
51
52 SpdyString a2b_hex(const char* hex_data);
53
54 // Returns a SHA1 HashValue in which each byte has the value |label|.
55 HashValue GetTestHashValue(uint8_t label);
56
57 // Returns SHA1 pinning header for the of the base64 encoding of
58 // GetTestHashValue(|label|).
59 SpdyString GetTestPin(uint8_t label);
60
61 // Adds a pin for |host| to |state|.
62 void AddPin(TransportSecurityState* state,
63 const SpdyString& host,
64 uint8_t primary_label,
65 uint8_t backup_label);
66
67 // A test implementation of SpdyHeadersHandlerInterface that correctly
68 // reconstructs multiple header values for the same name.
69 class TestHeadersHandler : public SpdyHeadersHandlerInterface {
70 public:
71 TestHeadersHandler() {}
72
73 void OnHeaderBlockStart() override;
74
75 void OnHeader(SpdyStringPiece name, SpdyStringPiece value) override;
76
77 void OnHeaderBlockEnd(size_t header_bytes_parsed) override;
78
79 void OnHeaderBlockEnd(size_t header_bytes_parsed,
80 size_t compressed_header_bytes_parsed) override;
81
82 const SpdyHeaderBlock& decoded_block() const { return block_; }
83 size_t header_bytes_parsed() const { return header_bytes_parsed_; }
84 size_t compressed_header_bytes_parsed() const {
85 return compressed_header_bytes_parsed_;
86 }
87
88 private:
89 SpdyHeaderBlock block_;
90 size_t header_bytes_parsed_ = 0;
91 size_t compressed_header_bytes_parsed_ = 0;
92
93 DISALLOW_COPY_AND_ASSIGN(TestHeadersHandler);
94 };
95
96 // A test implementation of ServerPushDelegate that caches all the pushed
97 // request and provides a interface to cancel the push given url.
98 class TestServerPushDelegate : public ServerPushDelegate {
99 public:
100 TestServerPushDelegate();
101 ~TestServerPushDelegate() override;
102
103 void OnPush(std::unique_ptr<ServerPushHelper> push_helper,
104 const NetLogWithSource& session_net_log) override;
105
106 bool CancelPush(GURL url);
107
108 private:
109 std::map<GURL, std::unique_ptr<ServerPushHelper>> push_helpers;
110 };
111
112 } // namespace test
113 } // namespace net
114
115 #endif // NET_SPDY_SPDY_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_test_util_common.cc ('k') | net/spdy/spdy_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698