Revert of Recorded additional tough_energy_cases. (patchset #1 id:1 of https://codere...
[chromium-blink-merge.git] / extensions / test / extensions_unittests_main.cc
blob9ec7e24f6f88f370bbce2baf12fc029dd65e1f49
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 "base/base_paths.h"
6 #include "base/bind.h"
7 #include "base/macros.h"
8 #include "base/path_service.h"
9 #include "base/test/launcher/unit_test_launcher.h"
10 #include "content/public/common/content_client.h"
11 #include "content/public/test/content_test_suite_base.h"
12 #include "content/public/test/unittest_test_suite.h"
13 #include "extensions/common/constants.h"
14 #include "extensions/common/extension_paths.h"
15 #include "extensions/test/test_extensions_client.h"
16 #include "mojo/embedder/test_embedder.h"
17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/gl/gl_surface.h"
20 namespace {
22 // Content client that exists only to register chrome-extension:// scheme with
23 // the url module.
24 // TODO(jamescook): Should this be merged with ShellContentClient? Should this
25 // be a persistent object available to tests?
26 class ExtensionsContentClient : public content::ContentClient {
27 public:
28 ExtensionsContentClient() {}
29 virtual ~ExtensionsContentClient() {}
31 // content::ContentClient overrides:
32 virtual void AddAdditionalSchemes(
33 std::vector<std::string>* standard_schemes,
34 std::vector<std::string>* savable_schemes) OVERRIDE {
35 standard_schemes->push_back(extensions::kExtensionScheme);
36 savable_schemes->push_back(extensions::kExtensionScheme);
37 standard_schemes->push_back(extensions::kExtensionResourceScheme);
38 savable_schemes->push_back(extensions::kExtensionResourceScheme);
41 private:
42 DISALLOW_COPY_AND_ASSIGN(ExtensionsContentClient);
45 // The test suite for extensions_unittests.
46 class ExtensionsTestSuite : public content::ContentTestSuiteBase {
47 public:
48 ExtensionsTestSuite(int argc, char** argv);
49 virtual ~ExtensionsTestSuite();
51 private:
52 // base::TestSuite:
53 virtual void Initialize() OVERRIDE;
54 virtual void Shutdown() OVERRIDE;
56 scoped_ptr<extensions::TestExtensionsClient> client_;
58 DISALLOW_COPY_AND_ASSIGN(ExtensionsTestSuite);
61 ExtensionsTestSuite::ExtensionsTestSuite(int argc, char** argv)
62 : content::ContentTestSuiteBase(argc, argv) {}
64 ExtensionsTestSuite::~ExtensionsTestSuite() {}
66 void ExtensionsTestSuite::Initialize() {
67 content::ContentTestSuiteBase::Initialize();
68 gfx::GLSurface::InitializeOneOffForTests();
70 // Register the chrome-extension:// scheme via this circuitous path. Note
71 // that this does not persistently set up a ContentClient; individual tests
72 // must use content::SetContentClient().
74 ExtensionsContentClient content_client;
75 RegisterContentSchemes(&content_client);
78 extensions::RegisterPathProvider();
80 base::FilePath extensions_shell_and_test_pak_path;
81 PathService::Get(base::DIR_MODULE, &extensions_shell_and_test_pak_path);
82 ui::ResourceBundle::InitSharedInstanceWithPakPath(
83 extensions_shell_and_test_pak_path.AppendASCII(
84 "extensions_shell_and_test.pak"));
86 client_.reset(new extensions::TestExtensionsClient());
87 extensions::ExtensionsClient::Set(client_.get());
90 void ExtensionsTestSuite::Shutdown() {
91 extensions::ExtensionsClient::Set(NULL);
92 client_.reset();
94 ui::ResourceBundle::CleanupSharedInstance();
95 content::ContentTestSuiteBase::Shutdown();
98 } // namespace
100 int main(int argc, char** argv) {
101 content::UnitTestTestSuite test_suite(new ExtensionsTestSuite(argc, argv));
103 mojo::embedder::test::InitWithSimplePlatformSupport();
104 return base::LaunchUnitTests(argc,
105 argv,
106 base::Bind(&content::UnitTestTestSuite::Run,
107 base::Unretained(&test_suite)));