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

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

Issue 2849523003: Add billing address as a mandatory field of Payments credit cards. (Closed)
Patch Set: Components Unittests fix Created 3 years, 7 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_test_utils.h" 5 #include "components/autofill/core/browser/autofill_test_utils.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 220
221 AutofillProfile GetVerifiedProfile2() { 221 AutofillProfile GetVerifiedProfile2() {
222 AutofillProfile profile(GetFullProfile2()); 222 AutofillProfile profile(GetFullProfile2());
223 profile.set_origin(kSettingsOrigin); 223 profile.set_origin(kSettingsOrigin);
224 return profile; 224 return profile;
225 } 225 }
226 226
227 CreditCard GetCreditCard() { 227 CreditCard GetCreditCard() {
228 CreditCard credit_card(base::GenerateGUID(), "http://www.example.com"); 228 CreditCard credit_card(base::GenerateGUID(), "http://www.example.com");
229 SetCreditCardInfo(&credit_card, "Test User", "4111111111111111" /* Visa */, 229 SetCreditCardInfo(&credit_card, "Test User", "4111111111111111" /* Visa */,
230 "11", "2022"); 230 "11", "2022", "1");
231 return credit_card; 231 return credit_card;
232 } 232 }
233 233
234 CreditCard GetCreditCard2() { 234 CreditCard GetCreditCard2() {
235 CreditCard credit_card(base::GenerateGUID(), "https://www.example.com"); 235 CreditCard credit_card(base::GenerateGUID(), "https://www.example.com");
236 SetCreditCardInfo(&credit_card, "Someone Else", "378282246310005" /* AmEx */, 236 SetCreditCardInfo(&credit_card, "Someone Else", "378282246310005" /* AmEx */,
237 "07", "2022"); 237 "07", "2022", "1");
238 return credit_card; 238 return credit_card;
239 } 239 }
240 240
241 CreditCard GetVerifiedCreditCard() { 241 CreditCard GetVerifiedCreditCard() {
242 CreditCard credit_card(GetCreditCard()); 242 CreditCard credit_card(GetCreditCard());
243 credit_card.set_origin(kSettingsOrigin); 243 credit_card.set_origin(kSettingsOrigin);
244 return credit_card; 244 return credit_card;
245 } 245 }
246 246
247 CreditCard GetVerifiedCreditCard2() { 247 CreditCard GetVerifiedCreditCard2() {
248 CreditCard credit_card(GetCreditCard2()); 248 CreditCard credit_card(GetCreditCard2());
249 credit_card.set_origin(kSettingsOrigin); 249 credit_card.set_origin(kSettingsOrigin);
250 return credit_card; 250 return credit_card;
251 } 251 }
252 252
253 CreditCard GetMaskedServerCard() { 253 CreditCard GetMaskedServerCard() {
254 CreditCard credit_card(CreditCard::MASKED_SERVER_CARD, "a123"); 254 CreditCard credit_card(CreditCard::MASKED_SERVER_CARD, "a123");
255 test::SetCreditCardInfo(&credit_card, "Bonnie Parker", 255 test::SetCreditCardInfo(&credit_card, "Bonnie Parker",
256 "2109" /* Mastercard */, "12", "2020"); 256 "2109" /* Mastercard */, "12", "2020", "1");
257 credit_card.SetNetworkForMaskedCard(kMasterCard); 257 credit_card.SetNetworkForMaskedCard(kMasterCard);
258 return credit_card; 258 return credit_card;
259 } 259 }
260 260
261 CreditCard GetMaskedServerCardAmex() { 261 CreditCard GetMaskedServerCardAmex() {
262 CreditCard credit_card(CreditCard::MASKED_SERVER_CARD, "b456"); 262 CreditCard credit_card(CreditCard::MASKED_SERVER_CARD, "b456");
263 test::SetCreditCardInfo(&credit_card, "Justin Thyme", 263 test::SetCreditCardInfo(&credit_card, "Justin Thyme", "8431" /* Amex */, "9",
264 "8431" /* Amex */, "9", "2020"); 264 "2020", "1");
265 credit_card.SetNetworkForMaskedCard(kAmericanExpressCard); 265 credit_card.SetNetworkForMaskedCard(kAmericanExpressCard);
266 return credit_card; 266 return credit_card;
267 } 267 }
268 268
269 void SetProfileInfo(AutofillProfile* profile, 269 void SetProfileInfo(AutofillProfile* profile,
270 const char* first_name, const char* middle_name, 270 const char* first_name, const char* middle_name,
271 const char* last_name, const char* email, const char* company, 271 const char* last_name, const char* email, const char* company,
272 const char* address1, const char* address2, const char* city, 272 const char* address1, const char* address2, const char* city,
273 const char* state, const char* zipcode, const char* country, 273 const char* state, const char* zipcode, const char* country,
274 const char* phone) { 274 const char* phone) {
(...skipping 18 matching lines...) Expand all
293 const char* state, const char* zipcode, const char* country, 293 const char* state, const char* zipcode, const char* country,
294 const char* phone) { 294 const char* phone) {
295 if (guid) 295 if (guid)
296 profile->set_guid(guid); 296 profile->set_guid(guid);
297 SetProfileInfo(profile, first_name, middle_name, last_name, email, 297 SetProfileInfo(profile, first_name, middle_name, last_name, email,
298 company, address1, address2, city, state, zipcode, country, 298 company, address1, address2, city, state, zipcode, country,
299 phone); 299 phone);
300 } 300 }
301 301
302 void SetCreditCardInfo(CreditCard* credit_card, 302 void SetCreditCardInfo(CreditCard* credit_card,
303 const char* name_on_card, const char* card_number, 303 const char* name_on_card,
304 const char* expiration_month, const char* expiration_year) { 304 const char* card_number,
305 const char* expiration_month,
306 const char* expiration_year,
307 const std::string& billing_address_id) {
305 check_and_set(credit_card, CREDIT_CARD_NAME_FULL, name_on_card); 308 check_and_set(credit_card, CREDIT_CARD_NAME_FULL, name_on_card);
306 check_and_set(credit_card, CREDIT_CARD_NUMBER, card_number); 309 check_and_set(credit_card, CREDIT_CARD_NUMBER, card_number);
307 check_and_set(credit_card, CREDIT_CARD_EXP_MONTH, expiration_month); 310 check_and_set(credit_card, CREDIT_CARD_EXP_MONTH, expiration_month);
308 check_and_set(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR, expiration_year); 311 check_and_set(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR, expiration_year);
312 credit_card->set_billing_address_id(billing_address_id);
309 } 313 }
310 314
311 void DisableSystemServices(PrefService* prefs) { 315 void DisableSystemServices(PrefService* prefs) {
312 // Use a mock Keychain rather than the OS one to store credit card data. 316 // Use a mock Keychain rather than the OS one to store credit card data.
313 OSCryptMocker::SetUpWithSingleton(); 317 OSCryptMocker::SetUpWithSingleton();
314 } 318 }
315 319
316 void ReenableSystemServices() { 320 void ReenableSystemServices() {
317 OSCryptMocker::TearDown(); 321 OSCryptMocker::TearDown();
318 } 322 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 const char* control_type) { 361 const char* control_type) {
358 field->set_signature(signature); 362 field->set_signature(signature);
359 if (name) 363 if (name)
360 field->set_name(name); 364 field->set_name(name);
361 if (control_type) 365 if (control_type)
362 field->set_type(control_type); 366 field->set_type(control_type);
363 } 367 }
364 368
365 } // namespace test 369 } // namespace test
366 } // namespace autofill 370 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698