Commit 4da55b37 authored by Matthias Körber's avatar Matthias Körber Committed by Commit Bot

[Autofill][Slimshady] Fixed tests to work with globally enabled feature

Although not rolled out yet, some tests fail when structured names
are globally enabled. This CL proactively fixes most remaining issues.


Change-Id: I0f0a54612be8118cf472987cd022b702416b21be
Bug: 1099202
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2362734
Commit-Queue: Matthias Körber <koerber@google.com>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799614}
parent ccf9d19e
...@@ -2211,7 +2211,17 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest, ...@@ -2211,7 +2211,17 @@ IN_PROC_BROWSER_TEST_F(AutofillInteractiveTest,
ui_test_utils::NavigateToURL(browser(), url); ui_test_utils::NavigateToURL(browser(), url);
PopulateForm("NAME_FIRST"); PopulateForm("NAME_FIRST");
// In the legacy implementation for names, the initial is always created
// without a trailing dot even if the user explicitely used a dot.
// For structured names, we leave the choice to the user.
// TODO(crbug.com/1103421): Clean legacy implementation once structured names
// are fully launched.
if (base::FeatureList::IsEnabled(
features::kAutofillEnableSupportForMoreStructureInNames)) {
ExpectFieldValue("NAME_MIDDLE", "C.");
} else {
ExpectFieldValue("NAME_MIDDLE", "C"); ExpectFieldValue("NAME_MIDDLE", "C");
}
} }
// Test forms with multiple email addresses are filled properly. // Test forms with multiple email addresses are filled properly.
......
...@@ -38,7 +38,7 @@ class WindowedPersonalDataManagerObserver : public PersonalDataManagerObserver { ...@@ -38,7 +38,7 @@ class WindowedPersonalDataManagerObserver : public PersonalDataManagerObserver {
public: public:
explicit WindowedPersonalDataManagerObserver(Profile* profile) explicit WindowedPersonalDataManagerObserver(Profile* profile)
: profile_(profile), : profile_(profile),
message_loop_runner_(new content::MessageLoopRunner){ message_loop_runner_(new content::MessageLoopRunner) {
PersonalDataManagerFactory::GetForProfile(profile_)->AddObserver(this); PersonalDataManagerFactory::GetForProfile(profile_)->AddObserver(this);
} }
~WindowedPersonalDataManagerObserver() override {} ~WindowedPersonalDataManagerObserver() override {}
...@@ -145,8 +145,8 @@ class AutofillServerTest : public InProcessBrowserTest { ...@@ -145,8 +145,8 @@ class AutofillServerTest : public InProcessBrowserTest {
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
// Enable finch experiment for sending field metadata. // Enable finch experiment for sending field metadata.
command_line->AppendSwitchASCII( command_line->AppendSwitchASCII(::switches::kForceFieldTrials,
::switches::kForceFieldTrials, "AutofillFieldMetadata/Enabled/"); "AutofillFieldMetadata/Enabled/");
} }
private: private:
...@@ -195,8 +195,8 @@ IN_PROC_BROWSER_TEST_F(AutofillServerTest, ...@@ -195,8 +195,8 @@ IN_PROC_BROWSER_TEST_F(AutofillServerTest,
WindowedNetworkObserver query_network_observer(expected_query_string); WindowedNetworkObserver query_network_observer(expected_query_string);
ui_test_utils::NavigateToURL( ui_test_utils::NavigateToURL(browser(),
browser(), GURL(std::string(kDataURIPrefix) + kFormHtml)); GURL(std::string(kDataURIPrefix) + kFormHtml));
query_network_observer.Wait(); query_network_observer.Wait();
// Submit the form, using a simulated mouse click because form submissions not // Submit the form, using a simulated mouse click because form submissions not
...@@ -208,7 +208,15 @@ IN_PROC_BROWSER_TEST_F(AutofillServerTest, ...@@ -208,7 +208,15 @@ IN_PROC_BROWSER_TEST_F(AutofillServerTest,
upload->set_client_version("6.1.1715.1442/en (GGLL)"); upload->set_client_version("6.1.1715.1442/en (GGLL)");
upload->set_form_signature(15916856893790176210U); upload->set_form_signature(15916856893790176210U);
upload->set_autofill_used(false); upload->set_autofill_used(false);
// TODO(crbug.com/1103421): Clean legacy implementation once structured names
// are fully launched.
// For structured names, there is additional data present.
if (base::FeatureList::IsEnabled(
features::kAutofillEnableSupportForMoreStructureInNames)) {
upload->set_data_present("1f7e000378000008000400000004");
} else {
upload->set_data_present("1f7e0003780000080004"); upload->set_data_present("1f7e0003780000080004");
}
upload->set_action_signature(15724779818122431245U); upload->set_action_signature(15724779818122431245U);
upload->set_form_name("test_form"); upload->set_form_name("test_form");
upload->set_passwords_revealed(false); upload->set_passwords_revealed(false);
...@@ -238,8 +246,7 @@ IN_PROC_BROWSER_TEST_F(AutofillServerTest, ...@@ -238,8 +246,7 @@ IN_PROC_BROWSER_TEST_F(AutofillServerTest,
// Verify that a site with password fields will query even in the presence // Verify that a site with password fields will query even in the presence
// of user defined autocomplete types. // of user defined autocomplete types.
IN_PROC_BROWSER_TEST_F(AutofillServerTest, IN_PROC_BROWSER_TEST_F(AutofillServerTest, AlwaysQueryForPasswordFields) {
AlwaysQueryForPasswordFields) {
// Load the test page. Expect a query request upon loading the page. // Load the test page. Expect a query request upon loading the page.
const char kDataURIPrefix[] = "data:text/html;charset=utf-8,"; const char kDataURIPrefix[] = "data:text/html;charset=utf-8,";
const char kFormHtml[] = const char kFormHtml[] =
...@@ -264,8 +271,8 @@ IN_PROC_BROWSER_TEST_F(AutofillServerTest, ...@@ -264,8 +271,8 @@ IN_PROC_BROWSER_TEST_F(AutofillServerTest,
ASSERT_TRUE(query.SerializeToString(&expected_query_string)); ASSERT_TRUE(query.SerializeToString(&expected_query_string));
WindowedNetworkObserver query_network_observer(expected_query_string); WindowedNetworkObserver query_network_observer(expected_query_string);
ui_test_utils::NavigateToURL( ui_test_utils::NavigateToURL(browser(),
browser(), GURL(std::string(kDataURIPrefix) + kFormHtml)); GURL(std::string(kDataURIPrefix) + kFormHtml));
query_network_observer.Wait(); query_network_observer.Wait();
} }
......
...@@ -166,6 +166,9 @@ IN_PROC_BROWSER_TEST_P(HasEnrolledInstrumentTest, ...@@ -166,6 +166,9 @@ IN_PROC_BROWSER_TEST_P(HasEnrolledInstrumentTest,
address.SetRawInfo(autofill::ServerFieldType::NAME_FIRST, base::string16()); address.SetRawInfo(autofill::ServerFieldType::NAME_FIRST, base::string16());
address.SetRawInfo(autofill::ServerFieldType::NAME_MIDDLE, base::string16()); address.SetRawInfo(autofill::ServerFieldType::NAME_MIDDLE, base::string16());
address.SetRawInfo(autofill::ServerFieldType::NAME_LAST, base::string16()); address.SetRawInfo(autofill::ServerFieldType::NAME_LAST, base::string16());
// For structured names, it is neccessary to explicitely reset the full name.
address.SetInfo(autofill::ServerFieldType::NAME_FULL, base::string16(),
"en-US");
AddAutofillProfile(address); AddAutofillProfile(address);
CreateAndAddCreditCardForProfile(address); CreateAndAddCreditCardForProfile(address);
......
...@@ -7206,12 +7206,26 @@ TEST_F(PersonalDataManagerMockTest, ...@@ -7206,12 +7206,26 @@ TEST_F(PersonalDataManagerMockTest,
AutofillProfile profile2(test::GetFullValidProfileForCanada()); AutofillProfile profile2(test::GetFullValidProfileForCanada());
profile2.set_guid("00000000-0000-0000-0000-000000002019"); profile2.set_guid("00000000-0000-0000-0000-000000002019");
profile2.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, base::UTF8ToUTF16("")); profile2.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, base::UTF8ToUTF16(""));
profile2.FinalizeAfterImport();
AddProfileToPersonalDataManager(profile2); AddProfileToPersonalDataManager(profile2);
// The validities were set when the profiles were added. // The validities were set when the profiles were added.
auto profiles = personal_data_->GetProfiles(); auto profiles = personal_data_->GetProfiles();
ASSERT_EQ(2U, profiles.size()); ASSERT_EQ(2U, profiles.size());
// In the legacy implementation of names, the merge operation populates the
// full name field. This results in a change of the name although the names
// are technically the same. For structured names, this is not true anymore,
// because a name is always in a finalized state. To enforce a non-noop merge
// for structured names, we lift the verification status of the full name.
// TODO(crbug.com/1103421): Make the test logic less implicit once structured
// names are fully launched and remove feature test.
if (base::FeatureList::IsEnabled(
features::kAutofillEnableSupportForMoreStructureInNames)) {
profiles[0]->SetRawInfoWithVerificationStatus(
NAME_FULL, profiles[1]->GetRawInfo(NAME_FULL),
structured_address::VerificationStatus::kUserVerified);
}
profiles[1]->MergeDataFrom(*profiles[0], "en"); profiles[1]->MergeDataFrom(*profiles[0], "en");
ASSERT_TRUE(profiles[0]->is_client_validity_states_updated()); ASSERT_TRUE(profiles[0]->is_client_validity_states_updated());
ASSERT_FALSE(profiles[1]->is_client_validity_states_updated()); ASSERT_FALSE(profiles[1]->is_client_validity_states_updated());
......
...@@ -1397,7 +1397,14 @@ TEST_F(AutofillTableTest, AutofillProfile_StructuredNames) { ...@@ -1397,7 +1397,14 @@ TEST_F(AutofillTableTest, AutofillProfile_StructuredNames) {
EXPECT_FALSE(db_profile); EXPECT_FALSE(db_profile);
} }
// TODO(crbug.com/1103421): Clean legacy implementation once structured names
// are fully launched.
TEST_F(AutofillTableTest, AutofillProfile) { TEST_F(AutofillTableTest, AutofillProfile) {
// Disable the structured names since this test is only applicable if
// structured names are not used.
scoped_feature_list_.InitAndDisableFeature(
features::kAutofillEnableSupportForMoreStructureInNames);
// Add a 'Home' profile with non-default data. The specific values are not // Add a 'Home' profile with non-default data. The specific values are not
// important. // important.
AutofillProfile home_profile; AutofillProfile home_profile;
...@@ -1652,6 +1659,7 @@ TEST_F(AutofillTableTest, UpdateAutofillProfile) { ...@@ -1652,6 +1659,7 @@ TEST_F(AutofillTableTest, UpdateAutofillProfile) {
profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567")); profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567"));
profile.set_language_code("en"); profile.set_language_code("en");
profile.FinalizeAfterImport();
table_->AddAutofillProfile(profile); table_->AddAutofillProfile(profile);
// Set a mocked value for the profile's creation time. // Set a mocked value for the profile's creation time.
...@@ -1802,6 +1810,7 @@ TEST_F(AutofillTableTest, UpdateProfileOriginOnly) { ...@@ -1802,6 +1810,7 @@ TEST_F(AutofillTableTest, UpdateProfileOriginOnly) {
profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90025")); profile.SetRawInfo(ADDRESS_HOME_ZIP, ASCIIToUTF16("90025"));
profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US")); profile.SetRawInfo(ADDRESS_HOME_COUNTRY, ASCIIToUTF16("US"));
profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567")); profile.SetRawInfo(PHONE_HOME_WHOLE_NUMBER, ASCIIToUTF16("18181234567"));
profile.FinalizeAfterImport();
table_->AddAutofillProfile(profile); table_->AddAutofillProfile(profile);
// Set a mocked value for the profile's creation time. // Set a mocked value for the profile's creation time.
......
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