OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/test/content_test_suite.h" | 5 #include "content/test/content_test_suite.h" |
6 | 6 |
7 #if defined(OS_ANDROID) | 7 #if defined(OS_ANDROID) |
8 #include <android/native_window.h> | 8 #include <android/native_window.h> |
9 #include <android/native_window_jni.h> | 9 #include <android/native_window_jni.h> |
10 #endif | 10 #endif |
11 | 11 |
12 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
15 #include "content/public/common/content_paths.h" | 15 #include "content/public/common/content_paths.h" |
16 #include "content/public/test/test_content_client_initializer.h" | 16 #include "content/public/test/test_content_client_initializer.h" |
17 #include "gpu/config/gpu_util.h" | 17 #include "gpu/config/gpu_util.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 #if defined(OS_WIN) | 20 #if defined(OS_WIN) |
21 #include "ui/gfx/win/dpi.h" | 21 #include "ui/gfx/win/dpi.h" |
22 #endif | 22 #endif |
23 | 23 |
24 #if defined(OS_MACOSX) | 24 #if defined(OS_MACOSX) |
25 #include "base/mac/scoped_nsautorelease_pool.h" | 25 #include "base/mac/scoped_nsautorelease_pool.h" |
26 #if !defined(OS_IOS) | 26 #if !defined(OS_IOS) |
| 27 #include "base/containers/scoped_ptr_hash_map.h" |
| 28 #include "base/mac/scoped_mach_port.h" |
| 29 #include "base/memory/scoped_ptr.h" |
27 #include "base/test/mock_chrome_application_mac.h" | 30 #include "base/test/mock_chrome_application_mac.h" |
| 31 #include "content/common/mac/io_surface_manager.h" |
28 #endif | 32 #endif |
29 #endif | 33 #endif |
30 | 34 |
31 #if !defined(OS_IOS) | 35 #if !defined(OS_IOS) |
32 #include "base/base_switches.h" | 36 #include "base/base_switches.h" |
33 #include "base/command_line.h" | 37 #include "base/command_line.h" |
34 #include "media/base/media.h" | 38 #include "media/base/media.h" |
35 #include "ui/gl/gl_surface.h" | 39 #include "ui/gl/gl_surface.h" |
36 #endif | 40 #endif |
37 | 41 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 env, surfaces_.get(surface_texture_id)->j_surface().obj()); | 92 env, surfaces_.get(surface_texture_id)->j_surface().obj()); |
89 } | 93 } |
90 | 94 |
91 private: | 95 private: |
92 using SurfaceMap = | 96 using SurfaceMap = |
93 base::ScopedPtrHashMap<int, scoped_ptr<gfx::ScopedJavaSurface>>; | 97 base::ScopedPtrHashMap<int, scoped_ptr<gfx::ScopedJavaSurface>>; |
94 SurfaceMap surfaces_; | 98 SurfaceMap surfaces_; |
95 }; | 99 }; |
96 #endif | 100 #endif |
97 | 101 |
| 102 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 103 class TestIOSurfaceManager : public IOSurfaceManager { |
| 104 public: |
| 105 // Overridden from IOSurfaceManager: |
| 106 bool RegisterIOSurface(int io_surface_id, |
| 107 int client_id, |
| 108 IOSurfaceRef io_surface) override { |
| 109 io_surfaces_.add(io_surface_id, |
| 110 make_scoped_ptr(new base::mac::ScopedMachSendRight( |
| 111 IOSurfaceCreateMachPort(io_surface)))); |
| 112 return true; |
| 113 } |
| 114 void UnregisterIOSurface(int io_surface_id, int client_id) override { |
| 115 io_surfaces_.erase(io_surface_id); |
| 116 } |
| 117 IOSurfaceRef AcquireIOSurface(int io_surface_id) override { |
| 118 return IOSurfaceLookupFromMachPort(io_surfaces_.get(io_surface_id)->get()); |
| 119 } |
| 120 |
| 121 private: |
| 122 using IOSurfaceMap = |
| 123 base::ScopedPtrHashMap<int, scoped_ptr<base::mac::ScopedMachSendRight>>; |
| 124 IOSurfaceMap io_surfaces_; |
| 125 }; |
| 126 #endif |
| 127 |
98 } // namespace | 128 } // namespace |
99 | 129 |
100 ContentTestSuite::ContentTestSuite(int argc, char** argv) | 130 ContentTestSuite::ContentTestSuite(int argc, char** argv) |
101 : ContentTestSuiteBase(argc, argv) { | 131 : ContentTestSuiteBase(argc, argv) { |
102 } | 132 } |
103 | 133 |
104 ContentTestSuite::~ContentTestSuite() { | 134 ContentTestSuite::~ContentTestSuite() { |
105 } | 135 } |
106 | 136 |
107 void ContentTestSuite::Initialize() { | 137 void ContentTestSuite::Initialize() { |
(...skipping 23 matching lines...) Expand all Loading... |
131 gfx::GLSurface::InitializeOneOffForTests(); | 161 gfx::GLSurface::InitializeOneOffForTests(); |
132 gpu::ApplyGpuDriverBugWorkarounds(base::CommandLine::ForCurrentProcess()); | 162 gpu::ApplyGpuDriverBugWorkarounds(base::CommandLine::ForCurrentProcess()); |
133 } | 163 } |
134 #endif | 164 #endif |
135 testing::TestEventListeners& listeners = | 165 testing::TestEventListeners& listeners = |
136 testing::UnitTest::GetInstance()->listeners(); | 166 testing::UnitTest::GetInstance()->listeners(); |
137 listeners.Append(new TestInitializationListener); | 167 listeners.Append(new TestInitializationListener); |
138 #if defined(OS_ANDROID) | 168 #if defined(OS_ANDROID) |
139 SurfaceTextureManager::SetInstance(new TestSurfaceTextureManager); | 169 SurfaceTextureManager::SetInstance(new TestSurfaceTextureManager); |
140 #endif | 170 #endif |
| 171 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 172 IOSurfaceManager::SetInstance(new TestIOSurfaceManager); |
| 173 #endif |
141 } | 174 } |
142 | 175 |
143 } // namespace content | 176 } // namespace content |
OLD | NEW |