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/core/quic_packet_generator.h" | 5 #include "net/quic/core/quic_packet_generator.h" |
6 | 6 |
7 #include <cstdint> | 7 #include <cstdint> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "net/quic/core/crypto/crypto_protocol.h" | 12 #include "net/quic/core/crypto/crypto_protocol.h" |
13 #include "net/quic/core/crypto/null_encrypter.h" | 13 #include "net/quic/core/crypto/null_encrypter.h" |
14 #include "net/quic/core/crypto/quic_decrypter.h" | 14 #include "net/quic/core/crypto/quic_decrypter.h" |
15 #include "net/quic/core/crypto/quic_encrypter.h" | 15 #include "net/quic/core/crypto/quic_encrypter.h" |
16 #include "net/quic/core/quic_flags.h" | 16 #include "net/quic/core/quic_flags.h" |
17 #include "net/quic/core/quic_simple_buffer_allocator.h" | 17 #include "net/quic/core/quic_simple_buffer_allocator.h" |
18 #include "net/quic/core/quic_utils.h" | 18 #include "net/quic/core/quic_utils.h" |
19 #include "net/quic/test_tools/quic_packet_creator_peer.h" | 19 #include "net/quic/test_tools/quic_packet_creator_peer.h" |
20 #include "net/quic/test_tools/quic_packet_generator_peer.h" | 20 #include "net/quic/test_tools/quic_packet_generator_peer.h" |
21 #include "net/quic/test_tools/quic_test_utils.h" | 21 #include "net/quic/test_tools/quic_test_utils.h" |
22 #include "net/quic/test_tools/simple_quic_framer.h" | 22 #include "net/quic/test_tools/simple_quic_framer.h" |
23 #include "net/test/gtest_util.h" | 23 #include "net/test/gtest_util.h" |
24 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
26 | 26 |
27 using base::StringPiece; | 27 using base::StringPiece; |
28 using std::string; | 28 using std::string; |
29 using std::vector; | |
30 using testing::InSequence; | 29 using testing::InSequence; |
31 using testing::Return; | 30 using testing::Return; |
32 using testing::StrictMock; | 31 using testing::StrictMock; |
33 using testing::_; | 32 using testing::_; |
34 | 33 |
35 namespace net { | 34 namespace net { |
36 namespace test { | 35 namespace test { |
37 namespace { | 36 namespace { |
38 | 37 |
39 class MockDelegate : public QuicPacketGenerator::DelegateInterface { | 38 class MockDelegate : public QuicPacketGenerator::DelegateInterface { |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 return ::net::MakeIOVector(s, &iov_); | 206 return ::net::MakeIOVector(s, &iov_); |
208 } | 207 } |
209 | 208 |
210 QuicFramer framer_; | 209 QuicFramer framer_; |
211 MockRandom random_; | 210 MockRandom random_; |
212 SimpleBufferAllocator buffer_allocator_; | 211 SimpleBufferAllocator buffer_allocator_; |
213 StrictMock<MockDelegate> delegate_; | 212 StrictMock<MockDelegate> delegate_; |
214 QuicPacketGenerator generator_; | 213 QuicPacketGenerator generator_; |
215 QuicPacketCreator* creator_; | 214 QuicPacketCreator* creator_; |
216 SimpleQuicFramer simple_framer_; | 215 SimpleQuicFramer simple_framer_; |
217 vector<SerializedPacket> packets_; | 216 std::vector<SerializedPacket> packets_; |
218 QuicAckFrame ack_frame_; | 217 QuicAckFrame ack_frame_; |
219 | 218 |
220 private: | 219 private: |
221 std::unique_ptr<char[]> data_array_; | 220 std::unique_ptr<char[]> data_array_; |
222 struct iovec iov_; | 221 struct iovec iov_; |
223 }; | 222 }; |
224 | 223 |
225 class MockDebugDelegate : public QuicPacketCreator::DebugDelegate { | 224 class MockDebugDelegate : public QuicPacketCreator::DebugDelegate { |
226 public: | 225 public: |
227 MOCK_METHOD1(OnFrameAddedToPacket, void(const QuicFrame&)); | 226 MOCK_METHOD1(OnFrameAddedToPacket, void(const QuicFrame&)); |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 frame->error_details = error_details.as_string(); | 885 frame->error_details = error_details.as_string(); |
887 EXPECT_CALL(delegate_, | 886 EXPECT_CALL(delegate_, |
888 OnUnrecoverableError(QUIC_FAILED_TO_SERIALIZE_PACKET, | 887 OnUnrecoverableError(QUIC_FAILED_TO_SERIALIZE_PACKET, |
889 "Single frame cannot fit into a packet", _)); | 888 "Single frame cannot fit into a packet", _)); |
890 EXPECT_QUIC_BUG(generator_.AddControlFrame(QuicFrame(frame)), ""); | 889 EXPECT_QUIC_BUG(generator_.AddControlFrame(QuicFrame(frame)), ""); |
891 EXPECT_TRUE(generator_.HasQueuedFrames()); | 890 EXPECT_TRUE(generator_.HasQueuedFrames()); |
892 } | 891 } |
893 | 892 |
894 } // namespace test | 893 } // namespace test |
895 } // namespace net | 894 } // namespace net |
OLD | NEW |