| 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/tools/quic/test_tools/quic_test_utils.h" | 5 #include "net/tools/quic/test_tools/quic_test_utils.h" |
| 6 | 6 |
| 7 #include "base/sha1.h" | 7 #include "base/sha1.h" |
| 8 #include "net/quic/quic_connection.h" | 8 #include "net/quic/quic_connection.h" |
| 9 #include "net/quic/test_tools/quic_connection_peer.h" | 9 #include "net/quic/test_tools/quic_connection_peer.h" |
| 10 #include "net/quic/test_tools/quic_test_utils.h" | 10 #include "net/quic/test_tools/quic_test_utils.h" |
| 11 #include "net/tools/quic/quic_epoll_connection_helper.h" | 11 #include "net/tools/quic/quic_epoll_connection_helper.h" |
| 12 | 12 |
| 13 using base::StringPiece; | 13 using base::StringPiece; |
| 14 using net::test::kInitialFlowControlWindowForTest; | 14 using net::test::kInitialFlowControlWindowForTest; |
| 15 using net::test::MockHelper; | 15 using net::test::MockHelper; |
| 16 using net::test::QuicConnectionPeer; |
| 16 | 17 |
| 17 namespace net { | 18 namespace net { |
| 18 namespace tools { | 19 namespace tools { |
| 19 namespace test { | 20 namespace test { |
| 20 | 21 |
| 21 MockConnection::MockConnection(bool is_server) | 22 MockConnection::MockConnection(bool is_server) |
| 22 : QuicConnection(kTestConnectionId, | 23 : QuicConnection(kTestConnectionId, |
| 23 IPEndPoint(net::test::Loopback4(), kTestPort), | 24 IPEndPoint(net::test::Loopback4(), kTestPort), |
| 24 new testing::NiceMock<MockHelper>(), | 25 new testing::NiceMock<MockHelper>(), |
| 25 new testing::NiceMock<MockPacketWriter>(), | 26 new testing::NiceMock<MockPacketWriter>(), |
| 26 is_server, QuicSupportedVersions(), | 27 is_server, QuicSupportedVersions()), |
| 27 kInitialFlowControlWindowForTest), | 28 writer_(QuicConnectionPeer::GetWriter(this)), |
| 28 writer_(net::test::QuicConnectionPeer::GetWriter(this)), | |
| 29 helper_(helper()) { | 29 helper_(helper()) { |
| 30 } | 30 } |
| 31 | 31 |
| 32 MockConnection::MockConnection(IPEndPoint address, | 32 MockConnection::MockConnection(IPEndPoint address, |
| 33 bool is_server) | 33 bool is_server) |
| 34 : QuicConnection(kTestConnectionId, address, | 34 : QuicConnection(kTestConnectionId, address, |
| 35 new testing::NiceMock<MockHelper>(), | 35 new testing::NiceMock<MockHelper>(), |
| 36 new testing::NiceMock<MockPacketWriter>(), | 36 new testing::NiceMock<MockPacketWriter>(), |
| 37 is_server, QuicSupportedVersions(), | 37 is_server, QuicSupportedVersions()), |
| 38 kInitialFlowControlWindowForTest), | 38 writer_(QuicConnectionPeer::GetWriter(this)), |
| 39 writer_(net::test::QuicConnectionPeer::GetWriter(this)), | |
| 40 helper_(helper()) { | 39 helper_(helper()) { |
| 41 } | 40 } |
| 42 | 41 |
| 43 MockConnection::MockConnection(QuicConnectionId connection_id, | 42 MockConnection::MockConnection(QuicConnectionId connection_id, |
| 44 bool is_server) | 43 bool is_server) |
| 45 : QuicConnection(connection_id, | 44 : QuicConnection(connection_id, |
| 46 IPEndPoint(net::test::Loopback4(), kTestPort), | 45 IPEndPoint(net::test::Loopback4(), kTestPort), |
| 47 new testing::NiceMock<MockHelper>(), | 46 new testing::NiceMock<MockHelper>(), |
| 48 new testing::NiceMock<MockPacketWriter>(), | 47 new testing::NiceMock<MockPacketWriter>(), |
| 49 is_server, QuicSupportedVersions(), | 48 is_server, QuicSupportedVersions()), |
| 50 kInitialFlowControlWindowForTest), | 49 writer_(QuicConnectionPeer::GetWriter(this)), |
| 51 writer_(net::test::QuicConnectionPeer::GetWriter(this)), | |
| 52 helper_(helper()) { | 50 helper_(helper()) { |
| 53 } | 51 } |
| 54 | 52 |
| 55 MockConnection::MockConnection(bool is_server, | 53 MockConnection::MockConnection(bool is_server, |
| 56 const QuicVersionVector& supported_versions) | 54 const QuicVersionVector& supported_versions) |
| 57 : QuicConnection(kTestConnectionId, | 55 : QuicConnection(kTestConnectionId, |
| 58 IPEndPoint(net::test::Loopback4(), kTestPort), | 56 IPEndPoint(net::test::Loopback4(), kTestPort), |
| 59 new testing::NiceMock<MockHelper>(), | 57 new testing::NiceMock<MockHelper>(), |
| 60 new testing::NiceMock<MockPacketWriter>(), | 58 new testing::NiceMock<MockPacketWriter>(), |
| 61 is_server, QuicSupportedVersions(), | 59 is_server, QuicSupportedVersions()), |
| 62 kInitialFlowControlWindowForTest), | 60 writer_(QuicConnectionPeer::GetWriter(this)), |
| 63 writer_(net::test::QuicConnectionPeer::GetWriter(this)), | |
| 64 helper_(helper()) { | 61 helper_(helper()) { |
| 65 } | 62 } |
| 66 | 63 |
| 67 MockConnection::~MockConnection() { | 64 MockConnection::~MockConnection() { |
| 68 } | 65 } |
| 69 | 66 |
| 70 void MockConnection::AdvanceTime(QuicTime::Delta delta) { | 67 void MockConnection::AdvanceTime(QuicTime::Delta delta) { |
| 71 static_cast<MockHelper*>(helper())->AdvanceTime(delta); | 68 static_cast<MockHelper*>(helper())->AdvanceTime(delta); |
| 72 } | 69 } |
| 73 | 70 |
| 74 uint64 SimpleRandom::RandUint64() { | 71 uint64 SimpleRandom::RandUint64() { |
| 75 unsigned char hash[base::kSHA1Length]; | 72 unsigned char hash[base::kSHA1Length]; |
| 76 base::SHA1HashBytes(reinterpret_cast<unsigned char*>(&seed_), sizeof(seed_), | 73 base::SHA1HashBytes(reinterpret_cast<unsigned char*>(&seed_), sizeof(seed_), |
| 77 hash); | 74 hash); |
| 78 memcpy(&seed_, hash, sizeof(seed_)); | 75 memcpy(&seed_, hash, sizeof(seed_)); |
| 79 return seed_; | 76 return seed_; |
| 80 } | 77 } |
| 81 | 78 |
| 82 TestSession::TestSession(QuicConnection* connection, | 79 TestSession::TestSession(QuicConnection* connection, |
| 83 const QuicConfig& config) | 80 const QuicConfig& config) |
| 84 : QuicSession(connection, config), | 81 : QuicSession(connection, kInitialFlowControlWindowForTest, config), |
| 85 crypto_stream_(NULL) { | 82 crypto_stream_(NULL) { |
| 86 } | 83 } |
| 87 | 84 |
| 88 TestSession::~TestSession() {} | 85 TestSession::~TestSession() {} |
| 89 | 86 |
| 90 void TestSession::SetCryptoStream(QuicCryptoStream* stream) { | 87 void TestSession::SetCryptoStream(QuicCryptoStream* stream) { |
| 91 crypto_stream_ = stream; | 88 crypto_stream_ = stream; |
| 92 } | 89 } |
| 93 | 90 |
| 94 QuicCryptoStream* TestSession::GetCryptoStream() { | 91 QuicCryptoStream* TestSession::GetCryptoStream() { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 109 | 106 |
| 110 MockAckNotifierDelegate::MockAckNotifierDelegate() { | 107 MockAckNotifierDelegate::MockAckNotifierDelegate() { |
| 111 } | 108 } |
| 112 | 109 |
| 113 MockAckNotifierDelegate::~MockAckNotifierDelegate() { | 110 MockAckNotifierDelegate::~MockAckNotifierDelegate() { |
| 114 } | 111 } |
| 115 | 112 |
| 116 } // namespace test | 113 } // namespace test |
| 117 } // namespace tools | 114 } // namespace tools |
| 118 } // namespace net | 115 } // namespace net |
| OLD | NEW |