Chromium Code Reviews| 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..e55da60299ce2f16f5826bbea51990b261021a2e 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,19 @@ TEST_F(AutofillManagerTest, GetAllForms) { |
| ASSERT_TRUE(HasSeenAutofillGetAllFormsMessage()); |
| } |
| +// Test that browser asks for all forms after dom changes when Autocheckout is enabled. |
|
ahutter
2013/03/29 19:48:31
DOM
Dane Wallinga
2013/03/29 21:41:12
Done.
|
| +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); |
| + |
| + ASSERT_TRUE(HasSeenAutofillGetAllFormsMessage()); |
|
ahutter
2013/03/29 19:48:31
EXPECT_TRUE
Dane Wallinga
2013/03/29 21:41:12
Done.
|
| +} |
| + |
| // Test that we return all address profile suggestions when all form fields are |
| // empty. |
| TEST_F(AutofillManagerTest, GetProfileSuggestionsEmptyValue) { |
| @@ -959,6 +980,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) { |