Unregister from GCM when the only GCM app is removed
[chromium-blink-merge.git] / chrome / test / base / chrome_render_view_host_test_harness.cc
blob8a76f35ca0041c251710e6e8704bbb2bfbeed840
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"
7 #include "chrome/browser/browser_process.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"
13 #if defined(USE_ASH)
14 #include "ash/shell.h"
15 #endif
17 #if defined(USE_AURA)
18 #include "ui/aura/env.h"
19 #include "ui/aura/window_event_dispatcher.h"
20 #endif
22 using content::RenderViewHostTester;
23 using content::RenderViewHostTestHarness;
25 ChromeRenderViewHostTestHarness::ChromeRenderViewHostTestHarness() {
28 ChromeRenderViewHostTestHarness::~ChromeRenderViewHostTestHarness() {
31 TestingProfile* ChromeRenderViewHostTestHarness::profile() {
32 return static_cast<TestingProfile*>(browser_context());
35 static KeyedService* BuildSigninManagerFake(content::BrowserContext* context) {
36 Profile* profile = static_cast<Profile*>(context);
37 #if defined (OS_CHROMEOS)
38 SigninManagerBase* signin = new SigninManagerBase(
39 ChromeSigninClientFactory::GetInstance()->GetForProfile(profile));
40 signin->Initialize(NULL);
41 return signin;
42 #else
43 FakeSigninManager* manager = new FakeSigninManager(profile);
44 manager->Initialize(g_browser_process->local_state());
45 return manager;
46 #endif
49 void ChromeRenderViewHostTestHarness::TearDown() {
50 RenderViewHostTestHarness::TearDown();
51 #if defined(USE_ASH)
52 ash::Shell::DeleteInstance();
53 #endif
54 #if defined(USE_AURA)
55 aura::Env::DeleteInstance();
56 #endif
59 content::BrowserContext*
60 ChromeRenderViewHostTestHarness::CreateBrowserContext() {
61 TestingProfile::Builder builder;
62 builder.AddTestingFactory(SigninManagerFactory::GetInstance(),
63 BuildSigninManagerFake);
64 return builder.Build().release();