test_signin_client.h revision 4ad1aa43a48567659193a298fad74f55e00b3dd9
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 a TestURLRequestContextGetter.
37  virtual net::URLRequestContextGetter* GetURLRequestContext() OVERRIDE;
38
39 private:
40  // Loads the token database.
41  void LoadDatabase();
42
43  base::ScopedTempDir temp_dir_;
44  scoped_refptr<net::TestURLRequestContextGetter> request_context_;
45  scoped_refptr<TokenWebData> database_;
46
47  DISALLOW_COPY_AND_ASSIGN(TestSigninClient);
48};
49
50#endif  // COMPONENTS_SIGNIN_CORE_BROWSER_TEST_SIGNIN_CLIENT_H_
51