OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/memory/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/tuple.h" | 6 #include "base/tuple.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/autofill/autocheckout_manager.h" | 8 #include "chrome/browser/autofill/autocheckout_manager.h" |
9 #include "chrome/browser/autofill/autofill_common_test.h" | 9 #include "chrome/browser/autofill/autofill_common_test.h" |
10 #include "chrome/browser/autofill/autofill_manager.h" | 10 #include "chrome/browser/autofill/autofill_manager.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 form.method = ASCIIToUTF16("POST"); | 50 form.method = ASCIIToUTF16("POST"); |
51 form.origin = GURL("https://myform.com/form.html"); | 51 form.origin = GURL("https://myform.com/form.html"); |
52 form.action = GURL("https://myform.com/submit.html"); | 52 form.action = GURL("https://myform.com/submit.html"); |
53 form.user_submitted = true; | 53 form.user_submitted = true; |
54 | 54 |
55 // Add some fields, autocomplete_attribute is not important and we | 55 // Add some fields, autocomplete_attribute is not important and we |
56 // fake that server sends authoritative field mappings. | 56 // fake that server sends authoritative field mappings. |
57 for (size_t i = 0; i < autofill_types.size(); ++i) | 57 for (size_t i = 0; i < autofill_types.size(); ++i) |
58 form.fields.push_back(BuildField("SomeField")); | 58 form.fields.push_back(BuildField("SomeField")); |
59 | 59 |
60 scoped_ptr<FormStructure> form_structure(new FormStructure(form)); | 60 scoped_ptr<FormStructure> form_structure( |
| 61 new FormStructure(form, std::string())); |
61 | 62 |
62 // Set mocked Autofill server field types. | 63 // Set mocked Autofill server field types. |
63 for (size_t i = 0; i < autofill_types.size(); ++i) | 64 for (size_t i = 0; i < autofill_types.size(); ++i) |
64 form_structure->field(i)->set_server_type(autofill_types[i]); | 65 form_structure->field(i)->set_server_type(autofill_types[i]); |
65 | 66 |
66 return form_structure.Pass(); | 67 return form_structure.Pass(); |
67 } | 68 } |
68 | 69 |
69 scoped_ptr<FormStructure> CreateTestAddressFormStructure() { | 70 scoped_ptr<FormStructure> CreateTestAddressFormStructure() { |
70 std::vector<AutofillFieldType> autofill_types; | 71 std::vector<AutofillFieldType> autofill_types; |
(...skipping 28 matching lines...) Expand all Loading... |
99 form.user_submitted = true; | 100 form.user_submitted = true; |
100 | 101 |
101 // Add two radio button fields. | 102 // Add two radio button fields. |
102 FormFieldData male = BuildFieldWithValue("sex", "male"); | 103 FormFieldData male = BuildFieldWithValue("sex", "male"); |
103 male.is_checkable = true; | 104 male.is_checkable = true; |
104 form.fields.push_back(male); | 105 form.fields.push_back(male); |
105 FormFieldData female = BuildFieldWithValue("sex", "female"); | 106 FormFieldData female = BuildFieldWithValue("sex", "female"); |
106 female.is_checkable = true; | 107 female.is_checkable = true; |
107 form.fields.push_back(female); | 108 form.fields.push_back(female); |
108 | 109 |
109 scoped_ptr<FormStructure> form_structure(new FormStructure(form)); | 110 scoped_ptr<FormStructure> form_structure( |
| 111 new FormStructure(form, std::string())); |
110 | 112 |
111 // Fake server response. Set all fields as fields with default value. | 113 // Fake server response. Set all fields as fields with default value. |
112 form_structure->field(0)->set_server_type(FIELD_WITH_DEFAULT_VALUE); | 114 form_structure->field(0)->set_server_type(FIELD_WITH_DEFAULT_VALUE); |
113 form_structure->field(0)->set_default_value("female"); | 115 form_structure->field(0)->set_default_value("female"); |
114 form_structure->field(1)->set_server_type(FIELD_WITH_DEFAULT_VALUE); | 116 form_structure->field(1)->set_server_type(FIELD_WITH_DEFAULT_VALUE); |
115 form_structure->field(1)->set_default_value("female"); | 117 form_structure->field(1)->set_default_value("female"); |
116 | 118 |
117 return form_structure.Pass(); | 119 return form_structure.Pass(); |
118 } | 120 } |
119 | 121 |
(...skipping 22 matching lines...) Expand all Loading... |
142 // Build Autocheckout specific form data to be consumed by | 144 // Build Autocheckout specific form data to be consumed by |
143 // AutofillDialogController to show the Autocheckout specific UI. | 145 // AutofillDialogController to show the Autocheckout specific UI. |
144 scoped_ptr<FormStructure> FakeUserSubmittedFormStructure() { | 146 scoped_ptr<FormStructure> FakeUserSubmittedFormStructure() { |
145 FormData formdata; | 147 FormData formdata; |
146 for (size_t i = 0; i < arraysize(kTestFields); i++) { | 148 for (size_t i = 0; i < arraysize(kTestFields); i++) { |
147 formdata.fields.push_back( | 149 formdata.fields.push_back( |
148 BuildFieldWithValue(kTestFields[i].field_type, | 150 BuildFieldWithValue(kTestFields[i].field_type, |
149 kTestFields[i].field_value)); | 151 kTestFields[i].field_value)); |
150 } | 152 } |
151 scoped_ptr<FormStructure> form_structure; | 153 scoped_ptr<FormStructure> form_structure; |
152 form_structure.reset(new FormStructure(formdata)); | 154 form_structure.reset(new FormStructure(formdata, std::string())); |
153 for (size_t i = 0; i < arraysize(kTestFields); ++i) | 155 for (size_t i = 0; i < arraysize(kTestFields); ++i) |
154 form_structure->field(i)->set_server_type(kTestFields[i].autofill_type); | 156 form_structure->field(i)->set_server_type(kTestFields[i].autofill_type); |
155 | 157 |
156 return form_structure.Pass(); | 158 return form_structure.Pass(); |
157 } | 159 } |
158 | 160 |
159 class TestAutofillManagerDelegate : public autofill::AutofillManagerDelegate { | 161 class TestAutofillManagerDelegate : public autofill::AutofillManagerDelegate { |
160 public: | 162 public: |
161 explicit TestAutofillManagerDelegate( | 163 explicit TestAutofillManagerDelegate( |
162 content::BrowserContext* browser_context) | 164 content::BrowserContext* browser_context) |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 autocheckout_manager_->FillForms(); | 362 autocheckout_manager_->FillForms(); |
361 | 363 |
362 filled_forms = ReadFilledForms(); | 364 filled_forms = ReadFilledForms(); |
363 ASSERT_EQ(1U, filled_forms.size()); | 365 ASSERT_EQ(1U, filled_forms.size()); |
364 ASSERT_EQ(2U, filled_forms[0].fields.size()); | 366 ASSERT_EQ(2U, filled_forms[0].fields.size()); |
365 EXPECT_FALSE(filled_forms[0].fields[0].is_checked); | 367 EXPECT_FALSE(filled_forms[0].fields[0].is_checked); |
366 EXPECT_EQ(ASCIIToUTF16("male"), filled_forms[0].fields[0].value); | 368 EXPECT_EQ(ASCIIToUTF16("male"), filled_forms[0].fields[0].value); |
367 EXPECT_TRUE(filled_forms[0].fields[1].is_checked); | 369 EXPECT_TRUE(filled_forms[0].fields[1].is_checked); |
368 EXPECT_EQ(ASCIIToUTF16("female"), filled_forms[0].fields[1].value); | 370 EXPECT_EQ(ASCIIToUTF16("female"), filled_forms[0].fields[1].value); |
369 } | 371 } |
OLD | NEW |