Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(343)

Side by Side Diff: net/tools/quic/test_tools/quic_test_utils.h

Issue 330333006: Land Recent QUIC Changes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix linus_tsan error - reverted the change to ConnectionMigrationClientPortChanged unitttest Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ 7 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
8 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ 8 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
9 9
10 #include <string> 10 #include <string>
(...skipping 16 matching lines...) Expand all
27 27
28 static const QuicConnectionId kTestConnectionId = 42; 28 static const QuicConnectionId kTestConnectionId = 42;
29 static const int kTestPort = 123; 29 static const int kTestPort = 123;
30 static const uint32 kInitialFlowControlWindowForTest = 32 * 1024; // 32 KB 30 static const uint32 kInitialFlowControlWindowForTest = 32 * 1024; // 32 KB
31 31
32 // Testing convenience method to construct a QuicAckFrame with |num_nack_ranges| 32 // Testing convenience method to construct a QuicAckFrame with |num_nack_ranges|
33 // nack ranges of width 1 packet, starting from |least_unacked|. 33 // nack ranges of width 1 packet, starting from |least_unacked|.
34 QuicAckFrame MakeAckFrameWithNackRanges(size_t num_nack_ranges, 34 QuicAckFrame MakeAckFrameWithNackRanges(size_t num_nack_ranges,
35 QuicPacketSequenceNumber least_unacked); 35 QuicPacketSequenceNumber least_unacked);
36 36
37 // Simple random number generator used to compute random numbers suitable
38 // for pseudo-randomly dropping packets in tests. It works by computing
39 // the sha1 hash of the current seed, and using the first 64 bits as
40 // the next random number, and the next seed.
41 class SimpleRandom {
42 public:
43 SimpleRandom() : seed_(0) {}
44
45 // Returns a random number in the range [0, kuint64max].
46 uint64 RandUint64();
47
48 void set_seed(uint64 seed) { seed_ = seed; }
49
50 private:
51 uint64 seed_;
52
53 DISALLOW_COPY_AND_ASSIGN(SimpleRandom);
54 };
55
56 class MockConnection : public QuicConnection { 37 class MockConnection : public QuicConnection {
57 public: 38 public:
58 // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123. 39 // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123.
59 explicit MockConnection(bool is_server); 40 explicit MockConnection(bool is_server);
60 41
61 // Uses a MockHelper, ConnectionId of 42. 42 // Uses a MockHelper, ConnectionId of 42.
62 MockConnection(IPEndPoint address, bool is_server); 43 MockConnection(IPEndPoint address, bool is_server);
63 44
64 // Uses a MockHelper, and 127.0.0.1:123 45 // Uses a MockHelper, and 127.0.0.1:123
65 MockConnection(QuicConnectionId connection_id, bool is_server); 46 MockConnection(QuicConnectionId connection_id, bool is_server);
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 virtual ~MockAckNotifierDelegate(); 153 virtual ~MockAckNotifierDelegate();
173 154
174 DISALLOW_COPY_AND_ASSIGN(MockAckNotifierDelegate); 155 DISALLOW_COPY_AND_ASSIGN(MockAckNotifierDelegate);
175 }; 156 };
176 157
177 } // namespace test 158 } // namespace test
178 } // namespace tools 159 } // namespace tools
179 } // namespace net 160 } // namespace net
180 161
181 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ 162 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « net/tools/quic/test_tools/quic_test_client.cc ('k') | net/tools/quic/test_tools/quic_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698