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