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 "content/public/common/content_client.h"
10 #include "content/public/common/content_paths.h"
11 #include "content/public/test/test_content_client_initializer.h"
12 #include "gpu/config/gpu_util.h"
13 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/gfx/win/dpi.h"
19 #if defined(OS_MACOSX)
20 #include "base/mac/scoped_nsautorelease_pool.h"
24 #include "base/base_switches.h"
25 #include "base/command_line.h"
26 #include "media/base/media.h"
27 #include "ui/gl/gl_surface.h"
32 class TestInitializationListener
: public testing::EmptyTestEventListener
{
34 TestInitializationListener() : test_content_client_initializer_(NULL
) {
37 virtual void OnTestStart(const testing::TestInfo
& test_info
) OVERRIDE
{
38 test_content_client_initializer_
=
39 new content::TestContentClientInitializer();
42 virtual void OnTestEnd(const testing::TestInfo
& test_info
) OVERRIDE
{
43 delete test_content_client_initializer_
;
47 content::TestContentClientInitializer
* test_content_client_initializer_
;
49 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener
);
56 ContentTestSuite::ContentTestSuite(int argc
, char** argv
)
57 : ContentTestSuiteBase(argc
, argv
) {
60 ContentTestSuite::~ContentTestSuite() {
63 void ContentTestSuite::Initialize() {
64 #if defined(OS_MACOSX)
65 base::mac::ScopedNSAutoreleasePool autorelease_pool
;
69 gfx::InitDeviceScaleFactor(1.0f
);
72 ContentTestSuiteBase::Initialize();
75 ContentTestSuiteBase::RegisterContentSchemes(&client
);
77 RegisterPathProvider();
79 media::InitializeMediaLibraryForTesting();
80 // When running in a child process for Mac sandbox tests, the sandbox exists
81 // to initialize GL, so don't do it here.
82 if (!CommandLine::ForCurrentProcess()->HasSwitch(
83 switches::kTestChildProcess
)) {
84 gfx::GLSurface::InitializeOneOffForTests();
85 gpu::ApplyGpuDriverBugWorkarounds(CommandLine::ForCurrentProcess());
88 testing::TestEventListeners
& listeners
=
89 testing::UnitTest::GetInstance()->listeners();
90 listeners
.Append(new TestInitializationListener
);
93 } // namespace content