| 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_creator.h" | 5 #include "net/quic/core/quic_packet_creator.h" |
| 6 | 6 |
| 7 #include <cstdint> | 7 #include <cstdint> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <ostream> | 9 #include <ostream> |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.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_pending_retransmission.h" | 16 #include "net/quic/core/quic_pending_retransmission.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/platform/api/quic_socket_address.h" | 19 #include "net/quic/platform/api/quic_socket_address.h" |
| 20 #include "net/quic/platform/api/quic_string_piece.h" | 20 #include "net/quic/platform/api/quic_string_piece.h" |
| 21 #include "net/quic/platform/api/quic_test.h" |
| 21 #include "net/quic/test_tools/quic_framer_peer.h" | 22 #include "net/quic/test_tools/quic_framer_peer.h" |
| 22 #include "net/quic/test_tools/quic_packet_creator_peer.h" | 23 #include "net/quic/test_tools/quic_packet_creator_peer.h" |
| 23 #include "net/quic/test_tools/quic_test_utils.h" | 24 #include "net/quic/test_tools/quic_test_utils.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | |
| 25 #include "testing/gtest/include/gtest/gtest.h" | |
| 26 | 25 |
| 27 using std::string; | 26 using std::string; |
| 28 using testing::DoAll; | 27 using testing::DoAll; |
| 29 using testing::InSequence; | 28 using testing::InSequence; |
| 30 using testing::Return; | 29 using testing::Return; |
| 31 using testing::SaveArg; | 30 using testing::SaveArg; |
| 32 using testing::StrictMock; | 31 using testing::StrictMock; |
| 33 using testing::_; | 32 using testing::_; |
| 34 | 33 |
| 35 namespace net { | 34 namespace net { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 MOCK_METHOD1(OnSerializedPacket, void(SerializedPacket* packet)); | 79 MOCK_METHOD1(OnSerializedPacket, void(SerializedPacket* packet)); |
| 81 MOCK_METHOD3(OnUnrecoverableError, | 80 MOCK_METHOD3(OnUnrecoverableError, |
| 82 void(QuicErrorCode, | 81 void(QuicErrorCode, |
| 83 const string&, | 82 const string&, |
| 84 ConnectionCloseSource source)); | 83 ConnectionCloseSource source)); |
| 85 | 84 |
| 86 private: | 85 private: |
| 87 DISALLOW_COPY_AND_ASSIGN(MockDelegate); | 86 DISALLOW_COPY_AND_ASSIGN(MockDelegate); |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 class QuicPacketCreatorTest : public ::testing::TestWithParam<TestParams> { | 89 class QuicPacketCreatorTest : public QuicTestWithParam<TestParams> { |
| 91 public: | 90 public: |
| 92 void ClearSerializedPacketForTests(SerializedPacket* serialized_packet) { | 91 void ClearSerializedPacketForTests(SerializedPacket* serialized_packet) { |
| 93 if (serialized_packet == nullptr) { | 92 if (serialized_packet == nullptr) { |
| 94 return; | 93 return; |
| 95 } | 94 } |
| 96 ClearSerializedPacket(serialized_packet); | 95 ClearSerializedPacket(serialized_packet); |
| 97 } | 96 } |
| 98 | 97 |
| 99 void SaveSerializedPacket(SerializedPacket* serialized_packet) { | 98 void SaveSerializedPacket(SerializedPacket* serialized_packet) { |
| 100 if (serialized_packet == nullptr) { | 99 if (serialized_packet == nullptr) { |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 int num_padding_bytes, | 202 int num_padding_bytes, |
| 204 EncryptionLevel encryption_level, | 203 EncryptionLevel encryption_level, |
| 205 QuicPacketNumberLength packet_number_length) { | 204 QuicPacketNumberLength packet_number_length) { |
| 206 return QuicPendingRetransmission( | 205 return QuicPendingRetransmission( |
| 207 1u, NOT_RETRANSMISSION, retransmittable_frames, has_crypto_handshake, | 206 1u, NOT_RETRANSMISSION, retransmittable_frames, has_crypto_handshake, |
| 208 num_padding_bytes, encryption_level, packet_number_length); | 207 num_padding_bytes, encryption_level, packet_number_length); |
| 209 } | 208 } |
| 210 | 209 |
| 211 static const QuicStreamOffset kOffset = 1u; | 210 static const QuicStreamOffset kOffset = 1u; |
| 212 | 211 |
| 213 QuicFlagSaver flags_; // Save/restore all QUIC flag values. | |
| 214 char buffer_[kMaxPacketSize]; | 212 char buffer_[kMaxPacketSize]; |
| 215 QuicFrames frames_; | 213 QuicFrames frames_; |
| 216 QuicFramer server_framer_; | 214 QuicFramer server_framer_; |
| 217 QuicFramer client_framer_; | 215 QuicFramer client_framer_; |
| 218 StrictMock<MockFramerVisitor> framer_visitor_; | 216 StrictMock<MockFramerVisitor> framer_visitor_; |
| 219 StrictMock<MockDelegate> delegate_; | 217 StrictMock<MockDelegate> delegate_; |
| 220 QuicConnectionId connection_id_; | 218 QuicConnectionId connection_id_; |
| 221 string data_; | 219 string data_; |
| 222 struct iovec iov_; | 220 struct iovec iov_; |
| 223 SimpleBufferAllocator buffer_allocator_; | 221 SimpleBufferAllocator buffer_allocator_; |
| (...skipping 801 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 // Flush all paddings. | 1023 // Flush all paddings. |
| 1026 while (creator_.pending_padding_bytes() > 0) { | 1024 while (creator_.pending_padding_bytes() > 0) { |
| 1027 creator_.Flush(); | 1025 creator_.Flush(); |
| 1028 } | 1026 } |
| 1029 EXPECT_EQ(0u, creator_.pending_padding_bytes()); | 1027 EXPECT_EQ(0u, creator_.pending_padding_bytes()); |
| 1030 } | 1028 } |
| 1031 | 1029 |
| 1032 } // namespace | 1030 } // namespace |
| 1033 } // namespace test | 1031 } // namespace test |
| 1034 } // namespace net | 1032 } // namespace net |
| OLD | NEW |