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_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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 // Uses a Mock helper, ConnectionId of 42, and 127.0.0.1:123. | 62 // Uses a Mock helper, ConnectionId of 42, and 127.0.0.1:123. |
63 MockConnection(bool is_server, const QuicVersionVector& supported_versions); | 63 MockConnection(bool is_server, const QuicVersionVector& supported_versions); |
64 | 64 |
65 virtual ~MockConnection(); | 65 virtual ~MockConnection(); |
66 | 66 |
67 // If the constructor that uses a MockHelper has been used then this method | 67 // If the constructor that uses a MockHelper has been used then this method |
68 // will advance the time of the MockClock. | 68 // will advance the time of the MockClock. |
69 void AdvanceTime(QuicTime::Delta delta); | 69 void AdvanceTime(QuicTime::Delta delta); |
70 | 70 |
71 MOCK_METHOD3(ProcessUdpPacket, void(const IPEndPoint& self_address, | 71 MOCK_METHOD3(ProcessUdpPacket, |
72 const IPEndPoint& peer_address, | 72 void(const IPEndPoint& self_address, |
73 const QuicEncryptedPacket& packet)); | 73 const IPEndPoint& peer_address, |
| 74 const QuicEncryptedPacket& packet)); |
74 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error)); | 75 MOCK_METHOD1(SendConnectionClose, void(QuicErrorCode error)); |
75 MOCK_METHOD2(SendConnectionCloseWithDetails, void( | 76 MOCK_METHOD2(SendConnectionCloseWithDetails, |
76 QuicErrorCode error, | 77 void(QuicErrorCode error, const std::string& details)); |
77 const std::string& details)); | 78 MOCK_METHOD2(SendConnectionClosePacket, |
78 MOCK_METHOD2(SendConnectionClosePacket, void(QuicErrorCode error, | 79 void(QuicErrorCode error, const std::string& details)); |
79 const std::string& details)); | 80 MOCK_METHOD3(SendRstStream, |
80 MOCK_METHOD3(SendRstStream, void(QuicStreamId id, | 81 void(QuicStreamId id, |
81 QuicRstStreamErrorCode error, | 82 QuicRstStreamErrorCode error, |
82 QuicStreamOffset bytes_written)); | 83 QuicStreamOffset bytes_written)); |
83 MOCK_METHOD3(SendGoAway, void(QuicErrorCode error, | 84 MOCK_METHOD3(SendGoAway, |
84 QuicStreamId last_good_stream_id, | 85 void(QuicErrorCode error, |
85 const std::string& reason)); | 86 QuicStreamId last_good_stream_id, |
| 87 const std::string& reason)); |
86 MOCK_METHOD1(SendBlocked, void(QuicStreamId id)); | 88 MOCK_METHOD1(SendBlocked, void(QuicStreamId id)); |
87 MOCK_METHOD2(SendWindowUpdate, void(QuicStreamId id, | 89 MOCK_METHOD2(SendWindowUpdate, |
88 QuicStreamOffset byte_offset)); | 90 void(QuicStreamId id, QuicStreamOffset byte_offset)); |
89 MOCK_METHOD0(OnCanWrite, void()); | 91 MOCK_METHOD0(OnCanWrite, void()); |
90 MOCK_CONST_METHOD0(HasPendingWrites, bool()); | 92 MOCK_CONST_METHOD0(HasPendingWrites, bool()); |
91 | 93 |
92 void ReallyProcessUdpPacket(const IPEndPoint& self_address, | 94 void ReallyProcessUdpPacket(const IPEndPoint& self_address, |
93 const IPEndPoint& peer_address, | 95 const IPEndPoint& peer_address, |
94 const QuicEncryptedPacket& packet) { | 96 const QuicEncryptedPacket& packet) { |
95 return QuicConnection::ProcessUdpPacket(self_address, peer_address, packet); | 97 return QuicConnection::ProcessUdpPacket(self_address, peer_address, packet); |
96 } | 98 } |
97 | 99 |
98 virtual bool OnProtocolVersionMismatch(QuicVersion version) { return false; } | 100 virtual bool OnProtocolVersionMismatch(QuicVersion version) { return false; } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 MOCK_METHOD0(SetWritable, void()); | 139 MOCK_METHOD0(SetWritable, void()); |
138 | 140 |
139 private: | 141 private: |
140 DISALLOW_COPY_AND_ASSIGN(MockPacketWriter); | 142 DISALLOW_COPY_AND_ASSIGN(MockPacketWriter); |
141 }; | 143 }; |
142 | 144 |
143 class MockQuicServerSessionVisitor : public QuicServerSessionVisitor { | 145 class MockQuicServerSessionVisitor : public QuicServerSessionVisitor { |
144 public: | 146 public: |
145 MockQuicServerSessionVisitor(); | 147 MockQuicServerSessionVisitor(); |
146 virtual ~MockQuicServerSessionVisitor(); | 148 virtual ~MockQuicServerSessionVisitor(); |
147 MOCK_METHOD2(OnConnectionClosed, void(QuicConnectionId connection_id, | 149 MOCK_METHOD2(OnConnectionClosed, |
148 QuicErrorCode error)); | 150 void(QuicConnectionId connection_id, QuicErrorCode error)); |
149 MOCK_METHOD1(OnWriteBlocked, void(QuicBlockedWriterInterface* writer)); | 151 MOCK_METHOD1(OnWriteBlocked, void(QuicBlockedWriterInterface* writer)); |
150 | 152 |
151 private: | 153 private: |
152 DISALLOW_COPY_AND_ASSIGN(MockQuicServerSessionVisitor); | 154 DISALLOW_COPY_AND_ASSIGN(MockQuicServerSessionVisitor); |
153 }; | 155 }; |
154 | 156 |
155 class MockAckNotifierDelegate : public QuicAckNotifier::DelegateInterface { | 157 class MockAckNotifierDelegate : public QuicAckNotifier::DelegateInterface { |
156 public: | 158 public: |
157 MockAckNotifierDelegate(); | 159 MockAckNotifierDelegate(); |
158 | 160 |
159 MOCK_METHOD5(OnAckNotification, void(int num_original_packets, | 161 MOCK_METHOD5(OnAckNotification, |
160 int num_original_bytes, | 162 void(int num_original_packets, |
161 int num_retransmitted_packets, | 163 int num_original_bytes, |
162 int num_retransmitted_bytes, | 164 int num_retransmitted_packets, |
163 QuicTime::Delta delta_largest_observed)); | 165 int num_retransmitted_bytes, |
| 166 QuicTime::Delta delta_largest_observed)); |
164 | 167 |
165 protected: | 168 protected: |
166 // Object is ref counted. | 169 // Object is ref counted. |
167 virtual ~MockAckNotifierDelegate(); | 170 virtual ~MockAckNotifierDelegate(); |
168 | 171 |
169 DISALLOW_COPY_AND_ASSIGN(MockAckNotifierDelegate); | 172 DISALLOW_COPY_AND_ASSIGN(MockAckNotifierDelegate); |
170 }; | 173 }; |
171 | 174 |
172 } // namespace test | 175 } // namespace test |
173 } // namespace tools | 176 } // namespace tools |
174 } // namespace net | 177 } // namespace net |
175 | 178 |
176 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ | 179 #endif // NET_TOOLS_QUIC_TEST_TOOLS_QUIC_TEST_UTILS_H_ |
OLD | NEW |