| 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 "net/quic/crypto/crypto_framer.h" | 7 #include "net/quic/crypto/crypto_framer.h" |
| 8 #include "net/quic/crypto/crypto_utils.h" |
| 8 | 9 |
| 9 using std::max; | 10 using std::max; |
| 10 using std::min; | 11 using std::min; |
| 11 using std::string; | 12 using std::string; |
| 12 using testing::_; | 13 using testing::_; |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 namespace test { | 16 namespace test { |
| 16 | 17 |
| 17 MockFramerVisitor::MockFramerVisitor() { | 18 MockFramerVisitor::MockFramerVisitor() { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 } | 74 } |
| 74 | 75 |
| 75 MockScheduler::~MockScheduler() { | 76 MockScheduler::~MockScheduler() { |
| 76 } | 77 } |
| 77 | 78 |
| 78 MockConnection::MockConnection(QuicGuid guid, IPEndPoint address) | 79 MockConnection::MockConnection(QuicGuid guid, IPEndPoint address) |
| 79 : QuicConnection(guid, address, new MockHelper()), | 80 : QuicConnection(guid, address, new MockHelper()), |
| 80 helper_(helper()) { | 81 helper_(helper()) { |
| 81 } | 82 } |
| 82 | 83 |
| 84 MockConnection::MockConnection(QuicGuid guid, |
| 85 IPEndPoint address, |
| 86 QuicConnectionHelperInterface* helper) |
| 87 : QuicConnection(guid, address, helper), |
| 88 helper_(helper) { |
| 89 } |
| 90 |
| 83 MockConnection::~MockConnection() { | 91 MockConnection::~MockConnection() { |
| 84 } | 92 } |
| 85 | 93 |
| 86 PacketSavingConnection::PacketSavingConnection(QuicGuid guid, | 94 PacketSavingConnection::PacketSavingConnection(QuicGuid guid, |
| 87 IPEndPoint address) | 95 IPEndPoint address) |
| 88 : MockConnection(guid, address) { | 96 : MockConnection(guid, address) { |
| 89 } | 97 } |
| 90 | 98 |
| 91 PacketSavingConnection::~PacketSavingConnection() { | 99 PacketSavingConnection::~PacketSavingConnection() { |
| 92 } | 100 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 215 |
| 208 QuicStreamFrame stream_frame(kCryptoStreamId, false, 0, | 216 QuicStreamFrame stream_frame(kCryptoStreamId, false, 0, |
| 209 data->AsStringPiece()); | 217 data->AsStringPiece()); |
| 210 | 218 |
| 211 QuicFrame frame(&stream_frame); | 219 QuicFrame frame(&stream_frame); |
| 212 QuicFrames frames; | 220 QuicFrames frames; |
| 213 frames.push_back(frame); | 221 frames.push_back(frame); |
| 214 return quic_framer.ConstructFrameDataPacket(header, frames); | 222 return quic_framer.ConstructFrameDataPacket(header, frames); |
| 215 } | 223 } |
| 216 | 224 |
| 225 QuicPacket* ConstructClientHelloPacket(QuicGuid guid, |
| 226 const QuicClock* clock, |
| 227 QuicRandom* random_generator) { |
| 228 QuicClientCryptoConfig config; |
| 229 config.SetDefaults(); |
| 230 string nonce; |
| 231 CryptoUtils::GenerateNonce(clock, random_generator, &nonce); |
| 232 |
| 233 CryptoHandshakeMessage message; |
| 234 CryptoUtils::FillClientHelloMessage(config, nonce, &message); |
| 235 CryptoFramer crypto_framer; |
| 236 scoped_ptr<QuicData> data(crypto_framer.ConstructHandshakeMessage(message)); |
| 237 QuicFramer quic_framer(QuicDecrypter::Create(kNULL), |
| 238 QuicEncrypter::Create(kNULL)); |
| 239 |
| 240 QuicPacketHeader header; |
| 241 header.guid = guid; |
| 242 header.packet_sequence_number = 1; |
| 243 header.flags = PACKET_FLAGS_NONE; |
| 244 header.fec_group = 0; |
| 245 |
| 246 QuicStreamFrame stream_frame(kCryptoStreamId, false, 0, |
| 247 data->AsStringPiece()); |
| 248 |
| 249 QuicFrame frame(&stream_frame); |
| 250 QuicFrames frames; |
| 251 frames.push_back(frame); |
| 252 return quic_framer.ConstructFrameDataPacket(header, frames); |
| 253 } |
| 254 |
| 255 |
| 217 } // namespace test | 256 } // namespace test |
| 218 } // namespace net | 257 } // namespace net |
| OLD | NEW |