Index: content/test/content_test_suite.cc |
diff --git a/content/test/content_test_suite.cc b/content/test/content_test_suite.cc |
index 6a3610a46ac4a425edbc5b4891f2a03eb60ee8f2..949ff4d8352738b848351b59954ed2bf1ea4b66c 100644 |
--- a/content/test/content_test_suite.cc |
+++ b/content/test/content_test_suite.cc |
@@ -25,7 +25,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/common/mac/io_surface_manager.h" |
#endif |
#endif |
@@ -94,6 +98,32 @@ class TestSurfaceTextureManager : public SurfaceTextureManager { |
}; |
#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 |
ContentTestSuite::ContentTestSuite(int argc, char** argv) |
@@ -137,6 +167,9 @@ void ContentTestSuite::Initialize() { |
#if defined(OS_ANDROID) |
SurfaceTextureManager::InitInstance(new TestSurfaceTextureManager); |
#endif |
+#if defined(OS_MACOSX) && !defined(OS_IOS) |
+ IOSurfaceManager::SetInstance(new TestIOSurfaceManager); |
+#endif |
} |
} // namespace content |