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

Unified Diff: components/cronet/android/test/experimental_options_test.cc

Issue 2970563002: Fix hostCachePersistenceTest for devices with no IPv6 connectivity (Closed)
Patch Set: Created 3 years, 6 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/cronet/android/test/experimental_options_test.cc
diff --git a/components/cronet/android/test/experimental_options_test.cc b/components/cronet/android/test/experimental_options_test.cc
index e33fabff4871b393e620271cd175f459625f83be..8804e56d9e9beebc866d83f044279c89a7c81eec 100644
--- a/components/cronet/android/test/experimental_options_test.cc
+++ b/components/cronet/android/test/experimental_options_test.cc
@@ -28,14 +28,23 @@ void WriteToHostCacheOnNetworkThread(jlong jcontext_adapter,
net::URLRequestContext* context =
TestUtil::GetURLRequestContext(jcontext_adapter);
net::HostCache* cache = context->host_resolver()->GetHostCache();
- net::HostCache::Key key("host-cache-test-host",
- net::ADDRESS_FAMILY_UNSPECIFIED, 0);
+ const std::string hostname = "host-cache-test-host";
+
+ // Create multiple keys to ensure the test works in a variety of network
+ // conditions.
+ net::HostCache::Key key1(hostname, net::ADDRESS_FAMILY_UNSPECIFIED, 0);
+ net::HostCache::Key key2(
+ hostname, net::ADDRESS_FAMILY_IPV4,
+ net::HOST_RESOLVER_DEFAULT_FAMILY_SET_DUE_TO_NO_IPV6);
+
net::IPAddress address;
CHECK(address.AssignFromIPLiteral(address_string));
net::AddressList address_list =
net::AddressList::CreateFromIPAddress(address, 0);
net::HostCache::Entry entry(net::OK, address_list);
- cache->Set(key, entry, base::TimeTicks::Now(),
+ cache->Set(key1, entry, base::TimeTicks::Now(),
+ base::TimeDelta::FromSeconds(1));
+ cache->Set(key2, entry, base::TimeTicks::Now(),
base::TimeDelta::FromSeconds(1));
}
} // namespace
« 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