| 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 "components/autofill/core/browser/form_structure.h" | 5 #include "components/autofill/core/browser/form_structure.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 2126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2137 field.label = ASCIIToUTF16("password"); | 2137 field.label = ASCIIToUTF16("password"); |
| 2138 field.name = ASCIIToUTF16("password"); | 2138 field.name = ASCIIToUTF16("password"); |
| 2139 field.form_control_type = "password"; | 2139 field.form_control_type = "password"; |
| 2140 form.fields.push_back(field); | 2140 form.fields.push_back(field); |
| 2141 possible_field_types.push_back(ServerFieldTypeSet()); | 2141 possible_field_types.push_back(ServerFieldTypeSet()); |
| 2142 possible_field_types.back().insert(ACCOUNT_CREATION_PASSWORD); | 2142 possible_field_types.back().insert(ACCOUNT_CREATION_PASSWORD); |
| 2143 | 2143 |
| 2144 form_structure.reset(new FormStructure(form)); | 2144 form_structure.reset(new FormStructure(form)); |
| 2145 | 2145 |
| 2146 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); | 2146 ASSERT_EQ(form_structure->field_count(), possible_field_types.size()); |
| 2147 for (size_t i = 0; i < form_structure->field_count(); ++i) | 2147 for (size_t i = 0; i < form_structure->field_count(); ++i) { |
| 2148 form_structure->field(i)->set_possible_types(possible_field_types[i]); | 2148 form_structure->field(i)->set_possible_types(possible_field_types[i]); |
| 2149 if (form_structure->field(i)->name == ASCIIToUTF16("password")) |
| 2150 form_structure->field(i)->set_generation_type( |
| 2151 autofill::AutofillUploadContents::Field:: |
| 2152 MANUALLY_TRIGGERED_GENERATION_ON_SIGN_UP_FORM); |
| 2153 } |
| 2149 | 2154 |
| 2150 ServerFieldTypeSet available_field_types; | 2155 ServerFieldTypeSet available_field_types; |
| 2151 available_field_types.insert(NAME_FIRST); | 2156 available_field_types.insert(NAME_FIRST); |
| 2152 available_field_types.insert(NAME_LAST); | 2157 available_field_types.insert(NAME_LAST); |
| 2153 available_field_types.insert(EMAIL_ADDRESS); | 2158 available_field_types.insert(EMAIL_ADDRESS); |
| 2154 available_field_types.insert(USERNAME); | 2159 available_field_types.insert(USERNAME); |
| 2155 available_field_types.insert(ACCOUNT_CREATION_PASSWORD); | 2160 available_field_types.insert(ACCOUNT_CREATION_PASSWORD); |
| 2156 | 2161 |
| 2157 // Prepare the expected proto string. | 2162 // Prepare the expected proto string. |
| 2158 AutofillUploadContents upload; | 2163 AutofillUploadContents upload; |
| 2159 upload.set_submission(true); | 2164 upload.set_submission(true); |
| 2160 upload.set_client_version("6.1.1715.1442/en (GGLL)"); | 2165 upload.set_client_version("6.1.1715.1442/en (GGLL)"); |
| 2161 upload.set_form_signature(5810032074788446513U); | 2166 upload.set_form_signature(5810032074788446513U); |
| 2162 upload.set_autofill_used(true); | 2167 upload.set_autofill_used(true); |
| 2163 upload.set_data_present("1440000000000000000802"); | 2168 upload.set_data_present("1440000000000000000802"); |
| 2164 upload.set_action_signature(15724779818122431245U); | 2169 upload.set_action_signature(15724779818122431245U); |
| 2165 upload.set_login_form_signature(42); | 2170 upload.set_login_form_signature(42); |
| 2166 | 2171 |
| 2167 test::FillUploadField(upload.add_field(), 4224610201U, "firstname", "", | 2172 test::FillUploadField(upload.add_field(), 4224610201U, "firstname", "", |
| 2168 "First Name", "given-name", 3U); | 2173 "First Name", "given-name", 3U); |
| 2169 test::FillUploadField(upload.add_field(), 2786066110U, "lastname", "", | 2174 test::FillUploadField(upload.add_field(), 2786066110U, "lastname", "", |
| 2170 "Last Name", "family-name", 5U); | 2175 "Last Name", "family-name", 5U); |
| 2171 test::FillUploadField(upload.add_field(), 1029417091U, "email", "email", | 2176 test::FillUploadField(upload.add_field(), 1029417091U, "email", "email", |
| 2172 "Email", "email", 9U); | 2177 "Email", "email", 9U); |
| 2173 test::FillUploadField(upload.add_field(), 239111655U, "username", "text", | 2178 test::FillUploadField(upload.add_field(), 239111655U, "username", "text", |
| 2174 "username", "email", 86U); | 2179 "username", "email", 86U); |
| 2175 test::FillUploadField(upload.add_field(), 2051817934U, "password", "password", | 2180 auto* upload_password_field = upload.add_field(); |
| 2176 "password", "email", 76U); | 2181 test::FillUploadField(upload_password_field, 2051817934U, "password", |
| 2182 "password", "password", "email", 76U); |
| 2183 upload_password_field->set_generation_type( |
| 2184 autofill::AutofillUploadContents::Field:: |
| 2185 MANUALLY_TRIGGERED_GENERATION_ON_SIGN_UP_FORM); |
| 2177 | 2186 |
| 2178 std::string expected_upload_string; | 2187 std::string expected_upload_string; |
| 2179 ASSERT_TRUE(upload.SerializeToString(&expected_upload_string)); | 2188 ASSERT_TRUE(upload.SerializeToString(&expected_upload_string)); |
| 2180 | 2189 |
| 2181 AutofillUploadContents encoded_upload; | 2190 AutofillUploadContents encoded_upload; |
| 2182 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, | 2191 EXPECT_TRUE(form_structure->EncodeUploadRequest(available_field_types, true, |
| 2183 "42", true, &encoded_upload)); | 2192 "42", true, &encoded_upload)); |
| 2184 | 2193 |
| 2185 std::string encoded_upload_string; | 2194 std::string encoded_upload_string; |
| 2186 encoded_upload.SerializeToString(&encoded_upload_string); | 2195 encoded_upload.SerializeToString(&encoded_upload_string); |
| (...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3510 prefix = FormStructure::FindLongestCommonPrefix(strings); | 3519 prefix = FormStructure::FindLongestCommonPrefix(strings); |
| 3511 EXPECT_EQ(ASCIIToUTF16("123456789"), prefix.as_string()); | 3520 EXPECT_EQ(ASCIIToUTF16("123456789"), prefix.as_string()); |
| 3512 | 3521 |
| 3513 // Empty vector. | 3522 // Empty vector. |
| 3514 strings.clear(); | 3523 strings.clear(); |
| 3515 prefix = FormStructure::FindLongestCommonPrefix(strings); | 3524 prefix = FormStructure::FindLongestCommonPrefix(strings); |
| 3516 EXPECT_EQ(ASCIIToUTF16(""), prefix.as_string()); | 3525 EXPECT_EQ(ASCIIToUTF16(""), prefix.as_string()); |
| 3517 } | 3526 } |
| 3518 | 3527 |
| 3519 } // namespace autofill | 3528 } // namespace autofill |
| OLD | NEW |