test_signin_client.h revision e5d81f57cb97b3b6b7fccc9c5610d21eb81db09d
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 3// found in the LICENSE file. 4 5#ifndef COMPONENTS_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_ 6#define COMPONENTS_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_ 7 8#include "base/basictypes.h" 9#include "base/compiler_specific.h" 10#include "base/files/scoped_temp_dir.h" 11#include "base/memory/ref_counted.h" 12#include "components/signin/core/browser/signin_client.h" 13#include "net/url_request/url_request_test_util.h" 14 15// An implementation of SigninClient for use in unittests. Instantiates test 16// versions of the various objects that SigninClient is required to provide as 17// part of its interface. 18class TestSigninClient : public SigninClient { 19 public: 20 TestSigninClient(); 21 virtual ~TestSigninClient(); 22 23 // SigninClient implementation that is specialized for unit tests. 24 25 // Returns NULL. 26 // NOTE: This should be changed to return a properly-initalized PrefService 27 // once there is a unit test that requires it. 28 virtual PrefService* GetPrefs() OVERRIDE; 29 30 // Returns a pointer to a loaded database. 31 virtual scoped_refptr<TokenWebData> GetDatabase() OVERRIDE; 32 33 // Returns true. 34 virtual bool CanRevokeCredentials() OVERRIDE; 35 36 // Returns the empty string. 37 virtual std::string GetProductVersion() OVERRIDE; 38 39 // Returns a TestURLRequestContextGetter. 40 virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE; 41 42 // Returns true. 43 virtual bool ShouldMergeSigninCredentialsIntoCookieJar() OVERRIDE; 44 45 // Does nothing. 46 virtual void SetCookieChangedCallback(const CookieChangedCallback& callback) 47 OVERRIDE; 48 49 private: 50 // Loads the token database. 51 void LoadDatabase(); 52 53 base::ScopedTempDir temp_dir_; 54 scoped_refptr<net::TestURLRequestContextGetter> request_context_; 55 scoped_refptr<TokenWebData> database_; 56 57 DISALLOW_COPY_AND_ASSIGN(TestSigninClient); 58}; 59 60#endif // COMPONENTS_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_ 61