| 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/containers/scoped_ptr_hash_map.h" |
| 29 #include "base/mac/scoped_mach_port.h" |
| 30 #include "base/memory/scoped_ptr.h" |
| 28 #include "base/test/mock_chrome_application_mac.h" | 31 #include "base/test/mock_chrome_application_mac.h" |
| 32 #include "content/common/mac/io_surface_manager.h" |
| 29 #endif | 33 #endif |
| 30 #endif | 34 #endif |
| 31 | 35 |
| 32 #if !defined(OS_IOS) | 36 #if !defined(OS_IOS) |
| 33 #include "base/base_switches.h" | 37 #include "base/base_switches.h" |
| 34 #include "base/command_line.h" | 38 #include "base/command_line.h" |
| 35 #include "media/base/media.h" | 39 #include "media/base/media.h" |
| 36 #include "ui/gl/gl_surface.h" | 40 #include "ui/gl/gl_surface.h" |
| 37 #endif | 41 #endif |
| 38 | 42 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 return ANativeWindow_fromSurface( | 91 return ANativeWindow_fromSurface( |
| 88 env, surfaces_[surface_texture_id]->j_surface().obj()); | 92 env, surfaces_[surface_texture_id]->j_surface().obj()); |
| 89 } | 93 } |
| 90 | 94 |
| 91 private: | 95 private: |
| 92 typedef std::map<int, linked_ptr<gfx::ScopedJavaSurface>> SurfaceMap; | 96 typedef std::map<int, linked_ptr<gfx::ScopedJavaSurface>> SurfaceMap; |
| 93 SurfaceMap surfaces_; | 97 SurfaceMap surfaces_; |
| 94 }; | 98 }; |
| 95 #endif | 99 #endif |
| 96 | 100 |
| 101 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 102 class TestIOSurfaceManager : public IOSurfaceManager { |
| 103 public: |
| 104 // Overridden from IOSurfaceManager: |
| 105 bool RegisterIOSurface(int io_surface_id, |
| 106 int client_id, |
| 107 IOSurfaceRef io_surface) override { |
| 108 io_surfaces_.add(io_surface_id, |
| 109 make_scoped_ptr(new base::mac::ScopedMachSendRight( |
| 110 IOSurfaceCreateMachPort(io_surface)))); |
| 111 return true; |
| 112 } |
| 113 void UnregisterIOSurface(int io_surface_id, int client_id) override { |
| 114 io_surfaces_.erase(io_surface_id); |
| 115 } |
| 116 IOSurfaceRef AcquireIOSurface(int io_surface_id) override { |
| 117 return IOSurfaceLookupFromMachPort(io_surfaces_.get(io_surface_id)->get()); |
| 118 } |
| 119 |
| 120 private: |
| 121 using IOSurfaceMap = |
| 122 base::ScopedPtrHashMap<int, scoped_ptr<base::mac::ScopedMachSendRight>>; |
| 123 IOSurfaceMap io_surfaces_; |
| 124 }; |
| 125 #endif |
| 126 |
| 97 } // namespace | 127 } // namespace |
| 98 | 128 |
| 99 ContentTestSuite::ContentTestSuite(int argc, char** argv) | 129 ContentTestSuite::ContentTestSuite(int argc, char** argv) |
| 100 : ContentTestSuiteBase(argc, argv) { | 130 : ContentTestSuiteBase(argc, argv) { |
| 101 } | 131 } |
| 102 | 132 |
| 103 ContentTestSuite::~ContentTestSuite() { | 133 ContentTestSuite::~ContentTestSuite() { |
| 104 } | 134 } |
| 105 | 135 |
| 106 void ContentTestSuite::Initialize() { | 136 void ContentTestSuite::Initialize() { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 130 gfx::GLSurface::InitializeOneOffForTests(); | 160 gfx::GLSurface::InitializeOneOffForTests(); |
| 131 gpu::ApplyGpuDriverBugWorkarounds(base::CommandLine::ForCurrentProcess()); | 161 gpu::ApplyGpuDriverBugWorkarounds(base::CommandLine::ForCurrentProcess()); |
| 132 } | 162 } |
| 133 #endif | 163 #endif |
| 134 testing::TestEventListeners& listeners = | 164 testing::TestEventListeners& listeners = |
| 135 testing::UnitTest::GetInstance()->listeners(); | 165 testing::UnitTest::GetInstance()->listeners(); |
| 136 listeners.Append(new TestInitializationListener); | 166 listeners.Append(new TestInitializationListener); |
| 137 #if defined(OS_ANDROID) | 167 #if defined(OS_ANDROID) |
| 138 SurfaceTextureManager::InitInstance(new TestSurfaceTextureManager); | 168 SurfaceTextureManager::InitInstance(new TestSurfaceTextureManager); |
| 139 #endif | 169 #endif |
| 170 #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 171 IOSurfaceManager::SetInstance(new TestIOSurfaceManager); |
| 172 #endif |
| 140 } | 173 } |
| 141 | 174 |
| 142 } // namespace content | 175 } // namespace content |
| OLD | NEW |