Index: content/test/content_test_suite.cc |
diff --git a/content/test/content_test_suite.cc b/content/test/content_test_suite.cc |
index 116bd0ce472064bf8445bc610e3bafd172f4f860..e3b2ae2865549dc3a65ad8992acf1e1061fef063 100644 |
--- a/content/test/content_test_suite.cc |
+++ b/content/test/content_test_suite.cc |
@@ -3,6 +3,11 @@ |
// found in the LICENSE file. |
#include "content/test/content_test_suite.h" |
+ |
+#if defined(OS_ANDROID) |
+#include <android/native_window.h> |
+#include <android/native_window_jni.h> |
+#endif |
#include "base/base_paths.h" |
#include "base/logging.h" |
@@ -19,8 +24,11 @@ |
#if defined(OS_MACOSX) |
#include "base/mac/scoped_nsautorelease_pool.h" |
#if !defined(OS_IOS) |
+#include "base/containers/scoped_ptr_hash_map.h" |
+#include "base/mac/scoped_mach_port.h" |
+#include "base/memory/scoped_ptr.h" |
#include "base/test/mock_chrome_application_mac.h" |
-#include "content/browser/in_process_io_surface_manager_mac.h" |
+#include "content/common/mac/io_surface_manager.h" |
#endif |
#endif |
@@ -32,7 +40,12 @@ |
#endif |
#if defined(OS_ANDROID) |
-#include "content/browser/android/in_process_surface_texture_manager.h" |
+#include "base/android/jni_android.h" |
+#include "base/containers/scoped_ptr_hash_map.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "content/common/android/surface_texture_manager.h" |
+#include "ui/gl/android/scoped_java_surface.h" |
+#include "ui/gl/android/surface_texture.h" |
#endif |
namespace content { |
@@ -57,6 +70,60 @@ |
DISALLOW_COPY_AND_ASSIGN(TestInitializationListener); |
}; |
+ |
+#if defined(OS_ANDROID) |
+class TestSurfaceTextureManager : public SurfaceTextureManager { |
+ public: |
+ // Overridden from SurfaceTextureManager: |
+ void RegisterSurfaceTexture(int surface_texture_id, |
+ int client_id, |
+ gfx::SurfaceTexture* surface_texture) override { |
+ surfaces_.add(surface_texture_id, |
+ make_scoped_ptr(new gfx::ScopedJavaSurface(surface_texture))); |
+ } |
+ void UnregisterSurfaceTexture(int surface_texture_id, |
+ int client_id) override { |
+ surfaces_.erase(surface_texture_id); |
+ } |
+ gfx::AcceleratedWidget AcquireNativeWidgetForSurfaceTexture( |
+ int surface_texture_id) override { |
+ JNIEnv* env = base::android::AttachCurrentThread(); |
+ return ANativeWindow_fromSurface( |
+ env, surfaces_.get(surface_texture_id)->j_surface().obj()); |
+ } |
+ |
+ private: |
+ using SurfaceMap = |
+ base::ScopedPtrHashMap<int, scoped_ptr<gfx::ScopedJavaSurface>>; |
+ SurfaceMap surfaces_; |
+}; |
+#endif |
+ |
+#if defined(OS_MACOSX) && !defined(OS_IOS) |
+class TestIOSurfaceManager : public IOSurfaceManager { |
+ public: |
+ // Overridden from IOSurfaceManager: |
+ bool RegisterIOSurface(int io_surface_id, |
+ int client_id, |
+ IOSurfaceRef io_surface) override { |
+ io_surfaces_.add(io_surface_id, |
+ make_scoped_ptr(new base::mac::ScopedMachSendRight( |
+ IOSurfaceCreateMachPort(io_surface)))); |
+ return true; |
+ } |
+ void UnregisterIOSurface(int io_surface_id, int client_id) override { |
+ io_surfaces_.erase(io_surface_id); |
+ } |
+ IOSurfaceRef AcquireIOSurface(int io_surface_id) override { |
+ return IOSurfaceLookupFromMachPort(io_surfaces_.get(io_surface_id)->get()); |
+ } |
+ |
+ private: |
+ using IOSurfaceMap = |
+ base::ScopedPtrHashMap<int, scoped_ptr<base::mac::ScopedMachSendRight>>; |
+ IOSurfaceMap io_surfaces_; |
+}; |
+#endif |
} // namespace |
@@ -99,11 +166,10 @@ |
testing::UnitTest::GetInstance()->listeners(); |
listeners.Append(new TestInitializationListener); |
#if defined(OS_ANDROID) |
- SurfaceTextureManager::SetInstance( |
- InProcessSurfaceTextureManager::GetInstance()); |
+ SurfaceTextureManager::SetInstance(new TestSurfaceTextureManager); |
#endif |
#if defined(OS_MACOSX) && !defined(OS_IOS) |
- IOSurfaceManager::SetInstance(InProcessIOSurfaceManager::GetInstance()); |
+ IOSurfaceManager::SetInstance(new TestIOSurfaceManager); |
#endif |
} |