Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(462)

Side by Side Diff: components/autofill/core/browser/autofill_manager_unittest.cc

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

Powered by Google App Engine
This is Rietveld 408576698