| 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 <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 form_structure.reset(new FormStructure(form)); | 327 form_structure.reset(new FormStructure(form)); |
| 328 EXPECT_FALSE(form_structure->ShouldBeParsed()); | 328 EXPECT_FALSE(form_structure->ShouldBeParsed()); |
| 329 | 329 |
| 330 // We have two fields, which are passwords, should be parsed. | 330 // We have two fields, which are passwords, should be parsed. |
| 331 field.label = ASCIIToUTF16("New password"); | 331 field.label = ASCIIToUTF16("New password"); |
| 332 field.name = ASCIIToUTF16("new_pw"); | 332 field.name = ASCIIToUTF16("new_pw"); |
| 333 field.form_control_type = "password"; | 333 field.form_control_type = "password"; |
| 334 form.fields.push_back(field); | 334 form.fields.push_back(field); |
| 335 form_structure.reset(new FormStructure(form)); | 335 form_structure.reset(new FormStructure(form)); |
| 336 EXPECT_TRUE(form_structure->ShouldBeParsed()); | 336 EXPECT_TRUE(form_structure->ShouldBeParsed()); |
| 337 |
| 338 // There are 2 fields, one of which is password, and this is an upload of |
| 339 // a sign-in form submission, should be parsed. |
| 340 form.fields.clear(); |
| 341 field.name = ASCIIToUTF16("username"); |
| 342 field.form_control_type = "text"; |
| 343 form.fields.push_back(field); |
| 344 field.name = ASCIIToUTF16("pw"); |
| 345 field.form_control_type = "password"; |
| 346 form.fields.push_back(field); |
| 347 form_structure.reset(new FormStructure(form)); |
| 348 form_structure->set_is_signin_upload(true); |
| 349 EXPECT_TRUE(form_structure->ShouldBeParsed()); |
| 337 } | 350 } |
| 338 | 351 |
| 339 // Tests that ShouldBeParsed returns true for a form containing less than three | 352 // Tests that ShouldBeParsed returns true for a form containing less than three |
| 340 // fields if at least one has an autocomplete attribute. | 353 // fields if at least one has an autocomplete attribute. |
| 341 TEST_F(FormStructureTest, ShouldBeParsed_TwoFields_HasAutocomplete) { | 354 TEST_F(FormStructureTest, ShouldBeParsed_TwoFields_HasAutocomplete) { |
| 342 std::unique_ptr<FormStructure> form_structure; | 355 std::unique_ptr<FormStructure> form_structure; |
| 343 FormData form; | 356 FormData form; |
| 344 FormFieldData field; | 357 FormFieldData field; |
| 345 | 358 |
| 346 field.label = ASCIIToUTF16("Name"); | 359 field.label = ASCIIToUTF16("Name"); |
| (...skipping 3488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3835 prefix = FormStructure::FindLongestCommonPrefix(strings); | 3848 prefix = FormStructure::FindLongestCommonPrefix(strings); |
| 3836 EXPECT_EQ(ASCIIToUTF16("1234567890123456"), prefix); | 3849 EXPECT_EQ(ASCIIToUTF16("1234567890123456"), prefix); |
| 3837 | 3850 |
| 3838 // Empty vector. | 3851 // Empty vector. |
| 3839 strings.clear(); | 3852 strings.clear(); |
| 3840 prefix = FormStructure::FindLongestCommonPrefix(strings); | 3853 prefix = FormStructure::FindLongestCommonPrefix(strings); |
| 3841 EXPECT_EQ(ASCIIToUTF16(""), prefix); | 3854 EXPECT_EQ(ASCIIToUTF16(""), prefix); |
| 3842 } | 3855 } |
| 3843 | 3856 |
| 3844 } // namespace autofill | 3857 } // namespace autofill |
| OLD | NEW |