blob: faa22ce09f3159174f5edc4d13b233143514ff48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/base_paths.h"
#include "base/bind.h"
#include "base/macros.h"
#include "base/path_service.h"
#include "base/test/launcher/unit_test_launcher.h"
#include "content/public/common/content_client.h"
#include "content/public/test/content_test_suite_base.h"
#include "content/public/test/unittest_test_suite.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension_paths.h"
#include "extensions/test/test_extensions_client.h"
#include "mojo/edk/embedder/test_embedder.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gl/gl_surface.h"
namespace {
// Content client that exists only to register chrome-extension:// scheme with
// the url module.
// TODO(jamescook): Should this be merged with ShellContentClient? Should this
// be a persistent object available to tests?
class ExtensionsContentClient : public content::ContentClient {
public:
ExtensionsContentClient() {}
virtual ~ExtensionsContentClient() {}
// content::ContentClient overrides:
virtual void AddAdditionalSchemes(
std::vector<std::string>* standard_schemes,
std::vector<std::string>* savable_schemes) override {
standard_schemes->push_back(extensions::kExtensionScheme);
savable_schemes->push_back(extensions::kExtensionScheme);
standard_schemes->push_back(extensions::kExtensionResourceScheme);
savable_schemes->push_back(extensions::kExtensionResourceScheme);
}
private:
DISALLOW_COPY_AND_ASSIGN(ExtensionsContentClient);
};
// The test suite for extensions_unittests.
class ExtensionsTestSuite : public content::ContentTestSuiteBase {
public:
ExtensionsTestSuite(int argc, char** argv);
virtual ~ExtensionsTestSuite();
private:
// base::TestSuite:
virtual void Initialize() override;
virtual void Shutdown() override;
scoped_ptr<extensions::TestExtensionsClient> client_;
DISALLOW_COPY_AND_ASSIGN(ExtensionsTestSuite);
};
ExtensionsTestSuite::ExtensionsTestSuite(int argc, char** argv)
: content::ContentTestSuiteBase(argc, argv) {}
ExtensionsTestSuite::~ExtensionsTestSuite() {}
void ExtensionsTestSuite::Initialize() {
content::ContentTestSuiteBase::Initialize();
gfx::GLSurface::InitializeOneOffForTests();
// Register the chrome-extension:// scheme via this circuitous path. Note
// that this does not persistently set up a ContentClient; individual tests
// must use content::SetContentClient().
{
ExtensionsContentClient content_client;
RegisterContentSchemes(&content_client);
}
extensions::RegisterPathProvider();
base::FilePath extensions_shell_and_test_pak_path;
PathService::Get(base::DIR_MODULE, &extensions_shell_and_test_pak_path);
ui::ResourceBundle::InitSharedInstanceWithPakPath(
extensions_shell_and_test_pak_path.AppendASCII(
"extensions_shell_and_test.pak"));
client_.reset(new extensions::TestExtensionsClient());
extensions::ExtensionsClient::Set(client_.get());
}
void ExtensionsTestSuite::Shutdown() {
extensions::ExtensionsClient::Set(NULL);
client_.reset();
ui::ResourceBundle::CleanupSharedInstance();
content::ContentTestSuiteBase::Shutdown();
}
} // namespace
int main(int argc, char** argv) {
content::UnitTestTestSuite test_suite(new ExtensionsTestSuite(argc, argv));
mojo::embedder::test::InitWithSimplePlatformSupport();
return base::LaunchUnitTests(argc,
argv,
base::Bind(&content::UnitTestTestSuite::Run,
base::Unretained(&test_suite)));
}
|