Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / components / autofill / core / browser / test_personal_data_manager.h
blob4db9dd634bde42b3be92d7a2d2a76e8b8c67982e
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_PERSONAL_DATA_MANAGER_H_
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_PERSONAL_DATA_MANAGER_H_
8 #include <vector>
10 #include "components/autofill/core/browser/autofill_profile.h"
11 #include "components/autofill/core/browser/credit_card.h"
12 #include "components/autofill/core/browser/personal_data_manager.h"
14 namespace autofill {
16 // A simplistic PersonalDataManager used for testing.
17 class TestPersonalDataManager : public PersonalDataManager {
18 public:
19 TestPersonalDataManager();
20 ~TestPersonalDataManager() override;
22 // Sets which PrefService to use and observe. |pref_service| is not owned by
23 // this class and must outlive |this|.
24 void SetTestingPrefService(PrefService* pref_service);
26 // Adds |profile| to |profiles_|. This does not take ownership of |profile|.
27 void AddTestingProfile(AutofillProfile* profile);
29 // Adds |credit_card| to |credit_cards_|. This does not take ownership of
30 // |credit_card|.
31 void AddTestingCreditCard(CreditCard* credit_card);
33 // Adds |credit_card| to |server_credit_cards_| by copying.
34 void AddTestingServerCreditCard(const CreditCard& credit_card);
36 const std::vector<AutofillProfile*>& GetProfiles() const override;
37 const std::vector<AutofillProfile*>& web_profiles() const override;
38 const std::vector<CreditCard*>& GetCreditCards() const override;
40 std::string SaveImportedProfile(
41 const AutofillProfile& imported_profile) override;
42 std::string SaveImportedCreditCard(
43 const CreditCard& imported_credit_card) override;
45 std::string CountryCodeForCurrentTimezone() const override;
46 const std::string& GetDefaultCountryCodeForNewAddress() const override;
48 void set_timezone_country_code(const std::string& timezone_country_code) {
49 timezone_country_code_ = timezone_country_code;
51 void set_default_country_code(const std::string& default_country_code) {
52 default_country_code_ = default_country_code;
55 const AutofillProfile& imported_profile() { return imported_profile_; }
56 const CreditCard& imported_credit_card() { return imported_credit_card_; }
58 private:
59 std::vector<AutofillProfile*> profiles_;
60 std::vector<CreditCard*> credit_cards_;
61 AutofillProfile imported_profile_;
62 CreditCard imported_credit_card_;
63 std::string timezone_country_code_;
64 std::string default_country_code_;
67 } // namespace autofill
69 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_PERSONAL_DATA_MANAGER_H_