| OLD | NEW |
| 1 // Copyright (c) 2011 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 // Unit tests for helper functions for the Chrome Extensions Proxy Settings API. | 5 // Unit tests for helper functions for the Chrome Extensions Proxy Settings API. |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/extensions/extension_proxy_api_constants.h" | 9 #include "chrome/browser/extensions/api/proxy/proxy_api_constants.h" |
| 10 #include "chrome/browser/extensions/extension_proxy_api_helpers.h" | 10 #include "chrome/browser/extensions/api/proxy/proxy_api_helpers.h" |
| 11 #include "chrome/browser/prefs/proxy_config_dictionary.h" | 11 #include "chrome/browser/prefs/proxy_config_dictionary.h" |
| 12 #include "chrome/browser/prefs/proxy_prefs.h" | 12 #include "chrome/browser/prefs/proxy_prefs.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 | 14 |
| 15 namespace keys = extension_proxy_api_constants; | 15 namespace extensions { |
| 16 |
| 17 namespace keys = proxy_api_constants; |
| 16 | 18 |
| 17 namespace { | 19 namespace { |
| 18 | 20 |
| 19 const char kSamplePacScript[] = "test"; | 21 const char kSamplePacScript[] = "test"; |
| 20 const char kSamplePacScriptAsDataUrl[] = | 22 const char kSamplePacScriptAsDataUrl[] = |
| 21 "data:application/x-ns-proxy-autoconfig;base64,dGVzdA=="; | 23 "data:application/x-ns-proxy-autoconfig;base64,dGVzdA=="; |
| 22 const char kSamplePacScriptUrl[] = "http://wpad/wpad.dat"; | 24 const char kSamplePacScriptUrl[] = "http://wpad/wpad.dat"; |
| 23 | 25 |
| 24 // Helper function to create a ProxyServer dictionary as defined in the | 26 // Helper function to create a ProxyServer dictionary as defined in the |
| 25 // extension API. | 27 // extension API. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 36 int port) { | 38 int port) { |
| 37 DictionaryValue* dict = new DictionaryValue; | 39 DictionaryValue* dict = new DictionaryValue; |
| 38 dict->SetString(keys::kProxyConfigRuleScheme, schema); | 40 dict->SetString(keys::kProxyConfigRuleScheme, schema); |
| 39 dict->SetString(keys::kProxyConfigRuleHost, host); | 41 dict->SetString(keys::kProxyConfigRuleHost, host); |
| 40 dict->SetInteger(keys::kProxyConfigRulePort, port); | 42 dict->SetInteger(keys::kProxyConfigRulePort, port); |
| 41 return dict; | 43 return dict; |
| 42 } | 44 } |
| 43 | 45 |
| 44 } // namespace | 46 } // namespace |
| 45 | 47 |
| 46 namespace extension_proxy_api_helpers { | 48 namespace proxy_api_helpers { |
| 47 | 49 |
| 48 TEST(ExtensionProxyApiHelpers, CreateDataURLFromPACScript) { | 50 TEST(ExtensionProxyApiHelpers, CreateDataURLFromPACScript) { |
| 49 std::string out; | 51 std::string out; |
| 50 ASSERT_TRUE(CreateDataURLFromPACScript(kSamplePacScript, &out)); | 52 ASSERT_TRUE(CreateDataURLFromPACScript(kSamplePacScript, &out)); |
| 51 EXPECT_EQ(kSamplePacScriptAsDataUrl, out); | 53 EXPECT_EQ(kSamplePacScriptAsDataUrl, out); |
| 52 } | 54 } |
| 53 | 55 |
| 54 TEST(ExtensionProxyApiHelpers, CreatePACScriptFromDataURL) { | 56 TEST(ExtensionProxyApiHelpers, CreatePACScriptFromDataURL) { |
| 55 std::string out; | 57 std::string out; |
| 56 ASSERT_TRUE(CreatePACScriptFromDataURL(kSamplePacScriptAsDataUrl, &out)); | 58 ASSERT_TRUE(CreatePACScriptFromDataURL(kSamplePacScriptAsDataUrl, &out)); |
| (...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 TEST(ExtensionProxyApiHelpers, TokenizeToStringList) { | 354 TEST(ExtensionProxyApiHelpers, TokenizeToStringList) { |
| 353 ListValue expected; | 355 ListValue expected; |
| 354 expected.Append(Value::CreateStringValue("s1")); | 356 expected.Append(Value::CreateStringValue("s1")); |
| 355 expected.Append(Value::CreateStringValue("s2")); | 357 expected.Append(Value::CreateStringValue("s2")); |
| 356 expected.Append(Value::CreateStringValue("s3")); | 358 expected.Append(Value::CreateStringValue("s3")); |
| 357 | 359 |
| 358 scoped_ptr<ListValue> out(TokenizeToStringList("s1;s2;s3", ";")); | 360 scoped_ptr<ListValue> out(TokenizeToStringList("s1;s2;s3", ";")); |
| 359 EXPECT_TRUE(Value::Equals(&expected, out.get())); | 361 EXPECT_TRUE(Value::Equals(&expected, out.get())); |
| 360 } | 362 } |
| 361 | 363 |
| 362 } // namespace extension_proxy_api_helpers | 364 } // namespace proxy_api_helpers |
| 365 } // namespace extensions |
| OLD | NEW |