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_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_ | 5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_ |
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_ | 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/files/scoped_temp_dir.h" | 10 #include "base/files/scoped_temp_dir.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "components/signin/core/browser/signin_client.h" | 13 #include "components/signin/core/browser/signin_client.h" |
14 #include "net/url_request/url_request_test_util.h" | 14 #include "net/url_request/url_request_test_util.h" |
15 | 15 |
16 #if defined(OS_IOS) | 16 #if defined(OS_IOS) |
17 #include "ios/public/test/fake_profile_oauth2_token_service_ios_provider.h" | 17 #include "ios/public/test/fake_profile_oauth2_token_service_ios_provider.h" |
18 #endif | 18 #endif |
19 | 19 |
20 class PrefService; | 20 class PrefService; |
21 | 21 |
22 // An implementation of SigninClient for use in unittests. Instantiates test | 22 // An implementation of SigninClient for use in unittests. Instantiates test |
23 // versions of the various objects that SigninClient is required to provide as | 23 // versions of the various objects that SigninClient is required to provide as |
24 // part of its interface. | 24 // part of its interface. |
25 class TestSigninClient : public SigninClient { | 25 class TestSigninClient : public SigninClient { |
26 public: | 26 public: |
27 TestSigninClient(); | 27 TestSigninClient(); |
28 TestSigninClient(PrefService* pref_service); | 28 TestSigninClient(PrefService* pref_service); |
29 virtual ~TestSigninClient(); | 29 ~TestSigninClient() override; |
30 | 30 |
31 // SigninClient implementation that is specialized for unit tests. | 31 // SigninClient implementation that is specialized for unit tests. |
32 | 32 |
33 // Returns NULL. | 33 // Returns NULL. |
34 // NOTE: This should be changed to return a properly-initalized PrefService | 34 // NOTE: This should be changed to return a properly-initalized PrefService |
35 // once there is a unit test that requires it. | 35 // once there is a unit test that requires it. |
36 virtual PrefService* GetPrefs() override; | 36 PrefService* GetPrefs() override; |
37 | 37 |
38 // Returns a pointer to a loaded database. | 38 // Returns a pointer to a loaded database. |
39 virtual scoped_refptr<TokenWebData> GetDatabase() override; | 39 scoped_refptr<TokenWebData> GetDatabase() override; |
40 | 40 |
41 // Returns true. | 41 // Returns true. |
42 virtual bool CanRevokeCredentials() override; | 42 bool CanRevokeCredentials() override; |
43 | 43 |
44 // Returns empty string. | 44 // Returns empty string. |
45 virtual std::string GetSigninScopedDeviceId() override; | 45 std::string GetSigninScopedDeviceId() override; |
46 | 46 |
47 // Does nothing. | 47 // Does nothing. |
48 virtual void OnSignedOut() override; | 48 void OnSignedOut() override; |
49 | 49 |
50 // Returns the empty string. | 50 // Returns the empty string. |
51 virtual std::string GetProductVersion() override; | 51 std::string GetProductVersion() override; |
52 | 52 |
53 // Returns a TestURLRequestContextGetter or an manually provided | 53 // Returns a TestURLRequestContextGetter or an manually provided |
54 // URLRequestContextGetter. | 54 // URLRequestContextGetter. |
55 virtual net::URLRequestContextGetter* GetURLRequestContext() override; | 55 net::URLRequestContextGetter* GetURLRequestContext() override; |
56 | 56 |
57 // For testing purposes, can override the TestURLRequestContextGetter created | 57 // For testing purposes, can override the TestURLRequestContextGetter created |
58 // in the default constructor. | 58 // in the default constructor. |
59 void SetURLRequestContext(net::URLRequestContextGetter* request_context); | 59 void SetURLRequestContext(net::URLRequestContextGetter* request_context); |
60 | 60 |
61 #if defined(OS_IOS) | 61 #if defined(OS_IOS) |
62 virtual ios::ProfileOAuth2TokenServiceIOSProvider* GetIOSProvider() override; | 62 virtual ios::ProfileOAuth2TokenServiceIOSProvider* GetIOSProvider() override; |
63 #endif | 63 #endif |
64 | 64 |
65 // Returns true. | 65 // Returns true. |
66 virtual bool ShouldMergeSigninCredentialsIntoCookieJar() override; | 66 bool ShouldMergeSigninCredentialsIntoCookieJar() override; |
67 | 67 |
68 // Does nothing. | 68 // Does nothing. |
69 virtual scoped_ptr<CookieChangedCallbackList::Subscription> | 69 scoped_ptr<CookieChangedCallbackList::Subscription> AddCookieChangedCallback( |
70 AddCookieChangedCallback(const CookieChangedCallback& callback) override; | 70 const CookieChangedCallback& callback) override; |
71 | 71 |
72 #if defined(OS_IOS) | 72 #if defined(OS_IOS) |
73 ios::FakeProfileOAuth2TokenServiceIOSProvider* GetIOSProviderAsFake(); | 73 ios::FakeProfileOAuth2TokenServiceIOSProvider* GetIOSProviderAsFake(); |
74 #endif | 74 #endif |
75 | 75 |
76 // SigninClient overrides: | 76 // SigninClient overrides: |
77 virtual void SetSigninProcess(int host_id) override; | 77 void SetSigninProcess(int host_id) override; |
78 virtual void ClearSigninProcess() override; | 78 void ClearSigninProcess() override; |
79 virtual bool IsSigninProcess(int host_id) const override; | 79 bool IsSigninProcess(int host_id) const override; |
80 virtual bool HasSigninProcess() const override; | 80 bool HasSigninProcess() const override; |
81 virtual bool IsFirstRun() const override; | 81 bool IsFirstRun() const override; |
82 virtual base::Time GetInstallDate() override; | 82 base::Time GetInstallDate() override; |
83 | 83 |
84 private: | 84 private: |
85 // Loads the token database. | 85 // Loads the token database. |
86 void LoadDatabase(); | 86 void LoadDatabase(); |
87 | 87 |
88 base::ScopedTempDir temp_dir_; | 88 base::ScopedTempDir temp_dir_; |
89 scoped_refptr<net::URLRequestContextGetter> request_context_; | 89 scoped_refptr<net::URLRequestContextGetter> request_context_; |
90 scoped_refptr<TokenWebData> database_; | 90 scoped_refptr<TokenWebData> database_; |
91 int signin_host_id_; | 91 int signin_host_id_; |
92 CookieChangedCallbackList cookie_callbacks_; | 92 CookieChangedCallbackList cookie_callbacks_; |
93 | 93 |
94 PrefService* pref_service_; | 94 PrefService* pref_service_; |
95 | 95 |
96 #if defined(OS_IOS) | 96 #if defined(OS_IOS) |
97 scoped_ptr<ios::FakeProfileOAuth2TokenServiceIOSProvider> iosProvider_; | 97 scoped_ptr<ios::FakeProfileOAuth2TokenServiceIOSProvider> iosProvider_; |
98 #endif | 98 #endif |
99 | 99 |
100 DISALLOW_COPY_AND_ASSIGN(TestSigninClient); | 100 DISALLOW_COPY_AND_ASSIGN(TestSigninClient); |
101 }; | 101 }; |
102 | 102 |
103 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_ | 103 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_ |
OLD | NEW |