| 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/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "net/quic/crypto/crypto_framer.h" | 9 #include "net/quic/crypto/crypto_framer.h" |
| 10 #include "net/quic/crypto/crypto_handshake.h" | 10 #include "net/quic/crypto/crypto_handshake.h" |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 void MockHelper::AdvanceTime(QuicTime::Delta delta) { | 185 void MockHelper::AdvanceTime(QuicTime::Delta delta) { |
| 186 clock_.AdvanceTime(delta); | 186 clock_.AdvanceTime(delta); |
| 187 } | 187 } |
| 188 | 188 |
| 189 MockConnection::MockConnection(bool is_server) | 189 MockConnection::MockConnection(bool is_server) |
| 190 : QuicConnection(kTestConnectionId, | 190 : QuicConnection(kTestConnectionId, |
| 191 IPEndPoint(TestPeerIPAddress(), kTestPort), | 191 IPEndPoint(TestPeerIPAddress(), kTestPort), |
| 192 new testing::NiceMock<MockHelper>(), | 192 new testing::NiceMock<MockHelper>(), |
| 193 new testing::NiceMock<MockPacketWriter>(), | 193 new testing::NiceMock<MockPacketWriter>(), |
| 194 is_server, QuicSupportedVersions(), | 194 is_server, QuicSupportedVersions()), |
| 195 kInitialFlowControlWindowForTest), | |
| 196 writer_(QuicConnectionPeer::GetWriter(this)), | 195 writer_(QuicConnectionPeer::GetWriter(this)), |
| 197 helper_(helper()) { | 196 helper_(helper()) { |
| 198 } | 197 } |
| 199 | 198 |
| 200 MockConnection::MockConnection(IPEndPoint address, | 199 MockConnection::MockConnection(IPEndPoint address, |
| 201 bool is_server) | 200 bool is_server) |
| 202 : QuicConnection(kTestConnectionId, address, | 201 : QuicConnection(kTestConnectionId, address, |
| 203 new testing::NiceMock<MockHelper>(), | 202 new testing::NiceMock<MockHelper>(), |
| 204 new testing::NiceMock<MockPacketWriter>(), | 203 new testing::NiceMock<MockPacketWriter>(), |
| 205 is_server, QuicSupportedVersions(), | 204 is_server, QuicSupportedVersions()), |
| 206 kInitialFlowControlWindowForTest), | |
| 207 writer_(QuicConnectionPeer::GetWriter(this)), | 205 writer_(QuicConnectionPeer::GetWriter(this)), |
| 208 helper_(helper()) { | 206 helper_(helper()) { |
| 209 } | 207 } |
| 210 | 208 |
| 211 MockConnection::MockConnection(QuicConnectionId connection_id, | 209 MockConnection::MockConnection(QuicConnectionId connection_id, |
| 212 bool is_server) | 210 bool is_server) |
| 213 : QuicConnection(connection_id, | 211 : QuicConnection(connection_id, |
| 214 IPEndPoint(TestPeerIPAddress(), kTestPort), | 212 IPEndPoint(TestPeerIPAddress(), kTestPort), |
| 215 new testing::NiceMock<MockHelper>(), | 213 new testing::NiceMock<MockHelper>(), |
| 216 new testing::NiceMock<MockPacketWriter>(), | 214 new testing::NiceMock<MockPacketWriter>(), |
| 217 is_server, QuicSupportedVersions(), | 215 is_server, QuicSupportedVersions()), |
| 218 kInitialFlowControlWindowForTest), | |
| 219 writer_(QuicConnectionPeer::GetWriter(this)), | 216 writer_(QuicConnectionPeer::GetWriter(this)), |
| 220 helper_(helper()) { | 217 helper_(helper()) { |
| 221 } | 218 } |
| 222 | 219 |
| 223 MockConnection::MockConnection(bool is_server, | 220 MockConnection::MockConnection(bool is_server, |
| 224 const QuicVersionVector& supported_versions) | 221 const QuicVersionVector& supported_versions) |
| 225 : QuicConnection(kTestConnectionId, | 222 : QuicConnection(kTestConnectionId, |
| 226 IPEndPoint(TestPeerIPAddress(), kTestPort), | 223 IPEndPoint(TestPeerIPAddress(), kTestPort), |
| 227 new testing::NiceMock<MockHelper>(), | 224 new testing::NiceMock<MockHelper>(), |
| 228 new testing::NiceMock<MockPacketWriter>(), | 225 new testing::NiceMock<MockPacketWriter>(), |
| 229 is_server, supported_versions, | 226 is_server, supported_versions), |
| 230 kInitialFlowControlWindowForTest), | |
| 231 writer_(QuicConnectionPeer::GetWriter(this)), | 227 writer_(QuicConnectionPeer::GetWriter(this)), |
| 232 helper_(helper()) { | 228 helper_(helper()) { |
| 233 } | 229 } |
| 234 | 230 |
| 235 MockConnection::~MockConnection() { | 231 MockConnection::~MockConnection() { |
| 236 } | 232 } |
| 237 | 233 |
| 238 void MockConnection::AdvanceTime(QuicTime::Delta delta) { | 234 void MockConnection::AdvanceTime(QuicTime::Delta delta) { |
| 239 static_cast<MockHelper*>(helper())->AdvanceTime(delta); | 235 static_cast<MockHelper*>(helper())->AdvanceTime(delta); |
| 240 } | 236 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 259 const SerializedPacket& packet, | 255 const SerializedPacket& packet, |
| 260 TransmissionType transmission_type) { | 256 TransmissionType transmission_type) { |
| 261 packets_.push_back(packet.packet); | 257 packets_.push_back(packet.packet); |
| 262 QuicEncryptedPacket* encrypted = QuicConnectionPeer::GetFramer(this)-> | 258 QuicEncryptedPacket* encrypted = QuicConnectionPeer::GetFramer(this)-> |
| 263 EncryptPacket(level, packet.sequence_number, *packet.packet); | 259 EncryptPacket(level, packet.sequence_number, *packet.packet); |
| 264 encrypted_packets_.push_back(encrypted); | 260 encrypted_packets_.push_back(encrypted); |
| 265 return true; | 261 return true; |
| 266 } | 262 } |
| 267 | 263 |
| 268 MockSession::MockSession(QuicConnection* connection) | 264 MockSession::MockSession(QuicConnection* connection) |
| 269 : QuicSession(connection, DefaultQuicConfig()) { | 265 : QuicSession(connection, kInitialFlowControlWindowForTest, |
| 266 DefaultQuicConfig()) { |
| 270 ON_CALL(*this, WritevData(_, _, _, _, _)) | 267 ON_CALL(*this, WritevData(_, _, _, _, _)) |
| 271 .WillByDefault(testing::Return(QuicConsumedData(0, false))); | 268 .WillByDefault(testing::Return(QuicConsumedData(0, false))); |
| 272 } | 269 } |
| 273 | 270 |
| 274 MockSession::~MockSession() { | 271 MockSession::~MockSession() { |
| 275 } | 272 } |
| 276 | 273 |
| 277 TestSession::TestSession(QuicConnection* connection, | 274 TestSession::TestSession(QuicConnection* connection, const QuicConfig& config) |
| 278 const QuicConfig& config) | 275 : QuicSession(connection, kInitialFlowControlWindowForTest, config), |
| 279 : QuicSession(connection, config), | 276 crypto_stream_(NULL) {} |
| 280 crypto_stream_(NULL) { | |
| 281 } | |
| 282 | 277 |
| 283 TestSession::~TestSession() {} | 278 TestSession::~TestSession() {} |
| 284 | 279 |
| 285 void TestSession::SetCryptoStream(QuicCryptoStream* stream) { | 280 void TestSession::SetCryptoStream(QuicCryptoStream* stream) { |
| 286 crypto_stream_ = stream; | 281 crypto_stream_ = stream; |
| 287 } | 282 } |
| 288 | 283 |
| 289 QuicCryptoStream* TestSession::GetCryptoStream() { | 284 QuicCryptoStream* TestSession::GetCryptoStream() { |
| 290 return crypto_stream_; | 285 return crypto_stream_; |
| 291 } | 286 } |
| 292 | 287 |
| 293 TestClientSession::TestClientSession(QuicConnection* connection, | 288 TestClientSession::TestClientSession(QuicConnection* connection, |
| 294 const QuicConfig& config) | 289 const QuicConfig& config) |
| 295 : QuicClientSessionBase(connection, config), | 290 : QuicClientSessionBase(connection, kInitialFlowControlWindowForTest, |
| 291 config), |
| 296 crypto_stream_(NULL) { | 292 crypto_stream_(NULL) { |
| 297 EXPECT_CALL(*this, OnProofValid(_)).Times(AnyNumber()); | 293 EXPECT_CALL(*this, OnProofValid(_)).Times(AnyNumber()); |
| 298 } | 294 } |
| 299 | 295 |
| 300 TestClientSession::~TestClientSession() {} | 296 TestClientSession::~TestClientSession() {} |
| 301 | 297 |
| 302 void TestClientSession::SetCryptoStream(QuicCryptoStream* stream) { | 298 void TestClientSession::SetCryptoStream(QuicCryptoStream* stream) { |
| 303 crypto_stream_ = stream; | 299 crypto_stream_ = stream; |
| 304 } | 300 } |
| 305 | 301 |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 546 } |
| 551 | 547 |
| 552 QuicVersionVector SupportedVersions(QuicVersion version) { | 548 QuicVersionVector SupportedVersions(QuicVersion version) { |
| 553 QuicVersionVector versions; | 549 QuicVersionVector versions; |
| 554 versions.push_back(version); | 550 versions.push_back(version); |
| 555 return versions; | 551 return versions; |
| 556 } | 552 } |
| 557 | 553 |
| 558 } // namespace test | 554 } // namespace test |
| 559 } // namespace net | 555 } // namespace net |
| OLD | NEW |