[email protected] | a80de911 | 2014-07-31 03:15:08 | [diff] [blame] | 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. |
| 4 | |
| 5 | #ifndef EXTENSIONS_BROWSER_EXTENSIONS_TEST_H_ |
| 6 | #define EXTENSIONS_BROWSER_EXTENSIONS_TEST_H_ |
| 7 | |
[email protected] | 9fc5bdc8 | 2014-08-03 23:49:26 | [diff] [blame] | 8 | #include "base/compiler_specific.h" |
[email protected] | a80de911 | 2014-07-31 03:15:08 | [diff] [blame] | 9 | #include "base/macros.h" |
| 10 | #include "base/memory/scoped_ptr.h" |
| 11 | #include "testing/gtest/include/gtest/gtest.h" |
| 12 | |
| 13 | namespace content { |
jamescook | 30a1ccd | 2014-09-09 15:59:21 | [diff] [blame] | 14 | class BrowserContext; |
[email protected] | a80de911 | 2014-07-31 03:15:08 | [diff] [blame] | 15 | class ContentClient; |
| 16 | class ContentBrowserClient; |
[email protected] | a80de911 | 2014-07-31 03:15:08 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | namespace extensions { |
| 20 | class TestExtensionsBrowserClient; |
| 21 | |
| 22 | // Base class for extensions module unit tests of browser process code. Sets up |
| 23 | // the content module and extensions module client interfaces. Initializes |
| 24 | // services for a browser context. |
| 25 | // |
| 26 | // NOTE: Use this class only in extensions_unittests, not in Chrome unit_tests. |
| 27 | // BrowserContextKeyedServiceFactory singletons persist between tests. |
| 28 | // In Chrome those factories assume any BrowserContext is a Profile and will |
| 29 | // cause crashes if it is not. http://crbug.com/395820 |
| 30 | class ExtensionsTest : public testing::Test { |
| 31 | public: |
| 32 | ExtensionsTest(); |
dcheng | f9afb37 | 2014-10-27 21:43:14 | [diff] [blame^] | 33 | ~ExtensionsTest() override; |
[email protected] | a80de911 | 2014-07-31 03:15:08 | [diff] [blame] | 34 | |
jamescook | 30a1ccd | 2014-09-09 15:59:21 | [diff] [blame] | 35 | // Returned as a BrowserContext since most users don't need methods from |
| 36 | // TestBrowserContext. |
| 37 | content::BrowserContext* browser_context() { return browser_context_.get(); } |
| 38 | |
| 39 | // Returned as a TestExtensionsBrowserClient since most users need to call |
| 40 | // test-specific methods on it. |
[email protected] | a80de911 | 2014-07-31 03:15:08 | [diff] [blame] | 41 | TestExtensionsBrowserClient* extensions_browser_client() { |
| 42 | return extensions_browser_client_.get(); |
| 43 | } |
| 44 | |
[email protected] | 9fc5bdc8 | 2014-08-03 23:49:26 | [diff] [blame] | 45 | // testing::Test overrides: |
dcheng | f9afb37 | 2014-10-27 21:43:14 | [diff] [blame^] | 46 | void SetUp() override; |
| 47 | void TearDown() override; |
[email protected] | 9fc5bdc8 | 2014-08-03 23:49:26 | [diff] [blame] | 48 | |
[email protected] | a80de911 | 2014-07-31 03:15:08 | [diff] [blame] | 49 | private: |
| 50 | scoped_ptr<content::ContentClient> content_client_; |
| 51 | scoped_ptr<content::ContentBrowserClient> content_browser_client_; |
jamescook | 30a1ccd | 2014-09-09 15:59:21 | [diff] [blame] | 52 | scoped_ptr<content::BrowserContext> browser_context_; |
[email protected] | a80de911 | 2014-07-31 03:15:08 | [diff] [blame] | 53 | scoped_ptr<TestExtensionsBrowserClient> extensions_browser_client_; |
| 54 | |
| 55 | DISALLOW_COPY_AND_ASSIGN(ExtensionsTest); |
| 56 | }; |
| 57 | |
| 58 | } // namespace extensions |
| 59 | |
| 60 | #endif // EXTENSIONS_BROWSER_EXTENSIONS_TEST_H_ |