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

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

Issue 1899893002: Card unmasking without form filling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use the credit card number field in metrics tests, because ios single-field form fill will not requ… Created 4 years, 8 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 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 form->fields[1], *card); 926 form->fields[1], *card);
927 autofill_manager_->FillOrPreviewCreditCardForm( 927 autofill_manager_->FillOrPreviewCreditCardForm(
928 AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form, 928 AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form,
929 form->fields[2], *card); 929 form->fields[2], *card);
930 autofill_manager_->FillOrPreviewCreditCardForm( 930 autofill_manager_->FillOrPreviewCreditCardForm(
931 AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form, 931 AutofillDriver::FORM_DATA_ACTION_FILL, kDefaultPageID, *form,
932 form->fields[3], *card); 932 form->fields[3], *card);
933 #endif // defined(OS_IOS) 933 #endif // defined(OS_IOS)
934 } 934 }
935 935
936 // Convenience method to cast the FullCardRequest into a CardUnmaskDelegate.
937 CardUnmaskDelegate* full_card_unmask_delegate() {
938 DCHECK(autofill_manager_->full_card_request_);
939 return (CardUnmaskDelegate*)autofill_manager_->full_card_request_.get();
940 }
941
936 protected: 942 protected:
937 base::MessageLoop message_loop_; 943 base::MessageLoop message_loop_;
938 MockAutofillClient autofill_client_; 944 MockAutofillClient autofill_client_;
939 std::unique_ptr<MockAutofillDriver> autofill_driver_; 945 std::unique_ptr<MockAutofillDriver> autofill_driver_;
940 std::unique_ptr<TestAutofillManager> autofill_manager_; 946 std::unique_ptr<TestAutofillManager> autofill_manager_;
941 std::unique_ptr<TestAutofillExternalDelegate> external_delegate_; 947 std::unique_ptr<TestAutofillExternalDelegate> external_delegate_;
942 scoped_refptr<net::TestURLRequestContextGetter> request_context_; 948 scoped_refptr<net::TestURLRequestContextGetter> request_context_;
943 TestPaymentsClient* payments_client_; 949 TestPaymentsClient* payments_client_;
944 TestAutofillDownloadManager* download_manager_; 950 TestAutofillDownloadManager* download_manager_;
945 TestPersonalDataManager personal_data_; 951 TestPersonalDataManager personal_data_;
(...skipping 3195 matching lines...) Expand 10 before | Expand all | Expand 10 after
4141 if (form.fields[i].name == ASCIIToUTF16("cardnumber")) 4147 if (form.fields[i].name == ASCIIToUTF16("cardnumber"))
4142 form.fields[i].value = ASCIIToUTF16("4012888888881881"); 4148 form.fields[i].value = ASCIIToUTF16("4012888888881881");
4143 else if (form.fields[i].name == ASCIIToUTF16("nameoncard")) 4149 else if (form.fields[i].name == ASCIIToUTF16("nameoncard"))
4144 form.fields[i].value = ASCIIToUTF16("John H Dillinger"); 4150 form.fields[i].value = ASCIIToUTF16("John H Dillinger");
4145 else if (form.fields[i].name == ASCIIToUTF16("ccmonth")) 4151 else if (form.fields[i].name == ASCIIToUTF16("ccmonth"))
4146 form.fields[i].value = ASCIIToUTF16("01"); 4152 form.fields[i].value = ASCIIToUTF16("01");
4147 else if (form.fields[i].name == ASCIIToUTF16("ccyear")) 4153 else if (form.fields[i].name == ASCIIToUTF16("ccyear"))
4148 form.fields[i].value = ASCIIToUTF16("2017"); 4154 form.fields[i].value = ASCIIToUTF16("2017");
4149 } 4155 }
4150 4156
4151 AutofillManager::UnmaskResponse response; 4157 CardUnmaskDelegate::UnmaskResponse response;
4152 response.should_store_pan = false; 4158 response.should_store_pan = false;
4153 response.cvc = ASCIIToUTF16("123"); 4159 response.cvc = ASCIIToUTF16("123");
4154 autofill_manager_->OnUnmaskResponse(response); 4160 full_card_unmask_delegate()->OnUnmaskResponse(response);
4155 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, 4161 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS,
4156 "4012888888881881"); 4162 "4012888888881881");
4157 autofill_manager_->OnFormSubmitted(form); 4163 autofill_manager_->OnFormSubmitted(form);
4158 } 4164 }
4159 4165
4160 TEST_F(AutofillManagerTest, FillInUpdatedExpirationDate) { 4166 TEST_F(AutofillManagerTest, FillInUpdatedExpirationDate) {
4161 FormData form; 4167 FormData form;
4162 CreditCard card; 4168 CreditCard card;
4163 PrepareForRealPanResponse(&form, &card); 4169 PrepareForRealPanResponse(&form, &card);
4164 4170
4165 AutofillManager::UnmaskResponse response; 4171 CardUnmaskDelegate::UnmaskResponse response;
4166 response.should_store_pan = false; 4172 response.should_store_pan = false;
4167 response.cvc = ASCIIToUTF16("123"); 4173 response.cvc = ASCIIToUTF16("123");
4168 response.exp_month = ASCIIToUTF16("02"); 4174 response.exp_month = ASCIIToUTF16("02");
4169 response.exp_year = ASCIIToUTF16("2018"); 4175 response.exp_year = ASCIIToUTF16("2018");
4170 autofill_manager_->OnUnmaskResponse(response); 4176 full_card_unmask_delegate()->OnUnmaskResponse(response);
4171 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, 4177 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS,
4172 "4012888888881881"); 4178 "4012888888881881");
4173
4174 EXPECT_EQ(ASCIIToUTF16("02"),
4175 autofill_manager_->unmask_request_.card.GetRawInfo(
4176 CREDIT_CARD_EXP_MONTH));
4177 EXPECT_EQ(ASCIIToUTF16("2018"),
4178 autofill_manager_->unmask_request_.card.GetRawInfo(
4179 CREDIT_CARD_EXP_4_DIGIT_YEAR));
4180 } 4179 }
4181 4180
4182 TEST_F(AutofillManagerTest, UploadCreditCard) { 4181 TEST_F(AutofillManagerTest, UploadCreditCard) {
4183 autofill_manager_->set_credit_card_upload_enabled(true); 4182 autofill_manager_->set_credit_card_upload_enabled(true);
4184 4183
4185 // Create, fill and submit an address form in order to establish a recent 4184 // Create, fill and submit an address form in order to establish a recent
4186 // profile which can be selected for the upload request. 4185 // profile which can be selected for the upload request.
4187 FormData address_form; 4186 FormData address_form;
4188 test::CreateTestAddressFormData(&address_form); 4187 test::CreateTestAddressFormData(&address_form);
4189 FormsSeen(std::vector<FormData>(1, address_form)); 4188 FormsSeen(std::vector<FormData>(1, address_form));
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after
4947 FormsSeen(mixed_forms); 4946 FormsSeen(mixed_forms);
4948 4947
4949 // Suggestions should always be displayed. 4948 // Suggestions should always be displayed.
4950 for (const FormFieldData& field : mixed_form.fields) { 4949 for (const FormFieldData& field : mixed_form.fields) {
4951 GetAutofillSuggestions(mixed_form, field); 4950 GetAutofillSuggestions(mixed_form, field);
4952 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); 4951 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen());
4953 } 4952 }
4954 } 4953 }
4955 4954
4956 } // namespace autofill 4955 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.cc ('k') | components/autofill/core/browser/autofill_metrics_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698