Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: extensions/browser/extensions_test.cc

Issue 2697463002: Convert utility process extension Unpacker IPC to mojo (Closed)
Patch Set: Take #4, declare the IPC enum traits in the message file, try build fix. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "extensions/browser/extensions_test.h" 5 #include "extensions/browser/extensions_test.h"
6 6
7 #include "components/keyed_service/content/browser_context_dependency_manager.h" 7 #include "components/keyed_service/content/browser_context_dependency_manager.h"
8 #include "content/public/browser/content_browser_client.h" 8 #include "content/public/browser/content_browser_client.h"
9 #include "content/public/common/content_client.h" 9 #include "content/public/common/content_client.h"
10 #include "content/public/test/test_browser_context.h" 10 #include "content/public/test/test_browser_context.h"
11 #include "extensions/browser/test_extensions_browser_client.h" 11 #include "extensions/browser/test_extensions_browser_client.h"
12 #include "extensions/test/test_content_browser_client.h"
12 #include "extensions/test/test_content_utility_client.h" 13 #include "extensions/test/test_content_utility_client.h"
13 14
14 namespace extensions { 15 namespace extensions {
15 16
16 // This class does work in the constructor instead of SetUp() to give subclasses 17 // 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: 18 // a valid BrowserContext to use while initializing their members. For example:
18 // 19 //
19 // class MyExtensionsTest : public ExtensionsTest { 20 // class MyExtensionsTest : public ExtensionsTest {
20 // MyExtensionsTest() 21 // MyExtensionsTest()
21 // : my_object_(browser_context())) { 22 // : my_object_(browser_context())) {
22 // } 23 // }
23 // }; 24 // };
24 ExtensionsTest::ExtensionsTest() 25 ExtensionsTest::ExtensionsTest()
25 : content_utility_client_(new TestContentUtilityClient), 26 : content_browser_client_(new TestContentBrowserClient),
27 content_utility_client_(new TestContentUtilityClient),
26 browser_context_(new content::TestBrowserContext), 28 browser_context_(new content::TestBrowserContext),
27 extensions_browser_client_( 29 extensions_browser_client_(
28 new TestExtensionsBrowserClient(browser_context_.get())) { 30 new TestExtensionsBrowserClient(browser_context_.get())) {
31 content::SetBrowserClientForTesting(content_browser_client_.get());
29 content::SetUtilityClientForTesting(content_utility_client_.get()); 32 content::SetUtilityClientForTesting(content_utility_client_.get());
30 ExtensionsBrowserClient::Set(extensions_browser_client_.get()); 33 ExtensionsBrowserClient::Set(extensions_browser_client_.get());
31 extensions_browser_client_->set_extension_system_factory( 34 extensions_browser_client_->set_extension_system_factory(
32 &extension_system_factory_); 35 &extension_system_factory_);
33 } 36 }
34 37
35 ExtensionsTest::~ExtensionsTest() { 38 ExtensionsTest::~ExtensionsTest() {
36 ExtensionsBrowserClient::Set(nullptr); 39 ExtensionsBrowserClient::Set(nullptr);
37 content::SetBrowserClientForTesting(nullptr); 40 content::SetBrowserClientForTesting(nullptr);
38 content::SetUtilityClientForTesting(nullptr); 41 content::SetUtilityClientForTesting(nullptr);
39 } 42 }
40 43
41 void ExtensionsTest::SetUp() { 44 void ExtensionsTest::SetUp() {
42 // Crashing here? Don't use this class in Chrome's unit_tests. See header. 45 // Crashing here? Don't use this class in Chrome's unit_tests. See header.
43 BrowserContextDependencyManager::GetInstance() 46 BrowserContextDependencyManager::GetInstance()
44 ->CreateBrowserContextServicesForTest(browser_context_.get()); 47 ->CreateBrowserContextServicesForTest(browser_context_.get());
45 } 48 }
46 49
47 void ExtensionsTest::TearDown() { 50 void ExtensionsTest::TearDown() {
48 // Allows individual tests to have BrowserContextKeyedServiceFactory objects 51 // Allows individual tests to have BrowserContextKeyedServiceFactory objects
49 // as member variables instead of singletons. The individual services will be 52 // as member variables instead of singletons. The individual services will be
50 // cleaned up before the factories are destroyed. 53 // cleaned up before the factories are destroyed.
51 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( 54 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices(
52 browser_context_.get()); 55 browser_context_.get());
53 extensions_browser_client_.reset(); 56 extensions_browser_client_.reset();
54 browser_context_.reset(); 57 browser_context_.reset();
55 } 58 }
56 59
57 } // namespace extensions 60 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698