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