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