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 <stddef.h> | 10 #include <stddef.h> |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 class QuicFlagSaver { | 220 class QuicFlagSaver { |
221 public: | 221 public: |
222 QuicFlagSaver(); | 222 QuicFlagSaver(); |
223 ~QuicFlagSaver(); | 223 ~QuicFlagSaver(); |
224 }; | 224 }; |
225 | 225 |
226 // Simple random number generator used to compute random numbers suitable | 226 // Simple random number generator used to compute random numbers suitable |
227 // for pseudo-randomly dropping packets in tests. It works by computing | 227 // for pseudo-randomly dropping packets in tests. It works by computing |
228 // the sha1 hash of the current seed, and using the first 64 bits as | 228 // the sha1 hash of the current seed, and using the first 64 bits as |
229 // the next random number, and the next seed. | 229 // the next random number, and the next seed. |
230 class SimpleRandom { | 230 class SimpleRandom : public QuicRandom { |
231 public: | 231 public: |
232 SimpleRandom() : seed_(0) {} | 232 SimpleRandom() : seed_(0) {} |
| 233 ~SimpleRandom() override {} |
233 | 234 |
234 // Returns a random number in the range [0, kuint64max]. | 235 // Returns a random number in the range [0, kuint64max]. |
235 uint64_t RandUint64(); | 236 uint64_t RandUint64() override; |
| 237 |
| 238 void RandBytes(void* data, size_t len) override; |
| 239 void Reseed(const void* additional_entropy, size_t len) override; |
236 | 240 |
237 void set_seed(uint64_t seed) { seed_ = seed; } | 241 void set_seed(uint64_t seed) { seed_ = seed; } |
238 | 242 |
239 private: | 243 private: |
240 uint64_t seed_; | 244 uint64_t seed_; |
241 | 245 |
242 DISALLOW_COPY_AND_ASSIGN(SimpleRandom); | 246 DISALLOW_COPY_AND_ASSIGN(SimpleRandom); |
243 }; | 247 }; |
244 | 248 |
245 class MockFramerVisitor : public QuicFramerVisitorInterface { | 249 class MockFramerVisitor : public QuicFramerVisitorInterface { |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 | 656 |
653 MOCK_METHOD1(CreateIncomingDynamicStream, QuicSpdyStream*(QuicStreamId id)); | 657 MOCK_METHOD1(CreateIncomingDynamicStream, QuicSpdyStream*(QuicStreamId id)); |
654 MOCK_METHOD1(CreateOutgoingDynamicStream, | 658 MOCK_METHOD1(CreateOutgoingDynamicStream, |
655 QuicSpdyStream*(SpdyPriority priority)); | 659 QuicSpdyStream*(SpdyPriority priority)); |
656 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( | 660 QuicCryptoServerStreamBase* CreateQuicCryptoServerStream( |
657 const QuicCryptoServerConfig* crypto_config, | 661 const QuicCryptoServerConfig* crypto_config, |
658 QuicCompressedCertsCache* compressed_certs_cache) override; | 662 QuicCompressedCertsCache* compressed_certs_cache) override; |
659 | 663 |
660 QuicCryptoServerStream* GetCryptoStream() override; | 664 QuicCryptoServerStream* GetCryptoStream() override; |
661 | 665 |
662 MockQuicServerSessionHelper* helper() { return &helper_; } | 666 MockQuicCryptoServerStreamHelper* helper() { return &helper_; } |
663 | 667 |
664 private: | 668 private: |
665 MockQuicServerSessionVisitor visitor_; | 669 MockQuicServerSessionVisitor visitor_; |
666 MockQuicServerSessionHelper helper_; | 670 MockQuicCryptoServerStreamHelper helper_; |
667 | 671 |
668 DISALLOW_COPY_AND_ASSIGN(TestQuicSpdyServerSession); | 672 DISALLOW_COPY_AND_ASSIGN(TestQuicSpdyServerSession); |
669 }; | 673 }; |
670 | 674 |
671 class TestQuicSpdyClientSession : public QuicClientSessionBase { | 675 class TestQuicSpdyClientSession : public QuicClientSessionBase { |
672 public: | 676 public: |
673 TestQuicSpdyClientSession(QuicConnection* connection, | 677 TestQuicSpdyClientSession(QuicConnection* connection, |
674 const QuicConfig& config, | 678 const QuicConfig& config, |
675 const QuicServerId& server_id, | 679 const QuicServerId& server_id, |
676 QuicCryptoClientConfig* crypto_config); | 680 QuicCryptoClientConfig* crypto_config); |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 TestQuicSpdyServerSession** server_session); | 1028 TestQuicSpdyServerSession** server_session); |
1025 | 1029 |
1026 // Helper to generate client side stream ids, generalizes | 1030 // Helper to generate client side stream ids, generalizes |
1027 // kClientDataStreamId1 etc. above. | 1031 // kClientDataStreamId1 etc. above. |
1028 QuicStreamId QuicClientDataStreamId(int i); | 1032 QuicStreamId QuicClientDataStreamId(int i); |
1029 | 1033 |
1030 } // namespace test | 1034 } // namespace test |
1031 } // namespace net | 1035 } // namespace net |
1032 | 1036 |
1033 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 1037 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
OLD | NEW |