| Index: components/autofill/core/browser/autofill_manager_unittest.cc
|
| diff --git a/components/autofill/core/browser/autofill_manager_unittest.cc b/components/autofill/core/browser/autofill_manager_unittest.cc
|
| index bf3f7ba7b23ccc62a939e8e43fb723857a98335b..c9da4f2c188d01e21f5bac2ea579b944a633b59e 100644
|
| --- a/components/autofill/core/browser/autofill_manager_unittest.cc
|
| +++ b/components/autofill/core/browser/autofill_manager_unittest.cc
|
| @@ -4813,11 +4813,11 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcUnavailable) {
|
| FormSubmitted(credit_card_form);
|
| EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
|
|
|
| - // Verify that the correct histogram entries were logged.
|
| - ExpectCardUploadDecision(histogram_tester,
|
| - AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
|
| + // Verify that the correct histogram entry (and only that) was logged.
|
| + ExpectUniqueCardUploadDecision(histogram_tester,
|
| + AutofillMetrics::CVC_VALUE_NOT_FOUND);
|
| // Verify that the correct UKM was logged.
|
| - ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
|
| + ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_VALUE_NOT_FOUND);
|
|
|
| rappor::TestRapporServiceImpl* rappor_service =
|
| autofill_client_.test_rappor_service();
|
| @@ -4870,11 +4870,11 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcInvalidLength) {
|
| FormSubmitted(credit_card_form);
|
| EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
|
|
|
| - // Verify that the correct histogram entries were logged.
|
| - ExpectCardUploadDecision(histogram_tester,
|
| - AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
|
| + // Verify that the correct histogram entry (and only that) was logged.
|
| + ExpectUniqueCardUploadDecision(histogram_tester,
|
| + AutofillMetrics::INVALID_CVC_VALUE);
|
| // Verify that the correct UKM was logged.
|
| - ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
|
| + ExpectCardUploadDecisionUkm(AutofillMetrics::INVALID_CVC_VALUE);
|
|
|
| rappor::TestRapporServiceImpl* rappor_service =
|
| autofill_client_.test_rappor_service();
|
| @@ -4965,6 +4965,70 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_MultipleCvcFields) {
|
| UploadCreditCard_NoCvcFieldOnForm
|
| #endif
|
| TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoCvcFieldOnForm) {
|
| + EnableUkmLogging();
|
| + autofill_manager_->set_credit_card_upload_enabled(true);
|
| +
|
| + // Remove the profiles that were created in the TestPersonalDataManager
|
| + // constructor because they would result in conflicting names that would
|
| + // prevent the upload.
|
| + personal_data_.ClearAutofillProfiles();
|
| +
|
| + // Create, fill and submit an address form in order to establish a recent
|
| + // profile which can be selected for the upload request.
|
| + FormData address_form;
|
| + test::CreateTestAddressFormData(&address_form);
|
| + FormsSeen(std::vector<FormData>(1, address_form));
|
| + ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form);
|
| + FormSubmitted(address_form);
|
| +
|
| + // Set up our credit card form data. Note that CVC field is missing.
|
| + FormData credit_card_form;
|
| + credit_card_form.name = ASCIIToUTF16("MyForm");
|
| + credit_card_form.origin = GURL("https://myform.com/form.html");
|
| + credit_card_form.action = GURL("https://myform.com/submit.html");
|
| +
|
| + FormFieldData field;
|
| + test::CreateTestFormField("Card Name", "cardname", "", "text", &field);
|
| + credit_card_form.fields.push_back(field);
|
| + test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field);
|
| + credit_card_form.fields.push_back(field);
|
| + test::CreateTestFormField("Expiration Month", "ccmonth", "", "text", &field);
|
| + credit_card_form.fields.push_back(field);
|
| + test::CreateTestFormField("Expiration Year", "ccyear", "", "text", &field);
|
| + credit_card_form.fields.push_back(field);
|
| +
|
| + FormsSeen(std::vector<FormData>(1, credit_card_form));
|
| +
|
| + // Edit the data, and submit.
|
| + credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master");
|
| + credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111");
|
| + credit_card_form.fields[2].value = ASCIIToUTF16("11");
|
| + credit_card_form.fields[3].value = ASCIIToUTF16("2017");
|
| +
|
| + base::HistogramTester histogram_tester;
|
| +
|
| + // Upload should not happen because user did not provide CVC.
|
| + EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
|
| + FormSubmitted(credit_card_form);
|
| + EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
|
| +
|
| + // Verify that the correct histogram entries were logged.
|
| + ExpectUniqueCardUploadDecision(histogram_tester,
|
| + AutofillMetrics::CVC_FIELD_NOT_FOUND);
|
| + // Verify that the correct UKM was logged.
|
| + ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_FIELD_NOT_FOUND);
|
| +}
|
| +
|
| +// TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
|
| +#if defined(OS_ANDROID)
|
| +#define MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc \
|
| + DISABLED_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc
|
| +#else
|
| +#define MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc \
|
| + UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc
|
| +#endif
|
| +TEST_F(AutofillManagerTest,
|
| + MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc) {
|
| EnableAutofillUpstreamRequestCvcIfMissingExperimentAndUkmLogging();
|
| autofill_manager_->set_credit_card_upload_enabled(true);
|
|
|
| @@ -5013,13 +5077,15 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoCvcFieldOnForm) {
|
| EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
|
|
|
| // Verify that the correct histogram entries were logged.
|
| + ExpectCardUploadDecision(histogram_tester, AutofillMetrics::UPLOAD_OFFERED);
|
| ExpectCardUploadDecision(histogram_tester,
|
| - AutofillMetrics::UPLOAD_OFFERED_NO_CVC);
|
| + AutofillMetrics::CVC_FIELD_NOT_FOUND);
|
| // Verify that the correct UKM was logged.
|
| - ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
|
| - internal::kUKMCardUploadDecisionEntryName,
|
| - AutofillMetrics::UPLOAD_OFFERED_NO_CVC,
|
| - 1 /* expected_num_matching_entries */);
|
| + ExpectMetric(
|
| + internal::kUKMCardUploadDecisionMetricName,
|
| + internal::kUKMCardUploadDecisionEntryName,
|
| + AutofillMetrics::UPLOAD_OFFERED | AutofillMetrics::CVC_FIELD_NOT_FOUND,
|
| + 1 /* expected_num_matching_entries */);
|
| }
|
|
|
| // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
|
| @@ -5079,11 +5145,11 @@ TEST_F(AutofillManagerTest,
|
| FormSubmitted(credit_card_form);
|
| EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
|
|
|
| - // Verify that the correct histogram entries were logged.
|
| - ExpectCardUploadDecision(histogram_tester,
|
| - AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
|
| + // Verify that the correct histogram entry (and only that) was logged.
|
| + ExpectUniqueCardUploadDecision(histogram_tester,
|
| + AutofillMetrics::CVC_FIELD_NOT_FOUND);
|
| // Verify that the correct UKM was logged.
|
| - ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
|
| + ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_FIELD_NOT_FOUND);
|
|
|
| rappor::TestRapporServiceImpl* rappor_service =
|
| autofill_client_.test_rappor_service();
|
| @@ -5192,7 +5258,7 @@ TEST_F(AutofillManagerTest,
|
|
|
| // Verify that the correct histogram entries were logged.
|
| ExpectCardUploadDecision(histogram_tester,
|
| - AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC);
|
| + AutofillMetrics::CVC_VALUE_NOT_FOUND);
|
| ExpectCardUploadDecision(histogram_tester,
|
| AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS);
|
| ExpectCardUploadDecision(histogram_tester,
|
| @@ -5200,9 +5266,9 @@ TEST_F(AutofillManagerTest,
|
| // Verify that the correct UKM was logged.
|
| ExpectMetric(internal::kUKMCardUploadDecisionMetricName,
|
| internal::kUKMCardUploadDecisionEntryName,
|
| - AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC |
|
| - AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS |
|
| - AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE,
|
| + AutofillMetrics::CVC_VALUE_NOT_FOUND |
|
| + AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS |
|
| + AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE,
|
| 1 /* expected_num_matching_entries */);
|
|
|
| rappor::TestRapporServiceImpl* rappor_service =
|
| @@ -5255,9 +5321,9 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoNameAvailable) {
|
| FormSubmitted(credit_card_form);
|
| EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
|
|
|
| - // Verify that the correct histogram entries were logged.
|
| - ExpectCardUploadDecision(histogram_tester,
|
| - AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME);
|
| + // Verify that the correct histogram entry (and only that) was logged.
|
| + ExpectUniqueCardUploadDecision(histogram_tester,
|
| + AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME);
|
| // Verify that the correct UKM was logged.
|
| ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME);
|
|
|
| @@ -5322,8 +5388,8 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_ZipCodesConflict) {
|
| FormSubmitted(credit_card_form);
|
| EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
|
|
|
| - // Verify that the correct histogram entries were logged.
|
| - ExpectCardUploadDecision(
|
| + // Verify that the correct histogram entry (and only that) was logged.
|
| + ExpectUniqueCardUploadDecision(
|
| histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS);
|
| // Verify that the correct UKM was logged.
|
| ExpectCardUploadDecisionUkm(
|
| @@ -5432,9 +5498,9 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoZipCodeAvailable) {
|
| FormSubmitted(credit_card_form);
|
| EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
|
|
|
| - // Verify that the correct histogram entries were logged.
|
| - ExpectCardUploadDecision(histogram_tester,
|
| - AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
|
| + // Verify that the correct histogram entry (and only that) was logged.
|
| + ExpectUniqueCardUploadDecision(
|
| + histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
|
| // Verify that the correct UKM was logged.
|
| ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE);
|
| }
|
| @@ -5545,8 +5611,8 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NamesHaveToMatch) {
|
| FormSubmitted(credit_card_form);
|
| EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
|
|
|
| - // Verify that the correct histogram entries were logged.
|
| - ExpectCardUploadDecision(
|
| + // Verify that the correct histogram entry (and only that) was logged.
|
| + ExpectUniqueCardUploadDecision(
|
| histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES);
|
| // Verify that the correct UKM was logged.
|
| ExpectCardUploadDecisionUkm(
|
| @@ -5607,8 +5673,8 @@ TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_UploadDetailsFails) {
|
| FormSubmitted(credit_card_form);
|
| EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
|
|
|
| - // Verify that the correct histogram entries were logged.
|
| - ExpectCardUploadDecision(
|
| + // Verify that the correct histogram entry (and only that) was logged.
|
| + ExpectUniqueCardUploadDecision(
|
| histogram_tester,
|
| AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED);
|
| // Verify that the correct UKM was logged.
|
|
|