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

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

Issue 2611863002: Refactors cvc and expiration date validation in CC upload logic as well as unmask prompt. (Closed)
Patch Set: Addressed comments Created 3 years, 11 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 4583 matching lines...) Expand 10 before | Expand all | Expand 10 after
4594 std::string sample; 4594 std::string sample;
4595 rappor::RapporType type; 4595 rappor::RapporType type;
4596 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric( 4596 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
4597 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type)); 4597 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
4598 EXPECT_EQ("myform.com", sample); 4598 EXPECT_EQ("myform.com", sample);
4599 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type); 4599 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
4600 } 4600 }
4601 4601
4602 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot. 4602 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
4603 #if defined(OS_ANDROID) 4603 #if defined(OS_ANDROID)
4604 #define MAYBE_UploadCreditCard_CvcInvalidLength DISABLED_UploadCreditCard_CvcInv alidLength
4605 #else
4606 #define MAYBE_UploadCreditCard_CvcInvalidLength UploadCreditCard_CvcInvalidLengt h
4607 #endif
4608 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_CvcInvalidLength) {
4609 personal_data_.ClearAutofillProfiles();
4610 autofill_manager_->set_credit_card_upload_enabled(true);
4611
4612 // Create, fill and submit an address form in order to establish a recent
4613 // profile which can be selected for the upload request.
4614 FormData address_form;
4615 test::CreateTestAddressFormData(&address_form);
4616 FormsSeen(std::vector<FormData>(1, address_form));
4617 ManuallyFillAddressForm("Flo", "Master", "77401", "US", &address_form);
4618 FormSubmitted(address_form);
4619
4620 // Set up our credit card form data.
4621 FormData credit_card_form;
4622 CreateTestCreditCardFormData(&credit_card_form, true, false);
4623 FormsSeen(std::vector<FormData>(1, credit_card_form));
4624
4625 // Edit the data, and submit.
4626 credit_card_form.fields[0].value = ASCIIToUTF16("Flo Master");
4627 credit_card_form.fields[1].value = ASCIIToUTF16("4111111111111111");
4628 credit_card_form.fields[2].value = ASCIIToUTF16("11");
4629 credit_card_form.fields[3].value = ASCIIToUTF16("2017");
4630 credit_card_form.fields[4].value = ASCIIToUTF16("1234");
4631
4632 base::HistogramTester histogram_tester;
4633
4634 // Neither a local save nor an upload should happen in this case.
4635 EXPECT_CALL(autofill_client_, ConfirmSaveCreditCardLocally(_, _)).Times(0);
4636 FormSubmitted(credit_card_form);
4637 EXPECT_FALSE(autofill_manager_->credit_card_was_uploaded());
4638
4639 // Verify that the correct histogram entry (and only that) was logged.
4640 histogram_tester.ExpectUniqueSample(
4641 "Autofill.CardUploadDecisionExpanded",
4642 AutofillMetrics::UPLOAD_NOT_OFFERED_NO_CVC, 1);
4643
4644 rappor::TestRapporServiceImpl* rappor_service =
4645 autofill_client_.test_rappor_service();
4646 EXPECT_EQ(1, rappor_service->GetReportsCount());
4647 std::string sample;
4648 rappor::RapporType type;
4649 EXPECT_TRUE(rappor_service->GetRecordedSampleForMetric(
4650 "Autofill.CardUploadNotOfferedNoCvc", &sample, &type));
4651 EXPECT_EQ("myform.com", sample);
4652 EXPECT_EQ(rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, type);
4653 }
4654
4655 // TODO(crbug.com/666704): Flaky on android_n5x_swarming_rel bot.
4656 #if defined(OS_ANDROID)
4604 #define MAYBE_UploadCreditCard_MultipleCvcFields DISABLED_UploadCreditCard_Multi pleCvcFields 4657 #define MAYBE_UploadCreditCard_MultipleCvcFields DISABLED_UploadCreditCard_Multi pleCvcFields
4605 #else 4658 #else
4606 #define MAYBE_UploadCreditCard_MultipleCvcFields UploadCreditCard_MultipleCvcFie lds 4659 #define MAYBE_UploadCreditCard_MultipleCvcFields UploadCreditCard_MultipleCvcFie lds
4607 #endif 4660 #endif
4608 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_MultipleCvcFields) { 4661 TEST_F(AutofillManagerTest, MAYBE_UploadCreditCard_MultipleCvcFields) {
4609 autofill_manager_->set_credit_card_upload_enabled(true); 4662 autofill_manager_->set_credit_card_upload_enabled(true);
4610 4663
4611 // Remove the profiles that were created in the TestPersonalDataManager 4664 // Remove the profiles that were created in the TestPersonalDataManager
4612 // constructor because they would result in conflicting names that would 4665 // constructor because they would result in conflicting names that would
4613 // prevent the upload. 4666 // prevent the upload.
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
5530 5583
5531 // The driver should always be notified. 5584 // The driver should always be notified.
5532 for (const FormFieldData& field : form.fields) { 5585 for (const FormFieldData& field : form.fields) {
5533 GetAutofillSuggestions(form, field); 5586 GetAutofillSuggestions(form, field);
5534 EXPECT_TRUE(autofill_driver_->did_interact_with_credit_card_form()); 5587 EXPECT_TRUE(autofill_driver_->did_interact_with_credit_card_form());
5535 autofill_driver_->ClearDidInteractWithCreditCardForm(); 5588 autofill_driver_->ClearDidInteractWithCreditCardForm();
5536 } 5589 }
5537 } 5590 }
5538 5591
5539 } // namespace autofill 5592 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698