| OLD | NEW | 
|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <map> | 5 #include <map> | 
| 6 | 6 | 
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" | 
| 8 #include "base/tuple.h" | 8 #include "base/tuple.h" | 
| 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 9 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 
| 10 #include "components/autofill/content/browser/autocheckout_manager.h" | 10 #include "components/autofill/content/browser/autocheckout_manager.h" | 
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 49   field.autocomplete_attribute = autocomplete_attribute; | 49   field.autocomplete_attribute = autocomplete_attribute; | 
| 50   field.form_control_type = "text"; | 50   field.form_control_type = "text"; | 
| 51   return field; | 51   return field; | 
| 52 } | 52 } | 
| 53 | 53 | 
| 54 FormFieldData BuildField(const std::string& autocomplete_attribute) { | 54 FormFieldData BuildField(const std::string& autocomplete_attribute) { | 
| 55   return BuildFieldWithValue(autocomplete_attribute, autocomplete_attribute); | 55   return BuildFieldWithValue(autocomplete_attribute, autocomplete_attribute); | 
| 56 } | 56 } | 
| 57 | 57 | 
| 58 scoped_ptr<FormStructure> CreateTestFormStructure( | 58 scoped_ptr<FormStructure> CreateTestFormStructure( | 
| 59     const std::vector<AutofillFieldType>& autofill_types) { | 59     const std::vector<ServerFieldType>& autofill_types) { | 
| 60   FormData form; | 60   FormData form; | 
| 61   form.name = ASCIIToUTF16("MyForm"); | 61   form.name = ASCIIToUTF16("MyForm"); | 
| 62   form.method = ASCIIToUTF16("POST"); | 62   form.method = ASCIIToUTF16("POST"); | 
| 63   form.origin = GURL("https://myform.com/form.html"); | 63   form.origin = GURL("https://myform.com/form.html"); | 
| 64   form.action = GURL("https://myform.com/submit.html"); | 64   form.action = GURL("https://myform.com/submit.html"); | 
| 65   form.user_submitted = true; | 65   form.user_submitted = true; | 
| 66 | 66 | 
| 67   // Add some fields, autocomplete_attribute is not important and we | 67   // Add some fields, autocomplete_attribute is not important and we | 
| 68   // fake that server sends authoritative field mappings. | 68   // fake that server sends authoritative field mappings. | 
| 69   for (size_t i = 0; i < autofill_types.size(); ++i) | 69   for (size_t i = 0; i < autofill_types.size(); ++i) | 
| 70     form.fields.push_back(BuildField("SomeField")); | 70     form.fields.push_back(BuildField("SomeField")); | 
| 71 | 71 | 
| 72   scoped_ptr<FormStructure> form_structure( | 72   scoped_ptr<FormStructure> form_structure( | 
| 73       new FormStructure(form, std::string())); | 73       new FormStructure(form, std::string())); | 
| 74 | 74 | 
| 75   // Set mocked Autofill server field types. | 75   // Set mocked Autofill server field types. | 
| 76   for (size_t i = 0; i < autofill_types.size(); ++i) { | 76   for (size_t i = 0; i < autofill_types.size(); ++i) { | 
| 77     form_structure->field(i)->set_server_type(autofill_types[i]); | 77     form_structure->field(i)->set_server_type(autofill_types[i]); | 
| 78     // Set heuristic type to make sure that server_types are used and not | 78     // Set heuristic type to make sure that server_types are used and not | 
| 79     // heuritic type. | 79     // heuritic type. | 
| 80     form_structure->field(i)->set_heuristic_type(CREDIT_CARD_NUMBER); | 80     form_structure->field(i)->set_heuristic_type(CREDIT_CARD_NUMBER); | 
| 81   } | 81   } | 
| 82 | 82 | 
| 83   return form_structure.Pass(); | 83   return form_structure.Pass(); | 
| 84 } | 84 } | 
| 85 | 85 | 
| 86 scoped_ptr<FormStructure> CreateTestAddressFormStructure() { | 86 scoped_ptr<FormStructure> CreateTestAddressFormStructure() { | 
| 87   std::vector<AutofillFieldType> autofill_types; | 87   std::vector<ServerFieldType> autofill_types; | 
| 88   autofill_types.push_back(NAME_FULL); | 88   autofill_types.push_back(NAME_FULL); | 
| 89   autofill_types.push_back(PHONE_HOME_WHOLE_NUMBER); | 89   autofill_types.push_back(PHONE_HOME_WHOLE_NUMBER); | 
| 90   autofill_types.push_back(EMAIL_ADDRESS); | 90   autofill_types.push_back(EMAIL_ADDRESS); | 
| 91   autofill_types.push_back(ADDRESS_HOME_LINE1); | 91   autofill_types.push_back(ADDRESS_HOME_LINE1); | 
| 92   autofill_types.push_back(ADDRESS_HOME_CITY); | 92   autofill_types.push_back(ADDRESS_HOME_CITY); | 
| 93   autofill_types.push_back(ADDRESS_HOME_STATE); | 93   autofill_types.push_back(ADDRESS_HOME_STATE); | 
| 94   autofill_types.push_back(ADDRESS_HOME_COUNTRY); | 94   autofill_types.push_back(ADDRESS_HOME_COUNTRY); | 
| 95   autofill_types.push_back(ADDRESS_HOME_ZIP); | 95   autofill_types.push_back(ADDRESS_HOME_ZIP); | 
| 96   autofill_types.push_back(NO_SERVER_DATA); | 96   autofill_types.push_back(NO_SERVER_DATA); | 
| 97   return CreateTestFormStructure(autofill_types); | 97   return CreateTestFormStructure(autofill_types); | 
| 98 } | 98 } | 
| 99 | 99 | 
| 100 scoped_ptr<FormStructure> CreateTestCreditCardFormStructure() { | 100 scoped_ptr<FormStructure> CreateTestCreditCardFormStructure() { | 
| 101   std::vector<AutofillFieldType> autofill_types; | 101   std::vector<ServerFieldType> autofill_types; | 
| 102   autofill_types.push_back(CREDIT_CARD_NAME); | 102   autofill_types.push_back(CREDIT_CARD_NAME); | 
| 103   autofill_types.push_back(CREDIT_CARD_NUMBER); | 103   autofill_types.push_back(CREDIT_CARD_NUMBER); | 
| 104   autofill_types.push_back(CREDIT_CARD_EXP_MONTH); | 104   autofill_types.push_back(CREDIT_CARD_EXP_MONTH); | 
| 105   autofill_types.push_back(CREDIT_CARD_EXP_4_DIGIT_YEAR); | 105   autofill_types.push_back(CREDIT_CARD_EXP_4_DIGIT_YEAR); | 
| 106   autofill_types.push_back(CREDIT_CARD_VERIFICATION_CODE); | 106   autofill_types.push_back(CREDIT_CARD_VERIFICATION_CODE); | 
| 107   autofill_types.push_back(ADDRESS_BILLING_LINE1); | 107   autofill_types.push_back(ADDRESS_BILLING_LINE1); | 
| 108   autofill_types.push_back(ADDRESS_BILLING_CITY); | 108   autofill_types.push_back(ADDRESS_BILLING_CITY); | 
| 109   autofill_types.push_back(ADDRESS_BILLING_STATE); | 109   autofill_types.push_back(ADDRESS_BILLING_STATE); | 
| 110   autofill_types.push_back(ADDRESS_BILLING_COUNTRY); | 110   autofill_types.push_back(ADDRESS_BILLING_COUNTRY); | 
| 111   autofill_types.push_back(ADDRESS_BILLING_ZIP); | 111   autofill_types.push_back(ADDRESS_BILLING_ZIP); | 
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 222   PopulateClickElement(&element, "#before_form_fill_2"); | 222   PopulateClickElement(&element, "#before_form_fill_2"); | 
| 223   metadata->click_elements_before_form_fill.push_back(element); | 223   metadata->click_elements_before_form_fill.push_back(element); | 
| 224   PopulateClickElement(&element, "#after_form_fill"); | 224   PopulateClickElement(&element, "#after_form_fill"); | 
| 225   metadata->click_elements_after_form_fill.push_back(element); | 225   metadata->click_elements_after_form_fill.push_back(element); | 
| 226   return metadata.Pass(); | 226   return metadata.Pass(); | 
| 227 } | 227 } | 
| 228 | 228 | 
| 229 struct TestField { | 229 struct TestField { | 
| 230   const char* const field_type; | 230   const char* const field_type; | 
| 231   const char* const field_value; | 231   const char* const field_value; | 
| 232   AutofillFieldType autofill_type; | 232   ServerFieldType autofill_type; | 
| 233 }; | 233 }; | 
| 234 | 234 | 
| 235 const TestField kTestFields[] = { | 235 const TestField kTestFields[] = { | 
| 236   {"name", "Test User", NAME_FULL}, | 236   {"name", "Test User", NAME_FULL}, | 
| 237   {"tel", "650-123-9909", PHONE_HOME_WHOLE_NUMBER}, | 237   {"tel", "650-123-9909", PHONE_HOME_WHOLE_NUMBER}, | 
| 238   {"email", "blah@blah.com", EMAIL_ADDRESS}, | 238   {"email", "blah@blah.com", EMAIL_ADDRESS}, | 
| 239   {"cc-name", "Test User", CREDIT_CARD_NAME}, | 239   {"cc-name", "Test User", CREDIT_CARD_NAME}, | 
| 240   {"cc-number", "4444444444444448", CREDIT_CARD_NUMBER}, | 240   {"cc-number", "4444444444444448", CREDIT_CARD_NUMBER}, | 
| 241   {"cc-exp-month", "10", CREDIT_CARD_EXP_MONTH}, | 241   {"cc-exp-month", "10", CREDIT_CARD_EXP_MONTH}, | 
| 242   {"cc-exp-year", "2020", CREDIT_CARD_EXP_4_DIGIT_YEAR}, | 242   {"cc-exp-year", "2020", CREDIT_CARD_EXP_4_DIGIT_YEAR}, | 
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 939       frame_url, | 939       frame_url, | 
| 940       AUTOCHECKOUT_BUBBLE_CANCELED); | 940       AUTOCHECKOUT_BUBBLE_CANCELED); | 
| 941   EXPECT_FALSE(autocheckout_manager_->is_autocheckout_bubble_showing()); | 941   EXPECT_FALSE(autocheckout_manager_->is_autocheckout_bubble_showing()); | 
| 942   EXPECT_FALSE(autocheckout_manager_->should_show_bubble()); | 942   EXPECT_FALSE(autocheckout_manager_->should_show_bubble()); | 
| 943 | 943 | 
| 944   autocheckout_manager_->MaybeShowAutocheckoutBubble(frame_url, bounding_box); | 944   autocheckout_manager_->MaybeShowAutocheckoutBubble(frame_url, bounding_box); | 
| 945   EXPECT_FALSE(autocheckout_manager_->is_autocheckout_bubble_showing()); | 945   EXPECT_FALSE(autocheckout_manager_->is_autocheckout_bubble_showing()); | 
| 946 } | 946 } | 
| 947 | 947 | 
| 948 }  // namespace autofill | 948 }  // namespace autofill | 
| OLD | NEW | 
|---|