class CryptoTestUtils {
public:
+ // An interface for a source of callbacks. This is used for invoking
+ // callbacks asynchronously.
+ //
+ // Call the RunPendingCallbacks method regularly to run the callbacks from
+ // this source.
+ class CallbackSource {
+ public:
+ virtual ~CallbackSource() {}
+
+ // Runs pending callbacks from this source. If there is no pending
+ // callback, does nothing.
+ virtual void RunPendingCallbacks() = 0;
+ };
+
// FakeClientOptions bundles together a number of options for configuring
// HandshakeWithFakeClient.
struct FakeClientOptions {
// If channel_id_enabled is true then the client will attempt to send a
// ChannelID.
bool channel_id_enabled;
+
+ // If channel_id_source_async is true then the client will use an async
+ // ChannelIDSource for testing. Ignored if channel_id_enabled is false.
+ bool channel_id_source_async;
};
// returns: the number of client hellos that the client sent.
PacketSavingConnection* b_conn,
QuicCryptoStream* b);
+ // CommunicateHandshakeMessagesAndRunCallbacks moves messages from |a| to |b|
+ // and back until |a|'s handshake has completed. If |callback_source| is not
+ // NULL, CommunicateHandshakeMessagesAndRunCallbacks also runs callbacks from
+ // |callback_source| between processing messages.
+ static void CommunicateHandshakeMessagesAndRunCallbacks(
+ PacketSavingConnection* a_conn,
+ QuicCryptoStream* a,
+ PacketSavingConnection* b_conn,
+ QuicCryptoStream* b,
+ CallbackSource* callback_source);
+
// AdvanceHandshake attempts to moves messages from |a| to |b| and |b| to |a|.
// Returns the number of messages moved.
static std::pair<size_t, size_t> AdvanceHandshake(
// returned by |ProofVerifierForTesting|.
static ProofVerifyContext* ProofVerifyContextForTesting();
+ // These functions return a fake |ProofSource|, |ProofVerifier|, or
+ // |ProofVerifyContext| that works with each other. These are suitable for
+ // unit tests that aren't concerned with |ProofSource| and |ProofVerifier|.
+ // TODO(wtc): delete these when Chromium has a working
+ // ProofSourceForTesting().
+ static ProofSource* FakeProofSourceForTesting();
+ static ProofVerifier* FakeProofVerifierForTesting();
+ static ProofVerifyContext* FakeProofVerifyContextForTesting();
+
// MockCommonCertSets returns a CommonCertSets that contains a single set with
// hash |hash|, consisting of the certificate |cert| at index |index|.
static CommonCertSets* MockCommonCertSets(base::StringPiece cert,