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 "net/quic/test_tools/quic_test_utils.h" | 7 #include "net/quic/test_tools/quic_test_utils.h" |
8 #include "net/tools/quic/quic_epoll_connection_helper.h" | 8 #include "net/tools/quic/quic_epoll_connection_helper.h" |
9 | 9 |
10 using base::StringPiece; | 10 using base::StringPiece; |
11 using net::test::MockHelper; | 11 using net::test::MockHelper; |
12 | 12 |
13 namespace net { | 13 namespace net { |
14 namespace tools { | 14 namespace tools { |
15 namespace test { | 15 namespace test { |
16 | 16 |
17 MockConnection::MockConnection(QuicGuid guid, | 17 MockConnection::MockConnection(QuicGuid guid, |
18 IPEndPoint address, | 18 IPEndPoint address, |
19 int fd, | 19 int fd, |
20 EpollServer* eps, | 20 EpollServer* eps, |
21 bool is_server) | 21 bool is_server) |
22 : QuicConnection(guid, address, | 22 : QuicConnection(guid, address, |
23 new QuicEpollConnectionHelper(fd, eps), is_server), | 23 new QuicEpollConnectionHelper(fd, eps), is_server), |
24 has_mock_helper_(false) { | 24 has_mock_helper_(false) { |
25 } | 25 } |
26 | 26 |
27 MockConnection::MockConnection(QuicGuid guid, | 27 MockConnection::MockConnection(QuicGuid guid, |
28 IPEndPoint address, | 28 IPEndPoint address, |
29 bool is_server) | 29 bool is_server) |
30 : QuicConnection(guid, address, new MockHelper(), is_server), | 30 : QuicConnection(guid, address, new testing::NiceMock<MockHelper>(), |
| 31 is_server), |
31 has_mock_helper_(true) { | 32 has_mock_helper_(true) { |
32 } | 33 } |
33 | 34 |
34 MockConnection::MockConnection(QuicGuid guid, | 35 MockConnection::MockConnection(QuicGuid guid, |
35 IPEndPoint address, | 36 IPEndPoint address, |
36 QuicConnectionHelperInterface* helper, | 37 QuicConnectionHelperInterface* helper, |
37 bool is_server) | 38 bool is_server) |
38 : QuicConnection(guid, address, helper, is_server), | 39 : QuicConnection(guid, address, helper, is_server), |
39 has_mock_helper_(false) { | 40 has_mock_helper_(false) { |
40 } | 41 } |
41 | 42 |
42 MockConnection::~MockConnection() { | 43 MockConnection::~MockConnection() { |
43 } | 44 } |
44 | 45 |
45 void MockConnection::AdvanceTime(QuicTime::Delta delta) { | 46 void MockConnection::AdvanceTime(QuicTime::Delta delta) { |
46 CHECK(has_mock_helper_) << "Cannot advance time unless a MockClock is being" | 47 CHECK(has_mock_helper_) << "Cannot advance time unless a MockClock is being" |
47 " used"; | 48 " used"; |
48 static_cast<MockHelper*>(helper())->AdvanceTime(delta); | 49 static_cast<MockHelper*>(helper())->AdvanceTime(delta); |
49 } | 50 } |
50 | 51 |
51 bool TestDecompressorVisitor::OnDecompressedData(StringPiece data) { | 52 bool TestDecompressorVisitor::OnDecompressedData(StringPiece data) { |
52 data.AppendToString(&data_); | 53 data.AppendToString(&data_); |
53 return true; | 54 return true; |
54 } | 55 } |
55 | 56 |
| 57 TestSession::TestSession(QuicConnection* connection, bool is_server) |
| 58 : QuicSession(connection, is_server), |
| 59 crypto_stream_(NULL) { |
| 60 } |
| 61 |
| 62 TestSession::~TestSession() {} |
| 63 |
| 64 void TestSession::SetCryptoStream(QuicCryptoStream* stream) { |
| 65 crypto_stream_ = stream; |
| 66 } |
| 67 |
| 68 QuicCryptoStream* TestSession::GetCryptoStream() { |
| 69 return crypto_stream_; |
| 70 } |
| 71 |
56 } // namespace test | 72 } // namespace test |
57 } // namespace tools | 73 } // namespace tools |
58 } // namespace net | 74 } // namespace net |
OLD | NEW |