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

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

Issue 2798503002: Extensions: Pull duplicated functionality into ExtensionsTest fixture. (Closed)
Patch Set: Nits Created 3 years, 8 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
« no previous file with comments | « extensions/browser/event_router_unittest.cc ('k') | extensions/browser/extensions_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #ifndef EXTENSIONS_BROWSER_EXTENSIONS_TEST_H_ 5 #ifndef EXTENSIONS_BROWSER_EXTENSIONS_TEST_H_
6 #define EXTENSIONS_BROWSER_EXTENSIONS_TEST_H_ 6 #define EXTENSIONS_BROWSER_EXTENSIONS_TEST_H_
7 7
8 #include <memory> 8 #include <memory>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "content/public/test/test_content_client_initializer.h" 12 #include "content/public/test/test_content_client_initializer.h"
13 #include "content/public/test/test_renderer_host.h" 13 #include "content/public/test/test_renderer_host.h"
14 #include "extensions/browser/mock_extension_system.h" 14 #include "extensions/browser/mock_extension_system.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 class ExtensionPrefValueMap;
18 class PrefService;
19
17 namespace content { 20 namespace content {
18 class BrowserContext; 21 class BrowserContext;
19 class ContentBrowserClient; 22 class ContentBrowserClient;
20 class ContentUtilityClient; 23 class ContentUtilityClient;
21 class RenderViewHostTestEnabler; 24 class RenderViewHostTestEnabler;
22 } 25 }
23 26
24 namespace extensions { 27 namespace extensions {
25 class TestExtensionsBrowserClient; 28 class TestExtensionsBrowserClient;
26 29
27 // Base class for extensions module unit tests of browser process code. Sets up 30 // Base class for extensions module unit tests of browser process code. Sets up
28 // the content module and extensions module client interfaces. Initializes 31 // the content module and extensions module client interfaces. Initializes
29 // services for a browser context. 32 // services for a browser context and sets up extension preferences.
30 // 33 //
31 // NOTE: Use this class only in extensions_unittests, not in Chrome unit_tests. 34 // NOTE: Use this class only in extensions_unittests, not in Chrome unit_tests.
32 // BrowserContextKeyedServiceFactory singletons persist between tests.
33 // In Chrome those factories assume any BrowserContext is a Profile and will 35 // In Chrome those factories assume any BrowserContext is a Profile and will
34 // cause crashes if it is not. http://crbug.com/395820 36 // cause crashes if it is not. http://crbug.com/395820
35 class ExtensionsTest : public testing::Test { 37 class ExtensionsTest : public testing::Test {
36 public: 38 public:
37 ExtensionsTest(); 39 ExtensionsTest();
38 ~ExtensionsTest() override; 40 ~ExtensionsTest() override;
39 41
40 // Returned as a BrowserContext since most users don't need methods from 42 // Returned as a BrowserContext since most users don't need methods from
41 // TestBrowserContext. 43 // TestBrowserContext.
42 content::BrowserContext* browser_context() { return browser_context_.get(); } 44 content::BrowserContext* browser_context() { return browser_context_.get(); }
43 45
46 // Returns the incognito context associated with the ExtensionsBrowserClient.
47 content::BrowserContext* incognito_context() {
48 return incognito_context_.get();
49 }
50
44 // Returned as a TestExtensionsBrowserClient since most users need to call 51 // Returned as a TestExtensionsBrowserClient since most users need to call
45 // test-specific methods on it. 52 // test-specific methods on it.
46 TestExtensionsBrowserClient* extensions_browser_client() { 53 TestExtensionsBrowserClient* extensions_browser_client() {
47 return extensions_browser_client_.get(); 54 return extensions_browser_client_.get();
48 } 55 }
49 56
57 PrefService* pref_service() { return pref_service_.get(); }
58
50 // testing::Test overrides: 59 // testing::Test overrides:
51 void SetUp() override; 60 void SetUp() override;
52 void TearDown() override; 61 void TearDown() override;
53 62
54 private: 63 private:
55 content::TestContentClientInitializer content_client_initializer_; 64 content::TestContentClientInitializer content_client_initializer_;
56 std::unique_ptr<content::ContentBrowserClient> content_browser_client_; 65 std::unique_ptr<content::ContentBrowserClient> content_browser_client_;
57 std::unique_ptr<content::ContentUtilityClient> content_utility_client_; 66 std::unique_ptr<content::ContentUtilityClient> content_utility_client_;
58 std::unique_ptr<content::BrowserContext> browser_context_; 67 std::unique_ptr<content::BrowserContext> browser_context_;
68 std::unique_ptr<content::BrowserContext> incognito_context_;
59 std::unique_ptr<TestExtensionsBrowserClient> extensions_browser_client_; 69 std::unique_ptr<TestExtensionsBrowserClient> extensions_browser_client_;
70 std::unique_ptr<ExtensionPrefValueMap> extension_pref_value_map_;
71 std::unique_ptr<PrefService> pref_service_;
60 72
61 // The existence of this object enables tests via 73 // The existence of this object enables tests via
62 // RenderViewHostTester. 74 // RenderViewHostTester.
63 content::RenderViewHostTestEnabler rvh_test_enabler_; 75 content::RenderViewHostTestEnabler rvh_test_enabler_;
64 76
65 MockExtensionSystemFactory<MockExtensionSystem> extension_system_factory_; 77 MockExtensionSystemFactory<MockExtensionSystem> extension_system_factory_;
66 78
67 DISALLOW_COPY_AND_ASSIGN(ExtensionsTest); 79 DISALLOW_COPY_AND_ASSIGN(ExtensionsTest);
68 }; 80 };
69 81
70 } // namespace extensions 82 } // namespace extensions
71 83
72 #endif // EXTENSIONS_BROWSER_EXTENSIONS_TEST_H_ 84 #endif // EXTENSIONS_BROWSER_EXTENSIONS_TEST_H_
OLDNEW
« no previous file with comments | « extensions/browser/event_router_unittest.cc ('k') | extensions/browser/extensions_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698