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

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

Issue 22040002: [Autofill] Add a separate enumeration for HTML field type hints. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browser test Created 7 years, 4 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 | « components/autofill/core/browser/autofill_type.cc ('k') | components/autofill/core/browser/contact_info.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/autofill_type_unittest.cc
diff --git a/components/autofill/core/browser/autofill_type_unittest.cc b/components/autofill/core/browser/autofill_type_unittest.cc
index d9e8f9e6f03467c448b560d3da6e811883ecb31e..71e98b4996d7280e48d67edd71571d1e0e8885dc 100644
--- a/components/autofill/core/browser/autofill_type_unittest.cc
+++ b/components/autofill/core/browser/autofill_type_unittest.cc
@@ -8,47 +8,84 @@
namespace autofill {
namespace {
-TEST(AutofillTypeTest, AutofillTypes) {
+TEST(AutofillTypeTest, ServerFieldTypes) {
// No server data.
AutofillType none(NO_SERVER_DATA);
- EXPECT_EQ(NO_SERVER_DATA, none.server_type());
+ EXPECT_EQ(NO_SERVER_DATA, none.GetStorableType());
EXPECT_EQ(NO_GROUP, none.group());
// Unknown type.
AutofillType unknown(UNKNOWN_TYPE);
- EXPECT_EQ(UNKNOWN_TYPE, unknown.server_type());
+ EXPECT_EQ(UNKNOWN_TYPE, unknown.GetStorableType());
EXPECT_EQ(NO_GROUP, unknown.group());
// Type with group but no subgroup.
AutofillType first(NAME_FIRST);
- EXPECT_EQ(NAME_FIRST, first.server_type());
+ EXPECT_EQ(NAME_FIRST, first.GetStorableType());
EXPECT_EQ(NAME, first.group());
// Type with group and subgroup.
AutofillType phone(PHONE_HOME_NUMBER);
- EXPECT_EQ(PHONE_HOME_NUMBER, phone.server_type());
+ EXPECT_EQ(PHONE_HOME_NUMBER, phone.GetStorableType());
EXPECT_EQ(PHONE_HOME, phone.group());
+ // Billing type.
+ AutofillType billing_address(ADDRESS_BILLING_LINE1);
+ EXPECT_EQ(ADDRESS_HOME_LINE1, billing_address.GetStorableType());
+ EXPECT_EQ(ADDRESS_BILLING, billing_address.group());
+
// Last value, to check any offset errors.
- AutofillType last(COMPANY_NAME);
- EXPECT_EQ(COMPANY_NAME, last.server_type());
- EXPECT_EQ(COMPANY, last.group());
+ AutofillType last(NAME_BILLING_SUFFIX);
+ EXPECT_EQ(NAME_SUFFIX, last.GetStorableType());
+ EXPECT_EQ(NAME_BILLING, last.group());
// Boundary (error) condition.
AutofillType boundary(MAX_VALID_FIELD_TYPE);
- EXPECT_EQ(UNKNOWN_TYPE, boundary.server_type());
+ EXPECT_EQ(UNKNOWN_TYPE, boundary.GetStorableType());
EXPECT_EQ(NO_GROUP, boundary.group());
// Beyond the boundary (error) condition.
- AutofillType beyond(static_cast<ServerFieldType>(MAX_VALID_FIELD_TYPE+10));
- EXPECT_EQ(UNKNOWN_TYPE, beyond.server_type());
+ AutofillType beyond(static_cast<ServerFieldType>(MAX_VALID_FIELD_TYPE + 10));
+ EXPECT_EQ(UNKNOWN_TYPE, beyond.GetStorableType());
EXPECT_EQ(NO_GROUP, beyond.group());
// In-between value. Missing from enum but within range. Error condition.
AutofillType between(static_cast<ServerFieldType>(16));
- EXPECT_EQ(UNKNOWN_TYPE, between.server_type());
+ EXPECT_EQ(UNKNOWN_TYPE, between.GetStorableType());
EXPECT_EQ(NO_GROUP, between.group());
}
+TEST(AutofillTypeTest, HtmlFieldTypes) {
+ // Unknown type.
+ AutofillType unknown(HTML_TYPE_UNKNOWN, HTML_MODE_NONE);
+ EXPECT_EQ(UNKNOWN_TYPE, unknown.GetStorableType());
+ EXPECT_EQ(NO_GROUP, unknown.group());
+
+ // Type with group but no subgroup.
+ AutofillType first(HTML_TYPE_GIVEN_NAME, HTML_MODE_NONE);
+ EXPECT_EQ(NAME_FIRST, first.GetStorableType());
+ EXPECT_EQ(NAME, first.group());
+
+ // Type with group and subgroup.
+ AutofillType phone(HTML_TYPE_TEL, HTML_MODE_NONE);
+ EXPECT_EQ(PHONE_HOME_WHOLE_NUMBER, phone.GetStorableType());
+ EXPECT_EQ(PHONE_HOME, phone.group());
+
+ // Last value, to check any offset errors.
+ AutofillType last(HTML_TYPE_CREDIT_CARD_EXP_4_DIGIT_YEAR, HTML_MODE_NONE);
+ EXPECT_EQ(CREDIT_CARD_EXP_4_DIGIT_YEAR, last.GetStorableType());
+ EXPECT_EQ(CREDIT_CARD, last.group());
+
+ // Shipping mode.
+ AutofillType shipping_first(HTML_TYPE_GIVEN_NAME, HTML_MODE_SHIPPING);
+ EXPECT_EQ(NAME_FIRST, shipping_first.GetStorableType());
+ EXPECT_EQ(NAME, shipping_first.group());
+
+ // Billing mode.
+ AutofillType billing_first(HTML_TYPE_GIVEN_NAME, HTML_MODE_BILLING);
+ EXPECT_EQ(NAME_FIRST, billing_first.GetStorableType());
+ EXPECT_EQ(NAME_BILLING, billing_first.group());
+}
+
} // namespace
} // namespace autofill
« no previous file with comments | « components/autofill/core/browser/autofill_type.cc ('k') | components/autofill/core/browser/contact_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698