| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_CLIENT_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_CLIENT_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_CLIENT_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_CLIENT_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/i18n/rtl.h" | 14 #include "base/i18n/rtl.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "components/autofill/core/browser/autofill_client.h" | 16 #include "components/autofill/core/browser/autofill_client.h" |
| 17 #include "components/prefs/pref_service.h" | 17 #include "components/prefs/pref_service.h" |
| 18 #include "components/rappor/test_rappor_service.h" | 18 #include "components/rappor/test_rappor_service.h" |
| 19 #include "components/ukm/test_ukm_service.h" | 19 #include "components/ukm/test_ukm_recorder.h" |
| 20 #include "google_apis/gaia/fake_identity_provider.h" | 20 #include "google_apis/gaia/fake_identity_provider.h" |
| 21 #include "google_apis/gaia/fake_oauth2_token_service.h" | 21 #include "google_apis/gaia/fake_oauth2_token_service.h" |
| 22 | 22 |
| 23 namespace autofill { | 23 namespace autofill { |
| 24 | 24 |
| 25 // This class is for easier writing of tests. | 25 // This class is for easier writing of tests. |
| 26 class TestAutofillClient : public AutofillClient { | 26 class TestAutofillClient : public AutofillClient { |
| 27 public: | 27 public: |
| 28 TestAutofillClient(); | 28 TestAutofillClient(); |
| 29 ~TestAutofillClient() override; | 29 ~TestAutofillClient() override; |
| 30 | 30 |
| 31 // AutofillClient implementation. | 31 // AutofillClient implementation. |
| 32 PersonalDataManager* GetPersonalDataManager() override; | 32 PersonalDataManager* GetPersonalDataManager() override; |
| 33 scoped_refptr<AutofillWebDataService> GetDatabase() override; | 33 scoped_refptr<AutofillWebDataService> GetDatabase() override; |
| 34 PrefService* GetPrefs() override; | 34 PrefService* GetPrefs() override; |
| 35 syncer::SyncService* GetSyncService() override; | 35 syncer::SyncService* GetSyncService() override; |
| 36 IdentityProvider* GetIdentityProvider() override; | 36 IdentityProvider* GetIdentityProvider() override; |
| 37 rappor::RapporServiceImpl* GetRapporServiceImpl() override; | 37 rappor::RapporServiceImpl* GetRapporServiceImpl() override; |
| 38 ukm::UkmService* GetUkmService() override; | 38 ukm::UkmRecorder* GetUkmRecorder() override; |
| 39 SaveCardBubbleController* GetSaveCardBubbleController() override; | 39 SaveCardBubbleController* GetSaveCardBubbleController() override; |
| 40 void ShowAutofillSettings() override; | 40 void ShowAutofillSettings() override; |
| 41 void ShowUnmaskPrompt(const CreditCard& card, | 41 void ShowUnmaskPrompt(const CreditCard& card, |
| 42 UnmaskCardReason reason, | 42 UnmaskCardReason reason, |
| 43 base::WeakPtr<CardUnmaskDelegate> delegate) override; | 43 base::WeakPtr<CardUnmaskDelegate> delegate) override; |
| 44 void OnUnmaskVerificationResult(PaymentsRpcResult result) override; | 44 void OnUnmaskVerificationResult(PaymentsRpcResult result) override; |
| 45 void ConfirmSaveCreditCardLocally(const CreditCard& card, | 45 void ConfirmSaveCreditCardLocally(const CreditCard& card, |
| 46 const base::Closure& callback) override; | 46 const base::Closure& callback) override; |
| 47 void ConfirmSaveCreditCardToCloud( | 47 void ConfirmSaveCreditCardToCloud( |
| 48 const CreditCard& card, | 48 const CreditCard& card, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 void SetPrefs(std::unique_ptr<PrefService> prefs) { | 81 void SetPrefs(std::unique_ptr<PrefService> prefs) { |
| 82 prefs_ = std::move(prefs); | 82 prefs_ = std::move(prefs); |
| 83 } | 83 } |
| 84 | 84 |
| 85 rappor::TestRapporServiceImpl* test_rappor_service() { | 85 rappor::TestRapporServiceImpl* test_rappor_service() { |
| 86 return rappor_service_.get(); | 86 return rappor_service_.get(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void set_form_origin(const GURL& url) { form_origin_ = url; } | 89 void set_form_origin(const GURL& url) { form_origin_ = url; } |
| 90 | 90 |
| 91 ukm::TestUkmService* GetTestUkmService() { | 91 ukm::TestUkmRecorder* GetTestUkmRecorder() { return &test_ukm_recorder_; } |
| 92 return ukm_service_test_harness_.test_ukm_service(); | |
| 93 } | |
| 94 | 92 |
| 95 private: | 93 private: |
| 96 // NULL by default. | 94 // NULL by default. |
| 97 std::unique_ptr<PrefService> prefs_; | 95 std::unique_ptr<PrefService> prefs_; |
| 98 std::unique_ptr<FakeOAuth2TokenService> token_service_; | 96 std::unique_ptr<FakeOAuth2TokenService> token_service_; |
| 99 std::unique_ptr<FakeIdentityProvider> identity_provider_; | 97 std::unique_ptr<FakeIdentityProvider> identity_provider_; |
| 100 std::unique_ptr<rappor::TestRapporServiceImpl> rappor_service_; | 98 std::unique_ptr<rappor::TestRapporServiceImpl> rappor_service_; |
| 101 ukm::UkmServiceTestingHarness ukm_service_test_harness_; | 99 ukm::TestUkmRecorder test_ukm_recorder_; |
| 102 #if !defined(OS_ANDROID) | 100 #if !defined(OS_ANDROID) |
| 103 std::unique_ptr<SaveCardBubbleController> save_card_bubble_controller_; | 101 std::unique_ptr<SaveCardBubbleController> save_card_bubble_controller_; |
| 104 #endif | 102 #endif |
| 105 GURL form_origin_; | 103 GURL form_origin_; |
| 106 | 104 |
| 107 DISALLOW_COPY_AND_ASSIGN(TestAutofillClient); | 105 DISALLOW_COPY_AND_ASSIGN(TestAutofillClient); |
| 108 }; | 106 }; |
| 109 | 107 |
| 110 } // namespace autofill | 108 } // namespace autofill |
| 111 | 109 |
| 112 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_CLIENT_H_ | 110 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_TEST_AUTOFILL_CLIENT_H_ |
| OLD | NEW |