OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
622 new AutocheckoutPageMetaData()); | 622 new AutocheckoutPageMetaData()); |
623 start_of_flow->current_page_number = 0; | 623 start_of_flow->current_page_number = 0; |
624 start_of_flow->total_pages = 3; | 624 start_of_flow->total_pages = 3; |
625 WebElementDescriptor* proceed_element = | 625 WebElementDescriptor* proceed_element = |
626 &start_of_flow->proceed_element_descriptor; | 626 &start_of_flow->proceed_element_descriptor; |
627 proceed_element->descriptor = "#foo"; | 627 proceed_element->descriptor = "#foo"; |
628 proceed_element->retrieval_method = WebElementDescriptor::ID; | 628 proceed_element->retrieval_method = WebElementDescriptor::ID; |
629 autocheckout_manager()->OnLoadedPageMetaData(start_of_flow.Pass()); | 629 autocheckout_manager()->OnLoadedPageMetaData(start_of_flow.Pass()); |
630 } | 630 } |
631 | 631 |
632 // Set autocheckout manager's page meta data to first page on Autocheckout | |
633 // flow. | |
634 void MarkAsFirstPageInAutocheckoutFlowIgnoringAjax() { | |
635 scoped_ptr<AutocheckoutPageMetaData> start_of_flow( | |
636 new AutocheckoutPageMetaData()); | |
637 start_of_flow->current_page_number = 0; | |
638 start_of_flow->total_pages = 3; | |
639 start_of_flow->ignore_ajax = true; | |
640 WebElementDescriptor* proceed_element = | |
641 &start_of_flow->proceed_element_descriptor; | |
642 proceed_element->descriptor = "#foo"; | |
643 proceed_element->retrieval_method = WebElementDescriptor::ID; | |
644 autocheckout_manager()->OnLoadedPageMetaData(start_of_flow.Pass()); | |
645 } | |
646 | |
647 | |
632 private: | 648 private: |
633 // Weak reference. | 649 // Weak reference. |
634 TestPersonalDataManager* personal_data_; | 650 TestPersonalDataManager* personal_data_; |
635 | 651 |
636 bool autofill_enabled_; | 652 bool autofill_enabled_; |
637 std::vector<std::pair<WebFormElement::AutocompleteResult, FormData> > | 653 std::vector<std::pair<WebFormElement::AutocompleteResult, FormData> > |
638 request_autocomplete_results_; | 654 request_autocomplete_results_; |
639 | 655 |
640 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; | 656 scoped_refptr<content::MessageLoopRunner> message_loop_runner_; |
641 | 657 |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
967 // would indicate that the manager didn't reset upon being notified of | 983 // would indicate that the manager didn't reset upon being notified of |
968 // the new forms; | 984 // the new forms; |
969 DynamicFormsSeen(forms); | 985 DynamicFormsSeen(forms); |
970 form_structures = autofill_manager_->GetFormStructures(); | 986 form_structures = autofill_manager_->GetFormStructures(); |
971 ASSERT_EQ(3U, form_structures.size()); | 987 ASSERT_EQ(3U, form_structures.size()); |
972 EXPECT_EQ("/userspecified.html", form_structures[0]->source_url().path()); | 988 EXPECT_EQ("/userspecified.html", form_structures[0]->source_url().path()); |
973 EXPECT_EQ("/shipping.html", form_structures[1]->source_url().path()); | 989 EXPECT_EQ("/shipping.html", form_structures[1]->source_url().path()); |
974 EXPECT_EQ("/form.html", form_structures[2]->source_url().path()); | 990 EXPECT_EQ("/form.html", form_structures[2]->source_url().path()); |
975 } | 991 } |
976 | 992 |
993 // Test that in the case of Autocheckout, forms seen are in order supplied. | |
994 TEST_F(AutofillManagerTest, DynamicFormsSeenAndIgnored) { | |
995 FormData shipping_options; | |
996 CreateTestShippingOptionsFormData(&shipping_options); | |
997 FormData user_supplied; | |
998 CreateTestFormWithAutocompleteAttribute(&user_supplied); | |
999 FormData address; | |
1000 CreateTestAddressFormData(&address); | |
1001 | |
1002 autofill_manager_->set_autocheckout_url_prefix("test-prefix"); | |
1003 // Push user_supplied only | |
1004 std::vector<FormData> forms; | |
1005 forms.push_back(user_supplied); | |
1006 | |
1007 // Make sure normal form is handled correctly. | |
1008 FormsSeen(forms); | |
1009 autofill_manager_->MarkAsFirstPageInAutocheckoutFlowIgnoringAjax(); | |
1010 std::vector<FormStructure*> form_structures; | |
1011 form_structures = autofill_manager_->GetFormStructures(); | |
1012 ASSERT_EQ(1U, form_structures.size()); | |
1013 EXPECT_EQ("/userspecified.html", form_structures[0]->source_url().path()); | |
1014 | |
1015 autofill_manager_->autocheckout_manager()->set_in_autocheckout_flow(true); | |
1016 | |
1017 // Push other forms | |
1018 forms.push_back(shipping_options); | |
1019 forms.push_back(address); | |
1020 | |
1021 // FormStructure should contain the same forms as before. | |
1022 DynamicFormsSeen(forms); | |
1023 form_structures = autofill_manager_->GetFormStructures(); | |
1024 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.
| |
1025 ASSERT_EQ(1U, form_structures.size()); | |
1026 EXPECT_EQ("/userspecified.html", form_structures[0]->source_url().path()); | |
1027 } | |
1028 | |
977 // Test that we return only matching address profile suggestions when the | 1029 // Test that we return only matching address profile suggestions when the |
978 // selected form field has been partially filled out. | 1030 // selected form field has been partially filled out. |
979 TEST_F(AutofillManagerTest, GetProfileSuggestionsMatchCharacter) { | 1031 TEST_F(AutofillManagerTest, GetProfileSuggestionsMatchCharacter) { |
980 // Set up our form data. | 1032 // Set up our form data. |
981 FormData form; | 1033 FormData form; |
982 CreateTestAddressFormData(&form); | 1034 CreateTestAddressFormData(&form); |
983 std::vector<FormData> forms(1, form); | 1035 std::vector<FormData> forms(1, form); |
984 FormsSeen(forms); | 1036 FormsSeen(forms); |
985 | 1037 |
986 FormFieldData field; | 1038 FormFieldData field; |
(...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3304 CreateTestAddressFormData(&form); | 3356 CreateTestAddressFormData(&form); |
3305 std::vector<FormData> forms(1, form); | 3357 std::vector<FormData> forms(1, form); |
3306 FormsSeen(forms); | 3358 FormsSeen(forms); |
3307 const FormFieldData& field = form.fields[0]; | 3359 const FormFieldData& field = form.fields[0]; |
3308 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 3360 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
3309 | 3361 |
3310 autofill_manager_->SetExternalDelegate(NULL); | 3362 autofill_manager_->SetExternalDelegate(NULL); |
3311 } | 3363 } |
3312 | 3364 |
3313 } // namespace autofill | 3365 } // namespace autofill |
OLD | NEW |