Chromium Code Reviews| 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 // Test harness that does nothing but restore previous value to the | |
|
eroman
2011/05/13 05:03:32
I appreciate the thoroughness of testing. But in t
Jói
2011/05/13 20:19:09
This is just so that these unit tests can't interf
| |
| 14 // DhcpProxyScriptFetcherFactory::feature_enabled_ flag. | |
| 15 class DhcpProxyScriptFetcherFactoryTest : public testing::Test { | |
| 16 public: | |
| 17 virtual void SetUp() OVERRIDE { | |
| 18 original_feature_enabled_ = DhcpProxyScriptFetcherFactory::IsEnabled(); | |
| 19 } | |
| 20 | |
| 21 virtual void TearDown() OVERRIDE { | |
| 22 DhcpProxyScriptFetcherFactory::SetEnabled(original_feature_enabled_); | |
| 23 } | |
| 24 | |
| 25 private: | |
| 26 bool original_feature_enabled_; | |
| 27 }; | |
| 28 | |
| 29 TEST_F(DhcpProxyScriptFetcherFactoryTest, DoNothingWhenDisabled) { | |
| 30 DhcpProxyScriptFetcherFactory::SetEnabled(false); | |
| 31 // Non-do-nothing fetchers would DCHECK on the NULL pointer. | |
| 32 DhcpProxyScriptFetcher* fetcher = DhcpProxyScriptFetcherFactory::Create(NULL); | |
| 33 ASSERT_TRUE(fetcher); | |
| 34 EXPECT_EQ("", fetcher->GetFetcherName()); | |
| 35 } | |
| 36 | |
| 37 #if defined(OS_WIN) | |
| 38 TEST_F(DhcpProxyScriptFetcherFactoryTest, WindowsFetcherOnWindows) { | |
| 39 DhcpProxyScriptFetcherFactory::SetEnabled(true); | |
| 40 | |
| 41 scoped_refptr<TestURLRequestContext> context(new TestURLRequestContext()); | |
| 42 DhcpProxyScriptFetcher* fetcher = | |
| 43 DhcpProxyScriptFetcherFactory::Create(context); | |
| 44 ASSERT_TRUE(fetcher); | |
| 45 EXPECT_EQ("win", fetcher->GetFetcherName()); | |
| 46 } | |
| 47 #endif // defined(OS_WIN) | |
| 48 | |
| 49 TEST_F(DhcpProxyScriptFetcherFactoryTest, IsSupported) { | |
| 50 #if defined(OS_WIN) | |
| 51 ASSERT_TRUE(DhcpProxyScriptFetcherFactory::IsSupported()); | |
| 52 #else | |
| 53 ASSERT_FALSE(DhcpProxyScriptFetcherFactory::IsSupported()); | |
| 54 #endif // defined(OS_WIN) | |
| 55 } | |
| 56 | |
| 57 TEST_F(DhcpProxyScriptFetcherFactoryTest, SetEnabled) { | |
| 58 EXPECT_FALSE(DhcpProxyScriptFetcherFactory::IsEnabled()); | |
| 59 | |
| 60 DhcpProxyScriptFetcherFactory::SetEnabled(false); | |
| 61 EXPECT_FALSE(DhcpProxyScriptFetcherFactory::IsEnabled()); | |
| 62 | |
| 63 DhcpProxyScriptFetcherFactory::SetEnabled(true); | |
| 64 #if defined(OS_WIN) | |
| 65 EXPECT_TRUE(DhcpProxyScriptFetcherFactory::IsEnabled()); | |
| 66 #else | |
| 67 EXPECT_FALSE(DhcpProxyScriptFetcherFactory::IsEnabled()); | |
| 68 #endif // defined(OS_WIN) | |
| 69 } | |
| 70 | |
| 71 } // namespace | |
| 72 } // namespace net | |
| OLD | NEW |