| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/tools/quic/chlo_extractor.h" | 5 #include "net/tools/quic/chlo_extractor.h" |
| 6 | 6 |
| 7 #include "net/quic/core/quic_framer.h" | 7 #include "net/quic/core/quic_framer.h" |
| 8 #include "net/quic/platform/api/quic_test.h" |
| 8 #include "net/quic/test_tools/crypto_test_utils.h" | 9 #include "net/quic/test_tools/crypto_test_utils.h" |
| 9 #include "net/quic/test_tools/quic_test_utils.h" | 10 #include "net/quic/test_tools/quic_test_utils.h" |
| 10 | 11 |
| 11 using std::string; | 12 using std::string; |
| 12 using testing::Return; | 13 using testing::Return; |
| 13 using testing::_; | 14 using testing::_; |
| 14 | 15 |
| 15 namespace net { | 16 namespace net { |
| 16 namespace test { | 17 namespace test { |
| 17 namespace { | 18 namespace { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 33 QuicConnectionId connection_id() const { return connection_id_; } | 34 QuicConnectionId connection_id() const { return connection_id_; } |
| 34 QuicVersion version() const { return version_; } | 35 QuicVersion version() const { return version_; } |
| 35 const string& chlo() const { return chlo_; } | 36 const string& chlo() const { return chlo_; } |
| 36 | 37 |
| 37 private: | 38 private: |
| 38 QuicConnectionId connection_id_; | 39 QuicConnectionId connection_id_; |
| 39 QuicVersion version_; | 40 QuicVersion version_; |
| 40 string chlo_; | 41 string chlo_; |
| 41 }; | 42 }; |
| 42 | 43 |
| 43 class ChloExtractorTest : public ::testing::Test { | 44 class ChloExtractorTest : public QuicTest { |
| 44 public: | 45 public: |
| 45 ChloExtractorTest() { | 46 ChloExtractorTest() { |
| 46 header_.public_header.connection_id = 42; | 47 header_.public_header.connection_id = 42; |
| 47 header_.public_header.connection_id_length = PACKET_8BYTE_CONNECTION_ID; | 48 header_.public_header.connection_id_length = PACKET_8BYTE_CONNECTION_ID; |
| 48 header_.public_header.version_flag = true; | 49 header_.public_header.version_flag = true; |
| 49 header_.public_header.versions = | 50 header_.public_header.versions = |
| 50 SupportedVersions(AllSupportedVersions().front()); | 51 SupportedVersions(AllSupportedVersions().front()); |
| 51 header_.public_header.reset_flag = false; | 52 header_.public_header.reset_flag = false; |
| 52 header_.public_header.packet_number_length = PACKET_6BYTE_PACKET_NUMBER; | 53 header_.public_header.packet_number_length = PACKET_6BYTE_PACKET_NUMBER; |
| 53 header_.packet_number = 1; | 54 header_.packet_number = 1; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 130 |
| 130 TEST_F(ChloExtractorTest, DoesNotFindInvalidChlo) { | 131 TEST_F(ChloExtractorTest, DoesNotFindInvalidChlo) { |
| 131 MakePacket(new QuicStreamFrame(kCryptoStreamId, false, 0, "foo")); | 132 MakePacket(new QuicStreamFrame(kCryptoStreamId, false, 0, "foo")); |
| 132 EXPECT_FALSE( | 133 EXPECT_FALSE( |
| 133 ChloExtractor::Extract(*packet_, AllSupportedVersions(), &delegate_)); | 134 ChloExtractor::Extract(*packet_, AllSupportedVersions(), &delegate_)); |
| 134 } | 135 } |
| 135 | 136 |
| 136 } // namespace | 137 } // namespace |
| 137 } // namespace test | 138 } // namespace test |
| 138 } // namespace net | 139 } // namespace net |
| OLD | NEW |