| 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..a4834223217af35838ebebd992750fcfb9ace4a4
|
| --- /dev/null
|
| +++ b/net/proxy/dhcp_proxy_script_fetcher_factory_unittest.cc
|
| @@ -0,0 +1,63 @@
|
| +// 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 {
|
| +
|
| +// Makes constructors available to these tests.
|
| +class TestingDhcpProxyScriptFetcherFactory
|
| + : public DhcpProxyScriptFetcherFactory {
|
| +};
|
| +
|
| +TEST(DhcpProxyScriptFetcherFactory, DoNothingWhenDisabled) {
|
| + TestingDhcpProxyScriptFetcherFactory fac;
|
| + fac.SetEnabled(false);
|
| + // Non-do-nothing fetchers would DCHECK on the NULL pointer.
|
| + DhcpProxyScriptFetcher* fetcher = fac.Create(NULL);
|
| + ASSERT_TRUE(fetcher);
|
| + EXPECT_EQ("", fetcher->GetFetcherName());
|
| +}
|
| +
|
| +#if defined(OS_WIN)
|
| +TEST(DhcpProxyScriptFetcherFactory, WindowsFetcherOnWindows) {
|
| + TestingDhcpProxyScriptFetcherFactory fac;
|
| + fac.SetEnabled(true);
|
| +
|
| + scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext());
|
| + DhcpProxyScriptFetcher* fetcher = fac.Create(context);
|
| + ASSERT_TRUE(fetcher);
|
| + EXPECT_EQ("win", fetcher->GetFetcherName());
|
| +}
|
| +#endif // defined(OS_WIN)
|
| +
|
| +TEST(DhcpProxyScriptFetcherFactory, IsSupported) {
|
| +#if defined(OS_WIN)
|
| + ASSERT_TRUE(DhcpProxyScriptFetcherFactory::IsSupported());
|
| +#else
|
| + ASSERT_FALSE(DhcpProxyScriptFetcherFactory::IsSupported());
|
| +#endif // defined(OS_WIN)
|
| +}
|
| +
|
| +TEST(DhcpProxyScriptFetcherFactory, SetEnabled) {
|
| + TestingDhcpProxyScriptFetcherFactory fac;
|
| + EXPECT_FALSE(fac.IsEnabled());
|
| +
|
| + fac.SetEnabled(false);
|
| + EXPECT_FALSE(fac.IsEnabled());
|
| +
|
| + fac.SetEnabled(true);
|
| +#if defined(OS_WIN)
|
| + EXPECT_TRUE(fac.IsEnabled());
|
| +#else
|
| + EXPECT_FALSE(fac.IsEnabled());
|
| +#endif // defined(OS_WIN)
|
| +}
|
| +
|
| +} // namespace
|
| +} // namespace net
|
|
|