Roll src/third_party/WebKit cbf995c:8b279ab (svn 197774:197783)
[chromium-blink-merge.git] / content / test / content_test_suite.cc
blob116bd0ce472064bf8445bc610e3bafd172f4f860
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"
15 #if defined(OS_WIN)
16 #include "ui/gfx/win/dpi.h"
17 #endif
19 #if defined(OS_MACOSX)
20 #include "base/mac/scoped_nsautorelease_pool.h"
21 #if !defined(OS_IOS)
22 #include "base/test/mock_chrome_application_mac.h"
23 #include "content/browser/in_process_io_surface_manager_mac.h"
24 #endif
25 #endif
27 #if !defined(OS_IOS)
28 #include "base/base_switches.h"
29 #include "base/command_line.h"
30 #include "media/base/media.h"
31 #include "ui/gl/gl_surface.h"
32 #endif
34 #if defined(OS_ANDROID)
35 #include "content/browser/android/in_process_surface_texture_manager.h"
36 #endif
38 namespace content {
39 namespace {
41 class TestInitializationListener : public testing::EmptyTestEventListener {
42 public:
43 TestInitializationListener() : test_content_client_initializer_(NULL) {
46 void OnTestStart(const testing::TestInfo& test_info) override {
47 test_content_client_initializer_ =
48 new content::TestContentClientInitializer();
51 void OnTestEnd(const testing::TestInfo& test_info) override {
52 delete test_content_client_initializer_;
55 private:
56 content::TestContentClientInitializer* test_content_client_initializer_;
58 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener);
61 } // namespace
63 ContentTestSuite::ContentTestSuite(int argc, char** argv)
64 : ContentTestSuiteBase(argc, argv) {
67 ContentTestSuite::~ContentTestSuite() {
70 void ContentTestSuite::Initialize() {
71 #if defined(OS_MACOSX)
72 base::mac::ScopedNSAutoreleasePool autorelease_pool;
73 #if !defined(OS_IOS)
74 mock_cr_app::RegisterMockCrApp();
75 #endif
76 #endif
78 #if defined(OS_WIN)
79 gfx::InitDeviceScaleFactor(1.0f);
80 #endif
82 ContentTestSuiteBase::Initialize();
84 ContentClient client;
85 ContentTestSuiteBase::RegisterContentSchemes(&client);
87 RegisterPathProvider();
88 #if !defined(OS_IOS)
89 media::InitializeMediaLibrary();
90 // When running in a child process for Mac sandbox tests, the sandbox exists
91 // to initialize GL, so don't do it here.
92 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
93 switches::kTestChildProcess)) {
94 gfx::GLSurface::InitializeOneOffForTests();
95 gpu::ApplyGpuDriverBugWorkarounds(base::CommandLine::ForCurrentProcess());
97 #endif
98 testing::TestEventListeners& listeners =
99 testing::UnitTest::GetInstance()->listeners();
100 listeners.Append(new TestInitializationListener);
101 #if defined(OS_ANDROID)
102 SurfaceTextureManager::SetInstance(
103 InProcessSurfaceTextureManager::GetInstance());
104 #endif
105 #if defined(OS_MACOSX) && !defined(OS_IOS)
106 IOSurfaceManager::SetInstance(InProcessIOSurfaceManager::GetInstance());
107 #endif
110 } // namespace content