| Index: chrome/browser/chromeos/net/onc_utils_unittest.cc
|
| diff --git a/chrome/browser/chromeos/net/onc_utils_unittest.cc b/chrome/browser/chromeos/net/onc_utils_unittest.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..71f310cc7f4ad9ac42a23cb06409acb29f231e9a
|
| --- /dev/null
|
| +++ b/chrome/browser/chromeos/net/onc_utils_unittest.cc
|
| @@ -0,0 +1,73 @@
|
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/chromeos/net/onc_utils.h"
|
| +
|
| +#include <string>
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "base/values.h"
|
| +#include "chrome/browser/google_apis/test_util.h"
|
| +#include "chromeos/network/onc/onc_test_utils.h"
|
| +#include "testing/gtest/include/gtest/gtest.h"
|
| +
|
| +namespace chromeos {
|
| +namespace onc {
|
| +
|
| +TEST(ONCUtils, ProxySettingsToProxyConfig) {
|
| + scoped_ptr<base::Value> test_data =
|
| + google_apis::test_util::LoadJSONFile("net/proxy_config.json");
|
| +
|
| + base::ListValue* list_of_tests;
|
| + test_data->GetAsList(&list_of_tests);
|
| +
|
| + for (base::ListValue::iterator it = list_of_tests->begin();
|
| + it != list_of_tests->end(); ++it) {
|
| + base::DictionaryValue* test_case;
|
| + (*it)->GetAsDictionary(&test_case);
|
| +
|
| + base::DictionaryValue* onc_proxy_settings;
|
| + test_case->GetDictionary("ONC_ProxySettings", &onc_proxy_settings);
|
| +
|
| + base::DictionaryValue* expected_proxy_config;
|
| + test_case->GetDictionary("ProxyConfig", &expected_proxy_config);
|
| +
|
| + scoped_ptr<base::DictionaryValue> actual_proxy_config =
|
| + ConvertOncProxySettingsToProxyConfig(*onc_proxy_settings);
|
| + EXPECT_TRUE(actual_proxy_config != NULL);
|
| + EXPECT_TRUE(expected_proxy_config->Equals(actual_proxy_config.get()));
|
| + }
|
| +}
|
| +
|
| +class ONCCreateUIDataTest
|
| + : public ::testing::TestWithParam<std::pair<std::string, std::string> > {
|
| +};
|
| +
|
| +TEST_P(ONCCreateUIDataTest, CreateUIData) {
|
| + scoped_ptr<base::DictionaryValue> onc_network =
|
| + test_utils::ReadTestDictionary(GetParam().first);
|
| +
|
| + scoped_ptr<base::Value> expected_uidata =
|
| + google_apis::test_util::LoadJSONFile(GetParam().second);
|
| +
|
| + scoped_ptr<base::DictionaryValue> actual_uidata =
|
| + CreateUIData(ONC_SOURCE_USER_POLICY, *onc_network);
|
| + EXPECT_TRUE(actual_uidata != NULL);
|
| + EXPECT_TRUE(expected_uidata->Equals(actual_uidata.get())) << *actual_uidata;
|
| +}
|
| +
|
| +INSTANTIATE_TEST_CASE_P(
|
| + ONCCreateUIDataTest,
|
| + ONCCreateUIDataTest,
|
| + ::testing::Values(
|
| + std::make_pair("valid_wifi_clientcert.onc",
|
| + "net/uidata_for_wifi_clientcert.json"),
|
| + std::make_pair("valid_wifi_clientref.onc",
|
| + "net/uidata_for_wifi_clientref.json"),
|
| + std::make_pair("valid_wifi_psk.onc", "net/uidata_for_wifi_psk.json"),
|
| + std::make_pair("valid_l2tpipsec_clientcert.onc",
|
| + "net/uidata_for_l2tpipsec_clientcert.json")));
|
| +
|
| +} // namespace onc
|
| +} // namespace chromeos
|
|
|