| 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 field.label = base::string16(); | 449 field.label = base::string16(); |
| 450 field.name = ASCIIToUTF16("field2"); | 450 field.name = ASCIIToUTF16("field2"); |
| 451 field.autocomplete_attribute = "family-name"; | 451 field.autocomplete_attribute = "family-name"; |
| 452 form.fields.push_back(field); | 452 form.fields.push_back(field); |
| 453 | 453 |
| 454 field.label = base::string16(); | 454 field.label = base::string16(); |
| 455 field.name = ASCIIToUTF16("field3"); | 455 field.name = ASCIIToUTF16("field3"); |
| 456 field.autocomplete_attribute = "email"; | 456 field.autocomplete_attribute = "email"; |
| 457 form.fields.push_back(field); | 457 form.fields.push_back(field); |
| 458 | 458 |
| 459 field.label = base::string16(); |
| 460 field.name = ASCIIToUTF16("field4"); |
| 461 field.autocomplete_attribute = "upi-vpa"; |
| 462 form.fields.push_back(field); |
| 463 |
| 459 form_structure.reset(new FormStructure(form)); | 464 form_structure.reset(new FormStructure(form)); |
| 460 form_structure->DetermineHeuristicTypes(); | 465 form_structure->DetermineHeuristicTypes(); |
| 461 EXPECT_TRUE(form_structure->IsAutofillable()); | 466 EXPECT_TRUE(form_structure->IsAutofillable()); |
| 467 EXPECT_TRUE(form_structure->has_author_specified_types()); |
| 468 EXPECT_TRUE(form_structure->has_author_specified_upi_vpa_hint()); |
| 462 | 469 |
| 463 // Expect the correct number of fields. | 470 // Expect the correct number of fields. |
| 464 ASSERT_EQ(3U, form_structure->field_count()); | 471 ASSERT_EQ(4U, form_structure->field_count()); |
| 465 ASSERT_EQ(3U, form_structure->autofill_count()); | 472 ASSERT_EQ(3U, form_structure->autofill_count()); |
| 466 | 473 |
| 467 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type()); | 474 EXPECT_EQ(HTML_TYPE_GIVEN_NAME, form_structure->field(0)->html_type()); |
| 468 EXPECT_EQ(HTML_TYPE_FAMILY_NAME, form_structure->field(1)->html_type()); | 475 EXPECT_EQ(HTML_TYPE_FAMILY_NAME, form_structure->field(1)->html_type()); |
| 469 EXPECT_EQ(HTML_TYPE_EMAIL, form_structure->field(2)->html_type()); | 476 EXPECT_EQ(HTML_TYPE_EMAIL, form_structure->field(2)->html_type()); |
| 477 EXPECT_EQ(HTML_TYPE_UNRECOGNIZED, form_structure->field(3)->html_type()); |
| 470 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); | 478 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); |
| 471 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); | 479 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); |
| 472 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); | 480 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); |
| 481 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(3)->heuristic_type()); |
| 473 } | 482 } |
| 474 | 483 |
| 475 // Verify that the heuristics are not run for non checkout formless forms. | 484 // Verify that the heuristics are not run for non checkout formless forms. |
| 476 TEST_F(FormStructureTest, Heuristics_FormlessNonCheckoutForm) { | 485 TEST_F(FormStructureTest, Heuristics_FormlessNonCheckoutForm) { |
| 477 std::unique_ptr<FormStructure> form_structure; | 486 std::unique_ptr<FormStructure> form_structure; |
| 478 FormData form; | 487 FormData form; |
| 479 | 488 |
| 480 FormFieldData field; | 489 FormFieldData field; |
| 481 field.form_control_type = "text"; | 490 field.form_control_type = "text"; |
| 482 | 491 |
| (...skipping 3343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3826 prefix = FormStructure::FindLongestCommonPrefix(strings); | 3835 prefix = FormStructure::FindLongestCommonPrefix(strings); |
| 3827 EXPECT_EQ(ASCIIToUTF16("1234567890123456"), prefix); | 3836 EXPECT_EQ(ASCIIToUTF16("1234567890123456"), prefix); |
| 3828 | 3837 |
| 3829 // Empty vector. | 3838 // Empty vector. |
| 3830 strings.clear(); | 3839 strings.clear(); |
| 3831 prefix = FormStructure::FindLongestCommonPrefix(strings); | 3840 prefix = FormStructure::FindLongestCommonPrefix(strings); |
| 3832 EXPECT_EQ(ASCIIToUTF16(""), prefix); | 3841 EXPECT_EQ(ASCIIToUTF16(""), prefix); |
| 3833 } | 3842 } |
| 3834 | 3843 |
| 3835 } // namespace autofill | 3844 } // namespace autofill |
| OLD | NEW |