OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ | 5 #ifndef NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ |
6 #define NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ | 6 #define NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "net/quic/crypto/quic_random.h" | 9 #include "net/quic/crypto/quic_random.h" |
10 | 10 |
11 namespace net { | 11 namespace net { |
12 | 12 |
13 class MockRandom : public QuicRandom { | 13 class MockRandom : public QuicRandom { |
14 public: | 14 public: |
| 15 // Initializes base_ to 0xDEADBEEF. |
15 MockRandom(); | 16 MockRandom(); |
| 17 MockRandom(uint32 base); |
16 | 18 |
17 // QuicRandom: | 19 // QuicRandom: |
18 // Fills the |data| buffer with a repeating byte, initially 'r'. | 20 // Fills the |data| buffer with a repeating byte, initially 'r'. |
19 virtual void RandBytes(void* data, size_t len) OVERRIDE; | 21 virtual void RandBytes(void* data, size_t len) OVERRIDE; |
20 // Returns 0xDEADBEEF + the current increment. | 22 // Returns base + the current increment. |
21 virtual uint64 RandUint64() OVERRIDE; | 23 virtual uint64 RandUint64() OVERRIDE; |
22 // Returns false. | |
23 virtual bool RandBool() OVERRIDE; | |
24 // Does nothing. | 24 // Does nothing. |
25 virtual void Reseed(const void* additional_entropy, | 25 virtual void Reseed(const void* additional_entropy, |
26 size_t entropy_len) OVERRIDE; | 26 size_t entropy_len) OVERRIDE; |
27 | 27 |
28 // ChangeValue increments |increment_|. This causes the value returned by | 28 // ChangeValue increments |increment_|. This causes the value returned by |
29 // |RandUint64| and the byte that |RandBytes| fills with, to change. | 29 // |RandUint64| and the byte that |RandBytes| fills with, to change. |
30 void ChangeValue(); | 30 void ChangeValue(); |
31 | 31 |
32 private: | 32 private: |
| 33 uint32 base_; |
33 uint8 increment_; | 34 uint8 increment_; |
34 }; | 35 }; |
35 | 36 |
36 } // namespace net | 37 } // namespace net |
37 | 38 |
38 #endif // NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ | 39 #endif // NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ |
OLD | NEW |