| 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/autofill_manager.h" | 5 #include "components/autofill/core/browser/autofill_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 #include "components/autofill/core/common/autofill_pref_names.h" | 50 #include "components/autofill/core/common/autofill_pref_names.h" |
| 51 #include "components/autofill/core/common/autofill_switches.h" | 51 #include "components/autofill/core/common/autofill_switches.h" |
| 52 #include "components/autofill/core/common/autofill_util.h" | 52 #include "components/autofill/core/common/autofill_util.h" |
| 53 #include "components/autofill/core/common/form_data.h" | 53 #include "components/autofill/core/common/form_data.h" |
| 54 #include "components/autofill/core/common/form_field_data.h" | 54 #include "components/autofill/core/common/form_field_data.h" |
| 55 #include "components/metrics/proto/ukm/entry.pb.h" | 55 #include "components/metrics/proto/ukm/entry.pb.h" |
| 56 #include "components/prefs/pref_service.h" | 56 #include "components/prefs/pref_service.h" |
| 57 #include "components/rappor/test_rappor_service.h" | 57 #include "components/rappor/test_rappor_service.h" |
| 58 #include "components/security_state/core/security_state.h" | 58 #include "components/security_state/core/security_state.h" |
| 59 #include "components/strings/grit/components_strings.h" | 59 #include "components/strings/grit/components_strings.h" |
| 60 #include "components/ukm/test_ukm_service.h" | 60 #include "components/ukm/test_ukm_recorder.h" |
| 61 #include "components/ukm/ukm_entry.h" | |
| 62 #include "components/ukm/ukm_source.h" | 61 #include "components/ukm/ukm_source.h" |
| 63 #include "components/variations/variations_associated_data.h" | 62 #include "components/variations/variations_associated_data.h" |
| 64 #include "components/variations/variations_params_manager.h" | 63 #include "components/variations/variations_params_manager.h" |
| 65 #include "net/base/url_util.h" | 64 #include "net/base/url_util.h" |
| 66 #include "net/url_request/url_request_context_getter.h" | 65 #include "net/url_request/url_request_context_getter.h" |
| 67 #include "net/url_request/url_request_test_util.h" | 66 #include "net/url_request/url_request_test_util.h" |
| 68 #include "testing/gmock/include/gmock/gmock.h" | 67 #include "testing/gmock/include/gmock/gmock.h" |
| 69 #include "testing/gtest/include/gtest/gtest.h" | 68 #include "testing/gtest/include/gtest/gtest.h" |
| 70 #include "ui/base/l10n/l10n_util.h" | 69 #include "ui/base/l10n/l10n_util.h" |
| 71 #include "ui/gfx/geometry/rect.h" | 70 #include "ui/gfx/geometry/rect.h" |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 | 818 |
| 820 // The query id of the most recent Autofill query. | 819 // The query id of the most recent Autofill query. |
| 821 int query_id_; | 820 int query_id_; |
| 822 | 821 |
| 823 // The results returned by the most recent Autofill query. | 822 // The results returned by the most recent Autofill query. |
| 824 std::vector<Suggestion> suggestions_; | 823 std::vector<Suggestion> suggestions_; |
| 825 | 824 |
| 826 DISALLOW_COPY_AND_ASSIGN(TestAutofillExternalDelegate); | 825 DISALLOW_COPY_AND_ASSIGN(TestAutofillExternalDelegate); |
| 827 }; | 826 }; |
| 828 | 827 |
| 829 // Finds the specified UKM metric by |name| in the specified UKM |metrics|. | |
| 830 const ukm::Entry_Metric* FindMetric( | |
| 831 const char* name, | |
| 832 const google::protobuf::RepeatedPtrField<ukm::Entry_Metric>& metrics) { | |
| 833 for (const auto& metric : metrics) { | |
| 834 if (metric.metric_hash() == base::HashMetricName(name)) | |
| 835 return &metric; | |
| 836 } | |
| 837 return nullptr; | |
| 838 } | |
| 839 | |
| 840 // Get Ukm sources from the Ukm service. | 828 // Get Ukm sources from the Ukm service. |
| 841 std::vector<const ukm::UkmSource*> GetUkmSources(ukm::TestUkmService* service) { | 829 std::vector<const ukm::UkmSource*> GetUkmSources( |
| 830 ukm::TestUkmRecorder* service) { |
| 842 std::vector<const ukm::UkmSource*> sources; | 831 std::vector<const ukm::UkmSource*> sources; |
| 843 for (const auto& kv : service->GetSources()) | 832 for (const auto& kv : service->GetSources()) |
| 844 sources.push_back(kv.second.get()); | 833 sources.push_back(kv.second.get()); |
| 845 | 834 |
| 846 return sources; | 835 return sources; |
| 847 } | 836 } |
| 848 | 837 |
| 849 } // namespace | 838 } // namespace |
| 850 | 839 |
| 851 class AutofillManagerTest : public testing::Test { | 840 class AutofillManagerTest : public testing::Test { |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1078 scoped_feature_list_.InitWithFeatures( | 1067 scoped_feature_list_.InitWithFeatures( |
| 1079 {kAutofillUpstreamRequestCvcIfMissing, kAutofillUkmLogging}, {}); | 1068 {kAutofillUpstreamRequestCvcIfMissing, kAutofillUkmLogging}, {}); |
| 1080 } | 1069 } |
| 1081 | 1070 |
| 1082 void DisableAutofillUpstreamUseAutofillProfileComparatorForName() { | 1071 void DisableAutofillUpstreamUseAutofillProfileComparatorForName() { |
| 1083 scoped_feature_list_.InitAndDisableFeature( | 1072 scoped_feature_list_.InitAndDisableFeature( |
| 1084 kAutofillUpstreamUseAutofillProfileComparatorForName); | 1073 kAutofillUpstreamUseAutofillProfileComparatorForName); |
| 1085 } | 1074 } |
| 1086 | 1075 |
| 1087 void ExpectUniqueFillableFormParsedUkm() { | 1076 void ExpectUniqueFillableFormParsedUkm() { |
| 1088 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 1077 ukm::TestUkmRecorder* ukm_recorder = autofill_client_.GetTestUkmRecorder(); |
| 1089 | 1078 |
| 1090 // Check that one source is logged. | 1079 // Check that one source is logged. |
| 1091 ASSERT_EQ(1U, ukm_service->sources_count()); | 1080 ASSERT_EQ(1U, ukm_recorder->sources_count()); |
| 1092 const ukm::UkmSource* source = GetUkmSources(ukm_service)[0]; | 1081 const ukm::UkmSource* source = GetUkmSources(ukm_recorder)[0]; |
| 1093 | 1082 |
| 1094 // Check that one entry is logged. | 1083 // Check that one entry is logged. |
| 1095 EXPECT_EQ(1U, ukm_service->entries_count()); | 1084 EXPECT_EQ(1U, ukm_recorder->entries_count()); |
| 1096 const ukm::UkmEntry* entry = ukm_service->GetEntry(0); | 1085 const ukm::mojom::UkmEntry* entry = ukm_recorder->GetEntry(0); |
| 1097 EXPECT_EQ(source->id(), entry->source_id()); | 1086 EXPECT_EQ(source->id(), entry->source_id); |
| 1098 | 1087 |
| 1099 ukm::Entry entry_proto; | 1088 EXPECT_EQ(source->id(), entry->source_id); |
| 1100 entry->PopulateProto(&entry_proto); | |
| 1101 EXPECT_EQ(source->id(), entry_proto.source_id()); | |
| 1102 | 1089 |
| 1103 // Check if there is an entry for developer engagement decision. | 1090 // Check if there is an entry for developer engagement decision. |
| 1104 EXPECT_EQ(base::HashMetricName(internal::kUKMDeveloperEngagementEntryName), | 1091 EXPECT_EQ(base::HashMetricName(internal::kUKMDeveloperEngagementEntryName), |
| 1105 entry_proto.event_hash()); | 1092 entry->event_hash); |
| 1106 EXPECT_EQ(1, entry_proto.metrics_size()); | 1093 EXPECT_EQ(1U, entry->metrics.size()); |
| 1107 | 1094 |
| 1108 // Check that the expected developer engagement metric is logged. | 1095 // Check that the expected developer engagement metric is logged. |
| 1109 const ukm::Entry_Metric* metric = FindMetric( | 1096 const ukm::mojom::UkmMetric* metric = ukm::TestUkmRecorder::FindMetric( |
| 1110 internal::kUKMDeveloperEngagementMetricName, entry_proto.metrics()); | 1097 entry, internal::kUKMDeveloperEngagementMetricName); |
| 1111 ASSERT_NE(nullptr, metric); | 1098 ASSERT_NE(nullptr, metric); |
| 1112 EXPECT_EQ(1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS, | 1099 EXPECT_EQ(1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS, |
| 1113 metric->value()); | 1100 metric->value); |
| 1114 } | 1101 } |
| 1115 | 1102 |
| 1116 void ExpectUniqueCardUploadDecision( | 1103 void ExpectUniqueCardUploadDecision( |
| 1117 const base::HistogramTester& histogram_tester, | 1104 const base::HistogramTester& histogram_tester, |
| 1118 AutofillMetrics::CardUploadDecisionMetric metric) { | 1105 AutofillMetrics::CardUploadDecisionMetric metric) { |
| 1119 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionMetric", | 1106 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionMetric", |
| 1120 ToHistogramSample(metric), 1); | 1107 ToHistogramSample(metric), 1); |
| 1121 } | 1108 } |
| 1122 | 1109 |
| 1123 void ExpectCardUploadDecision( | 1110 void ExpectCardUploadDecision( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1139 ExpectMetric(internal::kUKMDeveloperEngagementMetricName, | 1126 ExpectMetric(internal::kUKMDeveloperEngagementMetricName, |
| 1140 internal::kUKMDeveloperEngagementEntryName, | 1127 internal::kUKMDeveloperEngagementEntryName, |
| 1141 1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS, | 1128 1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS, |
| 1142 num_fillable_forms_parsed); | 1129 num_fillable_forms_parsed); |
| 1143 } | 1130 } |
| 1144 | 1131 |
| 1145 void ExpectMetric(const char* metric_name, | 1132 void ExpectMetric(const char* metric_name, |
| 1146 const char* entry_name, | 1133 const char* entry_name, |
| 1147 int expected_metric_value, | 1134 int expected_metric_value, |
| 1148 int expected_num_matching_entries) { | 1135 int expected_num_matching_entries) { |
| 1149 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 1136 ukm::TestUkmRecorder* ukm_recorder = autofill_client_.GetTestUkmRecorder(); |
| 1150 | 1137 |
| 1151 int num_matching_entries = 0; | 1138 int num_matching_entries = 0; |
| 1152 for (size_t i = 0; i < ukm_service->entries_count(); ++i) { | 1139 for (size_t i = 0; i < ukm_recorder->entries_count(); ++i) { |
| 1153 const ukm::UkmEntry* entry = ukm_service->GetEntry(i); | 1140 const ukm::mojom::UkmEntry* entry = ukm_recorder->GetEntry(i); |
| 1154 | |
| 1155 ukm::Entry entry_proto; | |
| 1156 entry->PopulateProto(&entry_proto); | |
| 1157 EXPECT_EQ(entry->source_id(), entry_proto.source_id()); | |
| 1158 | |
| 1159 // Check if there is an entry for |entry_name|. | 1141 // Check if there is an entry for |entry_name|. |
| 1160 if (entry_proto.event_hash() == base::HashMetricName(entry_name)) { | 1142 if (entry->event_hash == base::HashMetricName(entry_name)) { |
| 1161 EXPECT_EQ(1, entry_proto.metrics_size()); | 1143 EXPECT_EQ(1UL, entry->metrics.size()); |
| 1162 | 1144 |
| 1163 // Check that the expected |metric_value| is logged. | 1145 // Check that the expected |metric_value| is logged. |
| 1164 const ukm::Entry_Metric* metric = | 1146 const ukm::mojom::UkmMetric* metric = |
| 1165 FindMetric(metric_name, entry_proto.metrics()); | 1147 ukm::TestUkmRecorder::FindMetric(entry, metric_name); |
| 1166 ASSERT_NE(nullptr, metric); | 1148 ASSERT_NE(nullptr, metric); |
| 1167 EXPECT_EQ(expected_metric_value, metric->value()); | 1149 EXPECT_EQ(expected_metric_value, metric->value); |
| 1168 ++num_matching_entries; | 1150 ++num_matching_entries; |
| 1169 } | 1151 } |
| 1170 } | 1152 } |
| 1171 EXPECT_EQ(expected_num_matching_entries, num_matching_entries); | 1153 EXPECT_EQ(expected_num_matching_entries, num_matching_entries); |
| 1172 } | 1154 } |
| 1173 | 1155 |
| 1174 protected: | 1156 protected: |
| 1175 base::test::ScopedTaskEnvironment scoped_task_environment_; | 1157 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 1176 MockAutofillClient autofill_client_; | 1158 MockAutofillClient autofill_client_; |
| 1177 std::unique_ptr<MockAutofillDriver> autofill_driver_; | 1159 std::unique_ptr<MockAutofillDriver> autofill_driver_; |
| (...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3566 // Test that OnLoadedServerPredictions can obtain the FormStructure with the | 3548 // Test that OnLoadedServerPredictions can obtain the FormStructure with the |
| 3567 // signature of the queried form and apply type predictions. | 3549 // signature of the queried form and apply type predictions. |
| 3568 TEST_F(AutofillManagerTest, OnLoadedServerPredictions) { | 3550 TEST_F(AutofillManagerTest, OnLoadedServerPredictions) { |
| 3569 // Set up our form data. | 3551 // Set up our form data. |
| 3570 FormData form; | 3552 FormData form; |
| 3571 test::CreateTestAddressFormData(&form); | 3553 test::CreateTestAddressFormData(&form); |
| 3572 | 3554 |
| 3573 // Simulate having seen this form on page load. | 3555 // Simulate having seen this form on page load. |
| 3574 // |form_structure| will be owned by |autofill_manager_|. | 3556 // |form_structure| will be owned by |autofill_manager_|. |
| 3575 TestFormStructure* form_structure = new TestFormStructure(form); | 3557 TestFormStructure* form_structure = new TestFormStructure(form); |
| 3576 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); | 3558 form_structure->DetermineHeuristicTypes(nullptr /* ukm_recorder */); |
| 3577 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); | 3559 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); |
| 3578 | 3560 |
| 3579 // Similarly, a second form. | 3561 // Similarly, a second form. |
| 3580 FormData form2; | 3562 FormData form2; |
| 3581 form2.name = ASCIIToUTF16("MyForm"); | 3563 form2.name = ASCIIToUTF16("MyForm"); |
| 3582 form2.origin = GURL("http://myform.com/form.html"); | 3564 form2.origin = GURL("http://myform.com/form.html"); |
| 3583 form2.action = GURL("http://myform.com/submit.html"); | 3565 form2.action = GURL("http://myform.com/submit.html"); |
| 3584 | 3566 |
| 3585 FormFieldData field; | 3567 FormFieldData field; |
| 3586 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); | 3568 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); |
| 3587 form2.fields.push_back(field); | 3569 form2.fields.push_back(field); |
| 3588 | 3570 |
| 3589 test::CreateTestFormField("Middle Name", "middlename", "", "text", &field); | 3571 test::CreateTestFormField("Middle Name", "middlename", "", "text", &field); |
| 3590 form2.fields.push_back(field); | 3572 form2.fields.push_back(field); |
| 3591 | 3573 |
| 3592 test::CreateTestFormField("Postal Code", "zipcode", "", "text", &field); | 3574 test::CreateTestFormField("Postal Code", "zipcode", "", "text", &field); |
| 3593 form2.fields.push_back(field); | 3575 form2.fields.push_back(field); |
| 3594 | 3576 |
| 3595 TestFormStructure* form_structure2 = new TestFormStructure(form2); | 3577 TestFormStructure* form_structure2 = new TestFormStructure(form2); |
| 3596 form_structure2->DetermineHeuristicTypes(nullptr /* ukm_service */); | 3578 form_structure2->DetermineHeuristicTypes(nullptr /* ukm_recorder */); |
| 3597 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure2)); | 3579 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure2)); |
| 3598 | 3580 |
| 3599 AutofillQueryResponseContents response; | 3581 AutofillQueryResponseContents response; |
| 3600 response.add_field()->set_autofill_type(3); | 3582 response.add_field()->set_autofill_type(3); |
| 3601 for (int i = 0; i < 7; ++i) { | 3583 for (int i = 0; i < 7; ++i) { |
| 3602 response.add_field()->set_autofill_type(0); | 3584 response.add_field()->set_autofill_type(0); |
| 3603 } | 3585 } |
| 3604 response.add_field()->set_autofill_type(3); | 3586 response.add_field()->set_autofill_type(3); |
| 3605 response.add_field()->set_autofill_type(2); | 3587 response.add_field()->set_autofill_type(2); |
| 3606 response.add_field()->set_autofill_type(61); | 3588 response.add_field()->set_autofill_type(61); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3638 // AutofillManager has been reset between the time the query was sent and the | 3620 // AutofillManager has been reset between the time the query was sent and the |
| 3639 // response received. | 3621 // response received. |
| 3640 TEST_F(AutofillManagerTest, OnLoadedServerPredictions_ResetManager) { | 3622 TEST_F(AutofillManagerTest, OnLoadedServerPredictions_ResetManager) { |
| 3641 // Set up our form data. | 3623 // Set up our form data. |
| 3642 FormData form; | 3624 FormData form; |
| 3643 test::CreateTestAddressFormData(&form); | 3625 test::CreateTestAddressFormData(&form); |
| 3644 | 3626 |
| 3645 // Simulate having seen this form on page load. | 3627 // Simulate having seen this form on page load. |
| 3646 // |form_structure| will be owned by |autofill_manager_|. | 3628 // |form_structure| will be owned by |autofill_manager_|. |
| 3647 TestFormStructure* form_structure = new TestFormStructure(form); | 3629 TestFormStructure* form_structure = new TestFormStructure(form); |
| 3648 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); | 3630 form_structure->DetermineHeuristicTypes(nullptr /* ukm_recorder */); |
| 3649 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); | 3631 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); |
| 3650 | 3632 |
| 3651 AutofillQueryResponseContents response; | 3633 AutofillQueryResponseContents response; |
| 3652 response.add_field()->set_autofill_type(3); | 3634 response.add_field()->set_autofill_type(3); |
| 3653 for (int i = 0; i < 7; ++i) { | 3635 for (int i = 0; i < 7; ++i) { |
| 3654 response.add_field()->set_autofill_type(0); | 3636 response.add_field()->set_autofill_type(0); |
| 3655 } | 3637 } |
| 3656 response.add_field()->set_autofill_type(3); | 3638 response.add_field()->set_autofill_type(3); |
| 3657 response.add_field()->set_autofill_type(2); | 3639 response.add_field()->set_autofill_type(2); |
| 3658 response.add_field()->set_autofill_type(61); | 3640 response.add_field()->set_autofill_type(61); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3676 // Test that we are able to save form data when forms are submitted and we only | 3658 // Test that we are able to save form data when forms are submitted and we only |
| 3677 // have server data for the field types. | 3659 // have server data for the field types. |
| 3678 TEST_F(AutofillManagerTest, FormSubmittedServerTypes) { | 3660 TEST_F(AutofillManagerTest, FormSubmittedServerTypes) { |
| 3679 // Set up our form data. | 3661 // Set up our form data. |
| 3680 FormData form; | 3662 FormData form; |
| 3681 test::CreateTestAddressFormData(&form); | 3663 test::CreateTestAddressFormData(&form); |
| 3682 | 3664 |
| 3683 // Simulate having seen this form on page load. | 3665 // Simulate having seen this form on page load. |
| 3684 // |form_structure| will be owned by |autofill_manager_|. | 3666 // |form_structure| will be owned by |autofill_manager_|. |
| 3685 TestFormStructure* form_structure = new TestFormStructure(form); | 3667 TestFormStructure* form_structure = new TestFormStructure(form); |
| 3686 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); | 3668 form_structure->DetermineHeuristicTypes(nullptr /* ukm_recorder */); |
| 3687 | 3669 |
| 3688 // Clear the heuristic types, and instead set the appropriate server types. | 3670 // Clear the heuristic types, and instead set the appropriate server types. |
| 3689 std::vector<ServerFieldType> heuristic_types, server_types; | 3671 std::vector<ServerFieldType> heuristic_types, server_types; |
| 3690 for (size_t i = 0; i < form.fields.size(); ++i) { | 3672 for (size_t i = 0; i < form.fields.size(); ++i) { |
| 3691 heuristic_types.push_back(UNKNOWN_TYPE); | 3673 heuristic_types.push_back(UNKNOWN_TYPE); |
| 3692 server_types.push_back(form_structure->field(i)->heuristic_type()); | 3674 server_types.push_back(form_structure->field(i)->heuristic_type()); |
| 3693 } | 3675 } |
| 3694 form_structure->SetFieldTypes(heuristic_types, server_types); | 3676 form_structure->SetFieldTypes(heuristic_types, server_types); |
| 3695 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); | 3677 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); |
| 3696 | 3678 |
| (...skipping 3110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6807 | 6789 |
| 6808 FormFieldData field; | 6790 FormFieldData field; |
| 6809 test::CreateTestFormField("Field 1", "field1", "", "text", &field); | 6791 test::CreateTestFormField("Field 1", "field1", "", "text", &field); |
| 6810 form.fields.push_back(field); | 6792 form.fields.push_back(field); |
| 6811 test::CreateTestFormField("Field 2", "field2", "", "text", &field); | 6793 test::CreateTestFormField("Field 2", "field2", "", "text", &field); |
| 6812 form.fields.push_back(field); | 6794 form.fields.push_back(field); |
| 6813 test::CreateTestFormField("Field 3", "field3", "", "text", &field); | 6795 test::CreateTestFormField("Field 3", "field3", "", "text", &field); |
| 6814 form.fields.push_back(field); | 6796 form.fields.push_back(field); |
| 6815 | 6797 |
| 6816 auto form_structure = base::MakeUnique<TestFormStructure>(form); | 6798 auto form_structure = base::MakeUnique<TestFormStructure>(form); |
| 6817 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); | 6799 form_structure->DetermineHeuristicTypes(nullptr /* ukm_recorder */); |
| 6818 // Make sure the form can not be autofilled now. | 6800 // Make sure the form can not be autofilled now. |
| 6819 ASSERT_EQ(0u, form_structure->autofill_count()); | 6801 ASSERT_EQ(0u, form_structure->autofill_count()); |
| 6820 for (size_t idx = 0; idx < form_structure->field_count(); ++idx) { | 6802 for (size_t idx = 0; idx < form_structure->field_count(); ++idx) { |
| 6821 ASSERT_EQ(UNKNOWN_TYPE, form_structure->field(idx)->heuristic_type()); | 6803 ASSERT_EQ(UNKNOWN_TYPE, form_structure->field(idx)->heuristic_type()); |
| 6822 } | 6804 } |
| 6823 | 6805 |
| 6824 // Prepare and set known server fields. | 6806 // Prepare and set known server fields. |
| 6825 const std::vector<ServerFieldType> heuristic_types(form.fields.size(), | 6807 const std::vector<ServerFieldType> heuristic_types(form.fields.size(), |
| 6826 UNKNOWN_TYPE); | 6808 UNKNOWN_TYPE); |
| 6827 const std::vector<ServerFieldType> server_types{NAME_FIRST, NAME_MIDDLE, | 6809 const std::vector<ServerFieldType> server_types{NAME_FIRST, NAME_MIDDLE, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6937 | 6919 |
| 6938 // Wait for upload to complete (will check expected types as well). | 6920 // Wait for upload to complete (will check expected types as well). |
| 6939 autofill_manager_->WaitForAsyncUploadProcess(); | 6921 autofill_manager_->WaitForAsyncUploadProcess(); |
| 6940 | 6922 |
| 6941 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); | 6923 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); |
| 6942 EXPECT_NE(uploaded_available_types.end(), | 6924 EXPECT_NE(uploaded_available_types.end(), |
| 6943 uploaded_available_types.find(autofill::PASSWORD)); | 6925 uploaded_available_types.find(autofill::PASSWORD)); |
| 6944 } | 6926 } |
| 6945 | 6927 |
| 6946 } // namespace autofill | 6928 } // namespace autofill |
| OLD | NEW |