Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(154)

Side by Side Diff: net/tools/quic/stateless_rejector_test.cc

Issue 2311543002: Improve test case naming in stateless_rejector_test (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 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/stateless_rejector.h" 5 #include "net/tools/quic/stateless_rejector.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/strings/stringprintf.h"
10 #include "net/quic/core/crypto/crypto_handshake_message.h" 11 #include "net/quic/core/crypto/crypto_handshake_message.h"
11 #include "net/quic/core/crypto/proof_source.h" 12 #include "net/quic/core/crypto/proof_source.h"
12 #include "net/quic/core/quic_utils.h" 13 #include "net/quic/core/quic_utils.h"
13 #include "net/quic/test_tools/crypto_test_utils.h" 14 #include "net/quic/test_tools/crypto_test_utils.h"
14 #include "net/quic/test_tools/quic_crypto_server_config_peer.h" 15 #include "net/quic/test_tools/quic_crypto_server_config_peer.h"
15 #include "net/quic/test_tools/quic_test_utils.h" 16 #include "net/quic/test_tools/quic_test_utils.h"
16 17
17 using std::ostream; 18 using std::ostream;
18 using std::string; 19 using std::string;
19 using std::vector; 20 using std::vector;
20 21
21 namespace net { 22 namespace net {
22 namespace test { 23 namespace test {
23 namespace { 24 namespace {
24 25
25 const QuicConnectionId kConnectionId = 42; 26 const QuicConnectionId kConnectionId = 42;
26 const QuicConnectionId kServerDesignateConnectionId = 24; 27 const QuicConnectionId kServerDesignateConnectionId = 24;
27 28
28 // All four combinations of the two flags involved. 29 // All four combinations of the two flags involved.
29 enum FlagsMode { ENABLED, STATELESS_DISABLED, CHEAP_DISABLED, BOTH_DISABLED }; 30 enum FlagsMode { ENABLED, STATELESS_DISABLED, CHEAP_DISABLED, BOTH_DISABLED };
30 31
32 const char* FlagsModeToString(FlagsMode mode) {
33 switch (mode) {
34 case ENABLED:
35 return "ENABLED";
36 case STATELESS_DISABLED:
37 return "STATELESS_DISABLED";
38 case CHEAP_DISABLED:
39 return "CHEAP_DISABLED";
40 case BOTH_DISABLED:
41 return "BOTH_DISABLED";
42 }
43 }
44
31 // Test various combinations of QUIC version and flag state. 45 // Test various combinations of QUIC version and flag state.
32 struct TestParams { 46 struct TestParams {
33 QuicVersion version; 47 QuicVersion version;
34 FlagsMode flags; 48 FlagsMode flags;
35 friend ostream& operator<<(ostream& os, const TestParams& p) {
36 os << "{ version: " << p.version << " flags: " << p.flags << " }";
37 return os;
38 }
39 }; 49 };
40 50
51 string TestParamToString(const testing::TestParamInfo<TestParams>& params) {
52 return base::StringPrintf("v%i_%s", params.param.version,
53 FlagsModeToString(params.param.flags));
54 }
55
41 vector<TestParams> GetTestParams() { 56 vector<TestParams> GetTestParams() {
42 vector<TestParams> params; 57 vector<TestParams> params;
43 for (FlagsMode flags : 58 for (FlagsMode flags :
44 {ENABLED, STATELESS_DISABLED, CHEAP_DISABLED, BOTH_DISABLED}) { 59 {ENABLED, STATELESS_DISABLED, CHEAP_DISABLED, BOTH_DISABLED}) {
45 for (QuicVersion version : AllSupportedVersions()) { 60 for (QuicVersion version : AllSupportedVersions()) {
46 TestParams param; 61 TestParams param;
47 param.version = version; 62 param.version = version;
48 param.flags = flags; 63 param.flags = flags;
49 params.push_back(param); 64 params.push_back(param);
50 } 65 }
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 // Values used in CHLO messages 138 // Values used in CHLO messages
124 string scid_hex_; 139 string scid_hex_;
125 string nonc_hex_; 140 string nonc_hex_;
126 string pubs_hex_; 141 string pubs_hex_;
127 string ver_hex_; 142 string ver_hex_;
128 string stk_hex_; 143 string stk_hex_;
129 }; 144 };
130 145
131 INSTANTIATE_TEST_CASE_P(Flags, 146 INSTANTIATE_TEST_CASE_P(Flags,
132 StatelessRejectorTest, 147 StatelessRejectorTest,
133 ::testing::ValuesIn(GetTestParams())); 148 ::testing::ValuesIn(GetTestParams()),
149 TestParamToString);
134 150
135 TEST_P(StatelessRejectorTest, InvalidChlo) { 151 TEST_P(StatelessRejectorTest, InvalidChlo) {
136 // clang-format off 152 // clang-format off
137 const CryptoHandshakeMessage client_hello = CryptoTestUtils::Message( 153 const CryptoHandshakeMessage client_hello = CryptoTestUtils::Message(
138 "CHLO", 154 "CHLO",
139 "PDMD", "X509", 155 "PDMD", "X509",
140 "COPT", "SREJ", 156 "COPT", "SREJ",
141 nullptr); 157 nullptr);
142 // clang-format on 158 // clang-format on
143 rejector_.OnChlo(GetParam().version, kConnectionId, 159 rejector_.OnChlo(GetParam().version, kConnectionId,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 if (GetParam().flags != ENABLED || GetParam().version <= QUIC_VERSION_32) { 249 if (GetParam().flags != ENABLED || GetParam().version <= QUIC_VERSION_32) {
234 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_.state()); 250 EXPECT_EQ(StatelessRejector::UNSUPPORTED, rejector_.state());
235 return; 251 return;
236 } 252 }
237 EXPECT_EQ(StatelessRejector::ACCEPTED, rejector_.state()); 253 EXPECT_EQ(StatelessRejector::ACCEPTED, rejector_.state());
238 } 254 }
239 255
240 } // namespace 256 } // namespace
241 } // namespace test 257 } // namespace test
242 } // namespace net 258 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698