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 MockRandom(); |
| 16 |
15 // QuicRandom: | 17 // QuicRandom: |
16 // Fills the |data| buffer with 'r'. | 18 // Fills the |data| buffer with a repeating byte, initially 'r'. |
17 virtual void RandBytes(void* data, size_t len) OVERRIDE; | 19 virtual void RandBytes(void* data, size_t len) OVERRIDE; |
18 // Returns 0xDEADBEEF. | 20 // Returns 0xDEADBEEF + the current increment. |
19 virtual uint64 RandUint64() OVERRIDE; | 21 virtual uint64 RandUint64() OVERRIDE; |
20 // Returns false. | 22 // Returns false. |
21 virtual bool RandBool() OVERRIDE; | 23 virtual bool RandBool() OVERRIDE; |
22 // Does nothing. | 24 // Reseed advances |increment_| which causes the value returned by |
| 25 // |RandUint64| to increment and the byte that |RandBytes| fills with, to |
| 26 // advance. |
23 virtual void Reseed(const void* additional_entropy, | 27 virtual void Reseed(const void* additional_entropy, |
24 size_t entropy_len) OVERRIDE; | 28 size_t entropy_len) OVERRIDE; |
| 29 |
| 30 private: |
| 31 uint8 increment_; |
25 }; | 32 }; |
26 | 33 |
27 } // namespace net | 34 } // namespace net |
28 | 35 |
29 #endif // NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ | 36 #endif // NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_ |
OLD | NEW |