QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 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 QUICHE_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ |
| 6 | #define QUICHE_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ |
| 7 | |
QUICHE team | a6ef0a6 | 2019-03-07 20:34:33 -0500 | [diff] [blame] | 8 | #include "net/third_party/quiche/src/quic/core/crypto/quic_random.h" |
| 9 | |
| 10 | namespace quic { |
| 11 | namespace test { |
| 12 | |
| 13 | class MockRandom : public QuicRandom { |
| 14 | public: |
| 15 | // Initializes base_ to 0xDEADBEEF. |
| 16 | MockRandom(); |
| 17 | explicit MockRandom(uint32_t base); |
| 18 | MockRandom(const MockRandom&) = delete; |
| 19 | MockRandom& operator=(const MockRandom&) = delete; |
| 20 | |
| 21 | // QuicRandom: |
| 22 | // Fills the |data| buffer with a repeating byte, initially 'r'. |
| 23 | void RandBytes(void* data, size_t len) override; |
| 24 | // Returns base + the current increment. |
| 25 | uint64_t RandUint64() override; |
| 26 | |
| 27 | // ChangeValue increments |increment_|. This causes the value returned by |
| 28 | // |RandUint64| and the byte that |RandBytes| fills with, to change. |
| 29 | void ChangeValue(); |
| 30 | |
| 31 | private: |
| 32 | uint32_t base_; |
| 33 | uint8_t increment_; |
| 34 | }; |
| 35 | |
| 36 | } // namespace test |
| 37 | } // namespace quic |
| 38 | |
| 39 | #endif // QUICHE_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ |