Commit ee7e175d authored by Caitlin Fischer's avatar Caitlin Fischer Committed by Commit Bot

[Autofill] Adds a function to see if profiles have the same data.

When constructing labels for a collection of profiles, it is useful to
know whether certain fields, such as email address and first name, can
disambiguate profiles.

Also (1) changes the name of GetLabelName to GetLabelFullName, (2) adds
GetLabelFirstName, and (3) removes HaveSameEmailAddresses.

GetLabelFirstName will be used by mobile-friendly LabelFormatters since
first names take up less space than full names.

This is a separate CL to reduce the size and complexity of the upcoming
mobile-friendly-related LabelFormatter changes.

Bug: 958333
Change-Id: I971cb78342ed89987765bb16656c302e5bc4d4e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1594074
Commit-Queue: Caitlin Fischer <caitlinfischer@google.com>
Reviewed-by: default avatarTommy Martino <tmartino@chromium.org>
Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#658716}
parent 7f6503d9
...@@ -37,7 +37,8 @@ base::string16 AddressContactFormLabelFormatter::GetLabelForProfile( ...@@ -37,7 +37,8 @@ base::string16 AddressContactFormLabelFormatter::GetLabelForProfile(
!IsStreetAddressPart(focused_field_type()); !IsStreetAddressPart(focused_field_type());
if (focused_group != NAME && !non_street_address_is_focused) { if (focused_group != NAME && !non_street_address_is_focused) {
AddLabelPartIfNotEmpty(GetLabelName(profile, app_locale()), &label_parts); AddLabelPartIfNotEmpty(GetLabelFullName(profile, app_locale()),
&label_parts);
} }
if (!street_address_is_focused) { if (!street_address_is_focused) {
......
...@@ -41,7 +41,8 @@ base::string16 AddressEmailFormLabelFormatter:: ...@@ -41,7 +41,8 @@ base::string16 AddressEmailFormLabelFormatter::
std::vector<base::string16> label_parts; std::vector<base::string16> label_parts;
if (focused_group != NAME) { if (focused_group != NAME) {
AddLabelPartIfNotEmpty(GetLabelName(profile, app_locale()), &label_parts); AddLabelPartIfNotEmpty(GetLabelFullName(profile, app_locale()),
&label_parts);
} }
if (focused_group != ADDRESS_HOME) { if (focused_group != ADDRESS_HOME) {
......
...@@ -26,7 +26,8 @@ base::string16 AddressFormLabelFormatter::GetLabelForProfile( ...@@ -26,7 +26,8 @@ base::string16 AddressFormLabelFormatter::GetLabelForProfile(
field_types_for_labels()); field_types_for_labels());
} else { } else {
std::vector<base::string16> label_parts; std::vector<base::string16> label_parts;
AddLabelPartIfNotEmpty(GetLabelName(profile, app_locale()), &label_parts); AddLabelPartIfNotEmpty(GetLabelFullName(profile, app_locale()),
&label_parts);
AddLabelPartIfNotEmpty(GetLabelForFocusedAddress( AddLabelPartIfNotEmpty(GetLabelForFocusedAddress(
focused_field_type(), form_has_street_address_, focused_field_type(), form_has_street_address_,
profile, app_locale(), field_types_for_labels()), profile, app_locale(), field_types_for_labels()),
......
...@@ -40,7 +40,8 @@ base::string16 AddressPhoneFormLabelFormatter:: ...@@ -40,7 +40,8 @@ base::string16 AddressPhoneFormLabelFormatter::
FieldTypeGroup focused_group) const { FieldTypeGroup focused_group) const {
std::vector<base::string16> label_parts; std::vector<base::string16> label_parts;
if (focused_group != NAME) { if (focused_group != NAME) {
AddLabelPartIfNotEmpty(GetLabelName(profile, app_locale()), &label_parts); AddLabelPartIfNotEmpty(GetLabelFullName(profile, app_locale()),
&label_parts);
} }
if (focused_group != PHONE_HOME) { if (focused_group != PHONE_HOME) {
......
...@@ -26,7 +26,8 @@ base::string16 ContactFormLabelFormatter::GetLabelForProfile( ...@@ -26,7 +26,8 @@ base::string16 ContactFormLabelFormatter::GetLabelForProfile(
FieldTypeGroup focused_group) const { FieldTypeGroup focused_group) const {
std::vector<base::string16> label_parts; std::vector<base::string16> label_parts;
if (focused_group != NAME) { if (focused_group != NAME) {
AddLabelPartIfNotEmpty(GetLabelName(profile, app_locale()), &label_parts); AddLabelPartIfNotEmpty(GetLabelFullName(profile, app_locale()),
&label_parts);
} }
if (focused_group != PHONE_HOME) { if (focused_group != PHONE_HOME) {
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#include <iterator> #include <iterator>
#include <memory> #include <memory>
#include "base/bind.h"
#include "base/callback.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/address_i18n.h" #include "components/autofill/core/browser/address_i18n.h"
...@@ -21,6 +23,38 @@ ...@@ -21,6 +23,38 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
namespace autofill { namespace autofill {
namespace {
// Returns true if all |profiles| have the same value for the data retrieved by
// |get_data|.
bool HaveSameData(
const std::vector<AutofillProfile*>& profiles,
const std::string& app_locale,
base::RepeatingCallback<base::string16(const AutofillProfile&,
const std::string&)> get_data,
base::RepeatingCallback<bool(const base::string16& str1,
const base::string16& str2)> matches) {
if (profiles.size() <= 1) {
return true;
}
const base::string16 first_profile_data =
get_data.Run(*profiles[0], app_locale);
for (size_t i = 1; i < profiles.size(); ++i) {
const base::string16 current_profile_data =
get_data.Run(*profiles[i], app_locale);
if (!matches.Run(first_profile_data, current_profile_data)) {
return false;
}
}
return true;
}
bool Equals(const base::string16& str1, const base::string16& str2) {
return str1 == str2;
}
} // namespace
const int kStreetAddressFieldTypes[] = { const int kStreetAddressFieldTypes[] = {
ADDRESS_HOME_LINE1, ADDRESS_HOME_LINE2, ADDRESS_HOME_LINE1, ADDRESS_HOME_LINE2,
...@@ -126,11 +160,6 @@ AutofillProfile MakeTrimmedProfile(const AutofillProfile& profile, ...@@ -126,11 +160,6 @@ AutofillProfile MakeTrimmedProfile(const AutofillProfile& profile,
return trimmed_profile; return trimmed_profile;
} }
base::string16 GetLabelName(const AutofillProfile& profile,
const std::string& app_locale) {
return profile.GetInfo(AutofillType(NAME_FULL), app_locale);
}
base::string16 GetLabelForFocusedAddress( base::string16 GetLabelForFocusedAddress(
ServerFieldType focused_field_type, ServerFieldType focused_field_type,
bool form_has_street_address, bool form_has_street_address,
...@@ -197,6 +226,16 @@ base::string16 GetLabelForProfileOnFocusedNonStreetAddress( ...@@ -197,6 +226,16 @@ base::string16 GetLabelForProfileOnFocusedNonStreetAddress(
return ConstructLabelLine(label_parts); return ConstructLabelLine(label_parts);
} }
base::string16 GetLabelFullName(const AutofillProfile& profile,
const std::string& app_locale) {
return profile.GetInfo(AutofillType(NAME_FULL), app_locale);
}
base::string16 GetLabelFirstName(const AutofillProfile& profile,
const std::string& app_locale) {
return profile.GetInfo(AutofillType(NAME_FIRST), app_locale);
}
base::string16 GetLabelEmail(const AutofillProfile& profile, base::string16 GetLabelEmail(const AutofillProfile& profile,
const std::string& app_locale) { const std::string& app_locale) {
const base::string16 email = const base::string16 email =
...@@ -217,46 +256,35 @@ base::string16 GetLabelPhone(const AutofillProfile& profile, ...@@ -217,46 +256,35 @@ base::string16 GetLabelPhone(const AutofillProfile& profile,
bool HaveSameEmailAddresses(const std::vector<AutofillProfile*>& profiles, bool HaveSameEmailAddresses(const std::vector<AutofillProfile*>& profiles,
const std::string& app_locale) { const std::string& app_locale) {
bool first_email_found = false; return HaveSameData(profiles, app_locale, base::BindRepeating(&GetLabelEmail),
base::string16 first_email; base::BindRepeating(&Equals));
}
for (const AutofillProfile* profile : profiles) {
base::string16 email_from_profile = GetLabelEmail(*profile, app_locale); bool HaveSameFirstNames(const std::vector<AutofillProfile*>& profiles,
const std::string& app_locale) {
if (!first_email_found) { return HaveSameData(profiles, app_locale,
// Store the first email address whether it's empty or not because we base::BindRepeating(&GetLabelFirstName),
// consider "" and "hao.le@aol.com" to be different email addresses. base::BindRepeating(&Equals));
first_email_found = true;
first_email = email_from_profile;
} else if (email_from_profile != first_email) {
return false;
}
}
return true;
} }
bool HaveSamePhoneNumbers(const std::vector<AutofillProfile*>& profiles, bool HaveSamePhoneNumbers(const std::vector<AutofillProfile*>& profiles,
const std::string& app_locale) { const std::string& app_locale) {
bool first_phone_found = false; // Note that the same country code is used in all comparisons.
base::string16 first_phone; auto equals = [](const std::string& country_code,
const std::string& app_locale, const base::string16& phone1,
for (const AutofillProfile* profile : profiles) { const base::string16& phone2) -> bool {
base::string16 phone_from_profile = GetLabelPhone(*profile, app_locale); return (phone1.empty() && phone2.empty()) ||
i18n::PhoneNumbersMatch(phone1, phone2, country_code, app_locale);
if (!first_phone_found) { };
// Store the first phone number whether it's empty or not because we
// consider "" and "(514) 873-1100" to be different phone numbers. return profiles.size() <= 1
first_phone_found = true; ? true
first_phone = phone_from_profile; : HaveSameData(
} else if (!(first_phone.empty() && phone_from_profile.empty()) && profiles, app_locale, base::BindRepeating(&GetLabelPhone),
!i18n::PhoneNumbersMatch(first_phone, phone_from_profile, base::BindRepeating(equals,
base::UTF16ToASCII(profile->GetInfo( base::UTF16ToASCII(profiles[0]->GetInfo(
ADDRESS_HOME_COUNTRY, app_locale)), ADDRESS_HOME_COUNTRY, app_locale)),
app_locale)) { app_locale));
return false;
}
}
return true;
} }
} // namespace autofill } // namespace autofill
...@@ -64,10 +64,6 @@ AutofillProfile MakeTrimmedProfile(const AutofillProfile& profile, ...@@ -64,10 +64,6 @@ AutofillProfile MakeTrimmedProfile(const AutofillProfile& profile,
const std::string& app_locale, const std::string& app_locale,
const std::vector<ServerFieldType>& types); const std::vector<ServerFieldType>& types);
// Returns the full name associated with |profile|.
base::string16 GetLabelName(const AutofillProfile& profile,
const std::string& app_locale);
// Returns either street-address data or non-street-address data found in // Returns either street-address data or non-street-address data found in
// |profile|. If |focused_field_type| is a street address field, then returns // |profile|. If |focused_field_type| is a street address field, then returns
// non-street-address data, e.g. Lowell, MA 01852. // non-street-address data, e.g. Lowell, MA 01852.
...@@ -122,6 +118,16 @@ base::string16 GetLabelForProfileOnFocusedNonStreetAddress( ...@@ -122,6 +118,16 @@ base::string16 GetLabelForProfileOnFocusedNonStreetAddress(
const std::vector<ServerFieldType>& types, const std::vector<ServerFieldType>& types,
const base::string16& contact_info); const base::string16& contact_info);
// Returns the full name associated with |profile|, if any; otherwise, returns
// an empty string.
base::string16 GetLabelFullName(const AutofillProfile& profile,
const std::string& app_locale);
// Returns the first name associated with |profile|, if any; otherwise, returns
// an empty string.
base::string16 GetLabelFirstName(const AutofillProfile& profile,
const std::string& app_locale);
// Returns the email address associated with |profile|, if any; otherwise, // Returns the email address associated with |profile|, if any; otherwise,
// returns an empty string. // returns an empty string.
base::string16 GetLabelEmail(const AutofillProfile& profile, base::string16 GetLabelEmail(const AutofillProfile& profile,
...@@ -139,12 +145,17 @@ base::string16 GetLabelPhone(const AutofillProfile& profile, ...@@ -139,12 +145,17 @@ base::string16 GetLabelPhone(const AutofillProfile& profile,
bool HaveSameEmailAddresses(const std::vector<AutofillProfile*>& profiles, bool HaveSameEmailAddresses(const std::vector<AutofillProfile*>& profiles,
const std::string& app_locale); const std::string& app_locale);
// Returns true if all |profiles| have the same first name. Note that names are
// compared without normalization, so José and Jose are considered different
// names.
bool HaveSameFirstNames(const std::vector<AutofillProfile*>& profiles,
const std::string& app_locale);
// Returns true if all |profiles| have the same phone number after // Returns true if all |profiles| have the same phone number after
// normalization. Note that the absence of a phone number and an actual phone // normalization. Note that the absence of a phone number and an actual phone
// number, e.g. (401) 847-8720, are considered different phone numbers. // number, e.g. (401) 847-8720, are considered different phone numbers.
bool HaveSamePhoneNumbers(const std::vector<AutofillProfile*>& profiles, bool HaveSamePhoneNumbers(const std::vector<AutofillProfile*>& profiles,
const std::string& app_locale); const std::string& app_locale);
} // namespace autofill } // namespace autofill
#endif // COMPONENTS_AUTOFILL_CORE_BROWSER_LABEL_FORMATTER_UTILS_H_ #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_LABEL_FORMATTER_UTILS_H_
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "components/autofill/core/browser/label_formatter_utils.h" #include "components/autofill/core/browser/label_formatter_utils.h"
#include "base/bind.h"
#include "base/guid.h" #include "base/guid.h"
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
...@@ -19,24 +20,73 @@ ...@@ -19,24 +20,73 @@
namespace autofill { namespace autofill {
namespace { namespace {
TEST(LabelFormatterUtilsTest, ConstructLabelLine) { TEST(LabelFormatterUtilsTest, HaveSameFirstNames_OneProfileAndNoFirstName) {
EXPECT_EQ(base::string16(), ConstructLabelLine({})); AutofillProfile profile =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile, "", "", "", "", "", "", "", "", "", "", "DE",
"");
EXPECT_TRUE(HaveSameFirstNames({&profile}, "de"));
}
base::string16 name = base::ASCIIToUTF16("Blaise Pascal"); TEST(LabelFormatterUtilsTest, HaveSameFirstNames_OneProfileAndFirstName) {
base::string16 phone = base::ASCIIToUTF16("01 53 01 82 00"); AutofillProfile profile =
base::string16 email = base::ASCIIToUTF16("b.pascal@orange.fr"); AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile, "Maria", "", "", "", "", "", "", "", "", "",
"DE", "");
EXPECT_TRUE(HaveSameFirstNames({&profile}, "de"));
}
base::string16 separator = TEST(LabelFormatterUtilsTest, HaveSameFirstNames_NoFirstNames) {
l10n_util::GetStringUTF16(IDS_AUTOFILL_SUGGESTION_LABEL_SEPARATOR); AutofillProfile profile1 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile1, "", "", "Kirch", "", "", "", "", "", "", "",
"DE", "");
AutofillProfile profile2 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile2, "", "", "Winckelmann", "", "", "", "", "", "",
"", "DE", "");
EXPECT_TRUE(HaveSameFirstNames({&profile1, &profile2}, "de"));
}
EXPECT_EQ(name, ConstructLabelLine({name})); TEST(LabelFormatterUtilsTest, HaveSameFirstNames_SameFirstNames) {
EXPECT_EQ(base::JoinString({name, separator, phone, separator, email}, AutofillProfile profile1 =
base::string16()), AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
ConstructLabelLine({name, phone, email})); test::SetProfileInfo(&profile1, "Maria", "", "Kirch", "", "", "", "", "", "",
"", "DE", "");
AutofillProfile profile2 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile2, "Maria", "", "Winckelmann", "", "", "", "",
"", "", "", "DE", "");
EXPECT_TRUE(HaveSameFirstNames({&profile1, &profile2}, "de"));
}
TEST(LabelFormatterUtilsTest, HaveSameFirstNames_DifferentNonEmptyFirstNames) {
AutofillProfile profile1 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile1, "Maria", "", "Kirch", "", "", "", "", "", "",
"", "DE", "");
AutofillProfile profile2 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile2, "Mary", "", "Kirch", "", "", "", "", "", "",
"", "DE", "");
EXPECT_FALSE(HaveSameFirstNames({&profile1, &profile2}, "de"));
}
TEST(LabelFormatterUtilsTest, HaveSameFirstNames_NonEmptyAndEmptyFirstNames) {
AutofillProfile profile1 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", "", "", "",
"", "", "", "", "DE", "");
AutofillProfile profile2 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile2, "", "Margaretha", "Winckelmann", "", "", "",
"", "", "", "", "DE", "");
EXPECT_FALSE(HaveSameFirstNames({&profile1, &profile2}, "de"));
EXPECT_FALSE(HaveSameFirstNames({&profile2, &profile1}, "de"));
} }
TEST(LabelFormatterUtilsTest, TEST(LabelFormatterUtilsTest,
HaveSameEmailAddressesWithOneProfileAndNoEmailAddress) { HaveSameEmailAddresses_OneProfileAndNoEmailAddress) {
AutofillProfile profile = AutofillProfile profile =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile, "Maria", "Margaretha", "Kirch", test::SetProfileInfo(&profile, "Maria", "Margaretha", "Kirch",
...@@ -45,7 +95,7 @@ TEST(LabelFormatterUtilsTest, ...@@ -45,7 +95,7 @@ TEST(LabelFormatterUtilsTest,
} }
TEST(LabelFormatterUtilsTest, TEST(LabelFormatterUtilsTest,
HaveSameEmailAddressesWithOneProfileAndEmailAddress) { HaveSameEmailAddresses_OneProfileAndEmailAddress) {
AutofillProfile profile = AutofillProfile profile =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile, "Maria", "Margaretha", "Kirch", "", "", "", "", test::SetProfileInfo(&profile, "Maria", "Margaretha", "Kirch", "", "", "", "",
...@@ -53,8 +103,7 @@ TEST(LabelFormatterUtilsTest, ...@@ -53,8 +103,7 @@ TEST(LabelFormatterUtilsTest,
EXPECT_TRUE(HaveSameEmailAddresses({&profile}, "de")); EXPECT_TRUE(HaveSameEmailAddresses({&profile}, "de"));
} }
TEST(LabelFormatterUtilsTest, TEST(LabelFormatterUtilsTest, HaveSameEmailAddresses_NoEmailAddresses) {
HaveSameEmailAddressesWithProfilesAndNoEmailAddresses) {
AutofillProfile profile1 = AutofillProfile profile1 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", "", "", "", test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", "", "", "",
...@@ -66,8 +115,7 @@ TEST(LabelFormatterUtilsTest, ...@@ -66,8 +115,7 @@ TEST(LabelFormatterUtilsTest,
EXPECT_TRUE(HaveSameEmailAddresses({&profile1, &profile2}, "de")); EXPECT_TRUE(HaveSameEmailAddresses({&profile1, &profile2}, "de"));
} }
TEST(LabelFormatterUtilsTest, TEST(LabelFormatterUtilsTest, HaveSameEmailAddresses_SameEmailAddresses) {
HaveSameEmailAddressesWithProfilesAndSameEmailAddresses) {
AutofillProfile profile1 = AutofillProfile profile1 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch",
...@@ -80,7 +128,7 @@ TEST(LabelFormatterUtilsTest, ...@@ -80,7 +128,7 @@ TEST(LabelFormatterUtilsTest,
} }
TEST(LabelFormatterUtilsTest, TEST(LabelFormatterUtilsTest,
HaveSameEmailAddressesWithProfilesAndDifferentNonEmptyEmailAddresses) { HaveSameEmailAddresses_DifferentNonEmptyEmailAddresses) {
AutofillProfile profile1 = AutofillProfile profile1 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch",
...@@ -93,7 +141,7 @@ TEST(LabelFormatterUtilsTest, ...@@ -93,7 +141,7 @@ TEST(LabelFormatterUtilsTest,
} }
TEST(LabelFormatterUtilsTest, TEST(LabelFormatterUtilsTest,
HaveSameEmailAddressesWithProfilesAndNonEmptyAndEmptyEmailAddresses) { HaveSameEmailAddresses_NonEmptyAndEmptyEmailAddresses) {
AutofillProfile profile1 = AutofillProfile profile1 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch",
...@@ -106,8 +154,7 @@ TEST(LabelFormatterUtilsTest, ...@@ -106,8 +154,7 @@ TEST(LabelFormatterUtilsTest,
EXPECT_FALSE(HaveSameEmailAddresses({&profile2, &profile1}, "de")); EXPECT_FALSE(HaveSameEmailAddresses({&profile2, &profile1}, "de"));
} }
TEST(LabelFormatterUtilsTest, TEST(LabelFormatterUtilsTest, HaveSamePhoneNumbers_OneProfileAndNoPhoneNumber) {
HaveSamePhoneNumbersWithOneProfileAndNoPhoneNumber) {
AutofillProfile profile = AutofillProfile profile =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile, "Maria", "Margaretha", "Kirch", "", "", "", "", test::SetProfileInfo(&profile, "Maria", "Margaretha", "Kirch", "", "", "", "",
...@@ -115,8 +162,7 @@ TEST(LabelFormatterUtilsTest, ...@@ -115,8 +162,7 @@ TEST(LabelFormatterUtilsTest,
EXPECT_TRUE(HaveSamePhoneNumbers({&profile}, "de")); EXPECT_TRUE(HaveSamePhoneNumbers({&profile}, "de"));
} }
TEST(LabelFormatterUtilsTest, TEST(LabelFormatterUtilsTest, HaveSamePhoneNumbers_OneProfileAndPhoneNumber) {
HaveSamePhoneNumbersWithOneProfileAndPhoneNumber) {
AutofillProfile profile = AutofillProfile profile =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile, "Maria", "Margaretha", "Kirch", "", "", "", "", test::SetProfileInfo(&profile, "Maria", "Margaretha", "Kirch", "", "", "", "",
...@@ -124,8 +170,7 @@ TEST(LabelFormatterUtilsTest, ...@@ -124,8 +170,7 @@ TEST(LabelFormatterUtilsTest,
EXPECT_TRUE(HaveSamePhoneNumbers({&profile}, "de")); EXPECT_TRUE(HaveSamePhoneNumbers({&profile}, "de"));
} }
TEST(LabelFormatterUtilsTest, TEST(LabelFormatterUtilsTest, HaveSamePhoneNumbers_NoPhoneNumber) {
HaveSamePhoneNumbersWithProfilesAndNoPhoneNumber) {
AutofillProfile profile1 = AutofillProfile profile1 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", "", "", "", test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", "", "", "",
...@@ -137,8 +182,7 @@ TEST(LabelFormatterUtilsTest, ...@@ -137,8 +182,7 @@ TEST(LabelFormatterUtilsTest,
EXPECT_TRUE(HaveSamePhoneNumbers({&profile1, &profile2}, "de")); EXPECT_TRUE(HaveSamePhoneNumbers({&profile1, &profile2}, "de"));
} }
TEST(LabelFormatterUtilsTest, TEST(LabelFormatterUtilsTest, HaveSamePhoneNumbers_SamePhoneNumbers) {
HaveSamePhoneNumbersWithProfilesAndSamePhoneNumbers) {
AutofillProfile profile1 = AutofillProfile profile1 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", "", "", "", test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", "", "", "",
...@@ -155,7 +199,7 @@ TEST(LabelFormatterUtilsTest, ...@@ -155,7 +199,7 @@ TEST(LabelFormatterUtilsTest,
} }
TEST(LabelFormatterUtilsTest, TEST(LabelFormatterUtilsTest,
HaveSamePhoneNumbersWithProfilesAndDifferentNonEmptyPhoneNumbers) { HaveSamePhoneNumbers_DifferentNonEmptyPhoneNumbers) {
AutofillProfile profile1 = AutofillProfile profile1 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", "", "", "", test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", "", "", "",
...@@ -168,7 +212,7 @@ TEST(LabelFormatterUtilsTest, ...@@ -168,7 +212,7 @@ TEST(LabelFormatterUtilsTest,
} }
TEST(LabelFormatterUtilsTest, TEST(LabelFormatterUtilsTest,
HaveSamePhoneNumbersWithProfilesAndNonEmptyAndEmptyPhoneNumbers) { HaveSamePhoneNumbers_NonEmptyAndEmptyPhoneNumbers) {
AutofillProfile profile1 = AutofillProfile profile1 =
AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin); AutofillProfile(base::GenerateGUID(), test::kEmptyOrigin);
test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", "", "", "", test::SetProfileInfo(&profile1, "Maria", "Margaretha", "Kirch", "", "", "",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment