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

Unified Diff: net/dns/dns_test_util.h

Issue 22909037: [net/dns] Reland of 218616 (Simultaneous A/AAAA queries). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix printing unsigned Created 7 years, 4 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 | « net/base/priority_queue_unittest.cc ('k') | net/dns/dns_test_util.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/dns_test_util.h
===================================================================
--- net/dns/dns_test_util.h (revision 219192)
+++ net/dns/dns_test_util.h (working copy)
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/memory/scoped_ptr.h"
+#include "net/dns/dns_client.h"
#include "net/dns/dns_config_service.h"
#include "net/dns/dns_protocol.h"
@@ -174,7 +175,9 @@
// +2 for the CNAME records, +1 for TXT record.
static const unsigned kT3RecordCount = arraysize(kT3IpAddresses) + 3;
+class AddressSorter;
class DnsClient;
+class MockTransactionFactory;
struct MockDnsClientRule {
enum Result {
@@ -184,22 +187,44 @@
OK, // Return a response with loopback address.
};
+ // If |delay| is true, matching transactions will be delayed until triggered
+ // by the consumer.
MockDnsClientRule(const std::string& prefix_arg,
uint16 qtype_arg,
- Result result_arg)
- : result(result_arg), prefix(prefix_arg), qtype(qtype_arg) { }
+ Result result_arg,
+ bool delay)
+ : result(result_arg), prefix(prefix_arg), qtype(qtype_arg),
+ delay(delay) {}
Result result;
std::string prefix;
uint16 qtype;
+ bool delay;
};
typedef std::vector<MockDnsClientRule> MockDnsClientRuleList;
-// Creates mock DnsClient for testing HostResolverImpl.
-scoped_ptr<DnsClient> CreateMockDnsClient(const DnsConfig& config,
- const MockDnsClientRuleList& rules);
+// MockDnsClient provides MockTransactionFactory.
+class MockDnsClient : public DnsClient {
+ public:
+ MockDnsClient(const DnsConfig& config, const MockDnsClientRuleList& rules);
+ virtual ~MockDnsClient();
+ // DnsClient interface:
+ virtual void SetConfig(const DnsConfig& config) OVERRIDE;
+ virtual const DnsConfig* GetConfig() const OVERRIDE;
+ virtual DnsTransactionFactory* GetTransactionFactory() OVERRIDE;
+ virtual AddressSorter* GetAddressSorter() OVERRIDE;
+
+ // Completes all DnsTransactions that were delayed by a rule.
+ void CompleteDelayedTransactions();
+
+ private:
+ DnsConfig config_;
+ scoped_ptr<MockTransactionFactory> factory_;
+ scoped_ptr<AddressSorter> address_sorter_;
+};
+
} // namespace net
#endif // NET_DNS_DNS_TEST_UTIL_H_
« no previous file with comments | « net/base/priority_queue_unittest.cc ('k') | net/dns/dns_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698