Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / extensions / browser / extensions_test.cc
blob5b7a8ce486ae7966a356bd192e1c0c0d71779dd7
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.
5 #include "extensions/browser/extensions_test.h"
7 #include "components/keyed_service/content/browser_context_dependency_manager.h"
8 #include "content/public/browser/content_browser_client.h"
9 #include "content/public/common/content_client.h"
10 #include "content/public/test/test_browser_context.h"
11 #include "extensions/browser/test_extensions_browser_client.h"
13 namespace extensions {
15 // This class does work in the constructor instead of SetUp() to give subclasses
16 // a valid BrowserContext to use while initializing their members. For example:
18 // class MyExtensionsTest : public ExtensionsTest {
19 // MyExtensionsTest()
20 // : my_object_(browser_context())) {
21 // }
22 // };
23 ExtensionsTest::ExtensionsTest()
24 : content_client_(new content::ContentClient),
25 content_browser_client_(new content::ContentBrowserClient),
26 browser_context_(new content::TestBrowserContext),
27 extensions_browser_client_(
28 new TestExtensionsBrowserClient(browser_context_.get())) {
29 content::SetContentClient(content_client_.get());
30 content::SetBrowserClientForTesting(content_browser_client_.get());
31 ExtensionsBrowserClient::Set(extensions_browser_client_.get());
34 ExtensionsTest::~ExtensionsTest() {
35 ExtensionsBrowserClient::Set(NULL);
36 content::SetBrowserClientForTesting(NULL);
37 content::SetContentClient(NULL);
40 void ExtensionsTest::SetUp() {
41 // Crashing here? Don't use this class in Chrome's unit_tests. See header.
42 BrowserContextDependencyManager::GetInstance()
43 ->CreateBrowserContextServicesForTest(browser_context_.get());
46 void ExtensionsTest::TearDown() {
47 // Allows individual tests to have BrowserContextKeyedServiceFactory objects
48 // as member variables instead of singletons. The individual services will be
49 // cleaned up before the factories are destroyed.
50 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
51 browser_context_.get());
54 } // namespace extensions