Update broken references to image assets
[chromium-blink-merge.git] / content / test / content_test_suite.cc
blobaaf664890c4a65a79188b6c3fae9fe49847fa6c1
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 #endif
42 namespace content {
43 namespace {
45 class TestInitializationListener : public testing::EmptyTestEventListener {
46 public:
47 TestInitializationListener() : test_content_client_initializer_(NULL) {
50 void OnTestStart(const testing::TestInfo& test_info) override {
51 test_content_client_initializer_ =
52 new content::TestContentClientInitializer();
55 void OnTestEnd(const testing::TestInfo& test_info) override {
56 delete test_content_client_initializer_;
59 private:
60 content::TestContentClientInitializer* test_content_client_initializer_;
62 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener);
65 } // namespace
67 ContentTestSuite::ContentTestSuite(int argc, char** argv)
68 : ContentTestSuiteBase(argc, argv) {
71 ContentTestSuite::~ContentTestSuite() {
74 void ContentTestSuite::Initialize() {
75 #if defined(OS_MACOSX)
76 base::mac::ScopedNSAutoreleasePool autorelease_pool;
77 #if !defined(OS_IOS)
78 mock_cr_app::RegisterMockCrApp();
79 #endif
80 #endif
82 #if defined(OS_WIN)
83 gfx::InitDeviceScaleFactor(1.0f);
84 #endif
86 ContentTestSuiteBase::Initialize();
88 ContentClient client;
89 ContentTestSuiteBase::RegisterContentSchemes(&client);
91 RegisterPathProvider();
92 #if !defined(OS_IOS)
93 media::InitializeMediaLibrary();
94 // When running in a child process for Mac sandbox tests, the sandbox exists
95 // to initialize GL, so don't do it here.
96 bool is_child_process = base::CommandLine::ForCurrentProcess()->HasSwitch(
97 switches::kTestChildProcess);
98 if (!is_child_process) {
99 gfx::GLSurfaceTestSupport::InitializeOneOff();
100 gpu::ApplyGpuDriverBugWorkarounds(base::CommandLine::ForCurrentProcess());
102 #endif
103 testing::TestEventListeners& listeners =
104 testing::UnitTest::GetInstance()->listeners();
105 listeners.Append(new TestInitializationListener);
106 #if defined(OS_ANDROID)
107 SurfaceTextureManager::SetInstance(
108 InProcessSurfaceTextureManager::GetInstance());
109 #endif
110 #if defined(OS_MACOSX) && !defined(OS_IOS)
111 IOSurfaceManager::SetInstance(InProcessIOSurfaceManager::GetInstance());
112 #endif
113 #if defined(USE_OZONE)
114 if (!is_child_process) {
115 client_native_pixmap_factory_ = ui::ClientNativePixmapFactory::Create();
116 ui::ClientNativePixmapFactory::SetInstance(
117 client_native_pixmap_factory_.get());
119 #endif
122 } // namespace content