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 #include "chrome/browser/browser_process.h"
6 #include "chrome/browser/signin/account_tracker_service_factory.h"
7 #include "chrome/browser/signin/chrome_signin_client_factory.h"
8 #include "chrome/browser/signin/gaia_cookie_manager_service_factory.h"
9 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
10 #include "chrome/browser/signin/signin_manager_factory.h"
11 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
12 #include "chrome/test/base/testing_profile.h"
13 #include "components/signin/core/browser/fake_signin_manager.h"
16 #include "ash/shell.h"
20 #include "ui/aura/env.h"
21 #include "ui/aura/window_event_dispatcher.h"
24 using content::RenderViewHostTester
;
25 using content::RenderViewHostTestHarness
;
29 scoped_ptr
<KeyedService
> BuildSigninManagerFake(
30 content::BrowserContext
* context
) {
31 Profile
* profile
= static_cast<Profile
*>(context
);
32 SigninClient
* signin_client
=
33 ChromeSigninClientFactory::GetForProfile(profile
);
34 AccountTrackerService
* account_tracker_service
=
35 AccountTrackerServiceFactory::GetForProfile(profile
);
36 #if defined (OS_CHROMEOS)
37 scoped_ptr
<SigninManagerBase
> signin(
38 new SigninManagerBase(signin_client
, account_tracker_service
));
39 signin
->Initialize(NULL
);
42 scoped_ptr
<FakeSigninManager
> manager(new FakeSigninManager(
43 signin_client
, ProfileOAuth2TokenServiceFactory::GetForProfile(profile
),
44 account_tracker_service
,
45 GaiaCookieManagerServiceFactory::GetForProfile(profile
)));
46 manager
->Initialize(g_browser_process
->local_state());
47 return manager
.Pass();
53 ChromeRenderViewHostTestHarness::ChromeRenderViewHostTestHarness() {
56 ChromeRenderViewHostTestHarness::~ChromeRenderViewHostTestHarness() {
59 TestingProfile
* ChromeRenderViewHostTestHarness::profile() {
60 return static_cast<TestingProfile
*>(browser_context());
63 void ChromeRenderViewHostTestHarness::TearDown() {
64 RenderViewHostTestHarness::TearDown();
66 ash::Shell::DeleteInstance();
69 aura::Env::DeleteInstance();
73 content::BrowserContext
*
74 ChromeRenderViewHostTestHarness::CreateBrowserContext() {
75 TestingProfile::Builder builder
;
76 builder
.AddTestingFactory(SigninManagerFactory::GetInstance(),
77 BuildSigninManagerFake
);
78 return builder
.Build().release();