| 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 c224044fb450616e3bf662805391dac2f3203d9f..edf404f07453e3d535d6b2dcbec341e17fed1e09 100644
|
| --- a/components/autofill/core/browser/autofill_manager_unittest.cc
|
| +++ b/components/autofill/core/browser/autofill_manager_unittest.cc
|
| @@ -1081,6 +1081,10 @@ class AutofillManagerTest : public testing::Test {
|
| kAutofillUpstreamRequestCvcIfMissing);
|
| }
|
|
|
| + void EnableAutofillUpstreamShowNewUiExperiment() {
|
| + scoped_feature_list_.InitAndEnableFeature(kAutofillUpstreamShowNewUi);
|
| + }
|
| +
|
| void DisableAutofillUpstreamUseAutofillProfileComparator() {
|
| scoped_feature_list_.InitAndDisableFeature(
|
| kAutofillUpstreamUseAutofillProfileComparator);
|
| @@ -5302,6 +5306,83 @@ TEST_F(AutofillManagerTest, UploadCreditCard_NoCvcFieldOnFormExperimentOff) {
|
| ExpectCardUploadDecisionUkm(AutofillMetrics::CVC_FIELD_NOT_FOUND);
|
| }
|
|
|
| +// kAutofillUpstreamShowNewUi flag is currently not available on Android.
|
| +#if !defined(OS_ANDROID)
|
| +TEST_F(AutofillManagerTest,
|
| + UploadCreditCard_AddNewUiFlagStateToRequestIfExperimentOn) {
|
| + EnableAutofillUpstreamShowNewUiExperiment();
|
| + personal_data_.ClearAutofillProfiles();
|
| + autofill_manager_->set_credit_card_upload_enabled(true);
|
| +
|
| + // 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.
|
| + FormData credit_card_form;
|
| + CreateTestCreditCardFormData(&credit_card_form, true, false);
|
| + 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");
|
| + credit_card_form.fields[4].value = ASCIIToUTF16("123");
|
| +
|
| + base::HistogramTester histogram_tester;
|
| +
|
| + // Confirm upload happened and the new UI flag was sent in the request.
|
| + EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
|
| + FormSubmitted(credit_card_form);
|
| + EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
|
| + EXPECT_THAT(
|
| + autofill_manager_->GetActiveExperiments(),
|
| + UnorderedElementsAre(kAutofillUpstreamUseAutofillProfileComparator.name,
|
| + kAutofillUpstreamShowNewUi.name));
|
| +}
|
| +
|
| +TEST_F(AutofillManagerTest,
|
| + UploadCreditCard_DoNotAddNewUiFlagStateToRequestIfExperimentOff) {
|
| + personal_data_.ClearAutofillProfiles();
|
| + autofill_manager_->set_credit_card_upload_enabled(true);
|
| +
|
| + // 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.
|
| + FormData credit_card_form;
|
| + CreateTestCreditCardFormData(&credit_card_form, true, false);
|
| + 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");
|
| + credit_card_form.fields[4].value = ASCIIToUTF16("123");
|
| +
|
| + base::HistogramTester histogram_tester;
|
| +
|
| + // Confirm upload happened and the new UI flag was sent in the request.
|
| + EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
|
| + FormSubmitted(credit_card_form);
|
| + EXPECT_TRUE(autofill_manager_->credit_card_was_uploaded());
|
| + EXPECT_THAT(
|
| + autofill_manager_->GetActiveExperiments(),
|
| + UnorderedElementsAre(kAutofillUpstreamUseAutofillProfileComparator.name));
|
| +}
|
| +#endif
|
| +
|
| TEST_F(AutofillManagerTest, UploadCreditCard_NoProfileAvailable) {
|
| personal_data_.ClearAutofillProfiles();
|
| autofill_manager_->set_credit_card_upload_enabled(true);
|
|
|