| 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> | |
| 11 #endif | 10 #endif |
| 12 | 11 |
| 13 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
| 14 #include "base/logging.h" | 13 #include "base/logging.h" |
| 15 #include "content/public/common/content_client.h" | 14 #include "content/public/common/content_client.h" |
| 16 #include "content/public/common/content_paths.h" | 15 #include "content/public/common/content_paths.h" |
| 17 #include "content/public/test/test_content_client_initializer.h" | 16 #include "content/public/test/test_content_client_initializer.h" |
| 18 #include "gpu/config/gpu_util.h" | 17 #include "gpu/config/gpu_util.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 20 | 19 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 31 | 30 |
| 32 #if !defined(OS_IOS) | 31 #if !defined(OS_IOS) |
| 33 #include "base/base_switches.h" | 32 #include "base/base_switches.h" |
| 34 #include "base/command_line.h" | 33 #include "base/command_line.h" |
| 35 #include "media/base/media.h" | 34 #include "media/base/media.h" |
| 36 #include "ui/gl/gl_surface.h" | 35 #include "ui/gl/gl_surface.h" |
| 37 #endif | 36 #endif |
| 38 | 37 |
| 39 #if defined(OS_ANDROID) | 38 #if defined(OS_ANDROID) |
| 40 #include "base/android/jni_android.h" | 39 #include "base/android/jni_android.h" |
| 41 #include "base/memory/linked_ptr.h" | 40 #include "base/containers/scoped_ptr_hash_map.h" |
| 41 #include "base/memory/scoped_ptr.h" |
| 42 #include "content/common/android/surface_texture_manager.h" | 42 #include "content/common/android/surface_texture_manager.h" |
| 43 #include "ui/gl/android/scoped_java_surface.h" | 43 #include "ui/gl/android/scoped_java_surface.h" |
| 44 #include "ui/gl/android/surface_texture.h" | 44 #include "ui/gl/android/surface_texture.h" |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 namespace content { | 47 namespace content { |
| 48 namespace { | 48 namespace { |
| 49 | 49 |
| 50 class TestInitializationListener : public testing::EmptyTestEventListener { | 50 class TestInitializationListener : public testing::EmptyTestEventListener { |
| 51 public: | 51 public: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 67 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener); | 67 DISALLOW_COPY_AND_ASSIGN(TestInitializationListener); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 #if defined(OS_ANDROID) | 70 #if defined(OS_ANDROID) |
| 71 class TestSurfaceTextureManager : public SurfaceTextureManager { | 71 class TestSurfaceTextureManager : public SurfaceTextureManager { |
| 72 public: | 72 public: |
| 73 // Overridden from SurfaceTextureManager: | 73 // Overridden from SurfaceTextureManager: |
| 74 void RegisterSurfaceTexture(int surface_texture_id, | 74 void RegisterSurfaceTexture(int surface_texture_id, |
| 75 int client_id, | 75 int client_id, |
| 76 gfx::SurfaceTexture* surface_texture) override { | 76 gfx::SurfaceTexture* surface_texture) override { |
| 77 surfaces_[surface_texture_id] = | 77 surfaces_.add(surface_texture_id, |
| 78 make_linked_ptr(new gfx::ScopedJavaSurface(surface_texture)); | 78 make_scoped_ptr(new gfx::ScopedJavaSurface(surface_texture))); |
| 79 } | 79 } |
| 80 void UnregisterSurfaceTexture(int surface_texture_id, | 80 void UnregisterSurfaceTexture(int surface_texture_id, |
| 81 int client_id) override { | 81 int client_id) override { |
| 82 surfaces_.erase(surface_texture_id); | 82 surfaces_.erase(surface_texture_id); |
| 83 } | 83 } |
| 84 gfx::AcceleratedWidget AcquireNativeWidgetForSurfaceTexture( | 84 gfx::AcceleratedWidget AcquireNativeWidgetForSurfaceTexture( |
| 85 int surface_texture_id) override { | 85 int surface_texture_id) override { |
| 86 JNIEnv* env = base::android::AttachCurrentThread(); | 86 JNIEnv* env = base::android::AttachCurrentThread(); |
| 87 return ANativeWindow_fromSurface( | 87 return ANativeWindow_fromSurface( |
| 88 env, surfaces_[surface_texture_id]->j_surface().obj()); | 88 env, surfaces_.get(surface_texture_id)->j_surface().obj()); |
| 89 } | 89 } |
| 90 | 90 |
| 91 private: | 91 private: |
| 92 typedef std::map<int, linked_ptr<gfx::ScopedJavaSurface>> SurfaceMap; | 92 using SurfaceMap = |
| 93 base::ScopedPtrHashMap<int, scoped_ptr<gfx::ScopedJavaSurface>>; |
| 93 SurfaceMap surfaces_; | 94 SurfaceMap surfaces_; |
| 94 }; | 95 }; |
| 95 #endif | 96 #endif |
| 96 | 97 |
| 97 } // namespace | 98 } // namespace |
| 98 | 99 |
| 99 ContentTestSuite::ContentTestSuite(int argc, char** argv) | 100 ContentTestSuite::ContentTestSuite(int argc, char** argv) |
| 100 : ContentTestSuiteBase(argc, argv) { | 101 : ContentTestSuiteBase(argc, argv) { |
| 101 } | 102 } |
| 102 | 103 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 133 #endif | 134 #endif |
| 134 testing::TestEventListeners& listeners = | 135 testing::TestEventListeners& listeners = |
| 135 testing::UnitTest::GetInstance()->listeners(); | 136 testing::UnitTest::GetInstance()->listeners(); |
| 136 listeners.Append(new TestInitializationListener); | 137 listeners.Append(new TestInitializationListener); |
| 137 #if defined(OS_ANDROID) | 138 #if defined(OS_ANDROID) |
| 138 SurfaceTextureManager::InitInstance(new TestSurfaceTextureManager); | 139 SurfaceTextureManager::InitInstance(new TestSurfaceTextureManager); |
| 139 #endif | 140 #endif |
| 140 } | 141 } |
| 141 | 142 |
| 142 } // namespace content | 143 } // namespace content |
| OLD | NEW |