| 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 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 scoped_feature_list_.InitWithFeatures( | 1063 scoped_feature_list_.InitWithFeatures( |
| 1075 {kAutofillUpstreamRequestCvcIfMissing}, {}); | 1064 {kAutofillUpstreamRequestCvcIfMissing}, {}); |
| 1076 } | 1065 } |
| 1077 | 1066 |
| 1078 void DisableAutofillUpstreamUseAutofillProfileComparatorForName() { | 1067 void DisableAutofillUpstreamUseAutofillProfileComparatorForName() { |
| 1079 scoped_feature_list_.InitAndDisableFeature( | 1068 scoped_feature_list_.InitAndDisableFeature( |
| 1080 kAutofillUpstreamUseAutofillProfileComparatorForName); | 1069 kAutofillUpstreamUseAutofillProfileComparatorForName); |
| 1081 } | 1070 } |
| 1082 | 1071 |
| 1083 void ExpectUniqueFillableFormParsedUkm() { | 1072 void ExpectUniqueFillableFormParsedUkm() { |
| 1084 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 1073 ukm::TestUkmRecorder* ukm_recorder = autofill_client_.GetTestUkmRecorder(); |
| 1085 | 1074 |
| 1086 // Check that one source is logged. | 1075 // Check that one source is logged. |
| 1087 ASSERT_EQ(1U, ukm_service->sources_count()); | 1076 ASSERT_EQ(1U, ukm_recorder->sources_count()); |
| 1088 const ukm::UkmSource* source = GetUkmSources(ukm_service)[0]; | 1077 const ukm::UkmSource* source = GetUkmSources(ukm_recorder)[0]; |
| 1089 | 1078 |
| 1090 // Check that one entry is logged. | 1079 // Check that one entry is logged. |
| 1091 EXPECT_EQ(1U, ukm_service->entries_count()); | 1080 EXPECT_EQ(1U, ukm_recorder->entries_count()); |
| 1092 const ukm::UkmEntry* entry = ukm_service->GetEntry(0); | 1081 const ukm::mojom::UkmEntry* entry = ukm_recorder->GetEntry(0); |
| 1093 EXPECT_EQ(source->id(), entry->source_id()); | 1082 EXPECT_EQ(source->id(), entry->source_id); |
| 1094 | 1083 |
| 1095 ukm::Entry entry_proto; | 1084 EXPECT_EQ(source->id(), entry->source_id); |
| 1096 entry->PopulateProto(&entry_proto); | |
| 1097 EXPECT_EQ(source->id(), entry_proto.source_id()); | |
| 1098 | 1085 |
| 1099 // Check if there is an entry for developer engagement decision. | 1086 // Check if there is an entry for developer engagement decision. |
| 1100 EXPECT_EQ(base::HashMetricName(internal::kUKMDeveloperEngagementEntryName), | 1087 EXPECT_EQ(base::HashMetricName(internal::kUKMDeveloperEngagementEntryName), |
| 1101 entry_proto.event_hash()); | 1088 entry->event_hash); |
| 1102 EXPECT_EQ(1, entry_proto.metrics_size()); | 1089 EXPECT_EQ(1U, entry->metrics.size()); |
| 1103 | 1090 |
| 1104 // Check that the expected developer engagement metric is logged. | 1091 // Check that the expected developer engagement metric is logged. |
| 1105 const ukm::Entry_Metric* metric = FindMetric( | 1092 const ukm::mojom::UkmMetric* metric = ukm::TestUkmRecorder::FindMetric( |
| 1106 internal::kUKMDeveloperEngagementMetricName, entry_proto.metrics()); | 1093 entry, internal::kUKMDeveloperEngagementMetricName); |
| 1107 ASSERT_NE(nullptr, metric); | 1094 ASSERT_NE(nullptr, metric); |
| 1108 EXPECT_EQ(1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS, | 1095 EXPECT_EQ(1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS, |
| 1109 metric->value()); | 1096 metric->value); |
| 1110 } | 1097 } |
| 1111 | 1098 |
| 1112 void ExpectUniqueCardUploadDecision( | 1099 void ExpectUniqueCardUploadDecision( |
| 1113 const base::HistogramTester& histogram_tester, | 1100 const base::HistogramTester& histogram_tester, |
| 1114 AutofillMetrics::CardUploadDecisionMetric metric) { | 1101 AutofillMetrics::CardUploadDecisionMetric metric) { |
| 1115 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionMetric", | 1102 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionMetric", |
| 1116 ToHistogramSample(metric), 1); | 1103 ToHistogramSample(metric), 1); |
| 1117 } | 1104 } |
| 1118 | 1105 |
| 1119 void ExpectCardUploadDecision( | 1106 void ExpectCardUploadDecision( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1135 ExpectMetric(internal::kUKMDeveloperEngagementMetricName, | 1122 ExpectMetric(internal::kUKMDeveloperEngagementMetricName, |
| 1136 internal::kUKMDeveloperEngagementEntryName, | 1123 internal::kUKMDeveloperEngagementEntryName, |
| 1137 1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS, | 1124 1 << AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS, |
| 1138 num_fillable_forms_parsed); | 1125 num_fillable_forms_parsed); |
| 1139 } | 1126 } |
| 1140 | 1127 |
| 1141 void ExpectMetric(const char* metric_name, | 1128 void ExpectMetric(const char* metric_name, |
| 1142 const char* entry_name, | 1129 const char* entry_name, |
| 1143 int expected_metric_value, | 1130 int expected_metric_value, |
| 1144 int expected_num_matching_entries) { | 1131 int expected_num_matching_entries) { |
| 1145 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 1132 ukm::TestUkmRecorder* ukm_recorder = autofill_client_.GetTestUkmRecorder(); |
| 1146 | 1133 |
| 1147 int num_matching_entries = 0; | 1134 int num_matching_entries = 0; |
| 1148 for (size_t i = 0; i < ukm_service->entries_count(); ++i) { | 1135 for (size_t i = 0; i < ukm_recorder->entries_count(); ++i) { |
| 1149 const ukm::UkmEntry* entry = ukm_service->GetEntry(i); | 1136 const ukm::mojom::UkmEntry* entry = ukm_recorder->GetEntry(i); |
| 1150 | |
| 1151 ukm::Entry entry_proto; | |
| 1152 entry->PopulateProto(&entry_proto); | |
| 1153 EXPECT_EQ(entry->source_id(), entry_proto.source_id()); | |
| 1154 | |
| 1155 // Check if there is an entry for |entry_name|. | 1137 // Check if there is an entry for |entry_name|. |
| 1156 if (entry_proto.event_hash() == base::HashMetricName(entry_name)) { | 1138 if (entry->event_hash == base::HashMetricName(entry_name)) { |
| 1157 EXPECT_EQ(1, entry_proto.metrics_size()); | 1139 EXPECT_EQ(1UL, entry->metrics.size()); |
| 1158 | 1140 |
| 1159 // Check that the expected |metric_value| is logged. | 1141 // Check that the expected |metric_value| is logged. |
| 1160 const ukm::Entry_Metric* metric = | 1142 const ukm::mojom::UkmMetric* metric = |
| 1161 FindMetric(metric_name, entry_proto.metrics()); | 1143 ukm::TestUkmRecorder::FindMetric(entry, metric_name); |
| 1162 ASSERT_NE(nullptr, metric); | 1144 ASSERT_NE(nullptr, metric); |
| 1163 EXPECT_EQ(expected_metric_value, metric->value()); | 1145 EXPECT_EQ(expected_metric_value, metric->value); |
| 1164 ++num_matching_entries; | 1146 ++num_matching_entries; |
| 1165 } | 1147 } |
| 1166 } | 1148 } |
| 1167 EXPECT_EQ(expected_num_matching_entries, num_matching_entries); | 1149 EXPECT_EQ(expected_num_matching_entries, num_matching_entries); |
| 1168 } | 1150 } |
| 1169 | 1151 |
| 1170 protected: | 1152 protected: |
| 1171 base::test::ScopedTaskEnvironment scoped_task_environment_; | 1153 base::test::ScopedTaskEnvironment scoped_task_environment_; |
| 1172 MockAutofillClient autofill_client_; | 1154 MockAutofillClient autofill_client_; |
| 1173 std::unique_ptr<MockAutofillDriver> autofill_driver_; | 1155 std::unique_ptr<MockAutofillDriver> autofill_driver_; |
| (...skipping 2388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3562 // Test that OnLoadedServerPredictions can obtain the FormStructure with the | 3544 // Test that OnLoadedServerPredictions can obtain the FormStructure with the |
| 3563 // signature of the queried form and apply type predictions. | 3545 // signature of the queried form and apply type predictions. |
| 3564 TEST_F(AutofillManagerTest, OnLoadedServerPredictions) { | 3546 TEST_F(AutofillManagerTest, OnLoadedServerPredictions) { |
| 3565 // Set up our form data. | 3547 // Set up our form data. |
| 3566 FormData form; | 3548 FormData form; |
| 3567 test::CreateTestAddressFormData(&form); | 3549 test::CreateTestAddressFormData(&form); |
| 3568 | 3550 |
| 3569 // Simulate having seen this form on page load. | 3551 // Simulate having seen this form on page load. |
| 3570 // |form_structure| will be owned by |autofill_manager_|. | 3552 // |form_structure| will be owned by |autofill_manager_|. |
| 3571 TestFormStructure* form_structure = new TestFormStructure(form); | 3553 TestFormStructure* form_structure = new TestFormStructure(form); |
| 3572 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); | 3554 form_structure->DetermineHeuristicTypes(nullptr /* ukm_recorder */); |
| 3573 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); | 3555 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); |
| 3574 | 3556 |
| 3575 // Similarly, a second form. | 3557 // Similarly, a second form. |
| 3576 FormData form2; | 3558 FormData form2; |
| 3577 form2.name = ASCIIToUTF16("MyForm"); | 3559 form2.name = ASCIIToUTF16("MyForm"); |
| 3578 form2.origin = GURL("http://myform.com/form.html"); | 3560 form2.origin = GURL("http://myform.com/form.html"); |
| 3579 form2.action = GURL("http://myform.com/submit.html"); | 3561 form2.action = GURL("http://myform.com/submit.html"); |
| 3580 | 3562 |
| 3581 FormFieldData field; | 3563 FormFieldData field; |
| 3582 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); | 3564 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); |
| 3583 form2.fields.push_back(field); | 3565 form2.fields.push_back(field); |
| 3584 | 3566 |
| 3585 test::CreateTestFormField("Middle Name", "middlename", "", "text", &field); | 3567 test::CreateTestFormField("Middle Name", "middlename", "", "text", &field); |
| 3586 form2.fields.push_back(field); | 3568 form2.fields.push_back(field); |
| 3587 | 3569 |
| 3588 test::CreateTestFormField("Postal Code", "zipcode", "", "text", &field); | 3570 test::CreateTestFormField("Postal Code", "zipcode", "", "text", &field); |
| 3589 form2.fields.push_back(field); | 3571 form2.fields.push_back(field); |
| 3590 | 3572 |
| 3591 TestFormStructure* form_structure2 = new TestFormStructure(form2); | 3573 TestFormStructure* form_structure2 = new TestFormStructure(form2); |
| 3592 form_structure2->DetermineHeuristicTypes(nullptr /* ukm_service */); | 3574 form_structure2->DetermineHeuristicTypes(nullptr /* ukm_recorder */); |
| 3593 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure2)); | 3575 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure2)); |
| 3594 | 3576 |
| 3595 AutofillQueryResponseContents response; | 3577 AutofillQueryResponseContents response; |
| 3596 response.add_field()->set_autofill_type(3); | 3578 response.add_field()->set_autofill_type(3); |
| 3597 for (int i = 0; i < 7; ++i) { | 3579 for (int i = 0; i < 7; ++i) { |
| 3598 response.add_field()->set_autofill_type(0); | 3580 response.add_field()->set_autofill_type(0); |
| 3599 } | 3581 } |
| 3600 response.add_field()->set_autofill_type(3); | 3582 response.add_field()->set_autofill_type(3); |
| 3601 response.add_field()->set_autofill_type(2); | 3583 response.add_field()->set_autofill_type(2); |
| 3602 response.add_field()->set_autofill_type(61); | 3584 response.add_field()->set_autofill_type(61); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3634 // AutofillManager has been reset between the time the query was sent and the | 3616 // AutofillManager has been reset between the time the query was sent and the |
| 3635 // response received. | 3617 // response received. |
| 3636 TEST_F(AutofillManagerTest, OnLoadedServerPredictions_ResetManager) { | 3618 TEST_F(AutofillManagerTest, OnLoadedServerPredictions_ResetManager) { |
| 3637 // Set up our form data. | 3619 // Set up our form data. |
| 3638 FormData form; | 3620 FormData form; |
| 3639 test::CreateTestAddressFormData(&form); | 3621 test::CreateTestAddressFormData(&form); |
| 3640 | 3622 |
| 3641 // Simulate having seen this form on page load. | 3623 // Simulate having seen this form on page load. |
| 3642 // |form_structure| will be owned by |autofill_manager_|. | 3624 // |form_structure| will be owned by |autofill_manager_|. |
| 3643 TestFormStructure* form_structure = new TestFormStructure(form); | 3625 TestFormStructure* form_structure = new TestFormStructure(form); |
| 3644 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); | 3626 form_structure->DetermineHeuristicTypes(nullptr /* ukm_recorder */); |
| 3645 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); | 3627 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); |
| 3646 | 3628 |
| 3647 AutofillQueryResponseContents response; | 3629 AutofillQueryResponseContents response; |
| 3648 response.add_field()->set_autofill_type(3); | 3630 response.add_field()->set_autofill_type(3); |
| 3649 for (int i = 0; i < 7; ++i) { | 3631 for (int i = 0; i < 7; ++i) { |
| 3650 response.add_field()->set_autofill_type(0); | 3632 response.add_field()->set_autofill_type(0); |
| 3651 } | 3633 } |
| 3652 response.add_field()->set_autofill_type(3); | 3634 response.add_field()->set_autofill_type(3); |
| 3653 response.add_field()->set_autofill_type(2); | 3635 response.add_field()->set_autofill_type(2); |
| 3654 response.add_field()->set_autofill_type(61); | 3636 response.add_field()->set_autofill_type(61); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 3673 // have server data for the field types. | 3655 // have server data for the field types. |
| 3674 TEST_F(AutofillManagerTest, FormSubmittedServerTypes) { | 3656 TEST_F(AutofillManagerTest, FormSubmittedServerTypes) { |
| 3675 // Set up our form data. | 3657 // Set up our form data. |
| 3676 FormData form; | 3658 FormData form; |
| 3677 test::CreateTestAddressFormData(&form); | 3659 test::CreateTestAddressFormData(&form); |
| 3678 FormsSeen(std::vector<FormData>(1, form)); | 3660 FormsSeen(std::vector<FormData>(1, form)); |
| 3679 | 3661 |
| 3680 // Simulate having seen this form on page load. | 3662 // Simulate having seen this form on page load. |
| 3681 // |form_structure| will be owned by |autofill_manager_|. | 3663 // |form_structure| will be owned by |autofill_manager_|. |
| 3682 TestFormStructure* form_structure = new TestFormStructure(form); | 3664 TestFormStructure* form_structure = new TestFormStructure(form); |
| 3683 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); | 3665 form_structure->DetermineHeuristicTypes(nullptr /* ukm_recorder */); |
| 3684 | 3666 |
| 3685 // Clear the heuristic types, and instead set the appropriate server types. | 3667 // Clear the heuristic types, and instead set the appropriate server types. |
| 3686 std::vector<ServerFieldType> heuristic_types, server_types; | 3668 std::vector<ServerFieldType> heuristic_types, server_types; |
| 3687 for (size_t i = 0; i < form.fields.size(); ++i) { | 3669 for (size_t i = 0; i < form.fields.size(); ++i) { |
| 3688 heuristic_types.push_back(UNKNOWN_TYPE); | 3670 heuristic_types.push_back(UNKNOWN_TYPE); |
| 3689 server_types.push_back(form_structure->field(i)->heuristic_type()); | 3671 server_types.push_back(form_structure->field(i)->heuristic_type()); |
| 3690 } | 3672 } |
| 3691 form_structure->SetFieldTypes(heuristic_types, server_types); | 3673 form_structure->SetFieldTypes(heuristic_types, server_types); |
| 3692 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); | 3674 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); |
| 3693 | 3675 |
| (...skipping 3089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6783 | 6765 |
| 6784 FormFieldData field; | 6766 FormFieldData field; |
| 6785 test::CreateTestFormField("Field 1", "field1", "", "text", &field); | 6767 test::CreateTestFormField("Field 1", "field1", "", "text", &field); |
| 6786 form.fields.push_back(field); | 6768 form.fields.push_back(field); |
| 6787 test::CreateTestFormField("Field 2", "field2", "", "text", &field); | 6769 test::CreateTestFormField("Field 2", "field2", "", "text", &field); |
| 6788 form.fields.push_back(field); | 6770 form.fields.push_back(field); |
| 6789 test::CreateTestFormField("Field 3", "field3", "", "text", &field); | 6771 test::CreateTestFormField("Field 3", "field3", "", "text", &field); |
| 6790 form.fields.push_back(field); | 6772 form.fields.push_back(field); |
| 6791 | 6773 |
| 6792 auto form_structure = base::MakeUnique<TestFormStructure>(form); | 6774 auto form_structure = base::MakeUnique<TestFormStructure>(form); |
| 6793 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); | 6775 form_structure->DetermineHeuristicTypes(nullptr /* ukm_recorder */); |
| 6794 // Make sure the form can not be autofilled now. | 6776 // Make sure the form can not be autofilled now. |
| 6795 ASSERT_EQ(0u, form_structure->autofill_count()); | 6777 ASSERT_EQ(0u, form_structure->autofill_count()); |
| 6796 for (size_t idx = 0; idx < form_structure->field_count(); ++idx) { | 6778 for (size_t idx = 0; idx < form_structure->field_count(); ++idx) { |
| 6797 ASSERT_EQ(UNKNOWN_TYPE, form_structure->field(idx)->heuristic_type()); | 6779 ASSERT_EQ(UNKNOWN_TYPE, form_structure->field(idx)->heuristic_type()); |
| 6798 } | 6780 } |
| 6799 | 6781 |
| 6800 // Prepare and set known server fields. | 6782 // Prepare and set known server fields. |
| 6801 const std::vector<ServerFieldType> heuristic_types(form.fields.size(), | 6783 const std::vector<ServerFieldType> heuristic_types(form.fields.size(), |
| 6802 UNKNOWN_TYPE); | 6784 UNKNOWN_TYPE); |
| 6803 const std::vector<ServerFieldType> server_types{NAME_FIRST, NAME_MIDDLE, | 6785 const std::vector<ServerFieldType> server_types{NAME_FIRST, NAME_MIDDLE, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6913 | 6895 |
| 6914 // Wait for upload to complete (will check expected types as well). | 6896 // Wait for upload to complete (will check expected types as well). |
| 6915 autofill_manager_->WaitForAsyncUploadProcess(); | 6897 autofill_manager_->WaitForAsyncUploadProcess(); |
| 6916 | 6898 |
| 6917 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); | 6899 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); |
| 6918 EXPECT_NE(uploaded_available_types.end(), | 6900 EXPECT_NE(uploaded_available_types.end(), |
| 6919 uploaded_available_types.find(autofill::PASSWORD)); | 6901 uploaded_available_types.find(autofill::PASSWORD)); |
| 6920 } | 6902 } |
| 6921 | 6903 |
| 6922 } // namespace autofill | 6904 } // namespace autofill |
| OLD | NEW |