| 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 #include "ui/base/l10n/l10n_util.h" | 70 #include "ui/base/l10n/l10n_util.h" |
| 71 #include "ui/gfx/geometry/rect.h" | 71 #include "ui/gfx/geometry/rect.h" |
| 72 #include "url/gurl.h" | 72 #include "url/gurl.h" |
| 73 | 73 |
| 74 using base::ASCIIToUTF16; | 74 using base::ASCIIToUTF16; |
| 75 using base::UTF8ToUTF16; | 75 using base::UTF8ToUTF16; |
| 76 using testing::_; | 76 using testing::_; |
| 77 using testing::AtLeast; | 77 using testing::AtLeast; |
| 78 using testing::Return; | 78 using testing::Return; |
| 79 using testing::SaveArg; | 79 using testing::SaveArg; |
| 80 using testing::UnorderedElementsAre; |
| 80 | 81 |
| 81 namespace autofill { | 82 namespace autofill { |
| 82 namespace { | 83 namespace { |
| 83 | 84 |
| 84 const int kDefaultPageID = 137; | 85 const int kDefaultPageID = 137; |
| 85 | 86 |
| 86 const char kUTF8MidlineEllipsis[] = | 87 const char kUTF8MidlineEllipsis[] = |
| 87 " " | 88 " " |
| 88 "\xE2\x80\xA2\xE2\x80\x86" | 89 "\xE2\x80\xA2\xE2\x80\x86" |
| 89 "\xE2\x80\xA2\xE2\x80\x86" | 90 "\xE2\x80\xA2\xE2\x80\x86" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 110 | 111 |
| 111 class TestPaymentsClient : public payments::PaymentsClient { | 112 class TestPaymentsClient : public payments::PaymentsClient { |
| 112 public: | 113 public: |
| 113 TestPaymentsClient(net::URLRequestContextGetter* context_getter, | 114 TestPaymentsClient(net::URLRequestContextGetter* context_getter, |
| 114 payments::PaymentsClientDelegate* delegate) | 115 payments::PaymentsClientDelegate* delegate) |
| 115 : PaymentsClient(context_getter, delegate), delegate_(delegate) {} | 116 : PaymentsClient(context_getter, delegate), delegate_(delegate) {} |
| 116 | 117 |
| 117 ~TestPaymentsClient() override {} | 118 ~TestPaymentsClient() override {} |
| 118 | 119 |
| 119 void GetUploadDetails(const std::vector<AutofillProfile>& addresses, | 120 void GetUploadDetails(const std::vector<AutofillProfile>& addresses, |
| 121 const std::vector<const char*>& active_experiments, |
| 120 const std::string& app_locale) override { | 122 const std::string& app_locale) override { |
| 123 active_experiments_ = active_experiments; |
| 121 delegate_->OnDidGetUploadDetails( | 124 delegate_->OnDidGetUploadDetails( |
| 122 app_locale == "en-US" ? AutofillClient::SUCCESS | 125 app_locale == "en-US" ? AutofillClient::SUCCESS |
| 123 : AutofillClient::PERMANENT_FAILURE, | 126 : AutofillClient::PERMANENT_FAILURE, |
| 124 ASCIIToUTF16("this is a context token"), | 127 ASCIIToUTF16("this is a context token"), |
| 125 std::unique_ptr<base::DictionaryValue>(nullptr)); | 128 std::unique_ptr<base::DictionaryValue>(nullptr)); |
| 126 } | 129 } |
| 127 | 130 |
| 128 void UploadCard(const payments::PaymentsClient::UploadRequestDetails& | 131 void UploadCard(const payments::PaymentsClient::UploadRequestDetails& |
| 129 request_details) override { | 132 request_details) override { |
| 133 active_experiments_ = request_details.active_experiments; |
| 130 delegate_->OnDidUploadCard(AutofillClient::SUCCESS, server_id_); | 134 delegate_->OnDidUploadCard(AutofillClient::SUCCESS, server_id_); |
| 131 } | 135 } |
| 132 | 136 |
| 133 std::string server_id_; | 137 std::string server_id_; |
| 138 std::vector<const char*> active_experiments_; |
| 134 | 139 |
| 135 private: | 140 private: |
| 136 payments::PaymentsClientDelegate* const delegate_; | 141 payments::PaymentsClientDelegate* const delegate_; |
| 137 | 142 |
| 138 DISALLOW_COPY_AND_ASSIGN(TestPaymentsClient); | 143 DISALLOW_COPY_AND_ASSIGN(TestPaymentsClient); |
| 139 }; | 144 }; |
| 140 | 145 |
| 141 class TestPersonalDataManager : public PersonalDataManager { | 146 class TestPersonalDataManager : public PersonalDataManager { |
| 142 public: | 147 public: |
| 143 TestPersonalDataManager() | 148 TestPersonalDataManager() |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 }; | 557 }; |
| 553 | 558 |
| 554 class TestAutofillManager : public AutofillManager { | 559 class TestAutofillManager : public AutofillManager { |
| 555 public: | 560 public: |
| 556 TestAutofillManager(AutofillDriver* driver, | 561 TestAutofillManager(AutofillDriver* driver, |
| 557 AutofillClient* client, | 562 AutofillClient* client, |
| 558 TestPersonalDataManager* personal_data) | 563 TestPersonalDataManager* personal_data) |
| 559 : AutofillManager(driver, client, personal_data), | 564 : AutofillManager(driver, client, personal_data), |
| 560 personal_data_(personal_data), | 565 personal_data_(personal_data), |
| 561 context_getter_(driver->GetURLRequestContext()), | 566 context_getter_(driver->GetURLRequestContext()), |
| 567 test_payments_client_(new TestPaymentsClient(context_getter_, this)), |
| 562 autofill_enabled_(true), | 568 autofill_enabled_(true), |
| 563 credit_card_upload_enabled_(false), | 569 credit_card_upload_enabled_(false), |
| 564 credit_card_was_uploaded_(false), | 570 credit_card_was_uploaded_(false), |
| 565 expected_observed_submission_(true), | 571 expected_observed_submission_(true), |
| 566 call_parent_upload_form_data_(false) { | 572 call_parent_upload_form_data_(false) { |
| 567 set_payments_client(new TestPaymentsClient(context_getter_, this)); | 573 set_payments_client(test_payments_client_); |
| 568 } | 574 } |
| 569 ~TestAutofillManager() override {} | 575 ~TestAutofillManager() override {} |
| 570 | 576 |
| 571 bool IsAutofillEnabled() const override { return autofill_enabled_; } | 577 bool IsAutofillEnabled() const override { return autofill_enabled_; } |
| 572 | 578 |
| 573 void set_autofill_enabled(bool autofill_enabled) { | 579 void set_autofill_enabled(bool autofill_enabled) { |
| 574 autofill_enabled_ = autofill_enabled; | 580 autofill_enabled_ = autofill_enabled; |
| 575 } | 581 } |
| 576 | 582 |
| 577 bool IsCreditCardUploadEnabled() override { | 583 bool IsCreditCardUploadEnabled() override { |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 } | 674 } |
| 669 | 675 |
| 670 void AddProfile(std::unique_ptr<AutofillProfile> profile) { | 676 void AddProfile(std::unique_ptr<AutofillProfile> profile) { |
| 671 personal_data_->AddProfile(std::move(profile)); | 677 personal_data_->AddProfile(std::move(profile)); |
| 672 } | 678 } |
| 673 | 679 |
| 674 void AddCreditCard(const CreditCard& credit_card) { | 680 void AddCreditCard(const CreditCard& credit_card) { |
| 675 personal_data_->AddCreditCard(credit_card); | 681 personal_data_->AddCreditCard(credit_card); |
| 676 } | 682 } |
| 677 | 683 |
| 684 const std::vector<const char*>& GetActiveExperiments() const { |
| 685 return test_payments_client_->active_experiments_; |
| 686 } |
| 687 |
| 678 int GetPackedCreditCardID(int credit_card_id) { | 688 int GetPackedCreditCardID(int credit_card_id) { |
| 679 std::string credit_card_guid = | 689 std::string credit_card_guid = |
| 680 base::StringPrintf("00000000-0000-0000-0000-%012d", credit_card_id); | 690 base::StringPrintf("00000000-0000-0000-0000-%012d", credit_card_id); |
| 681 | 691 |
| 682 return MakeFrontendID(credit_card_guid, std::string()); | 692 return MakeFrontendID(credit_card_guid, std::string()); |
| 683 } | 693 } |
| 684 | 694 |
| 685 void AddSeenForm(std::unique_ptr<FormStructure> form) { | 695 void AddSeenForm(std::unique_ptr<FormStructure> form) { |
| 686 form_structures()->push_back(std::move(form)); | 696 form_structures()->push_back(std::move(form)); |
| 687 } | 697 } |
| 688 | 698 |
| 689 void ClearFormStructures() { form_structures()->clear(); } | 699 void ClearFormStructures() { form_structures()->clear(); } |
| 690 | 700 |
| 691 void ResetPaymentsClientForCardUpload(const char* server_id) { | 701 void ResetPaymentsClientForCardUpload(const char* server_id) { |
| 692 TestPaymentsClient* payments_client = | 702 TestPaymentsClient* payments_client = |
| 693 new TestPaymentsClient(context_getter_, this); | 703 new TestPaymentsClient(context_getter_, this); |
| 694 payments_client->server_id_ = server_id; | 704 payments_client->server_id_ = server_id; |
| 695 set_payments_client(payments_client); | 705 set_payments_client(payments_client); |
| 696 } | 706 } |
| 697 | 707 |
| 698 private: | 708 private: |
| 699 void OnDidUploadCard(AutofillClient::PaymentsRpcResult result, | 709 void OnDidUploadCard(AutofillClient::PaymentsRpcResult result, |
| 700 const std::string& server_id) override { | 710 const std::string& server_id) override { |
| 701 credit_card_was_uploaded_ = true; | 711 credit_card_was_uploaded_ = true; |
| 702 AutofillManager::OnDidUploadCard(result, server_id); | 712 AutofillManager::OnDidUploadCard(result, server_id); |
| 703 }; | 713 }; |
| 704 | 714 |
| 705 TestPersonalDataManager* personal_data_; // Weak reference. | 715 TestPersonalDataManager* personal_data_; // Weak reference. |
| 706 net::URLRequestContextGetter* context_getter_; // Weak reference. | 716 net::URLRequestContextGetter* context_getter_; // Weak reference. |
| 717 TestPaymentsClient* test_payments_client_; // Weak reference. |
| 707 bool autofill_enabled_; | 718 bool autofill_enabled_; |
| 708 bool credit_card_upload_enabled_; | 719 bool credit_card_upload_enabled_; |
| 709 bool credit_card_was_uploaded_; | 720 bool credit_card_was_uploaded_; |
| 710 bool expected_observed_submission_; | 721 bool expected_observed_submission_; |
| 711 bool call_parent_upload_form_data_; | 722 bool call_parent_upload_form_data_; |
| 712 | 723 |
| 713 std::unique_ptr<base::RunLoop> run_loop_; | 724 std::unique_ptr<base::RunLoop> run_loop_; |
| 714 | 725 |
| 715 std::string submitted_form_signature_; | 726 std::string submitted_form_signature_; |
| 716 std::vector<ServerFieldTypeSet> expected_submitted_field_types_; | 727 std::vector<ServerFieldTypeSet> expected_submitted_field_types_; |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 return static_cast<CardUnmaskDelegate*>( | 1075 return static_cast<CardUnmaskDelegate*>( |
| 1065 autofill_manager_->full_card_request_.get()); | 1076 autofill_manager_->full_card_request_.get()); |
| 1066 } | 1077 } |
| 1067 | 1078 |
| 1068 void SetHttpWarningEnabled() { | 1079 void SetHttpWarningEnabled() { |
| 1069 scoped_feature_list_.InitAndEnableFeature( | 1080 scoped_feature_list_.InitAndEnableFeature( |
| 1070 security_state::kHttpFormWarningFeature); | 1081 security_state::kHttpFormWarningFeature); |
| 1071 } | 1082 } |
| 1072 | 1083 |
| 1073 void EnableAutofillUpstreamRequestCvcIfMissingExperiment() { | 1084 void EnableAutofillUpstreamRequestCvcIfMissingExperiment() { |
| 1074 scoped_feature_list_.InitWithFeatures( | 1085 scoped_feature_list_.InitAndEnableFeature( |
| 1075 {kAutofillUpstreamRequestCvcIfMissing}, {}); | 1086 kAutofillUpstreamRequestCvcIfMissing); |
| 1076 } | 1087 } |
| 1077 | 1088 |
| 1078 void DisableAutofillUpstreamUseAutofillProfileComparatorForName() { | 1089 void DisableAutofillUpstreamUseAutofillProfileComparatorForName() { |
| 1079 scoped_feature_list_.InitAndDisableFeature( | 1090 scoped_feature_list_.InitAndDisableFeature( |
| 1080 kAutofillUpstreamUseAutofillProfileComparatorForName); | 1091 kAutofillUpstreamUseAutofillProfileComparatorForName); |
| 1081 } | 1092 } |
| 1082 | 1093 |
| 1083 void ExpectUniqueFillableFormParsedUkm() { | 1094 void ExpectUniqueFillableFormParsedUkm() { |
| 1084 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); | 1095 ukm::TestUkmService* ukm_service = autofill_client_.GetTestUkmService(); |
| 1085 | 1096 |
| (...skipping 3575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4661 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 4672 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
| 4662 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 4673 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
| 4663 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 4674 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 4664 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 4675 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 4665 | 4676 |
| 4666 base::HistogramTester histogram_tester; | 4677 base::HistogramTester histogram_tester; |
| 4667 | 4678 |
| 4668 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 4679 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4669 FormSubmitted(credit_card_form); | 4680 FormSubmitted(credit_card_form); |
| 4670 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 4681 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4682 EXPECT_THAT(autofill_manager_->GetActiveExperiments(), |
| 4683 UnorderedElementsAre( |
| 4684 kAutofillUpstreamUseAutofillProfileComparatorForName.name)); |
| 4671 | 4685 |
| 4672 // Server did not send a server_id, expect copy of card is not stored. | 4686 // Server did not send a server_id, expect copy of card is not stored. |
| 4673 EXPECT_TRUE(autofill_manager_->GetCreditCards().empty()); | 4687 EXPECT_TRUE(autofill_manager_->GetCreditCards().empty()); |
| 4674 // Verify that the correct histogram entry (and only that) was logged. | 4688 // Verify that the correct histogram entry (and only that) was logged. |
| 4675 ExpectUniqueCardUploadDecision(histogram_tester, | 4689 ExpectUniqueCardUploadDecision(histogram_tester, |
| 4676 AutofillMetrics::UPLOAD_OFFERED); | 4690 AutofillMetrics::UPLOAD_OFFERED); |
| 4677 // Verify that the correct UKM was logged. | 4691 // Verify that the correct UKM was logged. |
| 4678 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); | 4692 ExpectCardUploadDecisionUkm(AutofillMetrics::UPLOAD_OFFERED); |
| 4679 // Verify the histogram entry for recent profile modification. | 4693 // Verify the histogram entry for recent profile modification. |
| 4680 histogram_tester.ExpectUniqueSample( | 4694 histogram_tester.ExpectUniqueSample( |
| 4681 "Autofill.HasModifiedProfile.CreditCardFormSubmission", true, 1); | 4695 "Autofill.HasModifiedProfile.CreditCardFormSubmission", true, 1); |
| 4682 // Verify that UMA for "DaysSincePreviousUse" was not logged because we | 4696 // Verify that UMA for "DaysSincePreviousUse" was not logged because we |
| 4683 // modified the profile. | 4697 // modified the profile. |
| 4684 histogram_tester.ExpectTotalCount( | 4698 histogram_tester.ExpectTotalCount( |
| 4685 "Autofill.DaysSincePreviousUseAtSubmission.Profile", 0); | 4699 "Autofill.DaysSincePreviousUseAtSubmission.Profile", 0); |
| 4686 } | 4700 } |
| 4687 | 4701 |
| 4702 TEST_F(AutofillManagerTest, UploadCreditCard_RequestCVCEnabled_DoesNotTrigger) { |
| 4703 EnableAutofillUpstreamRequestCvcIfMissingExperiment(); |
| 4704 |
| 4705 personal_data_.ClearCreditCards(); |
| 4706 personal_data_.ClearAutofillProfiles(); |
| 4707 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4708 |
| 4709 // Create, fill and submit an address form in order to establish a recent |
| 4710 // profile which can be selected for the upload request. |
| 4711 FormData address_form; |
| 4712 test::CreateTestAddressFormData(&address_form); |
| 4713 FormsSeen({address_form}); |
| 4714 |
| 4715 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form); |
| 4716 FormSubmitted(address_form); |
| 4717 |
| 4718 // Set up our credit card form data. |
| 4719 FormData credit_card_form; |
| 4720 CreateTestCreditCardFormData(&credit_card_form, true, false); |
| 4721 FormsSeen({credit_card_form}); |
| 4722 |
| 4723 // Edit the data, and submit. |
| 4724 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master"); |
| 4725 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
| 4726 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
| 4727 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 4728 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 4729 |
| 4730 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 4731 FormSubmitted(credit_card_form); |
| 4732 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 4733 // Submitted form included CVC, so user did not need to enter CVC. |
| 4734 EXPECT_THAT(autofill_manager_->GetActiveExperiments(), |
| 4735 UnorderedElementsAre( |
| 4736 kAutofillUpstreamUseAutofillProfileComparatorForName.name)); |
| 4737 } |
| 4738 |
| 4688 TEST_F(AutofillManagerTest, UploadCreditCardAndSaveCopy) { | 4739 TEST_F(AutofillManagerTest, UploadCreditCardAndSaveCopy) { |
| 4689 personal_data_.ClearCreditCards(); | 4740 personal_data_.ClearCreditCards(); |
| 4690 personal_data_.ClearAutofillProfiles(); | 4741 personal_data_.ClearAutofillProfiles(); |
| 4691 autofill_manager_->set_credit_card_upload_enabled(true); | 4742 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4692 | 4743 |
| 4693 const char* const server_id = "InstrumentData:1234"; | 4744 const char* const server_id = "InstrumentData:1234"; |
| 4694 autofill_manager_->ResetPaymentsClientForCardUpload(server_id); | 4745 autofill_manager_->ResetPaymentsClientForCardUpload(server_id); |
| 4695 | 4746 |
| 4696 // Create, fill and submit an address form in order to establish a recent | 4747 // Create, fill and submit an address form in order to establish a recent |
| 4697 // profile which can be selected for the upload request. | 4748 // profile which can be selected for the upload request. |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5204 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); | 5255 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111"); |
| 5205 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 5256 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
| 5206 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5257 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5207 | 5258 |
| 5208 base::HistogramTester histogram_tester; | 5259 base::HistogramTester histogram_tester; |
| 5209 | 5260 |
| 5210 // Upload should still happen as long as the user provides CVC in the bubble. | 5261 // Upload should still happen as long as the user provides CVC in the bubble. |
| 5211 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5262 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5212 FormSubmitted(credit_card_form); | 5263 FormSubmitted(credit_card_form); |
| 5213 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 5264 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 5265 EXPECT_THAT(autofill_manager_->GetActiveExperiments(), |
| 5266 UnorderedElementsAre( |
| 5267 kAutofillUpstreamUseAutofillProfileComparatorForName.name, |
| 5268 kAutofillUpstreamRequestCvcIfMissing.name)); |
| 5214 | 5269 |
| 5215 // Verify that the correct histogram entries were logged. | 5270 // Verify that the correct histogram entries were logged. |
| 5216 ExpectCardUploadDecision(histogram_tester, AutofillMetrics::UPLOAD_OFFERED); | 5271 ExpectCardUploadDecision(histogram_tester, AutofillMetrics::UPLOAD_OFFERED); |
| 5217 ExpectCardUploadDecision(histogram_tester, | 5272 ExpectCardUploadDecision(histogram_tester, |
| 5218 AutofillMetrics::CVC_FIELD_NOT_FOUND); | 5273 AutofillMetrics::CVC_FIELD_NOT_FOUND); |
| 5219 // Verify that the correct UKM was logged. | 5274 // Verify that the correct UKM was logged. |
| 5220 ExpectMetric( | 5275 ExpectMetric( |
| 5221 internal::kUKMCardUploadDecisionMetricName, | 5276 internal::kUKMCardUploadDecisionMetricName, |
| 5222 internal::kUKMCardUploadDecisionEntryName, | 5277 internal::kUKMCardUploadDecisionEntryName, |
| 5223 AutofillMetrics::UPLOAD_OFFERED | AutofillMetrics::CVC_FIELD_NOT_FOUND, | 5278 AutofillMetrics::UPLOAD_OFFERED | AutofillMetrics::CVC_FIELD_NOT_FOUND, |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5421 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 5476 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
| 5422 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5477 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5423 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5478 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5424 | 5479 |
| 5425 base::HistogramTester histogram_tester; | 5480 base::HistogramTester histogram_tester; |
| 5426 | 5481 |
| 5427 // Upload should be offered. | 5482 // Upload should be offered. |
| 5428 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5483 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5429 FormSubmitted(credit_card_form); | 5484 FormSubmitted(credit_card_form); |
| 5430 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 5485 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 5486 EXPECT_THAT(autofill_manager_->GetActiveExperiments(), |
| 5487 UnorderedElementsAre( |
| 5488 kAutofillUpstreamUseAutofillProfileComparatorForName.name, |
| 5489 kAutofillUpstreamUseNotRecentlyUsedAutofillProfile.name)); |
| 5431 | 5490 |
| 5432 // Verify that the correct histogram entry (and only that) was logged. | 5491 // Verify that the correct histogram entry (and only that) was logged. |
| 5433 ExpectUniqueCardUploadDecision(histogram_tester, | 5492 ExpectUniqueCardUploadDecision(histogram_tester, |
| 5434 AutofillMetrics::UPLOAD_OFFERED); | 5493 AutofillMetrics::UPLOAD_OFFERED); |
| 5435 } | 5494 } |
| 5436 | 5495 |
| 5437 TEST_F(AutofillManagerTest, | 5496 TEST_F(AutofillManagerTest, |
| 5438 UploadCreditCard_CvcUnavailableAndNoProfileAvailable) { | 5497 UploadCreditCard_CvcUnavailableAndNoProfileAvailable) { |
| 5439 personal_data_.ClearAutofillProfiles(); | 5498 personal_data_.ClearAutofillProfiles(); |
| 5440 autofill_manager_->set_credit_card_upload_enabled(true); | 5499 autofill_manager_->set_credit_card_upload_enabled(true); |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5750 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 5809 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
| 5751 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 5810 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 5752 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 5811 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 5753 | 5812 |
| 5754 base::HistogramTester histogram_tester; | 5813 base::HistogramTester histogram_tester; |
| 5755 | 5814 |
| 5756 // Names match loosely, upload should happen. | 5815 // Names match loosely, upload should happen. |
| 5757 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 5816 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 5758 FormSubmitted(credit_card_form); | 5817 FormSubmitted(credit_card_form); |
| 5759 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 5818 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 5819 EXPECT_TRUE(autofill_manager_->GetActiveExperiments().empty()); |
| 5760 | 5820 |
| 5761 // Verify that the correct histogram entry (and only that) was logged. | 5821 // Verify that the correct histogram entry (and only that) was logged. |
| 5762 ExpectUniqueCardUploadDecision(histogram_tester, | 5822 ExpectUniqueCardUploadDecision(histogram_tester, |
| 5763 AutofillMetrics::UPLOAD_OFFERED); | 5823 AutofillMetrics::UPLOAD_OFFERED); |
| 5764 } | 5824 } |
| 5765 | 5825 |
| 5766 TEST_F(AutofillManagerTest, UploadCreditCard_NoMiddleInitialInCCForm) { | 5826 TEST_F(AutofillManagerTest, UploadCreditCard_NoMiddleInitialInCCForm) { |
| 5767 personal_data_.ClearAutofillProfiles(); | 5827 personal_data_.ClearAutofillProfiles(); |
| 5768 autofill_manager_->set_credit_card_upload_enabled(true); | 5828 autofill_manager_->set_credit_card_upload_enabled(true); |
| 5769 | 5829 |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6107 credit_card_form.fields[2].value = ASCIIToUTF16("11"); | 6167 credit_card_form.fields[2].value = ASCIIToUTF16("11"); |
| 6108 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); | 6168 credit_card_form.fields[3].value = ASCIIToUTF16("2017"); |
| 6109 credit_card_form.fields[4].value = ASCIIToUTF16("123"); | 6169 credit_card_form.fields[4].value = ASCIIToUTF16("123"); |
| 6110 | 6170 |
| 6111 base::HistogramTester histogram_tester; | 6171 base::HistogramTester histogram_tester; |
| 6112 | 6172 |
| 6113 // Name matches recently used profile, should offer upload. | 6173 // Name matches recently used profile, should offer upload. |
| 6114 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); | 6174 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0); |
| 6115 FormSubmitted(credit_card_form); | 6175 FormSubmitted(credit_card_form); |
| 6116 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); | 6176 EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded()); |
| 6177 // Recently used profile was available, so did not need to use old profile. |
| 6178 EXPECT_THAT(autofill_manager_->GetActiveExperiments(), |
| 6179 UnorderedElementsAre( |
| 6180 kAutofillUpstreamUseAutofillProfileComparatorForName.name)); |
| 6117 | 6181 |
| 6118 // Verify that the correct histogram entry (and only that) was logged. | 6182 // Verify that the correct histogram entry (and only that) was logged. |
| 6119 ExpectUniqueCardUploadDecision(histogram_tester, | 6183 ExpectUniqueCardUploadDecision(histogram_tester, |
| 6120 AutofillMetrics::UPLOAD_OFFERED); | 6184 AutofillMetrics::UPLOAD_OFFERED); |
| 6121 } | 6185 } |
| 6122 | 6186 |
| 6123 TEST_F(AutofillManagerTest, | 6187 TEST_F(AutofillManagerTest, |
| 6124 UploadCreditCard_NamesHaveToMatch_DisableComparator) { | 6188 UploadCreditCard_NamesHaveToMatch_DisableComparator) { |
| 6125 DisableAutofillUpstreamUseAutofillProfileComparatorForName(); | 6189 DisableAutofillUpstreamUseAutofillProfileComparatorForName(); |
| 6126 personal_data_.ClearAutofillProfiles(); | 6190 personal_data_.ClearAutofillProfiles(); |
| (...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6913 | 6977 |
| 6914 // Wait for upload to complete (will check expected types as well). | 6978 // Wait for upload to complete (will check expected types as well). |
| 6915 autofill_manager_->WaitForAsyncUploadProcess(); | 6979 autofill_manager_->WaitForAsyncUploadProcess(); |
| 6916 | 6980 |
| 6917 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); | 6981 EXPECT_EQ(signature, autofill_manager_->GetSubmittedFormSignature()); |
| 6918 EXPECT_NE(uploaded_available_types.end(), | 6982 EXPECT_NE(uploaded_available_types.end(), |
| 6919 uploaded_available_types.find(autofill::PASSWORD)); | 6983 uploaded_available_types.find(autofill::PASSWORD)); |
| 6920 } | 6984 } |
| 6921 | 6985 |
| 6922 } // namespace autofill | 6986 } // namespace autofill |
| OLD | NEW |