Fix search results being clipped in app list.
[chromium-blink-merge.git] / extensions / browser / extensions_test.cc
blobc6962ed05662653269b7d2083379d39a3af37cc9
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"
12 #include "extensions/test/test_content_utility_client.h"
14 namespace extensions {
16 // This class does work in the constructor instead of SetUp() to give subclasses
17 // a valid BrowserContext to use while initializing their members. For example:
19 // class MyExtensionsTest : public ExtensionsTest {
20 // MyExtensionsTest()
21 // : my_object_(browser_context())) {
22 // }
23 // };
24 ExtensionsTest::ExtensionsTest()
25 : content_client_(new content::ContentClient),
26 content_utility_client_(new TestContentUtilityClient),
27 content_browser_client_(new content::ContentBrowserClient),
28 browser_context_(new content::TestBrowserContext),
29 extensions_browser_client_(
30 new TestExtensionsBrowserClient(browser_context_.get())) {
31 content::SetContentClient(content_client_.get());
32 content::SetUtilityClientForTesting(content_utility_client_.get());
33 content::SetBrowserClientForTesting(content_browser_client_.get());
34 ExtensionsBrowserClient::Set(extensions_browser_client_.get());
35 extensions_browser_client_->set_extension_system_factory(
36 &extension_system_factory_);
39 ExtensionsTest::~ExtensionsTest() {
40 ExtensionsBrowserClient::Set(NULL);
41 content::SetBrowserClientForTesting(NULL);
42 content::SetUtilityClientForTesting(NULL);
43 content::SetContentClient(NULL);
46 void ExtensionsTest::SetUp() {
47 // Crashing here? Don't use this class in Chrome's unit_tests. See header.
48 BrowserContextDependencyManager::GetInstance()
49 ->CreateBrowserContextServicesForTest(browser_context_.get());
52 void ExtensionsTest::TearDown() {
53 // Allows individual tests to have BrowserContextKeyedServiceFactory objects
54 // as member variables instead of singletons. The individual services will be
55 // cleaned up before the factories are destroyed.
56 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
57 browser_context_.get());
60 } // namespace extensions