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

Side by Side Diff: net/quic/test_tools/crypto_test_utils.h

Issue 380543003: Add an async ChannelIDSource for testing. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address rch review comments. Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « net/quic/quic_crypto_server_stream_test.cc ('k') | net/quic/test_tools/crypto_test_utils.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ 5 #ifndef NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_
6 #define NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ 6 #define NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_
7 7
8 #include <stdarg.h> 8 #include <stdarg.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 20 matching lines...) Expand all
31 class QuicCryptoServerStream; 31 class QuicCryptoServerStream;
32 class QuicCryptoStream; 32 class QuicCryptoStream;
33 class QuicRandom; 33 class QuicRandom;
34 34
35 namespace test { 35 namespace test {
36 36
37 class PacketSavingConnection; 37 class PacketSavingConnection;
38 38
39 class CryptoTestUtils { 39 class CryptoTestUtils {
40 public: 40 public:
41 // An interface for a source of work. Call the DoPendingWork method regularly
42 // to do the work from this source.
Ryan Hamilton 2014/07/09 22:55:49 Can you mentioned that this may be use for things
wtc 2014/07/09 23:21:48 Done.
43 class WorkSource {
44 public:
45 virtual ~WorkSource() {}
46
47 // Does pending work in this source. If there is no pending work, does
48 // nothing.
49 virtual void DoPendingWork() = 0;
50 };
51
41 // FakeClientOptions bundles together a number of options for configuring 52 // FakeClientOptions bundles together a number of options for configuring
42 // HandshakeWithFakeClient. 53 // HandshakeWithFakeClient.
43 struct FakeClientOptions { 54 struct FakeClientOptions {
44 FakeClientOptions(); 55 FakeClientOptions();
45 56
46 // If dont_verify_certs is true then no ProofVerifier is set on the client. 57 // If dont_verify_certs is true then no ProofVerifier is set on the client.
47 // Thus no certificates will be requested or checked. 58 // Thus no certificates will be requested or checked.
48 bool dont_verify_certs; 59 bool dont_verify_certs;
49 60
50 // If channel_id_enabled is true then the client will attempt to send a 61 // If channel_id_enabled is true then the client will attempt to send a
51 // ChannelID. 62 // ChannelID.
52 bool channel_id_enabled; 63 bool channel_id_enabled;
64
65 // If channel_id_source_async is true then the client will use an async
66 // ChannelIDSource for testing. Ignored if channel_id_enabled is false.
67 bool channel_id_source_async;
53 }; 68 };
54 69
55 // returns: the number of client hellos that the client sent. 70 // returns: the number of client hellos that the client sent.
56 static int HandshakeWithFakeServer(PacketSavingConnection* client_conn, 71 static int HandshakeWithFakeServer(PacketSavingConnection* client_conn,
57 QuicCryptoClientStream* client); 72 QuicCryptoClientStream* client);
58 73
59 // returns: the number of client hellos that the client sent. 74 // returns: the number of client hellos that the client sent.
60 static int HandshakeWithFakeClient(PacketSavingConnection* server_conn, 75 static int HandshakeWithFakeClient(PacketSavingConnection* server_conn,
61 QuicCryptoServerStream* server, 76 QuicCryptoServerStream* server,
62 const FakeClientOptions& options); 77 const FakeClientOptions& options);
63 78
64 // SetupCryptoServerConfigForTest configures |config| and |crypto_config| 79 // SetupCryptoServerConfigForTest configures |config| and |crypto_config|
65 // with sensible defaults for testing. 80 // with sensible defaults for testing.
66 static void SetupCryptoServerConfigForTest( 81 static void SetupCryptoServerConfigForTest(
67 const QuicClock* clock, 82 const QuicClock* clock,
68 QuicRandom* rand, 83 QuicRandom* rand,
69 QuicConfig* config, 84 QuicConfig* config,
70 QuicCryptoServerConfig* crypto_config); 85 QuicCryptoServerConfig* crypto_config);
71 86
72 // CommunicateHandshakeMessages moves messages from |a| to |b| and back until 87 // CommunicateHandshakeMessages moves messages from |a| to |b| and back until
73 // |a|'s handshake has completed. 88 // |a|'s handshake has completed.
74 static void CommunicateHandshakeMessages(PacketSavingConnection* a_conn, 89 static void CommunicateHandshakeMessages(PacketSavingConnection* a_conn,
75 QuicCryptoStream* a, 90 QuicCryptoStream* a,
76 PacketSavingConnection* b_conn, 91 PacketSavingConnection* b_conn,
77 QuicCryptoStream* b); 92 QuicCryptoStream* b);
78 93
94 // CommunicateHandshakeMessagesAndDoWork moves messages from |a| to |b| and
95 // back until |a|'s handshake has completed. If |work_source| is not NULL,
96 // CommunicateHandshakeMessagesAndDoWork also does work from |work_source|
97 // between processing messages.
98 static void CommunicateHandshakeMessagesAndDoWork(
99 PacketSavingConnection* a_conn,
100 QuicCryptoStream* a,
101 PacketSavingConnection* b_conn,
102 QuicCryptoStream* b,
103 WorkSource* work_source = NULL);
Ryan Hamilton 2014/07/09 22:55:49 I suspect that you meant to remove the = NULL here
wtc 2014/07/09 23:21:48 Done. Thank you for catching this!
104
79 // AdvanceHandshake attempts to moves messages from |a| to |b| and |b| to |a|. 105 // AdvanceHandshake attempts to moves messages from |a| to |b| and |b| to |a|.
80 // Returns the number of messages moved. 106 // Returns the number of messages moved.
81 static std::pair<size_t, size_t> AdvanceHandshake( 107 static std::pair<size_t, size_t> AdvanceHandshake(
82 PacketSavingConnection* a_conn, 108 PacketSavingConnection* a_conn,
83 QuicCryptoStream* a, 109 QuicCryptoStream* a,
84 size_t a_i, 110 size_t a_i,
85 PacketSavingConnection* b_conn, 111 PacketSavingConnection* b_conn,
86 QuicCryptoStream* b, 112 QuicCryptoStream* b,
87 size_t b_i); 113 size_t b_i);
88 114
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 QuicCryptoServerStream* server); 178 QuicCryptoServerStream* server);
153 179
154 DISALLOW_COPY_AND_ASSIGN(CryptoTestUtils); 180 DISALLOW_COPY_AND_ASSIGN(CryptoTestUtils);
155 }; 181 };
156 182
157 } // namespace test 183 } // namespace test
158 184
159 } // namespace net 185 } // namespace net
160 186
161 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_ 187 #endif // NET_QUIC_TEST_TOOLS_CRYPTO_TEST_UTILS_H_
OLDNEW
« no previous file with comments | « net/quic/quic_crypto_server_stream_test.cc ('k') | net/quic/test_tools/crypto_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698