| Index: components/autofill/browser/autofill_manager_unittest.cc
|
| diff --git a/components/autofill/browser/autofill_manager_unittest.cc b/components/autofill/browser/autofill_manager_unittest.cc
|
| index 2f9e5f528cd3f44a6be00133aa81048e51aa6747..1630d328a359adb66b765f66c280ea83a86d2fa0 100644
|
| --- a/components/autofill/browser/autofill_manager_unittest.cc
|
| +++ b/components/autofill/browser/autofill_manager_unittest.cc
|
| @@ -736,11 +736,19 @@ class AutofillManagerTest : public ChromeRenderViewHostTestHarness {
|
| }
|
|
|
| void FormsSeen(const std::vector<FormData>& forms) {
|
| - autofill_manager_->OnFormsSeen(forms, base::TimeTicks(), false);
|
| + autofill_manager_->OnFormsSeen(forms, base::TimeTicks(), false, false);
|
| }
|
|
|
| void PartialFormsSeen(const std::vector<FormData>& forms) {
|
| - autofill_manager_->OnFormsSeen(forms, base::TimeTicks(), true);
|
| + autofill_manager_->OnFormsSeen(forms, base::TimeTicks(), true, false);
|
| + }
|
| +
|
| + void DynamicFormsSeen(const std::vector<FormData>& forms) {
|
| + autofill_manager_->OnFormsSeen(forms, base::TimeTicks(), false, true);
|
| + }
|
| +
|
| + void PartialDynamicFormsSeen(const std::vector<FormData>& forms) {
|
| + autofill_manager_->OnFormsSeen(forms, base::TimeTicks(), true, true);
|
| }
|
|
|
| void FormSubmitted(const FormData& form) {
|
| @@ -880,6 +888,20 @@ TEST_F(AutofillManagerTest, GetAllForms) {
|
| ASSERT_TRUE(HasSeenAutofillGetAllFormsMessage());
|
| }
|
|
|
| +// Test that browser asks for all forms after DOM changes when
|
| +// Autocheckout is enabled.
|
| +TEST_F(AutofillManagerTest, GetAllDynamicForms) {
|
| + FormData form;
|
| + CreateTestAddressFormData(&form);
|
| + std::vector<FormData> forms(1, form);
|
| + // Enable autocheckout.
|
| + autofill_manager_->set_autocheckout_url_prefix("test-prefix");
|
| +
|
| + PartialDynamicFormsSeen(forms);
|
| +
|
| + EXPECT_TRUE(HasSeenAutofillGetAllFormsMessage());
|
| +}
|
| +
|
| // Test that we return all address profile suggestions when all form fields are
|
| // empty.
|
| TEST_F(AutofillManagerTest, GetProfileSuggestionsEmptyValue) {
|
| @@ -959,6 +981,42 @@ TEST_F(AutofillManagerTest, AutocheckoutFormsSeen) {
|
| EXPECT_EQ("/form.html", form_structures[2]->source_url().path());
|
| }
|
|
|
| +// Test that in the case of Autocheckout, forms seen are in order supplied.
|
| +TEST_F(AutofillManagerTest, DynamicFormsSeen) {
|
| + FormData shipping_options;
|
| + CreateTestShippingOptionsFormData(&shipping_options);
|
| + FormData user_supplied;
|
| + CreateTestFormWithAutocompleteAttribute(&user_supplied);
|
| + FormData address;
|
| + CreateTestAddressFormData(&address);
|
| +
|
| + autofill_manager_->set_autocheckout_url_prefix("test-prefix");
|
| + // Push user_supplied only
|
| + std::vector<FormData> forms;
|
| + forms.push_back(user_supplied);
|
| +
|
| + // Make sure normal form is handled correctly.
|
| + FormsSeen(forms);
|
| + std::vector<FormStructure*> form_structures;
|
| + form_structures = autofill_manager_->GetFormStructures();
|
| + ASSERT_EQ(1U, form_structures.size());
|
| + EXPECT_EQ("/userspecified.html", form_structures[0]->source_url().path());
|
| +
|
| + // Push other forms
|
| + forms.push_back(shipping_options);
|
| + forms.push_back(address);
|
| +
|
| + // FormStructure should contain three and only three forms. Otherwise, it
|
| + // would indicate that the manager didn't reset upon being notified of
|
| + // the new forms;
|
| + DynamicFormsSeen(forms);
|
| + form_structures = autofill_manager_->GetFormStructures();
|
| + ASSERT_EQ(3U, form_structures.size());
|
| + EXPECT_EQ("/userspecified.html", form_structures[0]->source_url().path());
|
| + EXPECT_EQ("/shipping.html", form_structures[1]->source_url().path());
|
| + EXPECT_EQ("/form.html", form_structures[2]->source_url().path());
|
| +}
|
| +
|
| // Test that we return only matching address profile suggestions when the
|
| // selected form field has been partially filled out.
|
| TEST_F(AutofillManagerTest, GetProfileSuggestionsMatchCharacter) {
|
|
|