| OLD | NEW |
| 1 // Copyright (c) 2012 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 #include "chrome/browser/chromeos/net/onc_utils.h" | 5 #include "chrome/browser/chromeos/net/onc_utils.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 11 #include "base/values.h" | 10 #include "base/values.h" |
| 12 #include "chrome/browser/chromeos/cros/network_ui_data.h" | |
| 13 #include "chrome/browser/google_apis/test_util.h" | 11 #include "chrome/browser/google_apis/test_util.h" |
| 12 #include "chromeos/network/network_ui_data.h" |
| 14 #include "chromeos/network/onc/onc_test_utils.h" | 13 #include "chromeos/network/onc/onc_test_utils.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 16 | 15 |
| 17 namespace chromeos { | 16 namespace chromeos { |
| 18 namespace onc { | 17 namespace onc { |
| 19 | 18 |
| 20 TEST(ONCUtils, ProxySettingsToProxyConfig) { | 19 TEST(ONCUtils, ProxySettingsToProxyConfig) { |
| 21 scoped_ptr<base::Value> test_data = | 20 scoped_ptr<base::Value> test_data = |
| 22 google_apis::test_util::LoadJSONFile("chromeos/net/proxy_config.json"); | 21 google_apis::test_util::LoadJSONFile("chromeos/net/proxy_config.json"); |
| 23 | 22 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 38 base::DictionaryValue* expected_proxy_config; | 37 base::DictionaryValue* expected_proxy_config; |
| 39 test_case->GetDictionary("ProxyConfig", &expected_proxy_config); | 38 test_case->GetDictionary("ProxyConfig", &expected_proxy_config); |
| 40 | 39 |
| 41 scoped_ptr<base::DictionaryValue> actual_proxy_config = | 40 scoped_ptr<base::DictionaryValue> actual_proxy_config = |
| 42 ConvertOncProxySettingsToProxyConfig(*onc_proxy_settings); | 41 ConvertOncProxySettingsToProxyConfig(*onc_proxy_settings); |
| 43 EXPECT_TRUE(test_utils::Equals(expected_proxy_config, | 42 EXPECT_TRUE(test_utils::Equals(expected_proxy_config, |
| 44 actual_proxy_config.get())); | 43 actual_proxy_config.get())); |
| 45 } | 44 } |
| 46 } | 45 } |
| 47 | 46 |
| 48 class ONCCreateUIDataTest | |
| 49 : public ::testing::TestWithParam<std::pair<std::string, std::string> > { | |
| 50 }; | |
| 51 | |
| 52 TEST_P(ONCCreateUIDataTest, CreateUIData) { | |
| 53 scoped_ptr<base::DictionaryValue> onc_network = | |
| 54 test_utils::ReadTestDictionary(GetParam().first); | |
| 55 | |
| 56 scoped_ptr<base::Value> expected_uidata = | |
| 57 google_apis::test_util::LoadJSONFile(GetParam().second); | |
| 58 const base::DictionaryValue* expected_uidata_dict; | |
| 59 expected_uidata->GetAsDictionary(&expected_uidata_dict); | |
| 60 | |
| 61 scoped_ptr<NetworkUIData> actual_uidata = | |
| 62 CreateUIData(ONC_SOURCE_USER_POLICY, *onc_network); | |
| 63 EXPECT_TRUE(actual_uidata != NULL); | |
| 64 | |
| 65 base::DictionaryValue actual_uidata_dict; | |
| 66 actual_uidata->FillDictionary(&actual_uidata_dict); | |
| 67 EXPECT_TRUE(test_utils::Equals(&actual_uidata_dict, expected_uidata_dict)); | |
| 68 } | |
| 69 | |
| 70 INSTANTIATE_TEST_CASE_P( | |
| 71 ONCCreateUIDataTest, | |
| 72 ONCCreateUIDataTest, | |
| 73 ::testing::Values( | |
| 74 std::make_pair("valid_wifi_clientcert.onc", | |
| 75 "chromeos/net/uidata_for_wifi_clientcert.json"), | |
| 76 std::make_pair("valid_wifi_clientref.onc", | |
| 77 "chromeos/net/uidata_for_wifi_clientref.json"), | |
| 78 std::make_pair("valid_wifi_psk.onc", | |
| 79 "chromeos/net/uidata_for_wifi_psk.json"), | |
| 80 std::make_pair("valid_openvpn_clientcert.onc", | |
| 81 "chromeos/net/uidata_for_openvpn_clientcert.json"), | |
| 82 std::make_pair("valid_l2tpipsec_clientcert.onc", | |
| 83 "chromeos/net/uidata_for_l2tpipsec_clientcert.json"))); | |
| 84 | |
| 85 } // namespace onc | 47 } // namespace onc |
| 86 } // namespace chromeos | 48 } // namespace chromeos |
| OLD | NEW |