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

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: Undo no-longer-needed virtual marking Created 6 years, 3 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
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..2693276482545179bbda16240a7556e97e6340e4 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,99 @@ TEST_F(PredictorTest, TestSimplePreconnectAdvisor) {
#endif // defined(OS_ANDROID) || defined(OS_IOS)
+net::ProxyService::PacRequest* FAKE_PAC_REQUEST_ADDRESS =
+ reinterpret_cast<net::ProxyService::PacRequest*>(123454321);
+
+class TestProxyService : public net::ProxyService {
+ public:
+ TestProxyService(int resolve_code, const net::ProxyInfo& proxy_info)
+ : ProxyService(new net::ProxyConfigServiceFixed(net::ProxyConfig()),
+ NULL, NULL),
+ resolve_code_(resolve_code),
+ proxy_info_(proxy_info) {
+ }
+
+ virtual int ResolveProxy(const GURL& url,
+ int load_flags,
+ net::ProxyInfo* result,
+ const net::CompletionCallback& callback,
+ PacRequest** pac_request,
+ net::NetworkDelegate* network_delegate,
+ const net::BoundNetLog& net_log) OVERRIDE {
+ EXPECT_TRUE(callback.is_null());
+ if (resolve_code_ == net::OK) {
+ *result = proxy_info_;
+ }
+
+ return resolve_code_;
+ }
+
+ int resolve_code_;
+ const net::ProxyInfo& proxy_info_;
+};
+
+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::ProxyInfo info;
+ info.UseNamedProxy("socks://localhost:12345");
+ testing_master.proxy_service_ = new TestProxyService(net::OK, info);
+
+ GURL goog("http://www.google.com:80");
+ testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED);
+ 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::ProxyInfo info;
+ info.UseDirect();
+ testing_master.proxy_service_ = new TestProxyService(net::OK, info);
+
+ GURL goog("http://www.google.com:80");
+ testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED);
+ 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::ProxyInfo info;
+ testing_master.proxy_service_ =
+ new TestProxyService(net::ERR_IO_PENDING, info);
+
+ GURL goog("http://www.google.com:80");
+ testing_master.Resolve(goog, UrlInfo::OMNIBOX_MOTIVATED);
+ EXPECT_FALSE(testing_master.work_queue_.IsEmpty());
+
+ delete testing_master.proxy_service_;
+ testing_master.Shutdown();
+}
+
} // namespace chrome_browser_net

Powered by Google App Engine
This is Rietveld 408576698