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

Unified Diff: net/proxy/dhcp_proxy_script_fetcher_factory_unittest.cc

Issue 6831025: Adds support for the DHCP portion of the WPAD (proxy auto-discovery) protocol. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Responding to review comments. Created 9 years, 8 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: net/proxy/dhcp_proxy_script_fetcher_factory_unittest.cc
diff --git a/net/proxy/dhcp_proxy_script_fetcher_factory_unittest.cc b/net/proxy/dhcp_proxy_script_fetcher_factory_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..3311f9f5b2e4c2b8c14bf24dff885f03dbea2462
--- /dev/null
+++ b/net/proxy/dhcp_proxy_script_fetcher_factory_unittest.cc
@@ -0,0 +1,72 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/proxy/dhcp_proxy_script_fetcher.h"
+#include "net/proxy/dhcp_proxy_script_fetcher_factory.h"
+#include "net/url_request/url_request_test_util.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+namespace {
+
+// Test harness that does nothing but restore previous value to the
eroman 2011/05/13 05:03:32 I appreciate the thoroughness of testing. But in t
Jói 2011/05/13 20:19:09 This is just so that these unit tests can't interf
+// DhcpProxyScriptFetcherFactory::feature_enabled_ flag.
+class DhcpProxyScriptFetcherFactoryTest : public testing::Test {
+ public:
+ virtual void SetUp() OVERRIDE {
+ original_feature_enabled_ = DhcpProxyScriptFetcherFactory::IsEnabled();
+ }
+
+ virtual void TearDown() OVERRIDE {
+ DhcpProxyScriptFetcherFactory::SetEnabled(original_feature_enabled_);
+ }
+
+ private:
+ bool original_feature_enabled_;
+};
+
+TEST_F(DhcpProxyScriptFetcherFactoryTest, DoNothingWhenDisabled) {
+ DhcpProxyScriptFetcherFactory::SetEnabled(false);
+ // Non-do-nothing fetchers would DCHECK on the NULL pointer.
+ DhcpProxyScriptFetcher* fetcher = DhcpProxyScriptFetcherFactory::Create(NULL);
+ ASSERT_TRUE(fetcher);
+ EXPECT_EQ("", fetcher->GetFetcherName());
+}
+
+#if defined(OS_WIN)
+TEST_F(DhcpProxyScriptFetcherFactoryTest, WindowsFetcherOnWindows) {
+ DhcpProxyScriptFetcherFactory::SetEnabled(true);
+
+ scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
+ DhcpProxyScriptFetcher* fetcher =
+ DhcpProxyScriptFetcherFactory::Create(context);
+ ASSERT_TRUE(fetcher);
+ EXPECT_EQ("win", fetcher->GetFetcherName());
+}
+#endif // defined(OS_WIN)
+
+TEST_F(DhcpProxyScriptFetcherFactoryTest, IsSupported) {
+#if defined(OS_WIN)
+ ASSERT_TRUE(DhcpProxyScriptFetcherFactory::IsSupported());
+#else
+ ASSERT_FALSE(DhcpProxyScriptFetcherFactory::IsSupported());
+#endif // defined(OS_WIN)
+}
+
+TEST_F(DhcpProxyScriptFetcherFactoryTest, SetEnabled) {
+ EXPECT_FALSE(DhcpProxyScriptFetcherFactory::IsEnabled());
+
+ DhcpProxyScriptFetcherFactory::SetEnabled(false);
+ EXPECT_FALSE(DhcpProxyScriptFetcherFactory::IsEnabled());
+
+ DhcpProxyScriptFetcherFactory::SetEnabled(true);
+#if defined(OS_WIN)
+ EXPECT_TRUE(DhcpProxyScriptFetcherFactory::IsEnabled());
+#else
+ EXPECT_FALSE(DhcpProxyScriptFetcherFactory::IsEnabled());
+#endif // defined(OS_WIN)
+}
+
+} // namespace
+} // namespace net

Powered by Google App Engine
This is Rietveld 408576698