Infobar material design refresh: bg color
[chromium-blink-merge.git] / content / test / content_test_suite.cc
blob341a64ed9466e16001cdcd28ff070f079ced3755
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/test/gl_surface_test_support.h"
32 #endif
34 #if defined(OS_ANDROID)
35 #include "content/browser/android/in_process_surface_texture_manager.h"
36 #endif
38 #if defined(USE_OZONE)
39 #include "ui/ozone/public/client_native_pixmap_factory.h"
40 #include "ui/ozone/public/ozone_platform.h"
41 #endif
43 namespace content {
44 namespace {
46 class TestInitializationListener : public testing::EmptyTestEventListener {
47 public:
48 TestInitializationListener() : test_content_client_initializer_(NULL) {
51 void OnTestStart(const testing::TestInfo& test_info) override {
52 test_content_client_initializer_ =
53 new content::TestContentClientInitializer();
56 void OnTestEnd(const testing::TestInfo& test_info) override {
57 delete test_content_client_initializer_;
60 private:
61 content::TestContentClientInitializer* test_content_client_initializer_;
63 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener);
66 } // namespace
68 ContentTestSuite::ContentTestSuite(int argc, char** argv)
69 : ContentTestSuiteBase(argc, argv) {
72 ContentTestSuite::~ContentTestSuite() {
75 void ContentTestSuite::Initialize() {
76 #if defined(OS_MACOSX)
77 base::mac::ScopedNSAutoreleasePool autorelease_pool;
78 #if !defined(OS_IOS)
79 mock_cr_app::RegisterMockCrApp();
80 #endif
81 #endif
83 #if defined(OS_WIN)
84 gfx::InitDeviceScaleFactor(1.0f);
85 #endif
87 ContentTestSuiteBase::Initialize();
89 ContentClient client;
90 ContentTestSuiteBase::RegisterContentSchemes(&client);
92 RegisterPathProvider();
93 #if !defined(OS_IOS)
94 media::InitializeMediaLibrary();
95 // When running in a child process for Mac sandbox tests, the sandbox exists
96 // to initialize GL, so don't do it here.
97 bool is_child_process = base::CommandLine::ForCurrentProcess()->HasSwitch(
98 switches::kTestChildProcess);
99 if (!is_child_process) {
100 gfx::GLSurfaceTestSupport::InitializeOneOff();
101 gpu::ApplyGpuDriverBugWorkarounds(base::CommandLine::ForCurrentProcess());
103 #endif
104 testing::TestEventListeners& listeners =
105 testing::UnitTest::GetInstance()->listeners();
106 listeners.Append(new TestInitializationListener);
107 #if defined(OS_ANDROID)
108 SurfaceTextureManager::SetInstance(
109 InProcessSurfaceTextureManager::GetInstance());
110 #endif
111 #if defined(OS_MACOSX) && !defined(OS_IOS)
112 IOSurfaceManager::SetInstance(InProcessIOSurfaceManager::GetInstance());
113 #endif
114 #if defined(USE_OZONE)
115 if (!is_child_process) {
116 client_native_pixmap_factory_ = ui::ClientNativePixmapFactory::Create();
117 ui::ClientNativePixmapFactory::SetInstance(
118 client_native_pixmap_factory_.get());
119 ui::ClientNativePixmapFactory::GetInstance()->Initialize(
120 ui::OzonePlatform::GetInstance()->OpenClientNativePixmapDevice());
122 #endif
125 } // namespace content