1 // Copyright (c) 2012 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 "content/test/content_test_suite.h"
7 #include "base/base_paths.h"
8 #include "base/logging.h"
9 #include "base/path_service.h"
10 #include "content/public/common/content_client.h"
11 #include "content/public/common/content_paths.h"
12 #include "content/public/test/test_content_client_initializer.h"
13 #include "gpu/config/gpu_util.h"
14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/base/resource/resource_bundle.h"
17 #if defined(OS_MACOSX)
18 #include "base/mac/scoped_nsautorelease_pool.h"
22 #include "base/base_switches.h"
23 #include "base/command_line.h"
24 #include "media/base/media.h"
25 #include "ui/gl/gl_surface.h"
30 class TestInitializationListener
: public testing::EmptyTestEventListener
{
32 TestInitializationListener() : test_content_client_initializer_(NULL
) {
35 virtual void OnTestStart(const testing::TestInfo
& test_info
) OVERRIDE
{
36 test_content_client_initializer_
=
37 new content::TestContentClientInitializer();
40 virtual void OnTestEnd(const testing::TestInfo
& test_info
) OVERRIDE
{
41 delete test_content_client_initializer_
;
45 content::TestContentClientInitializer
* test_content_client_initializer_
;
47 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener
);
54 ContentTestSuite::ContentTestSuite(int argc
, char** argv
)
55 : ContentTestSuiteBase(argc
, argv
) {
57 base::FilePath pak_file
;
58 PathService::Get(base::DIR_MODULE
, &pak_file
);
59 pak_file
= pak_file
.AppendASCII("ui_test.pak");
60 ui::ResourceBundle::InitSharedInstanceWithPakPath(pak_file
);
64 ContentTestSuite::~ContentTestSuite() {
66 ui::ResourceBundle::CleanupSharedInstance();
70 void ContentTestSuite::Initialize() {
71 #if defined(OS_MACOSX)
72 base::mac::ScopedNSAutoreleasePool autorelease_pool
;
75 ContentTestSuiteBase::Initialize();
78 ContentTestSuiteBase::RegisterContentSchemes(&client
);
80 RegisterPathProvider();
82 media::InitializeMediaLibraryForTesting();
83 // When running in a child process for Mac sandbox tests, the sandbox exists
84 // to initialize GL, so don't do it here.
85 if (!CommandLine::ForCurrentProcess()->HasSwitch(
86 switches::kTestChildProcess
)) {
87 gfx::GLSurface::InitializeOneOffForTests();
88 gpu::ApplyGpuDriverBugWorkarounds(CommandLine::ForCurrentProcess());
91 testing::TestEventListeners
& listeners
=
92 testing::UnitTest::GetInstance()->listeners();
93 listeners
.Append(new TestInitializationListener
);
96 } // namespace content