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 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ | 5 #ifndef NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ |
6 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ | 6 #define NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 namespace test { | 28 namespace test { |
29 | 29 |
30 class HTTPMessage; | 30 class HTTPMessage; |
31 class MockableQuicClient; | 31 class MockableQuicClient; |
32 | 32 |
33 // A quic client which allows mocking out writes. | 33 // A quic client which allows mocking out writes. |
34 class MockableQuicClient : public QuicClient { | 34 class MockableQuicClient : public QuicClient { |
35 public: | 35 public: |
36 MockableQuicClient(IPEndPoint server_address, | 36 MockableQuicClient(IPEndPoint server_address, |
37 const QuicServerId& server_id, | 37 const QuicServerId& server_id, |
38 const QuicVersionVector& supported_versions, | 38 const QuicVersionVector& supported_versions); |
39 uint32 initial_flow_control_window); | |
40 | 39 |
41 MockableQuicClient(IPEndPoint server_address, | 40 MockableQuicClient(IPEndPoint server_address, |
42 const QuicServerId& server_id, | 41 const QuicServerId& server_id, |
43 const QuicConfig& config, | 42 const QuicConfig& config, |
44 const QuicVersionVector& supported_versions, | 43 const QuicVersionVector& supported_versions); |
45 uint32 initial_flow_control_window); | |
46 | 44 |
47 virtual ~MockableQuicClient() OVERRIDE; | 45 virtual ~MockableQuicClient() OVERRIDE; |
48 virtual QuicPacketWriter* CreateQuicPacketWriter() OVERRIDE; | 46 virtual QuicPacketWriter* CreateQuicPacketWriter() OVERRIDE; |
49 virtual QuicConnectionId GenerateConnectionId() OVERRIDE; | 47 virtual QuicConnectionId GenerateConnectionId() OVERRIDE; |
50 void UseWriter(QuicPacketWriterWrapper* writer); | 48 void UseWriter(QuicPacketWriterWrapper* writer); |
51 void UseConnectionId(QuicConnectionId connection_id); | 49 void UseConnectionId(QuicConnectionId connection_id); |
52 | 50 |
53 private: | 51 private: |
54 QuicConnectionId override_connection_id_; // ConnectionId to use, if nonzero | 52 QuicConnectionId override_connection_id_; // ConnectionId to use, if nonzero |
55 QuicPacketWriterWrapper* test_writer_; | 53 QuicPacketWriterWrapper* test_writer_; |
56 | 54 |
57 DISALLOW_COPY_AND_ASSIGN(MockableQuicClient); | 55 DISALLOW_COPY_AND_ASSIGN(MockableQuicClient); |
58 }; | 56 }; |
59 | 57 |
60 // A toy QUIC client used for testing, mostly following the SimpleClient APIs. | 58 // A toy QUIC client used for testing, mostly following the SimpleClient APIs. |
61 class QuicTestClient : public SimpleClient, | 59 class QuicTestClient : public SimpleClient, |
62 public QuicDataStream::Visitor { | 60 public QuicDataStream::Visitor { |
63 public: | 61 public: |
64 QuicTestClient(IPEndPoint server_address, | 62 QuicTestClient(IPEndPoint server_address, |
65 const string& server_hostname, | 63 const string& server_hostname, |
66 const QuicVersionVector& supported_versions); | 64 const QuicVersionVector& supported_versions); |
67 QuicTestClient(IPEndPoint server_address, | 65 QuicTestClient(IPEndPoint server_address, |
68 const string& server_hostname, | 66 const string& server_hostname, |
69 bool secure, | 67 bool secure, |
70 const QuicVersionVector& supported_versions); | 68 const QuicVersionVector& supported_versions); |
71 QuicTestClient(IPEndPoint server_address, | 69 QuicTestClient(IPEndPoint server_address, |
72 const string& server_hostname, | 70 const string& server_hostname, |
73 bool secure, | 71 bool secure, |
74 const QuicConfig& config, | 72 const QuicConfig& config, |
75 const QuicVersionVector& supported_versions, | 73 const QuicVersionVector& supported_versions); |
76 uint32 client_initial_flow_control_receive_window); | |
77 | 74 |
78 virtual ~QuicTestClient(); | 75 virtual ~QuicTestClient(); |
79 | 76 |
80 // ExpectCertificates controls whether the server is expected to provide | 77 // ExpectCertificates controls whether the server is expected to provide |
81 // certificates. The certificates, if any, are not verified, but the common | 78 // certificates. The certificates, if any, are not verified, but the common |
82 // name is recorded and available with |cert_common_name()|. | 79 // name is recorded and available with |cert_common_name()|. |
83 void ExpectCertificates(bool on); | 80 void ExpectCertificates(bool on); |
84 | 81 |
85 // Wraps data in a quic packet and sends it. | 82 // Wraps data in a quic packet and sends it. |
86 ssize_t SendData(string data, bool last_data); | 83 ssize_t SendData(string data, bool last_data); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 193 |
197 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); | 194 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); |
198 }; | 195 }; |
199 | 196 |
200 } // namespace test | 197 } // namespace test |
201 | 198 |
202 } // namespace tools | 199 } // namespace tools |
203 } // namespace net | 200 } // namespace net |
204 | 201 |
205 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ | 202 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ |
OLD | NEW |