Chromium Code Reviews| 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 #include <map> | 10 #include <map> |
| 11 #endif | 11 #endif |
| 12 | 12 |
| 13 #include "base/base_paths.h" | 13 #include "base/base_paths.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "content/public/common/content_client.h" | 15 #include "content/public/common/content_client.h" |
| 16 #include "content/public/common/content_paths.h" | 16 #include "content/public/common/content_paths.h" |
| 17 #include "content/public/test/test_content_client_initializer.h" | 17 #include "content/public/test/test_content_client_initializer.h" |
| 18 #include "gpu/config/gpu_util.h" | 18 #include "gpu/config/gpu_util.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 20 |
| 21 #if defined(OS_WIN) | 21 #if defined(OS_WIN) |
| 22 #include "ui/gfx/win/dpi.h" | 22 #include "ui/gfx/win/dpi.h" |
| 23 #endif | 23 #endif |
| 24 | 24 |
| 25 #if defined(OS_MACOSX) | 25 #if defined(OS_MACOSX) |
| 26 #include "base/mac/scoped_nsautorelease_pool.h" | 26 #include "base/mac/scoped_nsautorelease_pool.h" |
| 27 #if !defined(OS_IOS) | 27 #if !defined(OS_IOS) |
| 28 #include "base/mac/scoped_mach_port.h" | |
| 29 #include "base/memory/linked_ptr.h" | |
| 28 #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" | |
| 29 #endif | 32 #endif |
| 30 #endif | 33 #endif |
| 31 | 34 |
| 32 #if !defined(OS_IOS) | 35 #if !defined(OS_IOS) |
| 33 #include "base/base_switches.h" | 36 #include "base/base_switches.h" |
| 34 #include "base/command_line.h" | 37 #include "base/command_line.h" |
| 35 #include "media/base/media.h" | 38 #include "media/base/media.h" |
| 36 #include "ui/gl/gl_surface.h" | 39 #include "ui/gl/gl_surface.h" |
| 37 #endif | 40 #endif |
| 38 | 41 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 return ANativeWindow_fromSurface( | 90 return ANativeWindow_fromSurface( |
| 88 env, surfaces_[surface_texture_id]->j_surface().obj()); | 91 env, surfaces_[surface_texture_id]->j_surface().obj()); |
| 89 } | 92 } |
| 90 | 93 |
| 91 private: | 94 private: |
| 92 typedef std::map<int, linked_ptr<gfx::ScopedJavaSurface>> SurfaceMap; | 95 typedef std::map<int, linked_ptr<gfx::ScopedJavaSurface>> SurfaceMap; |
| 93 SurfaceMap surfaces_; | 96 SurfaceMap surfaces_; |
| 94 }; | 97 }; |
| 95 #endif | 98 #endif |
| 96 | 99 |
| 100 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 101 class IOSurfaceManagerImpl : public IOSurfaceManager { | |
|
Avi (use Gerrit)
2015/05/09 18:00:28
Is this a simplified test implementation? Can you
reveman
2015/05/09 19:24:23
Sure, let me just land a patch that changes Surfac
reveman
2015/05/10 18:45:08
Done.
| |
| 102 public: | |
| 103 // Overridden from IOSurfaceManager: | |
| 104 bool RegisterIOSurface(int io_surface_id, | |
| 105 int client_id, | |
| 106 IOSurfaceRef io_surface) override { | |
| 107 mach_ports_[io_surface_id] = | |
| 108 make_linked_ptr(new base::mac::ScopedMachSendRight( | |
| 109 IOSurfaceCreateMachPort(io_surface))); | |
| 110 return true; | |
| 111 } | |
| 112 void UnregisterIOSurface(int io_surface_id, int client_id) override { | |
| 113 mach_ports_.erase(io_surface_id); | |
| 114 } | |
| 115 IOSurfaceRef AcquireIOSurface(int io_surface_id) override { | |
| 116 return IOSurfaceLookupFromMachPort(mach_ports_[io_surface_id]->get()); | |
| 117 } | |
| 118 | |
| 119 private: | |
| 120 typedef std::map<int, linked_ptr<base::mac::ScopedMachSendRight>> | |
| 121 MachSendRightMap; | |
| 122 MachSendRightMap mach_ports_; | |
| 123 }; | |
| 124 #endif | |
| 125 | |
| 97 } // namespace | 126 } // namespace |
| 98 | 127 |
| 99 ContentTestSuite::ContentTestSuite(int argc, char** argv) | 128 ContentTestSuite::ContentTestSuite(int argc, char** argv) |
| 100 : ContentTestSuiteBase(argc, argv) { | 129 : ContentTestSuiteBase(argc, argv) { |
| 101 } | 130 } |
| 102 | 131 |
| 103 ContentTestSuite::~ContentTestSuite() { | 132 ContentTestSuite::~ContentTestSuite() { |
| 104 } | 133 } |
| 105 | 134 |
| 106 void ContentTestSuite::Initialize() { | 135 void ContentTestSuite::Initialize() { |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 130 gfx::GLSurface::InitializeOneOffForTests(); | 159 gfx::GLSurface::InitializeOneOffForTests(); |
| 131 gpu::ApplyGpuDriverBugWorkarounds(base::CommandLine::ForCurrentProcess()); | 160 gpu::ApplyGpuDriverBugWorkarounds(base::CommandLine::ForCurrentProcess()); |
| 132 } | 161 } |
| 133 #endif | 162 #endif |
| 134 testing::TestEventListeners& listeners = | 163 testing::TestEventListeners& listeners = |
| 135 testing::UnitTest::GetInstance()->listeners(); | 164 testing::UnitTest::GetInstance()->listeners(); |
| 136 listeners.Append(new TestInitializationListener); | 165 listeners.Append(new TestInitializationListener); |
| 137 #if defined(OS_ANDROID) | 166 #if defined(OS_ANDROID) |
| 138 SurfaceTextureManager::InitInstance(new SurfaceTextureManagerImpl); | 167 SurfaceTextureManager::InitInstance(new SurfaceTextureManagerImpl); |
| 139 #endif | 168 #endif |
| 169 #if defined(OS_MACOSX) && !defined(OS_IOS) | |
| 170 IOSurfaceManager::InitInstance(new IOSurfaceManagerImpl); | |
|
Avi (use Gerrit)
2015/05/09 18:00:28
We're also calling InitInstance at the end of Cont
reveman
2015/05/09 19:24:23
Pretty sure ContentMainRunnerImpl::Initialize is n
Avi (use Gerrit)
2015/05/09 20:41:02
That makes sense.
| |
| 171 #endif | |
| 140 } | 172 } |
| 141 | 173 |
| 142 } // namespace content | 174 } // namespace content |
| OLD | NEW |