Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Unified Diff: chromeos/network/onc/onc_translator_unittest.cc

Issue 12390017: Separating ONC<->Shill translation from the ONC signature. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed browser tests. Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chromeos/network/onc/onc_translator_shill_to_onc.cc ('k') | chromeos/network/onc/onc_validator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chromeos/network/onc/onc_translator_shill_to_onc.cc ('k') | chromeos/network/onc/onc_validator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698