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

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

Issue 2010463002: Mocker for OSCrypt (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated doc Created 4 years, 6 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"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "components/autofill/core/browser/autofill_manager.h" 12 #include "components/autofill/core/browser/autofill_manager.h"
13 #include "components/autofill/core/browser/autofill_profile.h" 13 #include "components/autofill/core/browser/autofill_profile.h"
14 #include "components/autofill/core/browser/credit_card.h" 14 #include "components/autofill/core/browser/credit_card.h"
15 #include "components/autofill/core/browser/field_types.h" 15 #include "components/autofill/core/browser/field_types.h"
16 #include "components/autofill/core/browser/webdata/autofill_table.h" 16 #include "components/autofill/core/browser/webdata/autofill_table.h"
17 #include "components/autofill/core/common/autofill_constants.h" 17 #include "components/autofill/core/common/autofill_constants.h"
18 #include "components/autofill/core/common/autofill_pref_names.h" 18 #include "components/autofill/core/common/autofill_pref_names.h"
19 #include "components/autofill/core/common/form_data.h" 19 #include "components/autofill/core/common/form_data.h"
20 #include "components/autofill/core/common/form_field_data.h" 20 #include "components/autofill/core/common/form_field_data.h"
21 #include "components/os_crypt/os_crypt.h" 21 #include "components/os_crypt/os_crypt_mocker.h"
22 #include "components/pref_registry/pref_registry_syncable.h" 22 #include "components/pref_registry/pref_registry_syncable.h"
23 #include "components/prefs/pref_service.h" 23 #include "components/prefs/pref_service.h"
24 #include "components/prefs/pref_service_factory.h" 24 #include "components/prefs/pref_service_factory.h"
25 #include "components/prefs/testing_pref_store.h" 25 #include "components/prefs/testing_pref_store.h"
26 #include "components/signin/core/browser/account_fetcher_service.h" 26 #include "components/signin/core/browser/account_fetcher_service.h"
27 #include "components/signin/core/browser/account_tracker_service.h" 27 #include "components/signin/core/browser/account_tracker_service.h"
28 #include "components/signin/core/common/signin_pref_names.h" 28 #include "components/signin/core/common/signin_pref_names.h"
29 29
30 using base::ASCIIToUTF16; 30 using base::ASCIIToUTF16;
31 31
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 const char* name_on_card, const char* card_number, 303 const char* name_on_card, const char* card_number,
304 const char* expiration_month, const char* expiration_year) { 304 const char* expiration_month, const char* expiration_year) {
305 check_and_set(credit_card, CREDIT_CARD_NAME_FULL, name_on_card); 305 check_and_set(credit_card, CREDIT_CARD_NAME_FULL, name_on_card);
306 check_and_set(credit_card, CREDIT_CARD_NUMBER, card_number); 306 check_and_set(credit_card, CREDIT_CARD_NUMBER, card_number);
307 check_and_set(credit_card, CREDIT_CARD_EXP_MONTH, expiration_month); 307 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); 308 check_and_set(credit_card, CREDIT_CARD_EXP_4_DIGIT_YEAR, expiration_year);
309 } 309 }
310 310
311 void DisableSystemServices(PrefService* prefs) { 311 void DisableSystemServices(PrefService* prefs) {
312 // Use a mock Keychain rather than the OS one to store credit card data. 312 // Use a mock Keychain rather than the OS one to store credit card data.
313 #if defined(OS_MACOSX) 313 OSCryptMocker::SetUpWithSingleton();
314 OSCrypt::UseMockKeychain(true); 314 }
315 #endif // defined(OS_MACOSX) 315
316 void ReenableSystemServices() {
317 OSCryptMocker::TearDown();
316 } 318 }
317 319
318 void SetServerCreditCards(AutofillTable* table, 320 void SetServerCreditCards(AutofillTable* table,
319 const std::vector<CreditCard>& cards) { 321 const std::vector<CreditCard>& cards) {
320 std::vector<CreditCard> as_masked_cards = cards; 322 std::vector<CreditCard> as_masked_cards = cards;
321 for (CreditCard& card : as_masked_cards) { 323 for (CreditCard& card : as_masked_cards) {
322 card.set_record_type(CreditCard::MASKED_SERVER_CARD); 324 card.set_record_type(CreditCard::MASKED_SERVER_CARD);
323 std::string type = card.type(); 325 std::string type = card.type();
324 card.SetNumber(card.LastFourDigits()); 326 card.SetNumber(card.LastFourDigits());
325 card.SetTypeForMaskedCard(type.c_str()); 327 card.SetTypeForMaskedCard(type.c_str());
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 if (name) 364 if (name)
363 field->set_name(name); 365 field->set_name(name);
364 if (control_type) 366 if (control_type)
365 field->set_type(control_type); 367 field->set_type(control_type);
366 if (label) 368 if (label)
367 field->set_label(label); 369 field->set_label(label);
368 } 370 }
369 371
370 } // namespace test 372 } // namespace test
371 } // namespace autofill 373 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698