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/test/base/chrome_render_view_host_test_harness.h"
6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/signin/account_tracker_service_factory.h"
8 #include "chrome/browser/signin/chrome_signin_client_factory.h"
9 #include "chrome/browser/signin/fake_signin_manager.h"
10 #include "chrome/browser/signin/signin_manager_factory.h"
11 #include "chrome/test/base/testing_profile.h"
14 #include "ash/shell.h"
18 #include "ui/aura/env.h"
19 #include "ui/aura/window_event_dispatcher.h"
22 using content::RenderViewHostTester
;
23 using content::RenderViewHostTestHarness
;
27 scoped_ptr
<KeyedService
> BuildSigninManagerFake(
28 content::BrowserContext
* context
) {
29 Profile
* profile
= static_cast<Profile
*>(context
);
30 #if defined (OS_CHROMEOS)
31 scoped_ptr
<SigninManagerBase
> signin(new SigninManagerBase(
32 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile
),
33 AccountTrackerServiceFactory::GetInstance()->GetForProfile(profile
)));
34 signin
->Initialize(NULL
);
37 scoped_ptr
<FakeSigninManager
> manager(new FakeSigninManager(profile
));
38 manager
->Initialize(g_browser_process
->local_state());
39 return manager
.Pass();
45 ChromeRenderViewHostTestHarness::ChromeRenderViewHostTestHarness() {
48 ChromeRenderViewHostTestHarness::~ChromeRenderViewHostTestHarness() {
51 TestingProfile
* ChromeRenderViewHostTestHarness::profile() {
52 return static_cast<TestingProfile
*>(browser_context());
55 void ChromeRenderViewHostTestHarness::TearDown() {
56 RenderViewHostTestHarness::TearDown();
58 ash::Shell::DeleteInstance();
61 aura::Env::DeleteInstance();
65 content::BrowserContext
*
66 ChromeRenderViewHostTestHarness::CreateBrowserContext() {
67 TestingProfile::Builder builder
;
68 builder
.AddTestingFactory(SigninManagerFactory::GetInstance(),
69 BuildSigninManagerFake
);
70 return builder
.Build().release();