OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "net/proxy/dhcp_proxy_script_fetcher.h" |
| 6 #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" |
| 7 #include "net/url_request/url_request_test_util.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 |
| 10 namespace net { |
| 11 namespace { |
| 12 |
| 13 // Makes constructors available to these tests. |
| 14 class TestingDhcpProxyScriptFetcherFactory |
| 15 : public DhcpProxyScriptFetcherFactory { |
| 16 }; |
| 17 |
| 18 TEST(DhcpProxyScriptFetcherFactory, DoNothingWhenDisabled) { |
| 19 TestingDhcpProxyScriptFetcherFactory fac; |
| 20 fac.SetEnabled(false); |
| 21 // Non-do-nothing fetchers would DCHECK on the NULL pointer. |
| 22 DhcpProxyScriptFetcher* fetcher = fac.Create(NULL); |
| 23 ASSERT_TRUE(fetcher); |
| 24 EXPECT_EQ("", fetcher->GetFetcherName()); |
| 25 } |
| 26 |
| 27 #if defined(OS_WIN) |
| 28 TEST(DhcpProxyScriptFetcherFactory, WindowsFetcherOnWindows) { |
| 29 TestingDhcpProxyScriptFetcherFactory fac; |
| 30 fac.SetEnabled(true); |
| 31 |
| 32 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext()); |
| 33 DhcpProxyScriptFetcher* fetcher = fac.Create(context); |
| 34 ASSERT_TRUE(fetcher); |
| 35 EXPECT_EQ("win", fetcher->GetFetcherName()); |
| 36 } |
| 37 #endif // defined(OS_WIN) |
| 38 |
| 39 TEST(DhcpProxyScriptFetcherFactory, IsSupported) { |
| 40 #if defined(OS_WIN) |
| 41 ASSERT_TRUE(DhcpProxyScriptFetcherFactory::IsSupported()); |
| 42 #else |
| 43 ASSERT_FALSE(DhcpProxyScriptFetcherFactory::IsSupported()); |
| 44 #endif // defined(OS_WIN) |
| 45 } |
| 46 |
| 47 TEST(DhcpProxyScriptFetcherFactory, SetEnabled) { |
| 48 TestingDhcpProxyScriptFetcherFactory fac; |
| 49 EXPECT_FALSE(fac.IsEnabled()); |
| 50 |
| 51 fac.SetEnabled(false); |
| 52 EXPECT_FALSE(fac.IsEnabled()); |
| 53 |
| 54 fac.SetEnabled(true); |
| 55 #if defined(OS_WIN) |
| 56 EXPECT_TRUE(fac.IsEnabled()); |
| 57 #else |
| 58 EXPECT_FALSE(fac.IsEnabled()); |
| 59 #endif // defined(OS_WIN) |
| 60 } |
| 61 |
| 62 } // namespace |
| 63 } // namespace net |
OLD | NEW |