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> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/strings/string_piece.h" | 13 #include "base/strings/string_piece.h" |
14 #include "net/quic/congestion_control/loss_detection_interface.h" | 14 #include "net/quic/congestion_control/loss_detection_interface.h" |
15 #include "net/quic/congestion_control/send_algorithm_interface.h" | 15 #include "net/quic/congestion_control/send_algorithm_interface.h" |
16 #include "net/quic/quic_ack_notifier.h" | 16 #include "net/quic/quic_ack_notifier.h" |
17 #include "net/quic/quic_connection.h" | 17 #include "net/quic/quic_connection.h" |
18 #include "net/quic/quic_framer.h" | 18 #include "net/quic/quic_framer.h" |
19 #include "net/quic/quic_session.h" | 19 #include "net/quic/quic_session.h" |
20 #include "net/quic/quic_spdy_decompressor.h" | 20 #include "net/quic/quic_spdy_decompressor.h" |
21 #include "net/quic/test_tools/mock_clock.h" | 21 #include "net/quic/test_tools/mock_clock.h" |
22 #include "net/quic/test_tools/mock_random.h" | 22 #include "net/quic/test_tools/mock_random.h" |
23 #include "net/spdy/spdy_framer.h" | 23 #include "net/spdy/spdy_framer.h" |
24 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
25 | 25 |
26 namespace net { | 26 namespace net { |
27 | 27 |
28 namespace test { | 28 namespace test { |
29 | 29 |
30 static const QuicGuid kTestGuid = 42; | 30 static const QuicConnectionId kTestConnectionId = 42; |
31 static const int kTestPort = 123; | 31 static const int kTestPort = 123; |
32 | 32 |
33 // Returns the test peer IP address. | 33 // Returns the test peer IP address. |
34 IPAddressNumber TestPeerIPAddress(); | 34 IPAddressNumber TestPeerIPAddress(); |
35 | 35 |
36 // Upper limit on versions we support. | 36 // Upper limit on versions we support. |
37 QuicVersion QuicVersionMax(); | 37 QuicVersion QuicVersionMax(); |
38 | 38 |
39 // Lower limit on versions we support. | 39 // Lower limit on versions we support. |
40 QuicVersion QuicVersionMin(); | 40 QuicVersion QuicVersionMin(); |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 virtual QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) OVERRIDE; | 266 virtual QuicAlarm* CreateAlarm(QuicAlarm::Delegate* delegate) OVERRIDE; |
267 void AdvanceTime(QuicTime::Delta delta); | 267 void AdvanceTime(QuicTime::Delta delta); |
268 | 268 |
269 private: | 269 private: |
270 MockClock clock_; | 270 MockClock clock_; |
271 MockRandom random_generator_; | 271 MockRandom random_generator_; |
272 }; | 272 }; |
273 | 273 |
274 class MockConnection : public QuicConnection { | 274 class MockConnection : public QuicConnection { |
275 public: | 275 public: |
276 // Uses a MockHelper, GUID of 42, and 127.0.0.1:123. | 276 // Uses a MockHelper, ConnectionId of 42, and 127.0.0.1:123. |
277 explicit MockConnection(bool is_server); | 277 explicit MockConnection(bool is_server); |
278 | 278 |
279 // Uses a MockHelper, GUID of 42. | 279 // Uses a MockHelper, ConnectionId of 42. |
280 MockConnection(IPEndPoint address, bool is_server); | 280 MockConnection(IPEndPoint address, bool is_server); |
281 | 281 |
282 // Uses a MockHelper, and 127.0.0.1:123 | 282 // Uses a MockHelper, and 127.0.0.1:123 |
283 MockConnection(QuicGuid guid, bool is_server); | 283 MockConnection(QuicConnectionId connection_id, bool is_server); |
284 | 284 |
285 // Uses a Mock helper, GUID of 42, and 127.0.0.1:123. | 285 // Uses a Mock helper, ConnectionId of 42, and 127.0.0.1:123. |
286 MockConnection(bool is_server, const QuicVersionVector& supported_versions); | 286 MockConnection(bool is_server, const QuicVersionVector& supported_versions); |
287 | 287 |
288 virtual ~MockConnection(); | 288 virtual ~MockConnection(); |
289 | 289 |
290 // If the constructor that uses a MockHelper has been used then this method | 290 // If the constructor that uses a MockHelper has been used then this method |
291 // will advance the time of the MockClock. | 291 // will advance the time of the MockClock. |
292 void AdvanceTime(QuicTime::Delta delta); | 292 void AdvanceTime(QuicTime::Delta delta); |
293 | 293 |
294 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address, | 294 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address, |
295 const IPEndPoint& peer_address, | 295 const IPEndPoint& peer_address, |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
497 | 497 |
498 protected: | 498 protected: |
499 // Object is ref counted. | 499 // Object is ref counted. |
500 virtual ~MockAckNotifierDelegate(); | 500 virtual ~MockAckNotifierDelegate(); |
501 }; | 501 }; |
502 | 502 |
503 } // namespace test | 503 } // namespace test |
504 } // namespace net | 504 } // namespace net |
505 | 505 |
506 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 506 #endif // NET_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
OLD | NEW |