| 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 4795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4806 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 4806 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 4807 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING | 4807 credit_card_form.fields[4].value = ASCIIToUTF16(""); // CVC MISSING |
| 4808 | 4808 |
| 4809 base::HistogramTester histogram_tester; | 4809 base::HistogramTester histogram_tester; |
| 4810 | 4810 |
| 4811 // Neither a local save nor an upload should happen in this case. | 4811 // Neither a local save nor an upload should happen in this case. |
| 4812 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4812 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4813 FormSubmitted(credit_card_form); | 4813 FormSubmitted(credit_card_form); |
| 4814 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4814 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4815 | 4815 |
| 4816 // Verify that the correct histogram entries were logged. | 4816 // Verify that the correct histogram entry (and only that) was logged. |
| 4817 ExpectCardUploadDecision(histogram_tester, | 4817 ExpectUniqueCardUploadDecision(histogram_tester, |
| 4818 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 4818 AutofillMetrics::CVC_VALUE_NOT_FOUND); |
| 4819 // Verify that the correct UKM was logged. | 4819 // Verify that the correct UKM was logged. |
| 4820 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 4820 ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_VALUE_NOT_FOUND); |
| 4821 | 4821 |
| 4822 rappor::TestRapporServiceImpl* rappor_service = | 4822 rappor::TestRapporServiceImpl* rappor_service = |
| 4823 autofill_client_.test_rappor_service(); | 4823 autofill_client_.test_rappor_service(); |
| 4824 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4824 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 4825 std::string sample; | 4825 std::string sample; |
| 4826 rappor::RapporType type; | 4826 rappor::RapporType type; |
| 4827 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4827 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 4828 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 4828 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
| 4829 EXPECT_EQ("myform.com", sample); | 4829 EXPECT_EQ("myform.com", sample); |
| 4830 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 4830 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4863 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 4863 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 4864 credit_card_form.fields[4].value = ASCIIToUTF16("1234"); | 4864 credit_card_form.fields[4].value = ASCIIToUTF16("1234"); |
| 4865 | 4865 |
| 4866 base::HistogramTester histogram_tester; | 4866 base::HistogramTester histogram_tester; |
| 4867 | 4867 |
| 4868 // Neither a local save nor an upload should happen in this case. | 4868 // Neither a local save nor an upload should happen in this case. |
| 4869 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4869 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4870 FormSubmitted(credit_card_form); | 4870 FormSubmitted(credit_card_form); |
| 4871 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 4871 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 4872 | 4872 |
| 4873 // Verify that the correct histogram entries were logged. | 4873 // Verify that the correct histogram entry (and only that) was logged. |
| 4874 ExpectCardUploadDecision(histogram_tester, | 4874 ExpectUniqueCardUploadDecision(histogram_tester, |
| 4875 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 4875 AutofillMetrics::INVALID_CVC_VALUE); |
| 4876 // Verify that the correct UKM was logged. | 4876 // Verify that the correct UKM was logged. |
| 4877 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 4877 ExpectCardUploadDecisionUkm(AutofillMetrics::INVALID_CVC_VALUE); |
| 4878 | 4878 |
| 4879 rappor::TestRapporServiceImpl* rappor_service = | 4879 rappor::TestRapporServiceImpl* rappor_service = |
| 4880 autofill_client_.test_rappor_service(); | 4880 autofill_client_.test_rappor_service(); |
| 4881 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 4881 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 4882 std::string sample; | 4882 std::string sample; |
| 4883 rappor::RapporType type; | 4883 rappor::RapporType type; |
| 4884 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 4884 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 4885 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 4885 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
| 4886 EXPECT_EQ("myform.com", sample); | 4886 EXPECT_EQ("myform.com", sample); |
| 4887 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 4887 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4958 | 4958 |
| 4959 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 4959 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 4960 #if defined(OS_ANDROID) | 4960 #if defined(OS_ANDROID) |
| 4961 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \ | 4961 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \ |
| 4962 DISABLED_UploadCreditCard_NoCvcFieldOnForm | 4962 DISABLED_UploadCreditCard_NoCvcFieldOnForm |
| 4963 #else | 4963 #else |
| 4964 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \ | 4964 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm \ |
| 4965 UploadCreditCard_NoCvcFieldOnForm | 4965 UploadCreditCard_NoCvcFieldOnForm |
| 4966 #endif | 4966 #endif |
| 4967 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoCvcFieldOnForm) { | 4967 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_NoCvcFieldOnForm) { |
| 4968 EnableUkmLogging(); |
| 4969 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4970 |
| 4971 // Remove the profiles that were created in the TestPersonalDataManager |
| 4972 // constructor because they would result in conflicting names that would |
| 4973 // prevent the upload. |
| 4974 personal_data_.ClearAutofillProfiles(); |
| 4975 |
| 4976 // Create, fill and submit an address form in order to establish a recent |
| 4977 // profile which can be selected for the upload request. |
| 4978 FormData address_form; |
| 4979 test::CreateTestAddressFormData(&address_form); |
| 4980 FormsSeen(std::vector<FormData>(1, address_form)); |
| 4981 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); |
| 4982 FormSubmitted(address_form); |
| 4983 |
| 4984 // Set up our credit card form data. Note that CVC field is missing. |
| 4985 FormData credit_card_form; |
| 4986 credit_card_form.name = ASCIIToUTF16("MyForm"); |
| 4987 credit_card_form.origin = GURL("https://myform.com/form.html"); |
| 4988 credit_card_form.action = GURL("https://myform.com/submit.html"); |
| 4989 |
| 4990 FormFieldData field; |
| 4991 test::CreateTestFormField("Card Name", "cardname", "", "text", &field); |
| 4992 credit_card_form.fields.push_back(field); |
| 4993 test::CreateTestFormField("Card Number", "cardnumber", "", "text", &field); |
| 4994 credit_card_form.fields.push_back(field); |
| 4995 test::CreateTestFormField("Expiration Month", "ccmonth", "", "text", &field); |
| 4996 credit_card_form.fields.push_back(field); |
| 4997 test::CreateTestFormField("Expiration Year", "ccyear", "", "text", &field); |
| 4998 credit_card_form.fields.push_back(field); |
| 4999 |
| 5000 FormsSeen(std::vector<FormData>(1, credit_card_form)); |
| 5001 |
| 5002 // Edit the data, and submit. |
| 5003 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); |
| 5004 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
| 5005 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
| 5006 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5007 |
| 5008 base::HistogramTester histogram_tester; |
| 5009 |
| 5010 // Upload should not happen because user did not provide CVC. |
| 5011 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5012 FormSubmitted(credit_card_form); |
| 5013 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5014 |
| 5015 // Verify that the correct histogram entries were logged. |
| 5016 ExpectUniqueCardUploadDecision(histogram_tester, |
| 5017 AutofillMetrics::CVC_FIELD_NOT_FOUND); |
| 5018 // Verify that the correct UKM was logged. |
| 5019 ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_FIELD_NOT_FOUND); |
| 5020 } |
| 5021 |
| 5022 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5023 #if defined(OS_ANDROID) |
| 5024 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc \ |
| 5025 DISABLED_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc |
| 5026 #else |
| 5027 #define MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc \ |
| 5028 UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc |
| 5029 #endif |
| 5030 TEST_F(AutofillManagerTest, |
| 5031 MAYBE_UploadCreditCard_NoCvcFieldOnForm_UserEntersCvc) { |
| 4968 EnableAutofillUpstreamRequestCvcIfMissingExperimentAndUkmLogging(); | 5032 EnableAutofillUpstreamRequestCvcIfMissingExperimentAndUkmLogging(); |
| 4969 autofill_manager_->set_credit_card_upload_enabled(true); | 5033 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4970 | 5034 |
| 4971 // Remove the profiles that were created in the TestPersonalDataManager | 5035 // Remove the profiles that were created in the TestPersonalDataManager |
| 4972 // constructor because they would result in conflicting names that would | 5036 // constructor because they would result in conflicting names that would |
| 4973 // prevent the upload. | 5037 // prevent the upload. |
| 4974 personal_data_.ClearAutofillProfiles(); | 5038 personal_data_.ClearAutofillProfiles(); |
| 4975 | 5039 |
| 4976 // Create, fill and submit an address form in order to establish a recent | 5040 // Create, fill and submit an address form in order to establish a recent |
| 4977 // profile which can be selected for the upload request. | 5041 // profile which can be selected for the upload request. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 5006 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5070 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5007 | 5071 |
| 5008 base::HistogramTester histogram_tester; | 5072 base::HistogramTester histogram_tester; |
| 5009 | 5073 |
| 5010 // Upload should still happen as long as the user provides CVC in the bubble. | 5074 // Upload should still happen as long as the user provides CVC in the bubble. |
| 5011 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5075 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5012 FormSubmitted(credit_card_form); | 5076 FormSubmitted(credit_card_form); |
| 5013 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 5077 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 5014 | 5078 |
| 5015 // Verify that the correct histogram entries were logged. | 5079 // Verify that the correct histogram entries were logged. |
| 5080 ExpectCardUploadDecision(histogram_tester, AutofillMetrics::UPLOAD_OFFERED); |
| 5016 ExpectCardUploadDecision(histogram_tester, | 5081 ExpectCardUploadDecision(histogram_tester, |
| 5017 AutofillMetrics::UPLOAD_OFFERED_NO_CVC); | 5082 AutofillMetrics::CVC_FIELD_NOT_FOUND); |
| 5018 // Verify that the correct UKM was logged. | 5083 // Verify that the correct UKM was logged. |
| 5019 ExpectMetric(internal::kUKMCardUploadDecisionMetricName, | 5084 ExpectMetric( |
| 5020 internal::kUKMCardUploadDecisionEntryName, | 5085 internal::kUKMCardUploadDecisionMetricName, |
| 5021 AutofillMetrics::UPLOAD_OFFERED_NO_CVC, | 5086 internal::kUKMCardUploadDecisionEntryName, |
| 5022 1 /* expected_num_matching_entries */); | 5087 AutofillMetrics::UPLOAD_OFFERED | AutofillMetrics::CVC_FIELD_NOT_FOUND, |
| 5088 1 /* expected_num_matching_entries */); |
| 5023 } | 5089 } |
| 5024 | 5090 |
| 5025 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 5091 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5026 #if defined(OS_ANDROID) | 5092 #if defined(OS_ANDROID) |
| 5027 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ | 5093 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ |
| 5028 DISABLED_UploadCreditCard_NoCvcFieldOnFormExperimentOff | 5094 DISABLED_UploadCreditCard_NoCvcFieldOnFormExperimentOff |
| 5029 #else | 5095 #else |
| 5030 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ | 5096 #define MAYBE_UploadCreditCard_NoCvcFieldOnFormExperimentOff \ |
| 5031 UploadCreditCard_NoCvcFieldOnFormExperimentOff | 5097 UploadCreditCard_NoCvcFieldOnFormExperimentOff |
| 5032 #endif | 5098 #endif |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5072 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 5138 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
| 5073 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5139 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5074 | 5140 |
| 5075 base::HistogramTester histogram_tester; | 5141 base::HistogramTester histogram_tester; |
| 5076 | 5142 |
| 5077 // Neither a local save nor an upload should happen in this case. | 5143 // Neither a local save nor an upload should happen in this case. |
| 5078 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5144 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5079 FormSubmitted(credit_card_form); | 5145 FormSubmitted(credit_card_form); |
| 5080 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5146 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5081 | 5147 |
| 5082 // Verify that the correct histogram entries were logged. | 5148 // Verify that the correct histogram entry (and only that) was logged. |
| 5083 ExpectCardUploadDecision(histogram_tester, | 5149 ExpectUniqueCardUploadDecision(histogram_tester, |
| 5084 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 5150 AutofillMetrics::CVC_FIELD_NOT_FOUND); |
| 5085 // Verify that the correct UKM was logged. | 5151 // Verify that the correct UKM was logged. |
| 5086 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 5152 ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_FIELD_NOT_FOUND); |
| 5087 | 5153 |
| 5088 rappor::TestRapporServiceImpl* rappor_service = | 5154 rappor::TestRapporServiceImpl* rappor_service = |
| 5089 autofill_client_.test_rappor_service(); | 5155 autofill_client_.test_rappor_service(); |
| 5090 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5156 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 5091 std::string sample; | 5157 std::string sample; |
| 5092 rappor::RapporType type; | 5158 rappor::RapporType type; |
| 5093 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 5159 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 5094 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 5160 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
| 5095 EXPECT_EQ("myform.com", sample); | 5161 EXPECT_EQ("myform.com", sample); |
| 5096 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); | 5162 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5185 | 5251 |
| 5186 // Neither a local save nor an upload should happen in this case. | 5252 // Neither a local save nor an upload should happen in this case. |
| 5187 // Note that AutofillManager should *check* for both no CVC and no address | 5253 // Note that AutofillManager should *check* for both no CVC and no address |
| 5188 // profile, but the no CVC case should have priority over being reported. | 5254 // profile, but the no CVC case should have priority over being reported. |
| 5189 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5255 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5190 FormSubmitted(credit_card_form); | 5256 FormSubmitted(credit_card_form); |
| 5191 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5257 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5192 | 5258 |
| 5193 // Verify that the correct histogram entries were logged. | 5259 // Verify that the correct histogram entries were logged. |
| 5194 ExpectCardUploadDecision(histogram_tester, | 5260 ExpectCardUploadDecision(histogram_tester, |
| 5195 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC); | 5261 AutofillMetrics::CVC_VALUE_NOT_FOUND); |
| 5196 ExpectCardUploadDecision(histogram_tester, | 5262 ExpectCardUploadDecision(histogram_tester, |
| 5197 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS); | 5263 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS); |
| 5198 ExpectCardUploadDecision(histogram_tester, | 5264 ExpectCardUploadDecision(histogram_tester, |
| 5199 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); | 5265 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); |
| 5200 // Verify that the correct UKM was logged. | 5266 // Verify that the correct UKM was logged. |
| 5201 ExpectMetric(internal::kUKMCardUploadDecisionMetricName, | 5267 ExpectMetric(internal::kUKMCardUploadDecisionMetricName, |
| 5202 internal::kUKMCardUploadDecisionEntryName, | 5268 internal::kUKMCardUploadDecisionEntryName, |
| 5203 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC | | 5269 AutofillMetrics::CVC_VALUE_NOT_FOUND | |
| 5204 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS | | 5270 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ADDRESS | |
| 5205 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, | 5271 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE, |
| 5206 1 /* expected_num_matching_entries */); | 5272 1 /* expected_num_matching_entries */); |
| 5207 | 5273 |
| 5208 rappor::TestRapporServiceImpl* rappor_service = | 5274 rappor::TestRapporServiceImpl* rappor_service = |
| 5209 autofill_client_.test_rappor_service(); | 5275 autofill_client_.test_rappor_service(); |
| 5210 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5276 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 5211 std::string sample; | 5277 std::string sample; |
| 5212 rappor::RapporType type; | 5278 rappor::RapporType type; |
| 5213 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 5279 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 5214 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); | 5280 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); |
| 5215 EXPECT_EQ("myform.com", sample); | 5281 EXPECT_EQ("myform.com", sample); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5248 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5314 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5249 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5315 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5250 | 5316 |
| 5251 base::HistogramTester histogram_tester; | 5317 base::HistogramTester histogram_tester; |
| 5252 | 5318 |
| 5253 // Neither a local save nor an upload should happen in this case. | 5319 // Neither a local save nor an upload should happen in this case. |
| 5254 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5320 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5255 FormSubmitted(credit_card_form); | 5321 FormSubmitted(credit_card_form); |
| 5256 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5322 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5257 | 5323 |
| 5258 // Verify that the correct histogram entries were logged. | 5324 // Verify that the correct histogram entry (and only that) was logged. |
| 5259 ExpectCardUploadDecision(histogram_tester, | 5325 ExpectUniqueCardUploadDecision(histogram_tester, |
| 5260 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME); | 5326 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME); |
| 5261 // Verify that the correct UKM was logged. | 5327 // Verify that the correct UKM was logged. |
| 5262 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME); | 5328 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_NAME); |
| 5263 | 5329 |
| 5264 rappor::TestRapporServiceImpl* rappor_service = | 5330 rappor::TestRapporServiceImpl* rappor_service = |
| 5265 autofill_client_.test_rappor_service(); | 5331 autofill_client_.test_rappor_service(); |
| 5266 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5332 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 5267 std::string sample; | 5333 std::string sample; |
| 5268 rappor::RapporType type; | 5334 rappor::RapporType type; |
| 5269 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( | 5335 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( |
| 5270 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); | 5336 "Autofill.CardUploadNotOfferedNoName", &sample, &type)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5315 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5381 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5316 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5382 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5317 | 5383 |
| 5318 base::HistogramTester histogram_tester; | 5384 base::HistogramTester histogram_tester; |
| 5319 | 5385 |
| 5320 // Neither a local save nor an upload should happen in this case. | 5386 // Neither a local save nor an upload should happen in this case. |
| 5321 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5387 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5322 FormSubmitted(credit_card_form); | 5388 FormSubmitted(credit_card_form); |
| 5323 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5389 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5324 | 5390 |
| 5325 // Verify that the correct histogram entries were logged. | 5391 // Verify that the correct histogram entry (and only that) was logged. |
| 5326 ExpectCardUploadDecision( | 5392 ExpectUniqueCardUploadDecision( |
| 5327 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); | 5393 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); |
| 5328 // Verify that the correct UKM was logged. | 5394 // Verify that the correct UKM was logged. |
| 5329 ExpectCardUploadDecisionUkm( | 5395 ExpectCardUploadDecisionUkm( |
| 5330 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); | 5396 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_ZIPS); |
| 5331 } | 5397 } |
| 5332 | 5398 |
| 5333 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 5399 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5334 #if defined(OS_ANDROID) | 5400 #if defined(OS_ANDROID) |
| 5335 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch \ | 5401 #define MAYBE_UploadCreditCard_ZipCodesHavePrefixMatch \ |
| 5336 DISABLED_UploadCreditCard_ZipCodesHavePrefixMatch | 5402 DISABLED_UploadCreditCard_ZipCodesHavePrefixMatch |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5425 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5491 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5426 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5492 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5427 | 5493 |
| 5428 base::HistogramTester histogram_tester; | 5494 base::HistogramTester histogram_tester; |
| 5429 | 5495 |
| 5430 // Neither a local save nor an upload should happen in this case. | 5496 // Neither a local save nor an upload should happen in this case. |
| 5431 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5497 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5432 FormSubmitted(credit_card_form); | 5498 FormSubmitted(credit_card_form); |
| 5433 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5499 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5434 | 5500 |
| 5435 // Verify that the correct histogram entries were logged. | 5501 // Verify that the correct histogram entry (and only that) was logged. |
| 5436 ExpectCardUploadDecision(histogram_tester, | 5502 ExpectUniqueCardUploadDecision( |
| 5437 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); | 5503 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); |
| 5438 // Verify that the correct UKM was logged. | 5504 // Verify that the correct UKM was logged. |
| 5439 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); | 5505 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_NOT_OFFERED_NO_ZIP_CODE); |
| 5440 } | 5506 } |
| 5441 | 5507 |
| 5442 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 5508 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5443 #if defined(OS_ANDROID) | 5509 #if defined(OS_ANDROID) |
| 5444 #define MAYBE_UploadCreditCard_NamesMatchLoosely \ | 5510 #define MAYBE_UploadCreditCard_NamesMatchLoosely \ |
| 5445 DISABLED_UploadCreditCard_NamesMatchLoosely | 5511 DISABLED_UploadCreditCard_NamesMatchLoosely |
| 5446 #else | 5512 #else |
| 5447 #define MAYBE_UploadCreditCard_NamesMatchLoosely \ | 5513 #define MAYBE_UploadCreditCard_NamesMatchLoosely \ |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5538 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5604 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5539 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5605 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5540 | 5606 |
| 5541 base::HistogramTester histogram_tester; | 5607 base::HistogramTester histogram_tester; |
| 5542 | 5608 |
| 5543 // Names are required to match, upload should not happen. | 5609 // Names are required to match, upload should not happen. |
| 5544 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5610 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5545 FormSubmitted(credit_card_form); | 5611 FormSubmitted(credit_card_form); |
| 5546 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5612 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5547 | 5613 |
| 5548 // Verify that the correct histogram entries were logged. | 5614 // Verify that the correct histogram entry (and only that) was logged. |
| 5549 ExpectCardUploadDecision( | 5615 ExpectUniqueCardUploadDecision( |
| 5550 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); | 5616 histogram_tester, AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); |
| 5551 // Verify that the correct UKM was logged. | 5617 // Verify that the correct UKM was logged. |
| 5552 ExpectCardUploadDecisionUkm( | 5618 ExpectCardUploadDecisionUkm( |
| 5553 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); | 5619 AutofillMetrics::UPLOAD_NOT_OFFERED_CONFLICTING_NAMES); |
| 5554 | 5620 |
| 5555 rappor::TestRapporServiceImpl* rappor_service = | 5621 rappor::TestRapporServiceImpl* rappor_service = |
| 5556 autofill_client_.test_rappor_service(); | 5622 autofill_client_.test_rappor_service(); |
| 5557 EXPECT_EQ(1, rappor_service->GetReportsCount()); | 5623 EXPECT_EQ(1, rappor_service->GetReportsCount()); |
| 5558 std::string sample; | 5624 std::string sample; |
| 5559 rappor::RapporType type; | 5625 rappor::RapporType type; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5600 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5666 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5601 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5667 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5602 | 5668 |
| 5603 base::HistogramTester histogram_tester; | 5669 base::HistogramTester histogram_tester; |
| 5604 | 5670 |
| 5605 // The save prompt should be shown instead of doing an upload. | 5671 // The save prompt should be shown instead of doing an upload. |
| 5606 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); | 5672 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)); |
| 5607 FormSubmitted(credit_card_form); | 5673 FormSubmitted(credit_card_form); |
| 5608 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); | 5674 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded()); |
| 5609 | 5675 |
| 5610 // Verify that the correct histogram entries were logged. | 5676 // Verify that the correct histogram entry (and only that) was logged. |
| 5611 ExpectCardUploadDecision( | 5677 ExpectUniqueCardUploadDecision( |
| 5612 histogram_tester, | 5678 histogram_tester, |
| 5613 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); | 5679 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); |
| 5614 // Verify that the correct UKM was logged. | 5680 // Verify that the correct UKM was logged. |
| 5615 ExpectCardUploadDecisionUkm( | 5681 ExpectCardUploadDecisionUkm( |
| 5616 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); | 5682 AutofillMetrics::UPLOAD_NOT_OFFERED_GET_UPLOAD_DETAILS_FAILED); |
| 5617 } | 5683 } |
| 5618 | 5684 |
| 5619 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. | 5685 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. |
| 5620 #if defined(OS_ANDROID) | 5686 #if defined(OS_ANDROID) |
| 5621 #define MAYBE_DuplicateMaskedCreditCard DISABLED_DuplicatedMaskedCreditCard | 5687 #define MAYBE_DuplicateMaskedCreditCard DISABLED_DuplicatedMaskedCreditCard |
| (...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6269 | 6335 |
| 6270 // Wait for upload to complete (will check expected types as well). | 6336 // Wait for upload to complete (will check expected types as well). |
| 6271 autofill_manager_->WaitForAsyncUploadProcess(); | 6337 autofill_manager_->WaitForAsyncUploadProcess(); |
| 6272 | 6338 |
| 6273 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); | 6339 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); |
| 6274 EXPECT_NE(uploaded_available_types.end(), | 6340 EXPECT_NE(uploaded_available_types.end(), |
| 6275 uploaded_available_types.find(autofill::PASSWORD)); | 6341 uploaded_available_types.find(autofill::PASSWORD)); |
| 6276 } | 6342 } |
| 6277 | 6343 |
| 6278 } // namespace autofill | 6344 } // namespace autofill |
| OLD | NEW |