| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2009 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 "chrome/browser/net/chrome_url_request_context.h" | 5 #include "chrome/browser/net/chrome_url_request_context.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/format_macros.h" | 8 #include "base/format_macros.h" |
| 9 #include "chrome/browser/configuration_policy_pref_store.h" | 9 #include "chrome/browser/configuration_policy_pref_store.h" |
| 10 #include "chrome/browser/pref_value_store.h" | 10 #include "chrome/browser/pref_value_store.h" |
| 11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/test/testing_pref_service.h" |
| 12 #include "net/proxy/proxy_config.h" | 13 #include "net/proxy/proxy_config.h" |
| 13 #include "net/proxy/proxy_config_service_common_unittest.h" | 14 #include "net/proxy/proxy_config_service_common_unittest.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 // Builds an identifier for each test in an array. | 17 // Builds an identifier for each test in an array. |
| 17 #define TEST_DESC(desc) StringPrintf("at line %d <%s>", __LINE__, desc) | 18 #define TEST_DESC(desc) StringPrintf("at line %d <%s>", __LINE__, desc) |
| 18 | 19 |
| 19 TEST(ChromeURLRequestContextTest, CreateProxyConfigTest) { | 20 TEST(ChromeURLRequestContextTest, CreateProxyConfigTest) { |
| 20 FilePath unused_path(FILE_PATH_LITERAL("foo.exe")); | 21 FilePath unused_path(FILE_PATH_LITERAL("foo.exe")); |
| 21 // Build the input command lines here. | 22 // Build the input command lines here. |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 true, // auto_detect | 151 true, // auto_detect |
| 151 GURL(), // pac_url | 152 GURL(), // pac_url |
| 152 net::ProxyRulesExpectation::Empty(), | 153 net::ProxyRulesExpectation::Empty(), |
| 153 } | 154 } |
| 154 }; | 155 }; |
| 155 | 156 |
| 156 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); i++) { | 157 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(tests); i++) { |
| 157 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i, | 158 SCOPED_TRACE(StringPrintf("Test[%" PRIuS "] %s", i, |
| 158 tests[i].description.c_str())); | 159 tests[i].description.c_str())); |
| 159 CommandLine command_line(tests[i].command_line); | 160 CommandLine command_line(tests[i].command_line); |
| 160 PrefService prefs(new PrefValueStore( | 161 PrefService prefs(new TestingPrefService::TestingPrefValueStore( |
| 161 new ConfigurationPolicyPrefStore(&command_line, NULL), | 162 new ConfigurationPolicyPrefStore(&command_line, NULL), |
| 162 NULL, NULL, NULL, NULL)); // Only configuration-policy prefs. | 163 NULL, NULL, NULL, NULL)); // Only configuration-policy prefs. |
| 163 ChromeURLRequestContextGetter::RegisterUserPrefs(&prefs); | 164 ChromeURLRequestContextGetter::RegisterUserPrefs(&prefs); |
| 164 scoped_ptr<net::ProxyConfig> config(CreateProxyConfig(&prefs)); | 165 scoped_ptr<net::ProxyConfig> config(CreateProxyConfig(&prefs)); |
| 165 | 166 |
| 166 if (tests[i].is_null) { | 167 if (tests[i].is_null) { |
| 167 EXPECT_TRUE(config == NULL); | 168 EXPECT_TRUE(config == NULL); |
| 168 } else { | 169 } else { |
| 169 EXPECT_TRUE(config != NULL); | 170 EXPECT_TRUE(config != NULL); |
| 170 EXPECT_EQ(tests[i].auto_detect, config->auto_detect()); | 171 EXPECT_EQ(tests[i].auto_detect, config->auto_detect()); |
| 171 EXPECT_EQ(tests[i].pac_url, config->pac_url()); | 172 EXPECT_EQ(tests[i].pac_url, config->pac_url()); |
| 172 EXPECT_TRUE(tests[i].proxy_rules.Matches(config->proxy_rules())); | 173 EXPECT_TRUE(tests[i].proxy_rules.Matches(config->proxy_rules())); |
| 173 } | 174 } |
| 174 } | 175 } |
| 175 } | 176 } |
| 176 | 177 |
| OLD | NEW |