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

Unified Diff: net/dns/host_resolver_impl_unittest.cc

Issue 1138833003: Reduce frequency of IPv6 probes in HostResolverImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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/dns/host_resolver_impl.cc ('k') | net/log/test_net_log_entry.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/dns/host_resolver_impl_unittest.cc
diff --git a/net/dns/host_resolver_impl_unittest.cc b/net/dns/host_resolver_impl_unittest.cc
index 9a886a72c1999d13bcf9cc1467d372c0df7b718f..9166350121612230cce81d872c16a364793492ec 100644
--- a/net/dns/host_resolver_impl_unittest.cc
+++ b/net/dns/host_resolver_impl_unittest.cc
@@ -25,6 +25,7 @@
#include "net/dns/dns_client.h"
#include "net/dns/dns_test_util.h"
#include "net/dns/mock_host_resolver.h"
+#include "net/log/test_net_log.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace net {
@@ -530,6 +531,10 @@ class HostResolverImplTest : public testing::Test {
return HostResolverImpl::kMaximumDnsFailures;
}
+ bool IsIPv6Reachable(const BoundNetLog& net_log) {
+ return resolver_->IsIPv6Reachable(net_log);
+ }
+
scoped_refptr<MockHostResolverProc> proc_;
scoped_ptr<HostResolverImpl> resolver_;
ScopedVector<Request> requests_;
@@ -1397,6 +1402,33 @@ TEST_F(HostResolverImplTest, NameCollision127_0_53_53) {
EXPECT_EQ(OK, request->WaitForResult());
}
+TEST_F(HostResolverImplTest, IsIPv6Reachable) {
+ // Verify that two consecutive calls return the same value.
+ TestNetLog net_log;
+ BoundNetLog bound_net_log = BoundNetLog::Make(&net_log, NetLog::SOURCE_NONE);
+ bool result1 = IsIPv6Reachable(bound_net_log);
+ bool result2 = IsIPv6Reachable(bound_net_log);
+ EXPECT_EQ(result1, result2);
+
+ // Filter reachability check events and verify that there are two of them.
+ TestNetLogEntry::List event_list;
+ net_log.GetEntries(&event_list);
+ TestNetLogEntry::List probe_event_list;
+ for (const auto& event : event_list) {
+ if (event.type == NetLog::TYPE_HOST_RESOLVER_IMPL_IPV6_REACHABILITY_CHECK) {
+ probe_event_list.push_back(event);
+ }
+ }
+ ASSERT_EQ(2U, probe_event_list.size());
+
+ // Verify that the first request was not cached and the second one was.
+ bool cached;
+ EXPECT_TRUE(probe_event_list[0].GetBooleanValue("cached", &cached));
+ EXPECT_FALSE(cached);
+ EXPECT_TRUE(probe_event_list[1].GetBooleanValue("cached", &cached));
+ EXPECT_TRUE(cached);
+}
+
DnsConfig CreateValidDnsConfig() {
IPAddressNumber dns_ip;
bool rv = ParseIPLiteralToNumber("192.168.1.0", &dns_ip);
« no previous file with comments | « net/dns/host_resolver_impl.cc ('k') | net/log/test_net_log_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698