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

Unified Diff: chrome/browser/net/predictor_unittest.cc

Issue 545633002: Don't preresolve DNS if a fixed proxy configuration is in place. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remote superfluous net:: prefix Created 6 years, 2 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 | « chrome/browser/net/predictor.cc ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/net/predictor_unittest.cc
diff --git a/chrome/browser/net/predictor_unittest.cc b/chrome/browser/net/predictor_unittest.cc
index 4bdb21d710c4c082b9d1dab71f771e718f9f501a..1c45503b573dd39be78895f0ae57752b93fc79b5 100644
--- a/chrome/browser/net/predictor_unittest.cc
+++ b/chrome/browser/net/predictor_unittest.cc
@@ -19,9 +19,13 @@
#include "chrome/common/net/predictor_common.h"
#include "content/public/test/test_browser_thread.h"
#include "net/base/address_list.h"
+#include "net/base/load_flags.h"
+#include "net/base/net_errors.h"
#include "net/base/winsock_init.h"
#include "net/dns/mock_host_resolver.h"
#include "net/http/transport_security_state.h"
+#include "net/proxy/proxy_config_service_fixed.h"
+#include "net/proxy/proxy_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -865,4 +869,75 @@ TEST_F(PredictorTest, TestSimplePreconnectAdvisor) {
#endif // defined(OS_ANDROID) || defined(OS_IOS)
+TEST_F(PredictorTest, NoProxyService) {
+ // Don't actually try to resolve names.
+ Predictor::set_max_parallel_resolves(0);
+
+ Predictor testing_master(true, true);
+
+ GURL goog("http://www.google.com:80");
+ testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED);
+ EXPECT_FALSE(testing_master.work_queue_.IsEmpty());
+
+ testing_master.Shutdown();
+}
+
+TEST_F(PredictorTest, ProxyDefinitelyEnabled) {
+ // Don't actually try to resolve names.
+ Predictor::set_max_parallel_resolves(0);
+
+ Predictor testing_master(true, true);
+
+ net::ProxyConfig config;
+ config.proxy_rules().ParseFromString("http=socks://localhost:12345");
+ testing_master.proxy_service_ = net::ProxyService::CreateFixed(config);
+
+ GURL goog("http://www.google.com:80");
+ testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED);
+
+ // Proxy is definitely in use, so there is no need to pre-resolve the domain.
+ EXPECT_TRUE(testing_master.work_queue_.IsEmpty());
+
+ delete testing_master.proxy_service_;
+ testing_master.Shutdown();
+}
+
+TEST_F(PredictorTest, ProxyDefinitelyNotEnabled) {
+ // Don't actually try to resolve names.
+ Predictor::set_max_parallel_resolves(0);
+
+ Predictor testing_master(true, true);
+ net::ProxyConfig config = net::ProxyConfig::CreateDirect();
+ testing_master.proxy_service_ = net::ProxyService::CreateFixed(config);
+
+ GURL goog("http://www.google.com:80");
+ testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED);
+
+ // Proxy is not in use, so the name has been registered for pre-resolve.
+ EXPECT_FALSE(testing_master.work_queue_.IsEmpty());
+
+ delete testing_master.proxy_service_;
+ testing_master.Shutdown();
+}
+
+TEST_F(PredictorTest, ProxyMaybeEnabled) {
+ // Don't actually try to resolve names.
+ Predictor::set_max_parallel_resolves(0);
+
+ Predictor testing_master(true, true);
+ net::ProxyConfig config = net::ProxyConfig::CreateFromCustomPacURL(GURL(
+ "http://foopy/proxy.pac"));
+ testing_master.proxy_service_ = net::ProxyService::CreateFixed(config);
+
+ GURL goog("http://www.google.com:80");
+ testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED);
+
+ // Proxy may not be in use (the PAC script has not yet been evaluated), so the
+ // name has been registered for pre-resolve.
+ EXPECT_FALSE(testing_master.work_queue_.IsEmpty());
+
+ delete testing_master.proxy_service_;
+ testing_master.Shutdown();
+}
+
} // namespace chrome_browser_net
« no previous file with comments | « chrome/browser/net/predictor.cc ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698