| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/form_structure.h" | 5 #include "components/autofill/browser/form_structure.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "components/autofill/browser/autofill_metrics.h" | 10 #include "components/autofill/browser/autofill_metrics.h" |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 form_structure->DetermineHeuristicTypes(TestAutofillMetrics()); | 529 form_structure->DetermineHeuristicTypes(TestAutofillMetrics()); |
| 530 EXPECT_FALSE(form_structure->IsAutofillable(true)); | 530 EXPECT_FALSE(form_structure->IsAutofillable(true)); |
| 531 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced()); | 531 EXPECT_FALSE(form_structure->ShouldBeCrowdsourced()); |
| 532 | 532 |
| 533 ASSERT_EQ(3U, form_structure->field_count()); | 533 ASSERT_EQ(3U, form_structure->field_count()); |
| 534 ASSERT_EQ(0U, form_structure->autofill_count()); | 534 ASSERT_EQ(0U, form_structure->autofill_count()); |
| 535 | 535 |
| 536 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); | 536 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); |
| 537 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); | 537 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); |
| 538 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); | 538 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); |
| 539 |
| 540 // When Autocheckout is enabled, we should ignore 'autocomplete' attribute |
| 541 // when deciding to crowdsource. |
| 542 form_structure.reset(new FormStructure(form, "http://fake.url")); |
| 543 form_structure->DetermineHeuristicTypes(TestAutofillMetrics()); |
| 544 EXPECT_TRUE(form_structure->IsAutofillable(true)); |
| 545 EXPECT_TRUE(form_structure->ShouldBeCrowdsourced()); |
| 546 |
| 547 ASSERT_EQ(3U, form_structure->field_count()); |
| 548 ASSERT_EQ(0U, form_structure->autofill_count()); |
| 549 |
| 550 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(0)->heuristic_type()); |
| 551 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(1)->heuristic_type()); |
| 552 EXPECT_EQ(UNKNOWN_TYPE, form_structure->field(2)->heuristic_type()); |
| 539 } | 553 } |
| 540 | 554 |
| 541 // Verify that we can correctly process sections listed in the |autocomplete| | 555 // Verify that we can correctly process sections listed in the |autocomplete| |
| 542 // attribute. | 556 // attribute. |
| 543 TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSections) { | 557 TEST(FormStructureTest, HeuristicsAutocompleteAttributeWithSections) { |
| 544 FormData form; | 558 FormData form; |
| 545 form.method = ASCIIToUTF16("post"); | 559 form.method = ASCIIToUTF16("post"); |
| 546 | 560 |
| 547 FormFieldData field; | 561 FormFieldData field; |
| 548 field.form_control_type = "text"; | 562 field.form_control_type = "text"; |
| (...skipping 1644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2193 field.form_control_type = "submit"; | 2207 field.form_control_type = "submit"; |
| 2194 form.fields.push_back(field); | 2208 form.fields.push_back(field); |
| 2195 | 2209 |
| 2196 EXPECT_EQ(form, FormStructure(form, std::string()).ToFormData()); | 2210 EXPECT_EQ(form, FormStructure(form, std::string()).ToFormData()); |
| 2197 | 2211 |
| 2198 // Currently |FormStructure(form_data)ToFormData().user_submitted| is always | 2212 // Currently |FormStructure(form_data)ToFormData().user_submitted| is always |
| 2199 // false. This forces a future author that changes this to update this test. | 2213 // false. This forces a future author that changes this to update this test. |
| 2200 form.user_submitted = true; | 2214 form.user_submitted = true; |
| 2201 EXPECT_NE(form, FormStructure(form, std::string()).ToFormData()); | 2215 EXPECT_NE(form, FormStructure(form, std::string()).ToFormData()); |
| 2202 } | 2216 } |
| OLD | NEW |