1 // Copyright (c) 2012 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 CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_H_
6 #define CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_H_
10 #include "base/compiler_specific.h"
11 #include "components/signin/core/browser/signin_manager.h"
19 // SigninManager to use for testing. Tests should use the type
20 // SigninManagerForTesting to ensure that the right type for their platform is
23 // Overrides InitTokenService to do-nothing in tests.
24 class FakeSigninManagerBase : public SigninManagerBase {
26 explicit FakeSigninManagerBase(Profile* profile);
27 virtual ~FakeSigninManagerBase();
29 // Helper function to be used with
30 // KeyedService::SetTestingFactory(). In order to match
31 // the API of SigninManagerFactory::GetForProfile(), returns a
32 // FakeSigninManagerBase* on ChromeOS, and a FakeSigninManager* on all other
33 // platforms. The returned instance is initialized.
34 static KeyedService* Build(content::BrowserContext* context);
37 #if !defined(OS_CHROMEOS)
39 // A signin manager that bypasses actual authentication routines with servers
40 // and accepts the credentials provided to StartSignIn.
41 class FakeSigninManager : public SigninManager {
43 explicit FakeSigninManager(Profile* profile);
44 virtual ~FakeSigninManager();
46 void set_auth_in_progress(const std::string& username) {
47 possibly_invalid_username_ = username;
50 void set_password(const std::string& password) { password_ = password; }
52 void SignIn(const std::string& username, const std::string& password);
54 void FailSignin(const GoogleServiceAuthError& error);
56 virtual void StartSignInWithRefreshToken(
57 const std::string& refresh_token,
58 const std::string& username,
59 const std::string& password,
60 const OAuthTokenFetchedCallback& oauth_fetched_callback) OVERRIDE;
62 virtual void SignOut() OVERRIDE;
64 virtual void CompletePendingSignin() OVERRIDE;
66 virtual void AddMergeSessionObserver(
67 MergeSessionHelper::Observer* observer) OVERRIDE;
68 virtual void RemoveMergeSessionObserver(
69 MergeSessionHelper::Observer* observer) OVERRIDE;
71 void NotifyMergeSessionObservers(const GoogleServiceAuthError& error);
74 ObserverList<MergeSessionHelper::Observer, true> merge_session_observer_list_;
77 #endif // !defined (OS_CHROMEOS)
79 #if defined(OS_CHROMEOS)
80 typedef FakeSigninManagerBase FakeSigninManagerForTesting;
82 typedef FakeSigninManager FakeSigninManagerForTesting;
85 #endif // CHROME_BROWSER_SIGNIN_FAKE_SIGNIN_MANAGER_H_