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 QUICHE_HTTP2_TEST_TOOLS_FRAME_DECODER_STATE_TEST_UTIL_H_
6 #define QUICHE_HTTP2_TEST_TOOLS_FRAME_DECODER_STATE_TEST_UTIL_H_
7 
8 #include "quiche/http2/decoder/frame_decoder_state.h"
9 #include "quiche/http2/http2_structures.h"
10 #include "quiche/http2/test_tools/random_decoder_test_base.h"
11 #include "quiche/common/platform/api/quiche_export.h"
12 
13 namespace http2 {
14 namespace test {
15 
16 class QUICHE_NO_EXPORT FrameDecoderStatePeer {
17  public:
18   // Randomizes (i.e. corrupts) the fields of the FrameDecoderState.
19   // PayloadDecoderBaseTest::StartDecoding calls this before passing the first
20   // decode buffer to the payload decoder, which increases the likelihood of
21   // detecting any use of prior states of the decoder on the decoding of
22   // future payloads.
23   static void Randomize(FrameDecoderState* p, Http2Random* rng);
24 
25   // Inject a frame header into the FrameDecoderState.
26   // PayloadDecoderBaseTest::StartDecoding calls this just after calling
27   // Randomize (above), to simulate a full frame decoder having just finished
28   // decoding the common frame header and then calling the appropriate payload
29   // decoder based on the frame type in that frame header.
30   static void set_frame_header(const Http2FrameHeader& header,
31                                FrameDecoderState* p);
32 };
33 
34 }  // namespace test
35 }  // namespace http2
36 
37 #endif  // QUICHE_HTTP2_TEST_TOOLS_FRAME_DECODER_STATE_TEST_UTIL_H_
38