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

Unified Diff: components/certificate_transparency/mock_log_dns_traffic.h

Issue 2348393002: Minor improvements to MockLogDnsTraffic (Closed)
Patch Set: More documentation about socket read mode of MockLogDnsTraffic 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/certificate_transparency/mock_log_dns_traffic.h
diff --git a/components/certificate_transparency/mock_log_dns_traffic.h b/components/certificate_transparency/mock_log_dns_traffic.h
index f91e66824de64b4a0b1d63914ca54da1977eb80a..bf9391789968a62eefdb6f0f068c40b1270a96c9 100644
--- a/components/certificate_transparency/mock_log_dns_traffic.h
+++ b/components/certificate_transparency/mock_log_dns_traffic.h
@@ -73,10 +73,25 @@ class MockSocketData {
// Mocks DNS requests and responses for a Certificate Transparency (CT) log.
// This is implemented using mock sockets. Call the CreateDnsClient() method to
// get a net::DnsClient wired up to these mock sockets.
// The Expect*() methods must be called from within a GTest test case.
+//
+// Example Usage:
+// // Create a mock NetworkChangeNotifier to propogate DNS config.
+// std::unique_ptr<net::NetworkChangeNotifier> net_change_notifier =
+// net::NetworkChangeNotifier::CreateMock();
+//
+// MockLogDnsTraffic mock_dns;
+// mock_dns.InitializeDnsConfig();
+// // Use the Expect* methods to define expected DNS requests and responses.
+// mock_dns.ExpectLeafIndexRequestAndResponse(
+// "D4S6DSV2J743QJZEQMH4UYHEYK7KRQ5JIQOCPMFUHZVJNFGHXACA.hash.ct.test.",
+// "123456");
+//
+// LogDnsClient log_client(mock_dns.CreateDnsClient(), ...);
+// log_client.QueryLeafIndex("ct.test", ...);
Eran Messeri 2016/09/20 14:31:04 Which message loop should be pumped to guarantee t
Rob Percival 2016/09/20 16:33:11 I've added a few more lines to the example usage t
class MockLogDnsTraffic {
public:
MockLogDnsTraffic();
~MockLogDnsTraffic();
@@ -124,10 +139,12 @@ class MockLogDnsTraffic {
// Creates a DNS client that uses mock sockets.
// It is this DNS client that the expectations will be tested against.
std::unique_ptr<net::DnsClient> CreateDnsClient();
// Sets whether mock reads should complete synchronously or asynchronously.
+ // By default, they complete asynchronously. The only reason to change this
+ // is to test that LogDnsClient handles both modes in the same way.
void SetSocketReadMode(net::IoMode read_mode) {
socket_read_mode_ = read_mode;
}
private:
« 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