| Index: chromeos/network/onc/onc_translator_unittest.cc
|
| diff --git a/chromeos/network/onc/onc_translator_unittest.cc b/chromeos/network/onc/onc_translator_unittest.cc
|
| index 565bb7739e70376cc85af14e3a961f0df29e2e13..5365b0b7d3c41d30859a8699172a804ba9888106 100644
|
| --- a/chromeos/network/onc/onc_translator_unittest.cc
|
| +++ b/chromeos/network/onc/onc_translator_unittest.cc
|
| @@ -25,14 +25,15 @@ TEST_P(ONCTranslatorOncToShillTest, Translate) {
|
| std::string source_onc_filename = GetParam().first;
|
| scoped_ptr<const base::DictionaryValue> onc_network(
|
| test_utils::ReadTestDictionary(source_onc_filename));
|
| - std::string result_json_filename = GetParam().second;
|
| - scoped_ptr<const base::DictionaryValue> shill_network(
|
| - test_utils::ReadTestDictionary(result_json_filename));
|
| + std::string result_shill_filename = GetParam().second;
|
| + scoped_ptr<const base::DictionaryValue> expected_shill_network(
|
| + test_utils::ReadTestDictionary(result_shill_filename));
|
|
|
| scoped_ptr<base::DictionaryValue> translation(TranslateONCObjectToShill(
|
| &kNetworkConfigurationSignature, *onc_network));
|
|
|
| - EXPECT_TRUE(test_utils::Equals(shill_network.get(), translation.get()));
|
| + EXPECT_TRUE(test_utils::Equals(expected_shill_network.get(),
|
| + translation.get()));
|
| }
|
|
|
| // Test different network types, such that each ONC object type is tested at
|
| @@ -54,56 +55,43 @@ INSTANTIATE_TEST_CASE_P(
|
| std::make_pair("valid_openvpn_clientcert.onc",
|
| "shill_openvpn_clientcert.json")));
|
|
|
| -// Test the translation from Shill json to ONC.
|
| +// First parameter: Filename of source Shill json.
|
| +// Second parameter: Filename of expected translated ONC network part.
|
| //
|
| // Note: This translation direction doesn't have to reconstruct all of the ONC
|
| // fields, as Chrome doesn't need all of a Service's properties.
|
| -TEST(ONCTranslatorShillToOncTest, L2TPIPsec) {
|
| - scoped_ptr<base::DictionaryValue> onc_network(
|
| - test_utils::ReadTestDictionary("valid_l2tpipsec.onc"));
|
| -
|
| - // These two fields are part of the ONC (and are required). However, they
|
| - // don't exist explicitly in the Shill dictionary. As there is no use-case
|
| - // yet, that requires to reconstruct these fields from a Shill dictionary, we
|
| - // don't require their translation.
|
| - onc_network->Remove("VPN.IPsec.AuthenticationType", NULL);
|
| - onc_network->Remove("VPN.IPsec.IKEVersion", NULL);
|
| +class ONCTranslatorShillToOncTest
|
| + : public ::testing::TestWithParam<std::pair<std::string, std::string> > {
|
| +};
|
|
|
| +TEST_P(ONCTranslatorShillToOncTest, Translate) {
|
| + std::string source_shill_filename = GetParam().first;
|
| scoped_ptr<const base::DictionaryValue> shill_network(
|
| - test_utils::ReadTestDictionary("shill_l2tpipsec.json"));
|
| -
|
| - scoped_ptr<base::DictionaryValue> translation(TranslateShillServiceToONCPart(
|
| - *shill_network, &kNetworkConfigurationSignature));
|
| -
|
| - EXPECT_TRUE(test_utils::Equals(onc_network.get(), translation.get()));
|
| -}
|
| -
|
| -TEST(ONCTranslatorShillToOncTest, OpenVPN) {
|
| - scoped_ptr<const base::DictionaryValue> onc_network(
|
| - test_utils::ReadTestDictionary("valid_openvpn.onc"));
|
| + test_utils::ReadTestDictionary(source_shill_filename));
|
|
|
| - scoped_ptr<const base::DictionaryValue> shill_network(
|
| - test_utils::ReadTestDictionary("shill_openvpn.json"));
|
| + std::string result_onc_filename = GetParam().second;
|
| + scoped_ptr<base::DictionaryValue> expected_onc_network(
|
| + test_utils::ReadTestDictionary(result_onc_filename));
|
|
|
| scoped_ptr<base::DictionaryValue> translation(TranslateShillServiceToONCPart(
|
| - *shill_network, &kNetworkConfigurationSignature));
|
| + *shill_network, &kNetworkWithStateSignature));
|
|
|
| - EXPECT_TRUE(test_utils::Equals(onc_network.get(), translation.get()));
|
| + EXPECT_TRUE(test_utils::Equals(expected_onc_network.get(),
|
| + translation.get()));
|
| }
|
|
|
| -TEST(ONCTranslatorShillToOncTest, OpenVPN_with_errors) {
|
| - scoped_ptr<const base::DictionaryValue> onc_network(
|
| - test_utils::ReadTestDictionary(
|
| - "translation_of_shill_openvpn_with_errors.onc"));
|
| -
|
| - scoped_ptr<const base::DictionaryValue> shill_network(
|
| - test_utils::ReadTestDictionary("shill_openvpn_with_errors.json"));
|
| -
|
| - scoped_ptr<base::DictionaryValue> translation(TranslateShillServiceToONCPart(
|
| - *shill_network, &kNetworkConfigurationSignature));
|
| -
|
| - EXPECT_TRUE(test_utils::Equals(onc_network.get(), translation.get()));
|
| -}
|
| +INSTANTIATE_TEST_CASE_P(
|
| + ONCTranslatorShillToOncTest,
|
| + ONCTranslatorShillToOncTest,
|
| + ::testing::Values(
|
| + std::make_pair("shill_l2tpipsec.json",
|
| + "translation_of_shill_l2tpipsec.onc"),
|
| + std::make_pair("shill_openvpn.json",
|
| + "valid_openvpn.onc"),
|
| + std::make_pair("shill_openvpn_with_errors.json",
|
| + "translation_of_shill_openvpn_with_errors.onc"),
|
| + std::make_pair("shill_wifi_with_state.json",
|
| + "translation_of_shill_wifi_with_state.onc")));
|
|
|
| } // namespace onc
|
| } // namespace chromeos
|
|
|