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 4b81964d778a1068f0a30b56483d83cf594fc4c3..395acd7d56ea61583311c0d7949dda85cf4314b4 100644 |
| --- a/components/autofill/browser/autofill_manager_unittest.cc |
| +++ b/components/autofill/browser/autofill_manager_unittest.cc |
| @@ -629,6 +629,22 @@ class TestAutofillManager : public AutofillManager { |
| autocheckout_manager()->OnLoadedPageMetaData(start_of_flow.Pass()); |
| } |
| + // Set autocheckout manager's page meta data to first page on Autocheckout |
| + // flow. |
| + void MarkAsFirstPageInAutocheckoutFlowIgnoringAjax() { |
| + scoped_ptr<AutocheckoutPageMetaData> start_of_flow( |
| + new AutocheckoutPageMetaData()); |
| + start_of_flow->current_page_number = 0; |
| + start_of_flow->total_pages = 3; |
| + start_of_flow->ignore_ajax = true; |
| + WebElementDescriptor* proceed_element = |
| + &start_of_flow->proceed_element_descriptor; |
| + proceed_element->descriptor = "#foo"; |
| + proceed_element->retrieval_method = WebElementDescriptor::ID; |
| + autocheckout_manager()->OnLoadedPageMetaData(start_of_flow.Pass()); |
| + } |
| + |
| + |
| private: |
| // Weak reference. |
| TestPersonalDataManager* personal_data_; |
| @@ -974,6 +990,42 @@ TEST_F(AutofillManagerTest, DynamicFormsSeen) { |
| 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, DynamicFormsSeenAndIgnored) { |
| + 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); |
| + autofill_manager_->MarkAsFirstPageInAutocheckoutFlowIgnoringAjax(); |
| + 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()); |
| + |
| + autofill_manager_->autocheckout_manager()->set_in_autocheckout_flow(true); |
| + |
| + // Push other forms |
| + forms.push_back(shipping_options); |
| + forms.push_back(address); |
| + |
| + // FormStructure should contain the same forms as before. |
| + DynamicFormsSeen(forms); |
| + form_structures = autofill_manager_->GetFormStructures(); |
| + form_structures = autofill_manager_->GetFormStructures(); |
|
Ilya Sherman
2013/06/11 01:11:20
Why is this line duplicated?
Dane Wallinga
2013/06/11 19:03:32
Just wanted to be absolutely sure it got executed.
|
| + ASSERT_EQ(1U, form_structures.size()); |
| + EXPECT_EQ("/userspecified.html", form_structures[0]->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) { |