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"
22 #include "base/test/mock_chrome_application_mac.h"
27 #include "base/base_switches.h"
28 #include "base/command_line.h"
29 #include "media/base/media.h"
30 #include "ui/gl/gl_surface.h"
35 class TestInitializationListener : public testing::EmptyTestEventListener {
37 TestInitializationListener() : test_content_client_initializer_(NULL) {
40 virtual void OnTestStart(const testing::TestInfo& test_info) override {
41 test_content_client_initializer_ =
42 new content::TestContentClientInitializer();
45 virtual void OnTestEnd(const testing::TestInfo& test_info) override {
46 delete test_content_client_initializer_;
50 content::TestContentClientInitializer* test_content_client_initializer_;
52 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener);
59 ContentTestSuite::ContentTestSuite(int argc, char** argv)
60 : ContentTestSuiteBase(argc, argv) {
63 ContentTestSuite::~ContentTestSuite() {
66 void ContentTestSuite::Initialize() {
67 #if defined(OS_MACOSX)
68 base::mac::ScopedNSAutoreleasePool autorelease_pool;
70 mock_cr_app::RegisterMockCrApp();
75 gfx::InitDeviceScaleFactor(1.0f);
78 ContentTestSuiteBase::Initialize();
81 ContentTestSuiteBase::RegisterContentSchemes(&client);
83 RegisterPathProvider();
85 media::InitializeMediaLibraryForTesting();
86 // When running in a child process for Mac sandbox tests, the sandbox exists
87 // to initialize GL, so don't do it here.
88 if (!CommandLine::ForCurrentProcess()->HasSwitch(
89 switches::kTestChildProcess)) {
90 gfx::GLSurface::InitializeOneOffForTests();
91 gpu::ApplyGpuDriverBugWorkarounds(CommandLine::ForCurrentProcess());
94 testing::TestEventListeners& listeners =
95 testing::UnitTest::GetInstance()->listeners();
96 listeners.Append(new TestInitializationListener);
99 } // namespace content