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

Unified Diff: components/cronet/stale_host_resolver_unittest.cc

Issue 2692043002: Allow HostCache to handle network changes itself (Closed)
Patch Set: Created 3 years, 10 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 | « components/cronet/android/BUILD.gn ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/cronet/stale_host_resolver_unittest.cc
diff --git a/components/cronet/stale_host_resolver_unittest.cc b/components/cronet/stale_host_resolver_unittest.cc
index 75b51c4b3238711df34ec94274a13e52685a1c37..9c1685e431681a63f57d3743ed4fbb2efb01d4bd 100644
--- a/components/cronet/stale_host_resolver_unittest.cc
+++ b/components/cronet/stale_host_resolver_unittest.cc
@@ -14,7 +14,9 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/values.h"
#include "components/cronet/url_request_context_config.h"
+#include "net/android/network_change_notifier_factory_android.h"
#include "net/base/net_errors.h"
+#include "net/base/network_change_notifier.h"
#include "net/cert/cert_verifier.h"
#include "net/dns/host_resolver_proc.h"
#include "net/http/http_network_session.h"
@@ -135,6 +137,12 @@ class StaleHostResolverTest : public testing::Test {
resolver_ = nullptr;
}
+ void CreateNetworkChangeNotifier() {
+ net::NetworkChangeNotifier::SetFactory(
+ new net::NetworkChangeNotifierFactoryAndroid());
+ net::NetworkChangeNotifier::Create();
+ }
+
// Creates a cache entry for |kHostname| that is |age_sec| seconds old.
void CreateCacheEntry(int age_sec) {
DCHECK(resolver_);
@@ -149,10 +157,8 @@ class StaleHostResolverTest : public testing::Test {
}
void OnNetworkChange() {
- DCHECK(resolver_);
- DCHECK(resolver_->GetHostCache());
-
- resolver_->GetHostCache()->OnNetworkChange();
+ net::NetworkChangeNotifier::NotifyObserversOfIPAddressChangeForTests();
+ base::RunLoop().RunUntilIdle(); // Wait for notification.
}
void LookupStale() {
@@ -400,6 +406,7 @@ TEST_F(StaleHostResolverTest, StaleUsability) {
};
SetStaleDelay(kNoStaleDelaySec);
+ CreateNetworkChangeNotifier();
for (size_t i = 0; i < arraysize(kUsabilityTestCases); ++i) {
const auto& test_case = kUsabilityTestCases[i];
« no previous file with comments | « components/cronet/android/BUILD.gn ('k') | net/dns/host_resolver_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698