| 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 #include "net/quic/test_tools/quic_test_utils.h" | 5 #include "net/quic/test_tools/quic_test_utils.h" |
| 6 | 6 |
| 7 #include "base/sha1.h" | 7 #include "base/sha1.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "net/quic/crypto/crypto_framer.h" | 10 #include "net/quic/crypto/crypto_framer.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 void MockHelper::AdvanceTime(QuicTime::Delta delta) { | 224 void MockHelper::AdvanceTime(QuicTime::Delta delta) { |
| 225 clock_.AdvanceTime(delta); | 225 clock_.AdvanceTime(delta); |
| 226 } | 226 } |
| 227 | 227 |
| 228 QuicPacketWriter* NiceMockPacketWriterFactory::Create( | 228 QuicPacketWriter* NiceMockPacketWriterFactory::Create( |
| 229 QuicConnection* /*connection*/) const { | 229 QuicConnection* /*connection*/) const { |
| 230 return new testing::NiceMock<MockPacketWriter>(); | 230 return new testing::NiceMock<MockPacketWriter>(); |
| 231 } | 231 } |
| 232 | 232 |
| 233 MockConnection::MockConnection(MockHelper* helper, Perspective perspective) | 233 MockConnection::MockConnection(MockHelper* helper, Perspective perspective) |
| 234 : MockConnection(helper, perspective, /* is_secure= */ false) {} | |
| 235 | |
| 236 MockConnection::MockConnection(MockHelper* helper, | |
| 237 Perspective perspective, | |
| 238 bool is_secure) | |
| 239 : MockConnection(kTestConnectionId, | 234 : MockConnection(kTestConnectionId, |
| 240 IPEndPoint(TestPeerIPAddress(), kTestPort), | 235 IPEndPoint(TestPeerIPAddress(), kTestPort), |
| 241 helper, | 236 helper, |
| 242 perspective, | 237 perspective, |
| 243 is_secure, | |
| 244 QuicSupportedVersions()) {} | 238 QuicSupportedVersions()) {} |
| 245 | 239 |
| 246 MockConnection::MockConnection(IPEndPoint address, | 240 MockConnection::MockConnection(IPEndPoint address, |
| 247 MockHelper* helper, | 241 MockHelper* helper, |
| 248 Perspective perspective) | 242 Perspective perspective) |
| 249 : MockConnection(kTestConnectionId, | 243 : MockConnection(kTestConnectionId, |
| 250 address, | 244 address, |
| 251 helper, | 245 helper, |
| 252 perspective, | 246 perspective, |
| 253 /* is_secure= */ false, | |
| 254 QuicSupportedVersions()) {} | 247 QuicSupportedVersions()) {} |
| 255 | 248 |
| 256 MockConnection::MockConnection(QuicConnectionId connection_id, | 249 MockConnection::MockConnection(QuicConnectionId connection_id, |
| 257 MockHelper* helper, | 250 MockHelper* helper, |
| 258 Perspective perspective) | 251 Perspective perspective) |
| 259 : MockConnection(connection_id, | 252 : MockConnection(connection_id, |
| 260 helper, | |
| 261 perspective, | |
| 262 /* is_secure= */ false) {} | |
| 263 | |
| 264 MockConnection::MockConnection(QuicConnectionId connection_id, | |
| 265 MockHelper* helper, | |
| 266 Perspective perspective, | |
| 267 bool is_secure) | |
| 268 : MockConnection(connection_id, | |
| 269 IPEndPoint(TestPeerIPAddress(), kTestPort), | 253 IPEndPoint(TestPeerIPAddress(), kTestPort), |
| 270 helper, | 254 helper, |
| 271 perspective, | 255 perspective, |
| 272 is_secure, | |
| 273 QuicSupportedVersions()) {} | 256 QuicSupportedVersions()) {} |
| 274 | 257 |
| 275 MockConnection::MockConnection(MockHelper* helper, | 258 MockConnection::MockConnection(MockHelper* helper, |
| 276 Perspective perspective, | 259 Perspective perspective, |
| 277 const QuicVersionVector& supported_versions) | 260 const QuicVersionVector& supported_versions) |
| 278 : MockConnection(kTestConnectionId, | 261 : MockConnection(kTestConnectionId, |
| 279 IPEndPoint(TestPeerIPAddress(), kTestPort), | 262 IPEndPoint(TestPeerIPAddress(), kTestPort), |
| 280 helper, | 263 helper, |
| 281 perspective, | 264 perspective, |
| 282 /* is_secure= */ false, | |
| 283 supported_versions) {} | 265 supported_versions) {} |
| 284 | 266 |
| 285 MockConnection::MockConnection(QuicConnectionId connection_id, | 267 MockConnection::MockConnection(QuicConnectionId connection_id, |
| 286 IPEndPoint address, | 268 IPEndPoint address, |
| 287 MockHelper* helper, | 269 MockHelper* helper, |
| 288 Perspective perspective, | 270 Perspective perspective, |
| 289 bool is_secure, | |
| 290 const QuicVersionVector& supported_versions) | 271 const QuicVersionVector& supported_versions) |
| 291 : QuicConnection(connection_id, | 272 : QuicConnection(connection_id, |
| 292 address, | 273 address, |
| 293 helper, | 274 helper, |
| 294 NiceMockPacketWriterFactory(), | 275 NiceMockPacketWriterFactory(), |
| 295 /* owns_writer= */ true, | 276 /* owns_writer= */ true, |
| 296 perspective, | 277 perspective, |
| 297 is_secure, | |
| 298 supported_versions) { | 278 supported_versions) { |
| 299 ON_CALL(*this, OnError(_)) | 279 ON_CALL(*this, OnError(_)) |
| 300 .WillByDefault( | 280 .WillByDefault( |
| 301 Invoke(this, &PacketSavingConnection::QuicConnection_OnError)); | 281 Invoke(this, &PacketSavingConnection::QuicConnection_OnError)); |
| 302 } | 282 } |
| 303 | 283 |
| 304 MockConnection::~MockConnection() {} | 284 MockConnection::~MockConnection() {} |
| 305 | 285 |
| 306 void MockConnection::AdvanceTime(QuicTime::Delta delta) { | 286 void MockConnection::AdvanceTime(QuicTime::Delta delta) { |
| 307 static_cast<MockHelper*>(helper())->AdvanceTime(delta); | 287 static_cast<MockHelper*>(helper())->AdvanceTime(delta); |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 // strike register worries that we've just overflowed a uint32 time. | 799 // strike register worries that we've just overflowed a uint32 time. |
| 820 (*server_connection)->AdvanceTime(connection_start_time); | 800 (*server_connection)->AdvanceTime(connection_start_time); |
| 821 } | 801 } |
| 822 | 802 |
| 823 QuicStreamId QuicClientDataStreamId(int i) { | 803 QuicStreamId QuicClientDataStreamId(int i) { |
| 824 return kClientDataStreamId1 + 2 * i; | 804 return kClientDataStreamId1 + 2 * i; |
| 825 } | 805 } |
| 826 | 806 |
| 827 } // namespace test | 807 } // namespace test |
| 828 } // namespace net | 808 } // namespace net |
| OLD | NEW |