| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/scoped_vector.h" | 9 #include "base/scoped_vector.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 scoped_refptr<TestPersonalDataManager> test_personal_data_; | 128 scoped_refptr<TestPersonalDataManager> test_personal_data_; |
| 129 | 129 |
| 130 DISALLOW_COPY_AND_ASSIGN(TestAutoFillManager); | 130 DISALLOW_COPY_AND_ASSIGN(TestAutoFillManager); |
| 131 }; | 131 }; |
| 132 | 132 |
| 133 void CreateTestFormData(FormData* form) { | 133 void CreateTestFormData(FormData* form) { |
| 134 form->name = ASCIIToUTF16("MyForm"); | 134 form->name = ASCIIToUTF16("MyForm"); |
| 135 form->method = ASCIIToUTF16("POST"); | 135 form->method = ASCIIToUTF16("POST"); |
| 136 form->origin = GURL("http://myform.com/form.html"); | 136 form->origin = GURL("http://myform.com/form.html"); |
| 137 form->action = GURL("http://myform.com/submit.html"); | 137 form->action = GURL("http://myform.com/submit.html"); |
| 138 form->user_submitted = true; |
| 138 | 139 |
| 139 webkit_glue::FormField field; | 140 webkit_glue::FormField field; |
| 140 autofill_unittest::CreateTestFormField( | 141 autofill_unittest::CreateTestFormField( |
| 141 "First Name", "firstname", "", "text", &field); | 142 "First Name", "firstname", "", "text", &field); |
| 142 form->fields.push_back(field); | 143 form->fields.push_back(field); |
| 143 autofill_unittest::CreateTestFormField( | 144 autofill_unittest::CreateTestFormField( |
| 144 "Middle Name", "middlename", "", "text", &field); | 145 "Middle Name", "middlename", "", "text", &field); |
| 145 form->fields.push_back(field); | 146 form->fields.push_back(field); |
| 146 autofill_unittest::CreateTestFormField( | 147 autofill_unittest::CreateTestFormField( |
| 147 "Last Name", "lastname", "", "text", &field); | 148 "Last Name", "lastname", "", "text", &field); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 170 autofill_unittest::CreateTestFormField( | 171 autofill_unittest::CreateTestFormField( |
| 171 "Email", "email", "", "text", &field); | 172 "Email", "email", "", "text", &field); |
| 172 form->fields.push_back(field); | 173 form->fields.push_back(field); |
| 173 } | 174 } |
| 174 | 175 |
| 175 void CreateTestFormDataBilling(FormData* form) { | 176 void CreateTestFormDataBilling(FormData* form) { |
| 176 form->name = ASCIIToUTF16("MyForm"); | 177 form->name = ASCIIToUTF16("MyForm"); |
| 177 form->method = ASCIIToUTF16("POST"); | 178 form->method = ASCIIToUTF16("POST"); |
| 178 form->origin = GURL("https://myform.com/form.html"); | 179 form->origin = GURL("https://myform.com/form.html"); |
| 179 form->action = GURL("https://myform.com/submit.html"); | 180 form->action = GURL("https://myform.com/submit.html"); |
| 181 form->user_submitted = true; |
| 180 | 182 |
| 181 webkit_glue::FormField field; | 183 webkit_glue::FormField field; |
| 182 autofill_unittest::CreateTestFormField( | 184 autofill_unittest::CreateTestFormField( |
| 183 "First Name", "firstname", "", "text", &field); | 185 "First Name", "firstname", "", "text", &field); |
| 184 form->fields.push_back(field); | 186 form->fields.push_back(field); |
| 185 autofill_unittest::CreateTestFormField( | 187 autofill_unittest::CreateTestFormField( |
| 186 "Middle Name", "middlename", "", "text", &field); | 188 "Middle Name", "middlename", "", "text", &field); |
| 187 form->fields.push_back(field); | 189 form->fields.push_back(field); |
| 188 autofill_unittest::CreateTestFormField( | 190 autofill_unittest::CreateTestFormField( |
| 189 "Last Name", "lastname", "", "text", &field); | 191 "Last Name", "lastname", "", "text", &field); |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 "Email", "email", "theking@gmail.com", "text", &field); | 1152 "Email", "email", "theking@gmail.com", "text", &field); |
| 1151 EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[4])); | 1153 EXPECT_TRUE(field.StrictlyEqualsHack(results.fields[4])); |
| 1152 } | 1154 } |
| 1153 | 1155 |
| 1154 TEST_F(AutoFillManagerTest, HiddenFields) { | 1156 TEST_F(AutoFillManagerTest, HiddenFields) { |
| 1155 FormData form; | 1157 FormData form; |
| 1156 form.name = ASCIIToUTF16("MyForm"); | 1158 form.name = ASCIIToUTF16("MyForm"); |
| 1157 form.method = ASCIIToUTF16("POST"); | 1159 form.method = ASCIIToUTF16("POST"); |
| 1158 form.origin = GURL("http://myform.com/form.html"); | 1160 form.origin = GURL("http://myform.com/form.html"); |
| 1159 form.action = GURL("http://myform.com/submit.html"); | 1161 form.action = GURL("http://myform.com/submit.html"); |
| 1162 form.user_submitted = true; |
| 1160 | 1163 |
| 1161 webkit_glue::FormField field; | 1164 webkit_glue::FormField field; |
| 1162 autofill_unittest::CreateTestFormField( | 1165 autofill_unittest::CreateTestFormField( |
| 1163 "E-mail", "one", "one", "hidden", &field); | 1166 "E-mail", "one", "one", "hidden", &field); |
| 1164 form.fields.push_back(field); | 1167 form.fields.push_back(field); |
| 1165 autofill_unittest::CreateTestFormField( | 1168 autofill_unittest::CreateTestFormField( |
| 1166 "E-mail", "two", "two", "hidden", &field); | 1169 "E-mail", "two", "two", "hidden", &field); |
| 1167 form.fields.push_back(field); | 1170 form.fields.push_back(field); |
| 1168 autofill_unittest::CreateTestFormField( | 1171 autofill_unittest::CreateTestFormField( |
| 1169 "E-mail", "three", "three", "hidden", &field); | 1172 "E-mail", "three", "three", "hidden", &field); |
| 1170 form.fields.push_back(field); | 1173 form.fields.push_back(field); |
| 1171 | 1174 |
| 1172 // Set up our FormStructures. | 1175 // Set up our FormStructures. |
| 1173 std::vector<FormData> forms; | 1176 std::vector<FormData> forms; |
| 1174 forms.push_back(form); | 1177 forms.push_back(form); |
| 1175 autofill_manager_->FormsSeen(forms); | 1178 autofill_manager_->FormsSeen(forms); |
| 1176 | 1179 |
| 1177 // Submit the form. | 1180 // Submit the form. |
| 1178 autofill_manager_->FormSubmitted(form); | 1181 autofill_manager_->FormSubmitted(form); |
| 1179 | 1182 |
| 1180 // TODO(jhawkins): We can't use the InfoBar anymore to determine if we saved | 1183 // TODO(jhawkins): We can't use the InfoBar anymore to determine if we saved |
| 1181 // fields. Need to query the PDM. | 1184 // fields. Need to query the PDM. |
| 1182 } | 1185 } |
| 1183 | 1186 |
| 1184 } // namespace | 1187 } // namespace |
| OLD | NEW |