| 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 4130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4141 if (form.fields[i].name == ASCIIToUTF16("cardnumber")) | 4141 if (form.fields[i].name == ASCIIToUTF16("cardnumber")) |
| 4142 form.fields[i].value = ASCIIToUTF16("4012888888881881"); | 4142 form.fields[i].value = ASCIIToUTF16("4012888888881881"); |
| 4143 else if (form.fields[i].name == ASCIIToUTF16("nameoncard")) | 4143 else if (form.fields[i].name == ASCIIToUTF16("nameoncard")) |
| 4144 form.fields[i].value = ASCIIToUTF16("John H Dillinger"); | 4144 form.fields[i].value = ASCIIToUTF16("John H Dillinger"); |
| 4145 else if (form.fields[i].name == ASCIIToUTF16("ccmonth")) | 4145 else if (form.fields[i].name == ASCIIToUTF16("ccmonth")) |
| 4146 form.fields[i].value = ASCIIToUTF16("01"); | 4146 form.fields[i].value = ASCIIToUTF16("01"); |
| 4147 else if (form.fields[i].name == ASCIIToUTF16("ccyear")) | 4147 else if (form.fields[i].name == ASCIIToUTF16("ccyear")) |
| 4148 form.fields[i].value = ASCIIToUTF16("2017"); | 4148 form.fields[i].value = ASCIIToUTF16("2017"); |
| 4149 } | 4149 } |
| 4150 | 4150 |
| 4151 AutofillManager::UnmaskResponse response; | 4151 autofill_manager_->full_card_request()->GetFullCard( |
| 4152 card, AutofillClient::UNMASK_FOR_AUTOFILL, |
| 4153 autofill_manager_->weak_ptr_factory_.GetWeakPtr()); |
| 4154 |
| 4155 CardUnmaskDelegate::UnmaskResponse response; |
| 4152 response.should_store_pan = false; | 4156 response.should_store_pan = false; |
| 4153 response.cvc = ASCIIToUTF16("123"); | 4157 response.cvc = ASCIIToUTF16("123"); |
| 4154 autofill_manager_->OnUnmaskResponse(response); | 4158 ((CardUnmaskDelegate*)autofill_manager_->full_card_request()) |
| 4155 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, | 4159 ->OnUnmaskResponse(response); |
| 4156 "4012888888881881"); | 4160 |
| 4161 ((payments::PaymentsClientDelegate*)autofill_manager_->full_card_request()) |
| 4162 ->OnDidGetRealPan(AutofillClient::SUCCESS, "4012888888881881"); |
| 4163 |
| 4157 autofill_manager_->OnFormSubmitted(form); | 4164 autofill_manager_->OnFormSubmitted(form); |
| 4158 } | 4165 } |
| 4159 | 4166 |
| 4160 TEST_F(AutofillManagerTest, FillInUpdatedExpirationDate) { | 4167 TEST_F(AutofillManagerTest, FillInUpdatedExpirationDate) { |
| 4161 FormData form; | 4168 FormData form; |
| 4162 CreditCard card; | 4169 CreditCard card; |
| 4163 PrepareForRealPanResponse(&form, &card); | 4170 PrepareForRealPanResponse(&form, &card); |
| 4164 | 4171 |
| 4165 AutofillManager::UnmaskResponse response; | 4172 CardUnmaskDelegate::UnmaskResponse response; |
| 4166 response.should_store_pan = false; | 4173 response.should_store_pan = false; |
| 4167 response.cvc = ASCIIToUTF16("123"); | 4174 response.cvc = ASCIIToUTF16("123"); |
| 4168 response.exp_month = ASCIIToUTF16("02"); | 4175 response.exp_month = ASCIIToUTF16("02"); |
| 4169 response.exp_year = ASCIIToUTF16("2018"); | 4176 response.exp_year = ASCIIToUTF16("2018"); |
| 4170 autofill_manager_->OnUnmaskResponse(response); | 4177 ((CardUnmaskDelegate*)autofill_manager_->full_card_request()) |
| 4171 autofill_manager_->OnDidGetRealPan(AutofillClient::SUCCESS, | 4178 ->OnUnmaskResponse(response); |
| 4172 "4012888888881881"); | |
| 4173 | 4179 |
| 4174 EXPECT_EQ(ASCIIToUTF16("02"), | 4180 ((payments::PaymentsClientDelegate*)autofill_manager_->full_card_request()) |
| 4175 autofill_manager_->unmask_request_.card.GetRawInfo( | 4181 ->OnDidGetRealPan(AutofillClient::SUCCESS, "4012888888881881"); |
| 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 } | 4182 } |
| 4181 | 4183 |
| 4182 TEST_F(AutofillManagerTest, UploadCreditCard) { | 4184 TEST_F(AutofillManagerTest, UploadCreditCard) { |
| 4183 autofill_manager_->set_credit_card_upload_enabled(true); | 4185 autofill_manager_->set_credit_card_upload_enabled(true); |
| 4184 | 4186 |
| 4185 // Create, fill and submit an address form in order to establish a recent | 4187 // Create, fill and submit an address form in order to establish a recent |
| 4186 // profile which can be selected for the upload request. | 4188 // profile which can be selected for the upload request. |
| 4187 FormData address_form; | 4189 FormData address_form; |
| 4188 test::CreateTestAddressFormData(&address_form); | 4190 test::CreateTestAddressFormData(&address_form); |
| 4189 FormsSeen(std::vector<FormData>(1, address_form)); | 4191 FormsSeen(std::vector<FormData>(1, address_form)); |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4947 FormsSeen(mixed_forms); | 4949 FormsSeen(mixed_forms); |
| 4948 | 4950 |
| 4949 // Suggestions should always be displayed. | 4951 // Suggestions should always be displayed. |
| 4950 for (const FormFieldData& field : mixed_form.fields) { | 4952 for (const FormFieldData& field : mixed_form.fields) { |
| 4951 GetAutofillSuggestions(mixed_form, field); | 4953 GetAutofillSuggestions(mixed_form, field); |
| 4952 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); | 4954 EXPECT_TRUE(external_delegate_->on_suggestions_returned_seen()); |
| 4953 } | 4955 } |
| 4954 } | 4956 } |
| 4955 | 4957 |
| 4956 } // namespace autofill | 4958 } // namespace autofill |
| OLD | NEW |