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 "net/quic/crypto/crypto_framer.h" | 8 #include "net/quic/crypto/crypto_framer.h" |
9 #include "net/quic/crypto/crypto_handshake.h" | 9 #include "net/quic/crypto/crypto_handshake.h" |
10 #include "net/quic/crypto/crypto_utils.h" | 10 #include "net/quic/crypto/crypto_utils.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 120 } |
121 | 121 |
122 const QuicClock* MockHelper::GetClock() const { | 122 const QuicClock* MockHelper::GetClock() const { |
123 return &clock_; | 123 return &clock_; |
124 } | 124 } |
125 | 125 |
126 QuicRandom* MockHelper::GetRandomGenerator() { | 126 QuicRandom* MockHelper::GetRandomGenerator() { |
127 return &random_generator_; | 127 return &random_generator_; |
128 } | 128 } |
129 | 129 |
| 130 void MockHelper::AdvanceTime(QuicTime::Delta delta) { |
| 131 clock_.AdvanceTime(delta); |
| 132 } |
| 133 |
130 MockConnection::MockConnection(QuicGuid guid, | 134 MockConnection::MockConnection(QuicGuid guid, |
131 IPEndPoint address, | 135 IPEndPoint address, |
132 bool is_server) | 136 bool is_server) |
133 : QuicConnection(guid, address, new MockHelper(), is_server) { | 137 : QuicConnection(guid, address, new MockHelper(), is_server), |
| 138 has_mock_helper_(true) { |
134 } | 139 } |
135 | 140 |
136 MockConnection::MockConnection(QuicGuid guid, | 141 MockConnection::MockConnection(QuicGuid guid, |
137 IPEndPoint address, | 142 IPEndPoint address, |
138 QuicConnectionHelperInterface* helper, | 143 QuicConnectionHelperInterface* helper, |
139 bool is_server) | 144 bool is_server) |
140 : QuicConnection(guid, address, helper, is_server) { | 145 : QuicConnection(guid, address, helper, is_server), |
| 146 has_mock_helper_(false) { |
141 } | 147 } |
142 | 148 |
143 MockConnection::~MockConnection() { | 149 MockConnection::~MockConnection() { |
144 } | 150 } |
145 | 151 |
| 152 void MockConnection::AdvanceTime(QuicTime::Delta delta) { |
| 153 CHECK(has_mock_helper_) << "Cannot advance time unless a MockClock is being" |
| 154 " used"; |
| 155 static_cast<MockHelper*>(helper())->AdvanceTime(delta); |
| 156 } |
| 157 |
146 PacketSavingConnection::PacketSavingConnection(QuicGuid guid, | 158 PacketSavingConnection::PacketSavingConnection(QuicGuid guid, |
147 IPEndPoint address, | 159 IPEndPoint address, |
148 bool is_server) | 160 bool is_server) |
149 : MockConnection(guid, address, is_server) { | 161 : MockConnection(guid, address, is_server) { |
150 } | 162 } |
151 | 163 |
152 PacketSavingConnection::~PacketSavingConnection() { | 164 PacketSavingConnection::~PacketSavingConnection() { |
153 STLDeleteElements(&packets_); | 165 STLDeleteElements(&packets_); |
154 } | 166 } |
155 | 167 |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 QuicPacketCreator::StreamFramePacketOverhead(1, include_version); | 315 QuicPacketCreator::StreamFramePacketOverhead(1, include_version); |
304 } | 316 } |
305 | 317 |
306 QuicPacketEntropyHash TestEntropyCalculator::ReceivedEntropyHash( | 318 QuicPacketEntropyHash TestEntropyCalculator::ReceivedEntropyHash( |
307 QuicPacketSequenceNumber sequence_number) const { | 319 QuicPacketSequenceNumber sequence_number) const { |
308 return 1u; | 320 return 1u; |
309 } | 321 } |
310 | 322 |
311 } // namespace test | 323 } // namespace test |
312 } // namespace net | 324 } // namespace net |
OLD | NEW |