| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 12 |
| 13 TEST(DhcpProxyScriptFetcherFactoryTest, DoNothingWhenDisabled) { | |
| 14 DhcpProxyScriptFetcherFactory factory; | |
| 15 factory.set_enabled(false); | |
| 16 std::unique_ptr<DhcpProxyScriptFetcher> fetcher(factory.Create(NULL)); | |
| 17 EXPECT_EQ("", fetcher->GetFetcherName()); | |
| 18 } | |
| 19 | |
| 20 #if defined(OS_WIN) | 13 #if defined(OS_WIN) |
| 21 TEST(DhcpProxyScriptFetcherFactoryTest, WindowsFetcherOnWindows) { | 14 TEST(DhcpProxyScriptFetcherFactoryTest, WindowsFetcherOnWindows) { |
| 22 DhcpProxyScriptFetcherFactory factory; | 15 DhcpProxyScriptFetcherFactory factory; |
| 23 factory.set_enabled(true); | 16 TestURLRequestContext context; |
| 24 | 17 std::unique_ptr<DhcpProxyScriptFetcher> fetcher(factory.Create(&context)); |
| 25 std::unique_ptr<TestURLRequestContext> context(new TestURLRequestContext()); | 18 ASSERT_TRUE(fetcher.get()); |
| 26 std::unique_ptr<DhcpProxyScriptFetcher> fetcher( | |
| 27 factory.Create(context.get())); | |
| 28 EXPECT_EQ("win", fetcher->GetFetcherName()); | 19 EXPECT_EQ("win", fetcher->GetFetcherName()); |
| 29 } | 20 } |
| 30 #endif // defined(OS_WIN) | |
| 31 | 21 |
| 32 TEST(DhcpProxyScriptFetcherFactoryTest, IsSupported) { | 22 #else // !defined(OS_WIN) |
| 33 #if defined(OS_WIN) | 23 |
| 34 ASSERT_TRUE(DhcpProxyScriptFetcherFactory::IsSupported()); | 24 TEST(DhcpProxyScriptFetcherFactoryTest, ReturnNullOnUnsupportedPlatforms) { |
| 35 #else | 25 DhcpProxyScriptFetcherFactory factory; |
| 36 ASSERT_FALSE(DhcpProxyScriptFetcherFactory::IsSupported()); | 26 TestURLRequestContext context; |
| 37 #endif // defined(OS_WIN) | 27 std::unique_ptr<DhcpProxyScriptFetcher> fetcher(factory.Create(&context)); |
| 28 ASSERT_TRUE(fetcher.get()); |
| 29 EXPECT_EQ("do nothing", fetcher->GetFetcherName()); |
| 38 } | 30 } |
| 39 | 31 |
| 40 TEST(DhcpProxyScriptFetcherFactoryTest, SetEnabled) { | |
| 41 DhcpProxyScriptFetcherFactory factory; | |
| 42 #if defined(OS_WIN) | |
| 43 EXPECT_TRUE(factory.enabled()); | |
| 44 #else | |
| 45 EXPECT_FALSE(factory.enabled()); | |
| 46 #endif // defined(OS_WIN) | 32 #endif // defined(OS_WIN) |
| 47 | 33 |
| 48 factory.set_enabled(false); | |
| 49 EXPECT_FALSE(factory.enabled()); | |
| 50 | |
| 51 factory.set_enabled(true); | |
| 52 #if defined(OS_WIN) | |
| 53 EXPECT_TRUE(factory.enabled()); | |
| 54 #else | |
| 55 EXPECT_FALSE(factory.enabled()); | |
| 56 #endif // defined(OS_WIN) | |
| 57 } | |
| 58 | |
| 59 } // namespace | 34 } // namespace |
| 60 } // namespace net | 35 } // namespace net |
| OLD | NEW |