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 // Common utilities for Quic tests | 5 // Common utilities for Quic tests |
6 | 6 |
7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 7 #ifndef NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 8 #define NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
9 | 9 |
10 #include <string> | 10 #include <string> |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 *name_ = value_; | 115 *name_ = value_; |
116 } | 116 } |
117 | 117 |
118 private: | 118 private: |
119 SaveType* name_; | 119 SaveType* name_; |
120 SaveType value_; | 120 SaveType value_; |
121 | 121 |
122 DISALLOW_COPY_AND_ASSIGN(ValueRestore); | 122 DISALLOW_COPY_AND_ASSIGN(ValueRestore); |
123 }; | 123 }; |
124 | 124 |
| 125 // Simple random number generator used to compute random numbers suitable |
| 126 // for pseudo-randomly dropping packets in tests. It works by computing |
| 127 // the sha1 hash of the current seed, and using the first 64 bits as |
| 128 // the next random number, and the next seed. |
| 129 class SimpleRandom { |
| 130 public: |
| 131 SimpleRandom() : seed_(0) {} |
| 132 |
| 133 // Returns a random number in the range [0, kuint64max]. |
| 134 uint64 RandUint64(); |
| 135 |
| 136 void set_seed(uint64 seed) { seed_ = seed; } |
| 137 |
| 138 private: |
| 139 uint64 seed_; |
| 140 |
| 141 DISALLOW_COPY_AND_ASSIGN(SimpleRandom); |
| 142 }; |
| 143 |
125 class MockFramerVisitor : public QuicFramerVisitorInterface { | 144 class MockFramerVisitor : public QuicFramerVisitorInterface { |
126 public: | 145 public: |
127 MockFramerVisitor(); | 146 MockFramerVisitor(); |
128 virtual ~MockFramerVisitor(); | 147 virtual ~MockFramerVisitor(); |
129 | 148 |
130 MOCK_METHOD1(OnError, void(QuicFramer* framer)); | 149 MOCK_METHOD1(OnError, void(QuicFramer* framer)); |
131 // The constructor sets this up to return false by default. | 150 // The constructor sets this up to return false by default. |
132 MOCK_METHOD1(OnProtocolVersionMismatch, bool(QuicVersion version)); | 151 MOCK_METHOD1(OnProtocolVersionMismatch, bool(QuicVersion version)); |
133 MOCK_METHOD0(OnPacket, void()); | 152 MOCK_METHOD0(OnPacket, void()); |
134 MOCK_METHOD1(OnPublicResetPacket, void(const QuicPublicResetPacket& header)); | 153 MOCK_METHOD1(OnPublicResetPacket, void(const QuicPublicResetPacket& header)); |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 virtual ~MockAckNotifierDelegate(); | 520 virtual ~MockAckNotifierDelegate(); |
502 | 521 |
503 private: | 522 private: |
504 DISALLOW_COPY_AND_ASSIGN(MockAckNotifierDelegate); | 523 DISALLOW_COPY_AND_ASSIGN(MockAckNotifierDelegate); |
505 }; | 524 }; |
506 | 525 |
507 } // namespace test | 526 } // namespace test |
508 } // namespace net | 527 } // namespace net |
509 | 528 |
510 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 529 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
OLD | NEW |