blob: e930421a1e1c7fda437e560af79621c16643a393 [file] [log] [blame]
[email protected]a80de9112014-07-31 03:15:081// 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]9fc5bdc82014-08-03 23:49:268#include "base/compiler_specific.h"
[email protected]a80de9112014-07-31 03:15:089#include "base/macros.h"
10#include "base/memory/scoped_ptr.h"
sudarsana.nagineni745ff1db2015-01-31 00:26:1911#include "content/public/test/test_renderer_host.h"
thestig34f7eca2015-02-03 18:42:4012#include "extensions/browser/mock_extension_system.h"
[email protected]a80de9112014-07-31 03:15:0813#include "testing/gtest/include/gtest/gtest.h"
14
15namespace content {
jamescook30a1ccd2014-09-09 15:59:2116class BrowserContext;
[email protected]a80de9112014-07-31 03:15:0817class ContentBrowserClient;
asargent275faaa2015-01-27 23:43:2918class ContentClient;
19class ContentUtilityClient;
sudarsana.nagineni745ff1db2015-01-31 00:26:1920class RenderViewHostTestEnabler;
[email protected]a80de9112014-07-31 03:15:0821}
22
23namespace extensions {
24class TestExtensionsBrowserClient;
25
26// Base class for extensions module unit tests of browser process code. Sets up
27// the content module and extensions module client interfaces. Initializes
28// services for a browser context.
29//
30// NOTE: Use this class only in extensions_unittests, not in Chrome unit_tests.
31// BrowserContextKeyedServiceFactory singletons persist between tests.
32// In Chrome those factories assume any BrowserContext is a Profile and will
33// cause crashes if it is not. http://crbug.com/395820
34class ExtensionsTest : public testing::Test {
35 public:
36 ExtensionsTest();
dchengf9afb372014-10-27 21:43:1437 ~ExtensionsTest() override;
[email protected]a80de9112014-07-31 03:15:0838
jamescook30a1ccd2014-09-09 15:59:2139 // Returned as a BrowserContext since most users don't need methods from
40 // TestBrowserContext.
41 content::BrowserContext* browser_context() { return browser_context_.get(); }
42
43 // Returned as a TestExtensionsBrowserClient since most users need to call
44 // test-specific methods on it.
[email protected]a80de9112014-07-31 03:15:0845 TestExtensionsBrowserClient* extensions_browser_client() {
46 return extensions_browser_client_.get();
47 }
48
[email protected]9fc5bdc82014-08-03 23:49:2649 // testing::Test overrides:
dchengf9afb372014-10-27 21:43:1450 void SetUp() override;
51 void TearDown() override;
[email protected]9fc5bdc82014-08-03 23:49:2652
[email protected]a80de9112014-07-31 03:15:0853 private:
yoz0e463fa2014-11-19 22:00:4854 // TODO(yoz): Add a NotificationService here; it's used widely enough.
[email protected]a80de9112014-07-31 03:15:0855 scoped_ptr<content::ContentClient> content_client_;
asargent275faaa2015-01-27 23:43:2956 scoped_ptr<content::ContentUtilityClient> content_utility_client_;
[email protected]a80de9112014-07-31 03:15:0857 scoped_ptr<content::ContentBrowserClient> content_browser_client_;
jamescook30a1ccd2014-09-09 15:59:2158 scoped_ptr<content::BrowserContext> browser_context_;
[email protected]a80de9112014-07-31 03:15:0859 scoped_ptr<TestExtensionsBrowserClient> extensions_browser_client_;
60
sudarsana.nagineni745ff1db2015-01-31 00:26:1961 // The existence of this object enables tests via
62 // RenderViewHostTester.
63 content::RenderViewHostTestEnabler rvh_test_enabler_;
64
thestig34f7eca2015-02-03 18:42:4065 MockExtensionSystemFactory<MockExtensionSystem> extension_system_factory_;
66
[email protected]a80de9112014-07-31 03:15:0867 DISALLOW_COPY_AND_ASSIGN(ExtensionsTest);
68};
69
70} // namespace extensions
71
72#endif // EXTENSIONS_BROWSER_EXTENSIONS_TEST_H_