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: |