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

Unified Diff: components/autofill/core/browser/autofill_data_util_unittest.cc

Issue 2829503002: [Payments] Normalize Shipping Address sent to merchant on Desktop. (Closed)
Patch Set: Be more strict on country code Created 3 years, 8 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
Index: components/autofill/core/browser/autofill_data_util_unittest.cc
diff --git a/components/autofill/core/browser/autofill_data_util_unittest.cc b/components/autofill/core/browser/autofill_data_util_unittest.cc
index 9aadd58bf4f01d64de0198142c640a1770d0559d..1a66f8e59a420e672af59634596a7f8823d49052 100644
--- a/components/autofill/core/browser/autofill_data_util_unittest.cc
+++ b/components/autofill/core/browser/autofill_data_util_unittest.cc
@@ -198,5 +198,46 @@ TEST(AutofillDataUtilTest, ProfileMatchesFullName) {
ProfileMatchesFullName(base::UTF8ToUTF16("Kirby Puckett"), profile));
}
+struct ValidCountryCodeTestCase {
+ std::string country_code;
+ bool expected_result;
+};
+
+class ValidCountryCodeTest
+ : public testing::TestWithParam<ValidCountryCodeTestCase> {};
+
+TEST_P(ValidCountryCodeTest, ValidCountryCode) {
+ auto test_case = GetParam();
+ EXPECT_EQ(test_case.expected_result,
+ IsValidCountryCode(test_case.country_code));
+}
+
+INSTANTIATE_TEST_CASE_P(
+ AutofillDataUtil,
+ ValidCountryCodeTest,
+ testing::Values(
+ // Valid country codes.
+ ValidCountryCodeTestCase{"US", true},
+ ValidCountryCodeTestCase{"CA", true},
+ ValidCountryCodeTestCase{"CN", true},
+
+ // Country names should not be considered valid.
+ ValidCountryCodeTestCase{"United States", false},
+ ValidCountryCodeTestCase{"Canada", false},
+ ValidCountryCodeTestCase{"China", false},
+
+ // Codes with numbers should not be considered valid.
+ ValidCountryCodeTestCase{"C2", false},
+
+ // Three letters abbreviations should not be considered valid.
+ ValidCountryCodeTestCase{"USA", false},
+ ValidCountryCodeTestCase{"CAN", false},
+ ValidCountryCodeTestCase{"CHN", false},
+
+ // Lowercase is invalid.
+ ValidCountryCodeTestCase{"us", false},
+ ValidCountryCodeTestCase{"Ca", false},
+ ValidCountryCodeTestCase{"cN", false}));
+
} // namespace data_util
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/autofill_data_util.cc ('k') | components/payments/content/payment_request_state.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698