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 <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <cstdint> | 11 #include <cstdint> |
12 #include <memory> | 12 #include <memory> |
13 #include <string> | 13 #include <string> |
14 | 14 |
15 #include "base/macros.h" | 15 #include "base/macros.h" |
16 #include "net/base/ip_address.h" | 16 #include "net/base/ip_address.h" |
17 #include "net/base/ip_endpoint.h" | 17 #include "net/base/ip_endpoint.h" |
18 #include "net/quic/core/proto/cached_network_parameters.pb.h" | 18 #include "net/quic/core/proto/cached_network_parameters.pb.h" |
19 #include "net/quic/core/quic_framer.h" | 19 #include "net/quic/core/quic_framer.h" |
20 #include "net/quic/core/quic_packet_creator.h" | 20 #include "net/quic/core/quic_packet_creator.h" |
21 #include "net/quic/core/quic_protocol.h" | 21 #include "net/quic/core/quic_protocol.h" |
22 #include "net/tools/balsa/balsa_frame.h" | 22 #include "net/tools/balsa/balsa_frame.h" |
23 #include "net/tools/epoll_server/epoll_server.h" | 23 #include "net/tools/epoll_server/epoll_server.h" |
24 #include "net/tools/quic/quic_client.h" | 24 #include "net/tools/quic/quic_client.h" |
25 #include "net/tools/quic/test_tools/simple_client.h" | 25 #include "net/tools/quic/test_tools/simple_client.h" |
| 26 #include "testing/gmock/include/gmock/gmock.h" |
26 | 27 |
27 using base::StringPiece; | 28 using base::StringPiece; |
28 | 29 |
29 namespace net { | 30 namespace net { |
30 | 31 |
31 class ProofVerifier; | 32 class ProofVerifier; |
32 | 33 |
33 class ProofVerifier; | 34 class ProofVerifier; |
34 class QuicPacketWriterWrapper; | 35 class QuicPacketWriterWrapper; |
35 | 36 |
36 namespace test { | 37 namespace test { |
37 | 38 |
38 class HTTPMessage; | 39 class HTTPMessage; |
39 class MockableQuicClient; | 40 class MockableQuicClient; |
40 | 41 |
41 // A quic client which allows mocking out writes. | 42 // A quic client which allows mocking out reads and writes. |
42 class MockableQuicClient : public QuicClient { | 43 class MockableQuicClient : public QuicClient { |
43 public: | 44 public: |
44 MockableQuicClient(IPEndPoint server_address, | 45 MockableQuicClient(IPEndPoint server_address, |
45 const QuicServerId& server_id, | 46 const QuicServerId& server_id, |
46 const QuicVersionVector& supported_versions, | 47 const QuicVersionVector& supported_versions, |
47 EpollServer* epoll_server); | 48 EpollServer* epoll_server); |
48 | 49 |
49 MockableQuicClient(IPEndPoint server_address, | 50 MockableQuicClient(IPEndPoint server_address, |
50 const QuicServerId& server_id, | 51 const QuicServerId& server_id, |
51 const QuicConfig& config, | 52 const QuicConfig& config, |
52 const QuicVersionVector& supported_versions, | 53 const QuicVersionVector& supported_versions, |
53 EpollServer* epoll_server); | 54 EpollServer* epoll_server); |
54 | 55 |
55 MockableQuicClient(IPEndPoint server_address, | 56 MockableQuicClient(IPEndPoint server_address, |
56 const QuicServerId& server_id, | 57 const QuicServerId& server_id, |
57 const QuicConfig& config, | 58 const QuicConfig& config, |
58 const QuicVersionVector& supported_versions, | 59 const QuicVersionVector& supported_versions, |
59 EpollServer* epoll_server, | 60 EpollServer* epoll_server, |
60 std::unique_ptr<ProofVerifier> proof_verifier); | 61 std::unique_ptr<ProofVerifier> proof_verifier); |
61 | 62 |
62 ~MockableQuicClient() override; | 63 ~MockableQuicClient() override; |
| 64 |
| 65 // By default, this will call QuicClient::ProcessPacket |
| 66 MOCK_METHOD3(ProcessPacket, |
| 67 void(const IPEndPoint&, |
| 68 const IPEndPoint&, |
| 69 const QuicReceivedPacket&)); |
| 70 |
| 71 void ProcessPacketBase(const IPEndPoint& self_address, |
| 72 const IPEndPoint& peer_address, |
| 73 const QuicReceivedPacket& packet); |
63 QuicPacketWriter* CreateQuicPacketWriter() override; | 74 QuicPacketWriter* CreateQuicPacketWriter() override; |
64 QuicConnectionId GenerateNewConnectionId() override; | 75 QuicConnectionId GenerateNewConnectionId() override; |
65 void UseWriter(QuicPacketWriterWrapper* writer); | 76 void UseWriter(QuicPacketWriterWrapper* writer); |
66 void UseConnectionId(QuicConnectionId connection_id); | 77 void UseConnectionId(QuicConnectionId connection_id); |
67 void SendCachedNetworkParamaters( | 78 void SendCachedNetworkParamaters( |
68 const CachedNetworkParameters& cached_network_params) { | 79 const CachedNetworkParameters& cached_network_params) { |
69 cached_network_paramaters_ = cached_network_params; | 80 cached_network_paramaters_ = cached_network_params; |
70 } | 81 } |
71 | 82 |
72 private: | 83 private: |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 std::string override_sni_; | 318 std::string override_sni_; |
308 | 319 |
309 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); | 320 DISALLOW_COPY_AND_ASSIGN(QuicTestClient); |
310 }; | 321 }; |
311 | 322 |
312 } // namespace test | 323 } // namespace test |
313 | 324 |
314 } // namespace net | 325 } // namespace net |
315 | 326 |
316 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ | 327 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_CLIENT_H_ |
OLD | NEW |