OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/chromeos/net/onc_utils.h" |
| 6 |
| 7 #include <string> |
| 8 |
| 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/values.h" |
| 11 #include "chrome/browser/google_apis/test_util.h" |
| 12 #include "chromeos/network/onc/onc_test_utils.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 |
| 15 namespace chromeos { |
| 16 namespace onc { |
| 17 |
| 18 TEST(ONCUtils, ProxySettingsToProxyConfig) { |
| 19 scoped_ptr<base::Value> test_data = |
| 20 google_apis::test_util::LoadJSONFile("net/proxy_config.json"); |
| 21 |
| 22 base::ListValue* list_of_tests; |
| 23 test_data->GetAsList(&list_of_tests); |
| 24 |
| 25 for (base::ListValue::iterator it = list_of_tests->begin(); |
| 26 it != list_of_tests->end(); ++it) { |
| 27 base::DictionaryValue* test_case; |
| 28 (*it)->GetAsDictionary(&test_case); |
| 29 |
| 30 base::DictionaryValue* onc_proxy_settings; |
| 31 test_case->GetDictionary("ONC_ProxySettings", &onc_proxy_settings); |
| 32 |
| 33 base::DictionaryValue* expected_proxy_config; |
| 34 test_case->GetDictionary("ProxyConfig", &expected_proxy_config); |
| 35 |
| 36 scoped_ptr<base::DictionaryValue> actual_proxy_config = |
| 37 ConvertOncProxySettingsToProxyConfig(*onc_proxy_settings); |
| 38 EXPECT_TRUE(actual_proxy_config != NULL); |
| 39 EXPECT_TRUE(expected_proxy_config->Equals(actual_proxy_config.get())); |
| 40 } |
| 41 } |
| 42 |
| 43 class ONCCreateUIDataTest |
| 44 : public ::testing::TestWithParam<std::pair<std::string, std::string> > { |
| 45 }; |
| 46 |
| 47 TEST_P(ONCCreateUIDataTest, CreateUIData) { |
| 48 scoped_ptr<base::DictionaryValue> onc_network = |
| 49 test_utils::ReadTestDictionary(GetParam().first); |
| 50 |
| 51 scoped_ptr<base::Value> expected_uidata = |
| 52 google_apis::test_util::LoadJSONFile(GetParam().second); |
| 53 |
| 54 scoped_ptr<base::DictionaryValue> actual_uidata = |
| 55 CreateUIData(ONC_SOURCE_USER_POLICY, *onc_network); |
| 56 EXPECT_TRUE(actual_uidata != NULL); |
| 57 EXPECT_TRUE(expected_uidata->Equals(actual_uidata.get())) << *actual_uidata; |
| 58 } |
| 59 |
| 60 INSTANTIATE_TEST_CASE_P( |
| 61 ONCCreateUIDataTest, |
| 62 ONCCreateUIDataTest, |
| 63 ::testing::Values( |
| 64 std::make_pair("valid_wifi_clientcert.onc", |
| 65 "net/uidata_for_wifi_clientcert.json"), |
| 66 std::make_pair("valid_wifi_clientref.onc", |
| 67 "net/uidata_for_wifi_clientref.json"), |
| 68 std::make_pair("valid_wifi_psk.onc", "net/uidata_for_wifi_psk.json"), |
| 69 std::make_pair("valid_l2tpipsec_clientcert.onc", |
| 70 "net/uidata_for_l2tpipsec_clientcert.json"))); |
| 71 |
| 72 } // namespace onc |
| 73 } // namespace chromeos |
OLD | NEW |