| 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/quic_packet_creator.h" | 5 #include "net/quic/quic_packet_creator.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "net/quic/crypto/null_encrypter.h" | 8 #include "net/quic/crypto/null_encrypter.h" |
| 9 #include "net/quic/crypto/quic_decrypter.h" | 9 #include "net/quic/crypto/quic_decrypter.h" |
| 10 #include "net/quic/crypto/quic_encrypter.h" | 10 #include "net/quic/crypto/quic_encrypter.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 using testing::SaveArg; | 23 using testing::SaveArg; |
| 24 using testing::_; | 24 using testing::_; |
| 25 | 25 |
| 26 namespace net { | 26 namespace net { |
| 27 namespace test { | 27 namespace test { |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 class QuicPacketCreatorTest : public ::testing::TestWithParam<bool> { | 30 class QuicPacketCreatorTest : public ::testing::TestWithParam<bool> { |
| 31 protected: | 31 protected: |
| 32 QuicPacketCreatorTest() | 32 QuicPacketCreatorTest() |
| 33 : server_framer_(kQuicVersion1, | 33 : server_framer_(kQuicVersion1, QuicTime::Zero(), true), |
| 34 QuicDecrypter::Create(kNULL), | 34 client_framer_(kQuicVersion1, QuicTime::Zero(), false), |
| 35 QuicEncrypter::Create(kNULL), | |
| 36 QuicTime::Zero(), | |
| 37 true), | |
| 38 client_framer_(kQuicVersion1, | |
| 39 QuicDecrypter::Create(kNULL), | |
| 40 QuicEncrypter::Create(kNULL), | |
| 41 QuicTime::Zero(), | |
| 42 false), | |
| 43 id_(1), | 35 id_(1), |
| 44 sequence_number_(0), | 36 sequence_number_(0), |
| 45 guid_(2), | 37 guid_(2), |
| 46 data_("foo"), | 38 data_("foo"), |
| 47 creator_(guid_, &client_framer_, QuicRandom::GetInstance(), false) { | 39 creator_(guid_, &client_framer_, QuicRandom::GetInstance(), false) { |
| 48 client_framer_.set_visitor(&framer_visitor_); | 40 client_framer_.set_visitor(&framer_visitor_); |
| 49 server_framer_.set_visitor(&framer_visitor_); | 41 server_framer_.set_visitor(&framer_visitor_); |
| 50 } | 42 } |
| 51 ~QuicPacketCreatorTest() { | 43 ~QuicPacketCreatorTest() { |
| 52 } | 44 } |
| 53 | 45 |
| 54 void ProcessPacket(QuicPacket* packet) { | 46 void ProcessPacket(QuicPacket* packet) { |
| 55 scoped_ptr<QuicEncryptedPacket> encrypted( | 47 scoped_ptr<QuicEncryptedPacket> encrypted( |
| 56 server_framer_.EncryptPacket(sequence_number_, *packet)); | 48 server_framer_.EncryptPacket(ENCRYPTION_NONE, sequence_number_, |
| 49 *packet)); |
| 57 server_framer_.ProcessPacket(*encrypted); | 50 server_framer_.ProcessPacket(*encrypted); |
| 58 } | 51 } |
| 59 | 52 |
| 60 void CheckStreamFrame(const QuicFrame& frame, QuicStreamId stream_id, | 53 void CheckStreamFrame(const QuicFrame& frame, QuicStreamId stream_id, |
| 61 const string& data, QuicStreamOffset offset, bool fin) { | 54 const string& data, QuicStreamOffset offset, bool fin) { |
| 62 EXPECT_EQ(STREAM_FRAME, frame.type); | 55 EXPECT_EQ(STREAM_FRAME, frame.type); |
| 63 ASSERT_TRUE(frame.stream_frame); | 56 ASSERT_TRUE(frame.stream_frame); |
| 64 EXPECT_EQ(stream_id, frame.stream_frame->stream_id); | 57 EXPECT_EQ(stream_id, frame.stream_frame->stream_id); |
| 65 EXPECT_EQ(data, frame.stream_frame->data); | 58 EXPECT_EQ(data, frame.stream_frame->data); |
| 66 EXPECT_EQ(offset, frame.stream_frame->offset); | 59 EXPECT_EQ(offset, frame.stream_frame->offset); |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 EXPECT_FALSE(creator_.HasPendingFrames()); | 284 EXPECT_FALSE(creator_.HasPendingFrames()); |
| 292 EXPECT_EQ(max_plaintext_size - | 285 EXPECT_EQ(max_plaintext_size - |
| 293 GetPacketHeaderSize( | 286 GetPacketHeaderSize( |
| 294 QuicPacketCreatorPeer::SendVersionInPacket(&creator_)), | 287 QuicPacketCreatorPeer::SendVersionInPacket(&creator_)), |
| 295 creator_.BytesFree()); | 288 creator_.BytesFree()); |
| 296 } | 289 } |
| 297 | 290 |
| 298 } // namespace | 291 } // namespace |
| 299 } // namespace test | 292 } // namespace test |
| 300 } // namespace net | 293 } // namespace net |
| OLD | NEW |