summaryrefslogtreecommitdiff
path: root/chromium/net/quic/test_tools/mock_random.h
blob: 544f5ce048ac6d1c5f7d70c900c5c2669970bc07 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_
#define NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_

#include "base/compiler_specific.h"
#include "net/quic/crypto/quic_random.h"

namespace net {

class MockRandom : public QuicRandom {
 public:
  MockRandom();

  // QuicRandom:
  // Fills the |data| buffer with a repeating byte, initially 'r'.
  virtual void RandBytes(void* data, size_t len) OVERRIDE;
  // Returns 0xDEADBEEF + the current increment.
  virtual uint64 RandUint64() OVERRIDE;
  // Returns false.
  virtual bool RandBool() OVERRIDE;
  // Does nothing.
  virtual void Reseed(const void* additional_entropy,
                      size_t entropy_len) OVERRIDE;

  // ChangeValue increments |increment_|. This causes the value returned by
  // |RandUint64| and the byte that |RandBytes| fills with, to change.
  void ChangeValue();

 private:
  uint8 increment_;
};

}  // namespace net

#endif  // NET_QUIC_TEST_TOOLS_MOCK_RANDOM_H_