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