Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: content/test/content_test_suite.cc

Issue 1171293005: Revert of content: Single process support for native GpuMemoryBuffers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dm-browsertests-refactor
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/content_browser.gypi ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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)
8 #include <android/native_window.h>
9 #include <android/native_window_jni.h>
10 #endif
11
7 #include "base/base_paths.h" 12 #include "base/base_paths.h"
8 #include "base/logging.h" 13 #include "base/logging.h"
9 #include "content/public/common/content_client.h" 14 #include "content/public/common/content_client.h"
10 #include "content/public/common/content_paths.h" 15 #include "content/public/common/content_paths.h"
11 #include "content/public/test/test_content_client_initializer.h" 16 #include "content/public/test/test_content_client_initializer.h"
12 #include "gpu/config/gpu_util.h" 17 #include "gpu/config/gpu_util.h"
13 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
14 19
15 #if defined(OS_WIN) 20 #if defined(OS_WIN)
16 #include "ui/gfx/win/dpi.h" 21 #include "ui/gfx/win/dpi.h"
17 #endif 22 #endif
18 23
19 #if defined(OS_MACOSX) 24 #if defined(OS_MACOSX)
20 #include "base/mac/scoped_nsautorelease_pool.h" 25 #include "base/mac/scoped_nsautorelease_pool.h"
21 #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"
22 #include "base/test/mock_chrome_application_mac.h" 30 #include "base/test/mock_chrome_application_mac.h"
23 #include "content/browser/in_process_io_surface_manager_mac.h" 31 #include "content/common/mac/io_surface_manager.h"
24 #endif 32 #endif
25 #endif 33 #endif
26 34
27 #if !defined(OS_IOS) 35 #if !defined(OS_IOS)
28 #include "base/base_switches.h" 36 #include "base/base_switches.h"
29 #include "base/command_line.h" 37 #include "base/command_line.h"
30 #include "media/base/media.h" 38 #include "media/base/media.h"
31 #include "ui/gl/gl_surface.h" 39 #include "ui/gl/gl_surface.h"
32 #endif 40 #endif
33 41
34 #if defined(OS_ANDROID) 42 #if defined(OS_ANDROID)
35 #include "content/browser/android/in_process_surface_texture_manager.h" 43 #include "base/android/jni_android.h"
44 #include "base/containers/scoped_ptr_hash_map.h"
45 #include "base/memory/scoped_ptr.h"
46 #include "content/common/android/surface_texture_manager.h"
47 #include "ui/gl/android/scoped_java_surface.h"
48 #include "ui/gl/android/surface_texture.h"
36 #endif 49 #endif
37 50
38 namespace content { 51 namespace content {
39 namespace { 52 namespace {
40 53
41 class TestInitializationListener : public testing::EmptyTestEventListener { 54 class TestInitializationListener : public testing::EmptyTestEventListener {
42 public: 55 public:
43 TestInitializationListener() : test_content_client_initializer_(NULL) { 56 TestInitializationListener() : test_content_client_initializer_(NULL) {
44 } 57 }
45 58
46 void OnTestStart(const testing::TestInfo& test_info) override { 59 void OnTestStart(const testing::TestInfo& test_info) override {
47 test_content_client_initializer_ = 60 test_content_client_initializer_ =
48 new content::TestContentClientInitializer(); 61 new content::TestContentClientInitializer();
49 } 62 }
50 63
51 void OnTestEnd(const testing::TestInfo& test_info) override { 64 void OnTestEnd(const testing::TestInfo& test_info) override {
52 delete test_content_client_initializer_; 65 delete test_content_client_initializer_;
53 } 66 }
54 67
55 private: 68 private:
56 content::TestContentClientInitializer* test_content_client_initializer_; 69 content::TestContentClientInitializer* test_content_client_initializer_;
57 70
58 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener); 71 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener);
59 }; 72 };
60 73
74 #if defined(OS_ANDROID)
75 class TestSurfaceTextureManager : public SurfaceTextureManager {
76 public:
77 // Overridden from SurfaceTextureManager:
78 void RegisterSurfaceTexture(int surface_texture_id,
79 int client_id,
80 gfx::SurfaceTexture* surface_texture) override {
81 surfaces_.add(surface_texture_id,
82 make_scoped_ptr(new gfx::ScopedJavaSurface(surface_texture)));
83 }
84 void UnregisterSurfaceTexture(int surface_texture_id,
85 int client_id) override {
86 surfaces_.erase(surface_texture_id);
87 }
88 gfx::AcceleratedWidget AcquireNativeWidgetForSurfaceTexture(
89 int surface_texture_id) override {
90 JNIEnv* env = base::android::AttachCurrentThread();
91 return ANativeWindow_fromSurface(
92 env, surfaces_.get(surface_texture_id)->j_surface().obj());
93 }
94
95 private:
96 using SurfaceMap =
97 base::ScopedPtrHashMap<int, scoped_ptr<gfx::ScopedJavaSurface>>;
98 SurfaceMap surfaces_;
99 };
100 #endif
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
61 } // namespace 128 } // namespace
62 129
63 ContentTestSuite::ContentTestSuite(int argc, char** argv) 130 ContentTestSuite::ContentTestSuite(int argc, char** argv)
64 : ContentTestSuiteBase(argc, argv) { 131 : ContentTestSuiteBase(argc, argv) {
65 } 132 }
66 133
67 ContentTestSuite::~ContentTestSuite() { 134 ContentTestSuite::~ContentTestSuite() {
68 } 135 }
69 136
70 void ContentTestSuite::Initialize() { 137 void ContentTestSuite::Initialize() {
(...skipping 21 matching lines...) Expand all
92 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 159 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
93 switches::kTestChildProcess)) { 160 switches::kTestChildProcess)) {
94 gfx::GLSurface::InitializeOneOffForTests(); 161 gfx::GLSurface::InitializeOneOffForTests();
95 gpu::ApplyGpuDriverBugWorkarounds(base::CommandLine::ForCurrentProcess()); 162 gpu::ApplyGpuDriverBugWorkarounds(base::CommandLine::ForCurrentProcess());
96 } 163 }
97 #endif 164 #endif
98 testing::TestEventListeners& listeners = 165 testing::TestEventListeners& listeners =
99 testing::UnitTest::GetInstance()->listeners(); 166 testing::UnitTest::GetInstance()->listeners();
100 listeners.Append(new TestInitializationListener); 167 listeners.Append(new TestInitializationListener);
101 #if defined(OS_ANDROID) 168 #if defined(OS_ANDROID)
102 SurfaceTextureManager::SetInstance( 169 SurfaceTextureManager::SetInstance(new TestSurfaceTextureManager);
103 InProcessSurfaceTextureManager::GetInstance());
104 #endif 170 #endif
105 #if defined(OS_MACOSX) && !defined(OS_IOS) 171 #if defined(OS_MACOSX) && !defined(OS_IOS)
106 IOSurfaceManager::SetInstance(InProcessIOSurfaceManager::GetInstance()); 172 IOSurfaceManager::SetInstance(new TestIOSurfaceManager);
107 #endif 173 #endif
108 } 174 }
109 175
110 } // namespace content 176 } // namespace content
OLDNEW
« no previous file with comments | « content/content_browser.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698