| 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 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1022 | 1022 |
| 1023 void SetHttpWarningEnabled() { | 1023 void SetHttpWarningEnabled() { |
| 1024 scoped_feature_list_.InitAndEnableFeature( | 1024 scoped_feature_list_.InitAndEnableFeature( |
| 1025 security_state::kHttpFormWarningFeature); | 1025 security_state::kHttpFormWarningFeature); |
| 1026 } | 1026 } |
| 1027 | 1027 |
| 1028 void EnableUkmLogging() { | 1028 void EnableUkmLogging() { |
| 1029 scoped_feature_list_.InitAndEnableFeature(kAutofillUkmLogging); | 1029 scoped_feature_list_.InitAndEnableFeature(kAutofillUkmLogging); |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 void ExpectUniqueCardUploadDecisionUkm( | 1032 void ExpectUniqueFillableFormParsedUkm() { |
| 1033 AutofillMetrics::CardUploadDecisionMetric upload_decision) { | |
| 1034 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 1033 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| 1035 | 1034 |
| 1036 // Check that one source is logged. | 1035 // Check that one source is logged. |
| 1037 ASSERT_EQ(1U, ukm_service->sources_count()); | 1036 ASSERT_EQ(1U, ukm_service->sources_count()); |
| 1038 const ukm::UkmSource* source = GetUkmSources(ukm_service)[0]; | 1037 const ukm::UkmSource* source = GetUkmSources(ukm_service)[0]; |
| 1039 | 1038 |
| 1040 // Check that one entry is logged. | 1039 // Check that one entry is logged. |
| 1041 EXPECT_EQ(1U, ukm_service->entries_count()); | 1040 EXPECT_EQ(1U, ukm_service->entries_count()); |
| 1042 const ukm::UkmEntry* entry = ukm_service->GetEntry(0); | 1041 const ukm::UkmEntry* entry = ukm_service->GetEntry(0); |
| 1043 EXPECT_EQ(source->id(), entry->source_id()); | 1042 EXPECT_EQ(source->id(), entry->source_id()); |
| 1044 | 1043 |
| 1045 ukm::Entry entry_proto; | 1044 ukm::Entry entry_proto; |
| 1046 entry->PopulateProto(&entry_proto); | 1045 entry->PopulateProto(&entry_proto); |
| 1047 EXPECT_EQ(source->id(), entry_proto.source_id()); | 1046 EXPECT_EQ(source->id(), entry_proto.source_id()); |
| 1048 | 1047 |
| 1049 // Check if there is an entry for card upload decisions. | 1048 // Check if there is an entry for developer engagement decision. |
| 1050 EXPECT_EQ(base::HashMetricName(internal::kUKMCardUploadDecisionEntryName), | 1049 EXPECT_EQ(base::HashMetricName(internal::kUKMDeveloperEngagementEntryName), |
| 1051 entry_proto.event_hash()); | 1050 entry_proto.event_hash()); |
| 1052 EXPECT_EQ(1, entry_proto.metrics_size()); | 1051 EXPECT_EQ(1, entry_proto.metrics_size()); |
| 1053 | 1052 |
| 1054 // Check that the expected upload decision is logged. | 1053 // Check that the expected developer engagement metric is logged. |
| 1055 const ukm::Entry_Metric* metric = FindMetric( | 1054 const ukm::Entry_Metric* metric = FindMetric( |
| 1056 internal::kUKMCardUploadDecisionMetricName, entry_proto.metrics()); | 1055 internal::kUKMDeveloperEngagementMetricName, entry_proto.metrics()); |
| 1057 ASSERT_NE(nullptr, metric); | 1056 ASSERT_NE(nullptr, metric); |
| 1058 EXPECT_EQ(static_cast<int>(upload_decision), metric->value()); | 1057 EXPECT_EQ(static_cast<int>( |
| 1058 AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS), |
| 1059 metric->value()); |
| 1060 } |
| 1061 |
| 1062 void ExpectCardUploadDecisionUkm( |
| 1063 AutofillMetrics::CardUploadDecisionMetric upload_decision) { |
| 1064 ExpectMetric(internal::kUKMCardUploadDecisionMetricName, |
| 1065 internal::kUKMCardUploadDecisionEntryName, |
| 1066 static_cast<int>(upload_decision), |
| 1067 1 /* expected_num_matching_entries */); |
| 1068 } |
| 1069 |
| 1070 void ExpectFillableFormParsedUkm(int num_fillable_forms_parsed) { |
| 1071 ExpectMetric(internal::kUKMDeveloperEngagementMetricName, |
| 1072 internal::kUKMDeveloperEngagementEntryName, |
| 1073 static_cast<int>( |
| 1074 AutofillMetrics::FILLABLE_FORM_PARSED_WITHOUT_TYPE_HINTS), |
| 1075 num_fillable_forms_parsed); |
| 1076 } |
| 1077 |
| 1078 void ExpectMetric(const char* metric_name, |
| 1079 const char* entry_name, |
| 1080 int metric_value, |
| 1081 int expected_num_matching_entries) { |
| 1082 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| 1083 |
| 1084 int num_matching_entries = 0; |
| 1085 for (size_t i = 0; i < ukm_service->entries_count(); ++i) { |
| 1086 const ukm::UkmEntry* entry = ukm_service->GetEntry(i); |
| 1087 |
| 1088 ukm::Entry entry_proto; |
| 1089 entry->PopulateProto(&entry_proto); |
| 1090 EXPECT_EQ(entry->source_id(), entry_proto.source_id()); |
| 1091 |
| 1092 // Check if there is an entry for |entry_name|. |
| 1093 if (entry_proto.event_hash() == base::HashMetricName(entry_name)) { |
| 1094 EXPECT_EQ(1, entry_proto.metrics_size()); |
| 1095 |
| 1096 // Check that the expected |metric_value| is logged. |
| 1097 const ukm::Entry_Metric* metric = |
| 1098 FindMetric(metric_name, entry_proto.metrics()); |
| 1099 ASSERT_NE(nullptr, metric); |
| 1100 EXPECT_EQ(metric_value, metric->value()); |
| 1101 ++num_matching_entries; |
| 1102 } |
| 1103 } |
| 1104 EXPECT_EQ(expected_num_matching_entries, num_matching_entries); |
| 1059 } | 1105 } |
| 1060 | 1106 |
| 1061 protected: | 1107 protected: |
| 1062 base::MessageLoop message_loop_; | 1108 base::MessageLoop message_loop_; |
| 1063 MockAutofillClient autofill_client_; | 1109 MockAutofillClient autofill_client_; |
| 1064 std::unique_ptr<MockAutofillDriver> autofill_driver_; | 1110 std::unique_ptr<MockAutofillDriver> autofill_driver_; |
| 1065 std::unique_ptr<TestAutofillManager> autofill_manager_; | 1111 std::unique_ptr<TestAutofillManager> autofill_manager_; |
| 1066 std::unique_ptr<TestAutofillExternalDelegate> external_delegate_; | 1112 std::unique_ptr<TestAutofillExternalDelegate> external_delegate_; |
| 1067 scoped_refptr<net::TestURLRequestContextGetter> request_context_; | 1113 scoped_refptr<net::TestURLRequestContextGetter> request_context_; |
| 1068 TestPaymentsClient* payments_client_; | 1114 TestPaymentsClient* payments_client_; |
| (...skipping 2380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3449 // Test that OnLoadedServerPredictions can obtain the FormStructure with the | 3495 // Test that OnLoadedServerPredictions can obtain the FormStructure with the |
| 3450 // signature of the queried form and apply type predictions. | 3496 // signature of the queried form and apply type predictions. |
| 3451 TEST_F(AutofillManagerTest, OnLoadedServerPredictions) { | 3497 TEST_F(AutofillManagerTest, OnLoadedServerPredictions) { |
| 3452 // Set up our form data. | 3498 // Set up our form data. |
| 3453 FormData form; | 3499 FormData form; |
| 3454 test::CreateTestAddressFormData(&form); | 3500 test::CreateTestAddressFormData(&form); |
| 3455 | 3501 |
| 3456 // Simulate having seen this form on page load. | 3502 // Simulate having seen this form on page load. |
| 3457 // |form_structure| will be owned by |autofill_manager_|. | 3503 // |form_structure| will be owned by |autofill_manager_|. |
| 3458 TestFormStructure* form_structure = new TestFormStructure(form); | 3504 TestFormStructure* form_structure = new TestFormStructure(form); |
| 3459 form_structure->DetermineHeuristicTypes(); | 3505 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); |
| 3460 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); | 3506 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); |
| 3461 | 3507 |
| 3462 // Similarly, a second form. | 3508 // Similarly, a second form. |
| 3463 FormData form2; | 3509 FormData form2; |
| 3464 form2.name = ASCIIToUTF16("MyForm"); | 3510 form2.name = ASCIIToUTF16("MyForm"); |
| 3465 form2.origin = GURL("http://myform.com/form.html"); | 3511 form2.origin = GURL("http://myform.com/form.html"); |
| 3466 form2.action = GURL("http://myform.com/submit.html"); | 3512 form2.action = GURL("http://myform.com/submit.html"); |
| 3467 | 3513 |
| 3468 FormFieldData field; | 3514 FormFieldData field; |
| 3469 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); | 3515 test::CreateTestFormField("Last Name", "lastname", "", "text", &field); |
| 3470 form2.fields.push_back(field); | 3516 form2.fields.push_back(field); |
| 3471 | 3517 |
| 3472 test::CreateTestFormField("Middle Name", "middlename", "", "text", &field); | 3518 test::CreateTestFormField("Middle Name", "middlename", "", "text", &field); |
| 3473 form2.fields.push_back(field); | 3519 form2.fields.push_back(field); |
| 3474 | 3520 |
| 3475 test::CreateTestFormField("Postal Code", "zipcode", "", "text", &field); | 3521 test::CreateTestFormField("Postal Code", "zipcode", "", "text", &field); |
| 3476 form2.fields.push_back(field); | 3522 form2.fields.push_back(field); |
| 3477 | 3523 |
| 3478 TestFormStructure* form_structure2 = new TestFormStructure(form2); | 3524 TestFormStructure* form_structure2 = new TestFormStructure(form2); |
| 3479 form_structure2->DetermineHeuristicTypes(); | 3525 form_structure2->DetermineHeuristicTypes(nullptr /* ukm_service */); |
| 3480 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure2)); | 3526 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure2)); |
| 3481 | 3527 |
| 3482 AutofillQueryResponseContents response; | 3528 AutofillQueryResponseContents response; |
| 3483 response.add_field()->set_autofill_type(3); | 3529 response.add_field()->set_autofill_type(3); |
| 3484 for (int i = 0; i < 7; ++i) { | 3530 for (int i = 0; i < 7; ++i) { |
| 3485 response.add_field()->set_autofill_type(0); | 3531 response.add_field()->set_autofill_type(0); |
| 3486 } | 3532 } |
| 3487 response.add_field()->set_autofill_type(3); | 3533 response.add_field()->set_autofill_type(3); |
| 3488 response.add_field()->set_autofill_type(2); | 3534 response.add_field()->set_autofill_type(2); |
| 3489 response.add_field()->set_autofill_type(61); | 3535 response.add_field()->set_autofill_type(61); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3522 // AutofillManager has been reset between the time the query was sent and the | 3568 // AutofillManager has been reset between the time the query was sent and the |
| 3523 // response received. | 3569 // response received. |
| 3524 TEST_F(AutofillManagerTest, OnLoadedServerPredictions_ResetManager) { | 3570 TEST_F(AutofillManagerTest, OnLoadedServerPredictions_ResetManager) { |
| 3525 // Set up our form data. | 3571 // Set up our form data. |
| 3526 FormData form; | 3572 FormData form; |
| 3527 test::CreateTestAddressFormData(&form); | 3573 test::CreateTestAddressFormData(&form); |
| 3528 | 3574 |
| 3529 // Simulate having seen this form on page load. | 3575 // Simulate having seen this form on page load. |
| 3530 // |form_structure| will be owned by |autofill_manager_|. | 3576 // |form_structure| will be owned by |autofill_manager_|. |
| 3531 TestFormStructure* form_structure = new TestFormStructure(form); | 3577 TestFormStructure* form_structure = new TestFormStructure(form); |
| 3532 form_structure->DetermineHeuristicTypes(); | 3578 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); |
| 3533 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); | 3579 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); |
| 3534 | 3580 |
| 3535 AutofillQueryResponseContents response; | 3581 AutofillQueryResponseContents response; |
| 3536 response.add_field()->set_autofill_type(3); | 3582 response.add_field()->set_autofill_type(3); |
| 3537 for (int i = 0; i < 7; ++i) { | 3583 for (int i = 0; i < 7; ++i) { |
| 3538 response.add_field()->set_autofill_type(0); | 3584 response.add_field()->set_autofill_type(0); |
| 3539 } | 3585 } |
| 3540 response.add_field()->set_autofill_type(3); | 3586 response.add_field()->set_autofill_type(3); |
| 3541 response.add_field()->set_autofill_type(2); | 3587 response.add_field()->set_autofill_type(2); |
| 3542 response.add_field()->set_autofill_type(61); | 3588 response.add_field()->set_autofill_type(61); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 3560 // Test that we are able to save form data when forms are submitted and we only | 3606 // Test that we are able to save form data when forms are submitted and we only |
| 3561 // have server data for the field types. | 3607 // have server data for the field types. |
| 3562 TEST_F(AutofillManagerTest, FormSubmittedServerTypes) { | 3608 TEST_F(AutofillManagerTest, FormSubmittedServerTypes) { |
| 3563 // Set up our form data. | 3609 // Set up our form data. |
| 3564 FormData form; | 3610 FormData form; |
| 3565 test::CreateTestAddressFormData(&form); | 3611 test::CreateTestAddressFormData(&form); |
| 3566 | 3612 |
| 3567 // Simulate having seen this form on page load. | 3613 // Simulate having seen this form on page load. |
| 3568 // |form_structure| will be owned by |autofill_manager_|. | 3614 // |form_structure| will be owned by |autofill_manager_|. |
| 3569 TestFormStructure* form_structure = new TestFormStructure(form); | 3615 TestFormStructure* form_structure = new TestFormStructure(form); |
| 3570 form_structure->DetermineHeuristicTypes(); | 3616 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); |
| 3571 | 3617 |
| 3572 // Clear the heuristic types, and instead set the appropriate server types. | 3618 // Clear the heuristic types, and instead set the appropriate server types. |
| 3573 std::vector<ServerFieldType> heuristic_types, server_types; | 3619 std::vector<ServerFieldType> heuristic_types, server_types; |
| 3574 for (size_t i = 0; i < form.fields.size(); ++i) { | 3620 for (size_t i = 0; i < form.fields.size(); ++i) { |
| 3575 heuristic_types.push_back(UNKNOWN_TYPE); | 3621 heuristic_types.push_back(UNKNOWN_TYPE); |
| 3576 server_types.push_back(form_structure->field(i)->heuristic_type()); | 3622 server_types.push_back(form_structure->field(i)->heuristic_type()); |
| 3577 } | 3623 } |
| 3578 form_structure->SetFieldTypes(heuristic_types, server_types); | 3624 form_structure->SetFieldTypes(heuristic_types, server_types); |
| 3579 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); | 3625 autofill_manager_->AddSeenForm(base::WrapUnique(form_structure)); |
| 3580 | 3626 |
| (...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4530 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard) { | 4576 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard) { |
| 4531 EnableUkmLogging(); | 4577 EnableUkmLogging(); |
| 4532 personal_data_.ClearAutofillProfiles(); | 4578 personal_data_.ClearAutofillProfiles(); |
| 4533 autofill_manager_->set_credit_card_upload_enabled(true); | 4579 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4534 | 4580 |
| 4535 // Create, fill and submit an address form in order to establish a recent | 4581 // Create, fill and submit an address form in order to establish a recent |
| 4536 // profile which can be selected for the upload request. | 4582 // profile which can be selected for the upload request. |
| 4537 FormData address_form; | 4583 FormData address_form; |
| 4538 test::CreateTestAddressFormData(&address_form); | 4584 test::CreateTestAddressFormData(&address_form); |
| 4539 FormsSeen(std::vector<FormData>(1, address_form)); | 4585 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4586 ExpectUniqueFillableFormParsedUkm(); |
| 4587 |
| 4540 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); | 4588 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); |
| 4541 FormSubmitted(address_form); | 4589 FormSubmitted(address_form); |
| 4542 | 4590 |
| 4543 // Set up our credit card form data. | 4591 // Set up our credit card form data. |
| 4544 FormData credit_card_form; | 4592 FormData credit_card_form; |
| 4545 CreateTestCreditCardFormData(&credit_card_form, true, false); | 4593 CreateTestCreditCardFormData(&credit_card_form, true, false); |
| 4546 FormsSeen(std::vector<FormData>(1, credit_card_form)); | 4594 FormsSeen(std::vector<FormData>(1, credit_card_form)); |
| 4595 ExpectFillableFormParsedUkm(2 /* num_fillable_forms_parsed */); |
| 4547 | 4596 |
| 4548 // Edit the data, and submit. | 4597 // Edit the data, and submit. |
| 4549 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); | 4598 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); |
| 4550 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 4599 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
| 4551 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 4600 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
| 4552 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 4601 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 4553 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 4602 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 4554 | 4603 |
| 4555 base::HistogramTester histogram_tester; | 4604 base::HistogramTester histogram_tester; |
| 4556 | 4605 |
| 4557 FormSubmitted(credit_card_form); | 4606 FormSubmitted(credit_card_form); |
| 4558 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4607 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4559 | 4608 |
| 4560 // Verify that the correct histogram entry (and only that) was logged. | 4609 // Verify that the correct histogram entry (and only that) was logged. |
| 4561 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", | 4610 histogram_tester.ExpectUniqueSample("Autofill.CardUploadDecisionExpanded", |
| 4562 AutofillMetrics::UPLOAD_OFFERED, 1); | 4611 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 4563 // Verify that the correct UKM was logged. | 4612 // Verify that the correct UKM was logged. |
| 4564 ExpectUniqueCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); | 4613 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); |
| 4565 } | 4614 } |
| 4566 | 4615 |
| 4567 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 4616 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4568 #if defined(OS_ANDROID) | 4617 #if defined(OS_ANDROID) |
| 4569 #define MAYBE_UploadCreditCard_FeatureNotEnabled DISABLED_UploadCreditCard_Featu
reNotEnabled | 4618 #define MAYBE_UploadCreditCard_FeatureNotEnabled DISABLED_UploadCreditCard_Featu
reNotEnabled |
| 4570 #else | 4619 #else |
| 4571 #define MAYBE_UploadCreditCard_FeatureNotEnabled UploadCreditCard_FeatureNotEnab
led | 4620 #define MAYBE_UploadCreditCard_FeatureNotEnabled UploadCreditCard_FeatureNotEnab
led |
| 4572 #endif | 4621 #endif |
| 4573 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_FeatureNotEnabled) { | 4622 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_FeatureNotEnabled) { |
| 4574 personal_data_.ClearAutofillProfiles(); | 4623 personal_data_.ClearAutofillProfiles(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4614 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcUnavailable) { | 4663 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcUnavailable) { |
| 4615 EnableUkmLogging(); | 4664 EnableUkmLogging(); |
| 4616 personal_data_.ClearAutofillProfiles(); | 4665 personal_data_.ClearAutofillProfiles(); |
| 4617 autofill_manager_->set_credit_card_upload_enabled(true); | 4666 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4618 | 4667 |
| 4619 // Create, fill and submit an address form in order to establish a recent | 4668 // Create, fill and submit an address form in order to establish a recent |
| 4620 // profile which can be selected for the upload request. | 4669 // profile which can be selected for the upload request. |
| 4621 FormData address_form; | 4670 FormData address_form; |
| 4622 test::CreateTestAddressFormData(&address_form); | 4671 test::CreateTestAddressFormData(&address_form); |
| 4623 FormsSeen(std::vector<FormData>(1, address_form)); | 4672 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4673 ExpectUniqueFillableFormParsedUkm(); |
| 4674 |
| 4624 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); | 4675 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); |
| 4625 FormSubmitted(address_form); | 4676 FormSubmitted(address_form); |
| 4626 | 4677 |
| 4627 // Set up our credit card form data. | 4678 // Set up our credit card form data. |
| 4628 FormData credit_card_form; | 4679 FormData credit_card_form; |
| 4629 CreateTestCreditCardFormData(&credit_card_form, true, false); | 4680 CreateTestCreditCardFormData(&credit_card_form, true, false); |
| 4630 FormsSeen(std::vector<FormData>(1, credit_card_form)); | 4681 FormsSeen(std::vector<FormData>(1, credit_card_form)); |
| 4682 ExpectFillableFormParsedUkm(2 /* num_fillable_forms_parsed */); |
| 4631 | 4683 |
| 4632 // Edit the data, and submit. | 4684 // Edit the data, and submit. |
| 4633 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); | 4685 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); |
| 4634 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 4686 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
| 4635 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 4687 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
| 4636 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 4688 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 4637 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING | 4689 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING |
| 4638 | 4690 |
| 4639 base::HistogramTester histogram_tester; | 4691 base::HistogramTester histogram_tester; |
| 4640 | 4692 |
| 4641 // Neither a local save nor an upload should happen in this case. | 4693 // Neither a local save nor an upload should happen in this case. |
| 4642 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4694 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4643 FormSubmitted(credit_card_form); | 4695 FormSubmitted(credit_card_form); |
| 4644 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4696 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4645 | 4697 |
| 4646 // Verify that the correct histogram entry (and only that) was logged. | 4698 // Verify that the correct histogram entry (and only that) was logged. |
| 4647 histogram_tester.ExpectUniqueSample( | 4699 histogram_tester.ExpectUniqueSample( |
| 4648 "Autofill.CardUploadDecisionExpanded", | 4700 "Autofill.CardUploadDecisionExpanded", |
| 4649 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); | 4701 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); |
| 4650 // Verify that the correct UKM was logged. | 4702 // Verify that the correct UKM was logged. |
| 4651 ExpectUniqueCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 4703 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 4652 | 4704 |
| 4653 rappor::TestRapporServiceImpl* rappor_service = | 4705 rappor::TestRapporServiceImpl* rappor_service = |
| 4654 autofill_client_.test_rappor_service(); | 4706 autofill_client_.test_rappor_service(); |
| 4655 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4707 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 4656 std::string sample; | 4708 std::string sample; |
| 4657 rappor::RapporType type; | 4709 rappor::RapporType type; |
| 4658 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4710 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 4659 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 4711 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
| 4660 EXPECT_EQ("myform.com", sample); | 4712 EXPECT_EQ("myform.com", sample); |
| 4661 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 4713 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4697 // Neither a local save nor an upload should happen in this case. | 4749 // Neither a local save nor an upload should happen in this case. |
| 4698 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4750 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4699 FormSubmitted(credit_card_form); | 4751 FormSubmitted(credit_card_form); |
| 4700 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4752 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4701 | 4753 |
| 4702 // Verify that the correct histogram entry (and only that) was logged. | 4754 // Verify that the correct histogram entry (and only that) was logged. |
| 4703 histogram_tester.ExpectUniqueSample( | 4755 histogram_tester.ExpectUniqueSample( |
| 4704 "Autofill.CardUploadDecisionExpanded", | 4756 "Autofill.CardUploadDecisionExpanded", |
| 4705 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); | 4757 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); |
| 4706 // Verify that the correct UKM was logged. | 4758 // Verify that the correct UKM was logged. |
| 4707 ExpectUniqueCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 4759 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 4708 | 4760 |
| 4709 rappor::TestRapporServiceImpl* rappor_service = | 4761 rappor::TestRapporServiceImpl* rappor_service = |
| 4710 autofill_client_.test_rappor_service(); | 4762 autofill_client_.test_rappor_service(); |
| 4711 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4763 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 4712 std::string sample; | 4764 std::string sample; |
| 4713 rappor::RapporType type; | 4765 rappor::RapporType type; |
| 4714 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4766 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 4715 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 4767 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
| 4716 EXPECT_EQ("myform.com", sample); | 4768 EXPECT_EQ("myform.com", sample); |
| 4717 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 4769 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4775 // A CVC value appeared in one of the two CVC fields, upload should happen. | 4827 // A CVC value appeared in one of the two CVC fields, upload should happen. |
| 4776 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4828 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4777 FormSubmitted(credit_card_form); | 4829 FormSubmitted(credit_card_form); |
| 4778 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4830 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4779 | 4831 |
| 4780 // Verify that the correct histogram entry (and only that) was logged. | 4832 // Verify that the correct histogram entry (and only that) was logged. |
| 4781 histogram_tester.ExpectUniqueSample( | 4833 histogram_tester.ExpectUniqueSample( |
| 4782 "Autofill.CardUploadDecisionExpanded", | 4834 "Autofill.CardUploadDecisionExpanded", |
| 4783 AutofillMetrics::UPLOAD_OFFERED, 1); | 4835 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 4784 // Verify that the correct UKM was logged. | 4836 // Verify that the correct UKM was logged. |
| 4785 ExpectUniqueCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); | 4837 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); |
| 4786 } | 4838 } |
| 4787 | 4839 |
| 4788 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 4840 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4789 #if defined(OS_ANDROID) | 4841 #if defined(OS_ANDROID) |
| 4790 #define MAYBE_UploadCreditCard_NoProfileAvailable DISABLED_UploadCreditCard_NoPr
ofileAvailable | 4842 #define MAYBE_UploadCreditCard_NoProfileAvailable DISABLED_UploadCreditCard_NoPr
ofileAvailable |
| 4791 #else | 4843 #else |
| 4792 #define MAYBE_UploadCreditCard_NoProfileAvailable UploadCreditCard_NoProfileAvai
lable | 4844 #define MAYBE_UploadCreditCard_NoProfileAvailable UploadCreditCard_NoProfileAvai
lable |
| 4793 #endif | 4845 #endif |
| 4794 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoProfileAvailable) { | 4846 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoProfileAvailable) { |
| 4795 EnableUkmLogging(); | 4847 EnableUkmLogging(); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4815 // Neither a local save nor an upload should happen in this case. | 4867 // Neither a local save nor an upload should happen in this case. |
| 4816 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4868 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4817 FormSubmitted(credit_card_form); | 4869 FormSubmitted(credit_card_form); |
| 4818 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4870 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4819 | 4871 |
| 4820 // Verify that the correct histogram entry (and only that) was logged. | 4872 // Verify that the correct histogram entry (and only that) was logged. |
| 4821 histogram_tester.ExpectUniqueSample( | 4873 histogram_tester.ExpectUniqueSample( |
| 4822 "Autofill.CardUploadDecisionExpanded", | 4874 "Autofill.CardUploadDecisionExpanded", |
| 4823 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); | 4875 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS, 1); |
| 4824 // Verify that the correct UKM was logged. | 4876 // Verify that the correct UKM was logged. |
| 4825 ExpectUniqueCardUploadDecisionUkm( | 4877 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS); |
| 4826 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS); | |
| 4827 | 4878 |
| 4828 rappor::TestRapporServiceImpl* rappor_service = | 4879 rappor::TestRapporServiceImpl* rappor_service = |
| 4829 autofill_client_.test_rappor_service(); | 4880 autofill_client_.test_rappor_service(); |
| 4830 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4881 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 4831 std::string sample; | 4882 std::string sample; |
| 4832 rappor::RapporType type; | 4883 rappor::RapporType type; |
| 4833 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4884 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 4834 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type)); | 4885 "Autofill.CardUploadNotOfferedNoAddress", &sample, &type)); |
| 4835 EXPECT_EQ("myform.com", sample); | 4886 EXPECT_EQ("myform.com", sample); |
| 4836 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 4887 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4869 // profile, but the no CVC case should have priority over being reported. | 4920 // profile, but the no CVC case should have priority over being reported. |
| 4870 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4921 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4871 FormSubmitted(credit_card_form); | 4922 FormSubmitted(credit_card_form); |
| 4872 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4923 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4873 | 4924 |
| 4874 // Verify that the correct histogram entry (and only that) was logged. | 4925 // Verify that the correct histogram entry (and only that) was logged. |
| 4875 histogram_tester.ExpectUniqueSample( | 4926 histogram_tester.ExpectUniqueSample( |
| 4876 "Autofill.CardUploadDecisionExpanded", | 4927 "Autofill.CardUploadDecisionExpanded", |
| 4877 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); | 4928 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1); |
| 4878 // Verify that the correct UKM was logged. | 4929 // Verify that the correct UKM was logged. |
| 4879 ExpectUniqueCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 4930 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); |
| 4880 | 4931 |
| 4881 rappor::TestRapporServiceImpl* rappor_service = | 4932 rappor::TestRapporServiceImpl* rappor_service = |
| 4882 autofill_client_.test_rappor_service(); | 4933 autofill_client_.test_rappor_service(); |
| 4883 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4934 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 4884 std::string sample; | 4935 std::string sample; |
| 4885 rappor::RapporType type; | 4936 rappor::RapporType type; |
| 4886 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4937 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 4887 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 4938 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
| 4888 EXPECT_EQ("myform.com", sample); | 4939 EXPECT_EQ("myform.com", sample); |
| 4889 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 4940 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4925 // Neither a local save nor an upload should happen in this case. | 4976 // Neither a local save nor an upload should happen in this case. |
| 4926 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4977 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4927 FormSubmitted(credit_card_form); | 4978 FormSubmitted(credit_card_form); |
| 4928 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4979 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4929 | 4980 |
| 4930 // Verify that the correct histogram entry (and only that) was logged. | 4981 // Verify that the correct histogram entry (and only that) was logged. |
| 4931 histogram_tester.ExpectUniqueSample( | 4982 histogram_tester.ExpectUniqueSample( |
| 4932 "Autofill.CardUploadDecisionExpanded", | 4983 "Autofill.CardUploadDecisionExpanded", |
| 4933 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME, 1); | 4984 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME, 1); |
| 4934 // Verify that the correct UKM was logged. | 4985 // Verify that the correct UKM was logged. |
| 4935 ExpectUniqueCardUploadDecisionUkm( | 4986 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME); |
| 4936 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME); | |
| 4937 | 4987 |
| 4938 rappor::TestRapporServiceImpl* rappor_service = | 4988 rappor::TestRapporServiceImpl* rappor_service = |
| 4939 autofill_client_.test_rappor_service(); | 4989 autofill_client_.test_rappor_service(); |
| 4940 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4990 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 4941 std::string sample; | 4991 std::string sample; |
| 4942 rappor::RapporType type; | 4992 rappor::RapporType type; |
| 4943 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4993 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 4944 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); | 4994 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); |
| 4945 EXPECT_EQ("myform.com", sample); | 4995 EXPECT_EQ("myform.com", sample); |
| 4946 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 4996 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 4959 | 5009 |
| 4960 // Create, fill and submit two address forms with different zip codes. | 5010 // Create, fill and submit two address forms with different zip codes. |
| 4961 FormData address_form1, address_form2; | 5011 FormData address_form1, address_form2; |
| 4962 test::CreateTestAddressFormData(&address_form1); | 5012 test::CreateTestAddressFormData(&address_form1); |
| 4963 test::CreateTestAddressFormData(&address_form2); | 5013 test::CreateTestAddressFormData(&address_form2); |
| 4964 | 5014 |
| 4965 std::vector<FormData> address_forms; | 5015 std::vector<FormData> address_forms; |
| 4966 address_forms.push_back(address_form1); | 5016 address_forms.push_back(address_form1); |
| 4967 address_forms.push_back(address_form2); | 5017 address_forms.push_back(address_form2); |
| 4968 FormsSeen(address_forms); | 5018 FormsSeen(address_forms); |
| 5019 ExpectFillableFormParsedUkm(2 /* num_fillable_forms_parsed */); |
| 4969 | 5020 |
| 4970 ManuallyFillAddressForm("Flo", "Master", "77401-8294", "US", &address_form1); | 5021 ManuallyFillAddressForm("Flo", "Master", "77401-8294", "US", &address_form1); |
| 4971 FormSubmitted(address_form1); | 5022 FormSubmitted(address_form1); |
| 4972 | 5023 |
| 4973 ManuallyFillAddressForm("Flo", "Master", "77401-1234", "US", &address_form2); | 5024 ManuallyFillAddressForm("Flo", "Master", "77401-1234", "US", &address_form2); |
| 4974 FormSubmitted(address_form2); | 5025 FormSubmitted(address_form2); |
| 4975 | 5026 |
| 4976 // Set up our credit card form data. | 5027 // Set up our credit card form data. |
| 4977 FormData credit_card_form; | 5028 FormData credit_card_form; |
| 4978 CreateTestCreditCardFormData(&credit_card_form, true, false); | 5029 CreateTestCreditCardFormData(&credit_card_form, true, false); |
| 4979 FormsSeen(std::vector<FormData>(1, credit_card_form)); | 5030 FormsSeen(std::vector<FormData>(1, credit_card_form)); |
| 5031 ExpectFillableFormParsedUkm(3 /* num_fillable_forms_parsed */); |
| 4980 | 5032 |
| 4981 // Edit the data, but don't include a name, and submit. | 5033 // Edit the data, but don't include a name, and submit. |
| 4982 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); | 5034 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); |
| 4983 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 5035 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
| 4984 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 5036 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
| 4985 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5037 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 4986 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5038 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 4987 | 5039 |
| 4988 base::HistogramTester histogram_tester; | 5040 base::HistogramTester histogram_tester; |
| 4989 | 5041 |
| 4990 // Neither a local save nor an upload should happen in this case. | 5042 // Neither a local save nor an upload should happen in this case. |
| 4991 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5043 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4992 FormSubmitted(credit_card_form); | 5044 FormSubmitted(credit_card_form); |
| 4993 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5045 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4994 | 5046 |
| 4995 // Verify that the correct histogram entry (and only that) was logged. | 5047 // Verify that the correct histogram entry (and only that) was logged. |
| 4996 histogram_tester.ExpectUniqueSample( | 5048 histogram_tester.ExpectUniqueSample( |
| 4997 "Autofill.CardUploadDecisionExpanded", | 5049 "Autofill.CardUploadDecisionExpanded", |
| 4998 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1); | 5050 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS, 1); |
| 4999 // Verify that the correct UKM was logged. | 5051 // Verify that the correct UKM was logged. |
| 5000 ExpectUniqueCardUploadDecisionUkm( | 5052 ExpectCardUploadDecisionUkm( |
| 5001 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); | 5053 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); |
| 5002 } | 5054 } |
| 5003 | 5055 |
| 5004 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 5056 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5005 #if defined(OS_ANDROID) | 5057 #if defined(OS_ANDROID) |
| 5006 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch DISABLED_UploadCreditCard
_ZipCodesHavePrefixMatch | 5058 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch DISABLED_UploadCreditCard
_ZipCodesHavePrefixMatch |
| 5007 #else | 5059 #else |
| 5008 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch UploadCreditCard_ZipCodes
HavePrefixMatch | 5060 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch UploadCreditCard_ZipCodes
HavePrefixMatch |
| 5009 #endif | 5061 #endif |
| 5010 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch) { | 5062 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5045 // One zip is a prefix of the other, upload should happen. | 5097 // One zip is a prefix of the other, upload should happen. |
| 5046 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5098 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5047 FormSubmitted(credit_card_form); | 5099 FormSubmitted(credit_card_form); |
| 5048 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 5100 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 5049 | 5101 |
| 5050 // Verify that the correct histogram entry (and only that) was logged. | 5102 // Verify that the correct histogram entry (and only that) was logged. |
| 5051 histogram_tester.ExpectUniqueSample( | 5103 histogram_tester.ExpectUniqueSample( |
| 5052 "Autofill.CardUploadDecisionExpanded", | 5104 "Autofill.CardUploadDecisionExpanded", |
| 5053 AutofillMetrics::UPLOAD_OFFERED, 1); | 5105 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 5054 // Verify that the correct UKM was logged. | 5106 // Verify that the correct UKM was logged. |
| 5055 ExpectUniqueCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); | 5107 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); |
| 5056 } | 5108 } |
| 5057 | 5109 |
| 5058 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 5110 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5059 #if defined(OS_ANDROID) | 5111 #if defined(OS_ANDROID) |
| 5060 #define MAYBE_UploadCreditCard_NoZipCodeAvailable DISABLED_UploadCreditCard_NoZi
pCodeAvailable | 5112 #define MAYBE_UploadCreditCard_NoZipCodeAvailable DISABLED_UploadCreditCard_NoZi
pCodeAvailable |
| 5061 #else | 5113 #else |
| 5062 #define MAYBE_UploadCreditCard_NoZipCodeAvailable UploadCreditCard_NoZipCodeAvai
lable | 5114 #define MAYBE_UploadCreditCard_NoZipCodeAvailable UploadCreditCard_NoZipCodeAvai
lable |
| 5063 #endif | 5115 #endif |
| 5064 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoZipCodeAvailable) { | 5116 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoZipCodeAvailable) { |
| 5065 EnableUkmLogging(); | 5117 EnableUkmLogging(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5098 // Neither a local save nor an upload should happen in this case. | 5150 // Neither a local save nor an upload should happen in this case. |
| 5099 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5151 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5100 FormSubmitted(credit_card_form); | 5152 FormSubmitted(credit_card_form); |
| 5101 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5153 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5102 | 5154 |
| 5103 // Verify that the correct histogram entry (and only that) was logged. | 5155 // Verify that the correct histogram entry (and only that) was logged. |
| 5104 histogram_tester.ExpectUniqueSample( | 5156 histogram_tester.ExpectUniqueSample( |
| 5105 "Autofill.CardUploadDecisionExpanded", | 5157 "Autofill.CardUploadDecisionExpanded", |
| 5106 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1); | 5158 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, 1); |
| 5107 // Verify that the correct UKM was logged. | 5159 // Verify that the correct UKM was logged. |
| 5108 ExpectUniqueCardUploadDecisionUkm( | 5160 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); |
| 5109 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); | |
| 5110 } | 5161 } |
| 5111 | 5162 |
| 5112 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 5163 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5113 #if defined(OS_ANDROID) | 5164 #if defined(OS_ANDROID) |
| 5114 #define MAYBE_UploadCreditCard_NamesMatchLoosely DISABLED_UploadCreditCard_Names
MatchLoosely | 5165 #define MAYBE_UploadCreditCard_NamesMatchLoosely DISABLED_UploadCreditCard_Names
MatchLoosely |
| 5115 #else | 5166 #else |
| 5116 #define MAYBE_UploadCreditCard_NamesMatchLoosely UploadCreditCard_NamesMatchLoos
ely | 5167 #define MAYBE_UploadCreditCard_NamesMatchLoosely UploadCreditCard_NamesMatchLoos
ely |
| 5117 #endif | 5168 #endif |
| 5118 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NamesMatchLoosely) { | 5169 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NamesMatchLoosely) { |
| 5119 EnableUkmLogging(); | 5170 EnableUkmLogging(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5156 // Names match loosely, upload should happen. | 5207 // Names match loosely, upload should happen. |
| 5157 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5208 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5158 FormSubmitted(credit_card_form); | 5209 FormSubmitted(credit_card_form); |
| 5159 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 5210 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 5160 | 5211 |
| 5161 // Verify that the correct histogram entry (and only that) was logged. | 5212 // Verify that the correct histogram entry (and only that) was logged. |
| 5162 histogram_tester.ExpectUniqueSample( | 5213 histogram_tester.ExpectUniqueSample( |
| 5163 "Autofill.CardUploadDecisionExpanded", | 5214 "Autofill.CardUploadDecisionExpanded", |
| 5164 AutofillMetrics::UPLOAD_OFFERED, 1); | 5215 AutofillMetrics::UPLOAD_OFFERED, 1); |
| 5165 // Verify that the correct UKM was logged. | 5216 // Verify that the correct UKM was logged. |
| 5166 ExpectUniqueCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); | 5217 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); |
| 5167 } | 5218 } |
| 5168 | 5219 |
| 5169 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 5220 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5170 #if defined(OS_ANDROID) | 5221 #if defined(OS_ANDROID) |
| 5171 #define MAYBE_UploadCreditCard_NamesHaveToMatch DISABLED_UploadCreditCard_NamesH
aveToMatch | 5222 #define MAYBE_UploadCreditCard_NamesHaveToMatch DISABLED_UploadCreditCard_NamesH
aveToMatch |
| 5172 #else | 5223 #else |
| 5173 #define MAYBE_UploadCreditCard_NamesHaveToMatch UploadCreditCard_NamesHaveToMatc
h | 5224 #define MAYBE_UploadCreditCard_NamesHaveToMatch UploadCreditCard_NamesHaveToMatc
h |
| 5174 #endif | 5225 #endif |
| 5175 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NamesHaveToMatch) { | 5226 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NamesHaveToMatch) { |
| 5176 EnableUkmLogging(); | 5227 EnableUkmLogging(); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5210 // Names are required to match, upload should not happen. | 5261 // Names are required to match, upload should not happen. |
| 5211 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5262 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5212 FormSubmitted(credit_card_form); | 5263 FormSubmitted(credit_card_form); |
| 5213 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5264 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5214 | 5265 |
| 5215 // Verify that the correct histogram entry (and only that) was logged. | 5266 // Verify that the correct histogram entry (and only that) was logged. |
| 5216 histogram_tester.ExpectUniqueSample( | 5267 histogram_tester.ExpectUniqueSample( |
| 5217 "Autofill.CardUploadDecisionExpanded", | 5268 "Autofill.CardUploadDecisionExpanded", |
| 5218 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, 1); | 5269 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES, 1); |
| 5219 // Verify that the correct UKM was logged. | 5270 // Verify that the correct UKM was logged. |
| 5220 ExpectUniqueCardUploadDecisionUkm( | 5271 ExpectCardUploadDecisionUkm( |
| 5221 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); | 5272 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); |
| 5222 | 5273 |
| 5223 rappor::TestRapporServiceImpl* rappor_service = | 5274 rappor::TestRapporServiceImpl* rappor_service = |
| 5224 autofill_client_.test_rappor_service(); | 5275 autofill_client_.test_rappor_service(); |
| 5225 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5276 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 5226 std::string sample; | 5277 std::string sample; |
| 5227 rappor::RapporType type; | 5278 rappor::RapporType type; |
| 5228 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 5279 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 5229 "Autofill.CardUploadNotOfferedConflictingNames", &sample, &type)); | 5280 "Autofill.CardUploadNotOfferedConflictingNames", &sample, &type)); |
| 5230 EXPECT_EQ("myform.com", sample); | 5281 EXPECT_EQ("myform.com", sample); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5271 // The save prompt should be shown instead of doing an upload. | 5322 // The save prompt should be shown instead of doing an upload. |
| 5272 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); | 5323 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
| 5273 FormSubmitted(credit_card_form); | 5324 FormSubmitted(credit_card_form); |
| 5274 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5325 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5275 | 5326 |
| 5276 // Verify that the correct histogram entry (and only that) was logged. | 5327 // Verify that the correct histogram entry (and only that) was logged. |
| 5277 histogram_tester.ExpectUniqueSample( | 5328 histogram_tester.ExpectUniqueSample( |
| 5278 "Autofill.CardUploadDecisionExpanded", | 5329 "Autofill.CardUploadDecisionExpanded", |
| 5279 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, 1); | 5330 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED, 1); |
| 5280 // Verify that the correct UKM was logged. | 5331 // Verify that the correct UKM was logged. |
| 5281 ExpectUniqueCardUploadDecisionUkm( | 5332 ExpectCardUploadDecisionUkm( |
| 5282 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); | 5333 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); |
| 5283 } | 5334 } |
| 5284 | 5335 |
| 5285 // Verify that typing "gmail" will match "theking@gmail.com" and | 5336 // Verify that typing "gmail" will match "theking@gmail.com" and |
| 5286 // "buddy@gmail.com" when substring matching is enabled. | 5337 // "buddy@gmail.com" when substring matching is enabled. |
| 5287 TEST_F(AutofillManagerTest, DisplaySuggestionsWithMatchingTokens) { | 5338 TEST_F(AutofillManagerTest, DisplaySuggestionsWithMatchingTokens) { |
| 5288 // Token matching is currently behind a flag. | 5339 // Token matching is currently behind a flag. |
| 5289 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 5340 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 5290 switches::kEnableSuggestionsWithSubstringMatch); | 5341 switches::kEnableSuggestionsWithSubstringMatch); |
| 5291 | 5342 |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5764 | 5815 |
| 5765 FormFieldData field; | 5816 FormFieldData field; |
| 5766 test::CreateTestFormField("Field 1", "field1", "", "text", &field); | 5817 test::CreateTestFormField("Field 1", "field1", "", "text", &field); |
| 5767 form.fields.push_back(field); | 5818 form.fields.push_back(field); |
| 5768 test::CreateTestFormField("Field 2", "field2", "", "text", &field); | 5819 test::CreateTestFormField("Field 2", "field2", "", "text", &field); |
| 5769 form.fields.push_back(field); | 5820 form.fields.push_back(field); |
| 5770 test::CreateTestFormField("Field 3", "field3", "", "text", &field); | 5821 test::CreateTestFormField("Field 3", "field3", "", "text", &field); |
| 5771 form.fields.push_back(field); | 5822 form.fields.push_back(field); |
| 5772 | 5823 |
| 5773 auto form_structure = base::MakeUnique<TestFormStructure>(form); | 5824 auto form_structure = base::MakeUnique<TestFormStructure>(form); |
| 5774 form_structure->DetermineHeuristicTypes(); | 5825 form_structure->DetermineHeuristicTypes(nullptr /* ukm_service */); |
| 5775 // Make sure the form can not be autofilled now. | 5826 // Make sure the form can not be autofilled now. |
| 5776 ASSERT_EQ(0u, form_structure->autofill_count()); | 5827 ASSERT_EQ(0u, form_structure->autofill_count()); |
| 5777 for (size_t idx = 0; idx < form_structure->field_count(); ++idx) { | 5828 for (size_t idx = 0; idx < form_structure->field_count(); ++idx) { |
| 5778 ASSERT_EQ(UNKNOWN_TYPE, form_structure->field(idx)->heuristic_type()); | 5829 ASSERT_EQ(UNKNOWN_TYPE, form_structure->field(idx)->heuristic_type()); |
| 5779 } | 5830 } |
| 5780 | 5831 |
| 5781 // Prepare and set known server fields. | 5832 // Prepare and set known server fields. |
| 5782 const std::vector<ServerFieldType> heuristic_types(form.fields.size(), | 5833 const std::vector<ServerFieldType> heuristic_types(form.fields.size(), |
| 5783 UNKNOWN_TYPE); | 5834 UNKNOWN_TYPE); |
| 5784 const std::vector<ServerFieldType> server_types{NAME_FIRST, NAME_MIDDLE, | 5835 const std::vector<ServerFieldType> server_types{NAME_FIRST, NAME_MIDDLE, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5839 FormsSeen({form}); | 5890 FormsSeen({form}); |
| 5840 | 5891 |
| 5841 // Suggestions should be displayed. | 5892 // Suggestions should be displayed. |
| 5842 for (const FormFieldData& field : form.fields) { | 5893 for (const FormFieldData& field : form.fields) { |
| 5843 GetAutofillSuggestions(form, field); | 5894 GetAutofillSuggestions(form, field); |
| 5844 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 5895 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); |
| 5845 } | 5896 } |
| 5846 } | 5897 } |
| 5847 | 5898 |
| 5848 } // namespace autofill | 5899 } // namespace autofill |
| OLD | NEW |