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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "components/autofill/core/browser/autofill_metrics.h" | 10 #include "components/autofill/core/browser/autofill_metrics.h" |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
475 form_structure->DetermineHeuristicTypes(TestAutofillMetrics()); | 475 form_structure->DetermineHeuristicTypes(TestAutofillMetrics()); |
476 EXPECT_FALSE(form_structure->IsAutofillable()); | 476 EXPECT_FALSE(form_structure->IsAutofillable()); |
477 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced()); | 477 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced()); |
478 | 478 |
479 ASSERT_EQ(3U, form_structure->field_count()); | 479 ASSERT_EQ(3U, form_structure->field_count()); |
480 ASSERT_EQ(0U, form_structure->autofill_count()); | 480 ASSERT_EQ(0U, form_structure->autofill_count()); |
481 | 481 |
482 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); | 482 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); |
483 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); | 483 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); |
484 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); | 484 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); |
485 | |
486 // Even with an 'autocomplete' attribute set, ShouldBeCrowdsourced() should | |
487 // return true if the structure contains a password field, since there are | |
488 // no local heuristics to depend upon in this case. Fields will still not be | |
489 // considered autofillable though. | |
Ilya Sherman
2014/10/24 01:24:45
Please create a separate TEST() for this case.
Garrett Casto
2014/10/24 21:13:10
Done.
| |
490 field.label = ASCIIToUTF16("Password"); | |
491 field.name = ASCIIToUTF16("Password"); | |
492 field.form_control_type = "password"; | |
493 form.fields.push_back(field); | |
494 | |
495 form_structure.reset(new FormStructure(form)); | |
496 form_structure->DetermineHeuristicTypes(TestAutofillMetrics()); | |
497 EXPECT_FALSE(form_structure->IsAutofillable()); | |
498 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced()); | |
499 | |
500 ASSERT_EQ(4U, form_structure->field_count()); | |
501 ASSERT_EQ(0U, form_structure->autofill_count()); | |
502 | |
503 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); | |
504 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); | |
505 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); | |
506 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(3)->heuristic_type()); | |
Ilya Sherman
2014/10/24 01:24:45
I'm not convinced that most of these expectations
Garrett Casto
2014/10/24 21:13:10
Do we not want to check that IsAutofillable() retu
Ilya Sherman
2014/10/24 22:42:30
It's not obvious to me why that's relevant to this
| |
485 } | 507 } |
486 | 508 |
487 // Verify that we can correctly process sections listed in the |autocomplete| | 509 // Verify that we can correctly process sections listed in the |autocomplete| |
488 // attribute. | 510 // attribute. |
489 TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSections) { | 511 TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSections) { |
490 FormData form; | 512 FormData form; |
491 | 513 |
492 FormFieldData field; | 514 FormFieldData field; |
493 field.form_control_type = "text"; | 515 field.form_control_type = "text"; |
494 | 516 |
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2341 // A freeform input (<input>) allows any value (overriding other <select>s). | 2363 // A freeform input (<input>) allows any value (overriding other <select>s). |
2342 FormFieldData freeform_field; | 2364 FormFieldData freeform_field; |
2343 freeform_field.autocomplete_attribute = "billing country"; | 2365 freeform_field.autocomplete_attribute = "billing country"; |
2344 form_data.fields.push_back(freeform_field); | 2366 form_data.fields.push_back(freeform_field); |
2345 FormStructure form_structure2(form_data); | 2367 FormStructure form_structure2(form_data); |
2346 form_structure2.ParseFieldTypesFromAutocompleteAttributes(&unused, &unused); | 2368 form_structure2.ParseFieldTypesFromAutocompleteAttributes(&unused, &unused); |
2347 EXPECT_EQ(0U, form_structure2.PossibleValues(ADDRESS_BILLING_COUNTRY).size()); | 2369 EXPECT_EQ(0U, form_structure2.PossibleValues(ADDRESS_BILLING_COUNTRY).size()); |
2348 } | 2370 } |
2349 | 2371 |
2350 } // namespace autofill | 2372 } // namespace autofill |
OLD | NEW |