| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/test/launcher/unit_test_launcher.h" | 7 #include "base/test/launcher/unit_test_launcher.h" |
| 8 #include "base/test/test_discardable_memory_allocator.h" | 8 #include "base/test/test_discardable_memory_allocator.h" |
| 9 #include "base/test/test_suite.h" | 9 #include "base/test/test_suite.h" |
| 10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 11 #include "media/base/fake_media_resources.h" | 11 #include "media/base/fake_media_resources.h" |
| 12 #include "media/base/media.h" | 12 #include "media/base/media.h" |
| 13 #include "media/base/media_switches.h" | 13 #include "media/base/media_switches.h" |
| 14 | 14 |
| 15 #if defined(OS_ANDROID) | 15 #if defined(OS_ANDROID) |
| 16 #include "base/android/jni_android.h" | 16 #include "base/android/jni_android.h" |
| 17 #include "media/base/android/media_codec_util.h" | 17 #include "media/base/android/media_codec_util.h" |
| 18 #include "media/base/android/media_jni_registrar.h" | 18 #include "media/base/android/media_jni_registrar.h" |
| 19 #include "media/capture/video/android/capture_jni_registrar.h" |
| 19 #include "ui/gl/android/gl_jni_registrar.h" | 20 #include "ui/gl/android/gl_jni_registrar.h" |
| 20 #endif | 21 #endif |
| 21 | 22 |
| 22 class TestSuiteNoAtExit : public base::TestSuite { | 23 class TestSuiteNoAtExit : public base::TestSuite { |
| 23 public: | 24 public: |
| 24 TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {} | 25 TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {} |
| 25 ~TestSuiteNoAtExit() override {} | 26 ~TestSuiteNoAtExit() override {} |
| 26 | 27 |
| 27 protected: | 28 protected: |
| 28 void Initialize() override; | 29 void Initialize() override; |
| 29 | 30 |
| 30 private: | 31 private: |
| 31 base::TestDiscardableMemoryAllocator discardable_memory_allocator_; | 32 base::TestDiscardableMemoryAllocator discardable_memory_allocator_; |
| 32 }; | 33 }; |
| 33 | 34 |
| 34 void TestSuiteNoAtExit::Initialize() { | 35 void TestSuiteNoAtExit::Initialize() { |
| 35 // Run TestSuite::Initialize first so that logging is initialized. | 36 // Run TestSuite::Initialize first so that logging is initialized. |
| 36 base::TestSuite::Initialize(); | 37 base::TestSuite::Initialize(); |
| 37 | 38 |
| 38 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 39 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 39 command_line->AppendSwitch(switches::kEnableInbandTextTracks); | 40 command_line->AppendSwitch(switches::kEnableInbandTextTracks); |
| 40 | 41 |
| 41 #if defined(OS_ANDROID) | 42 #if defined(OS_ANDROID) |
| 42 // Register JNI bindings for android. | 43 // Register JNI bindings for android. |
| 43 JNIEnv* env = base::android::AttachCurrentThread(); | 44 JNIEnv* env = base::android::AttachCurrentThread(); |
| 44 // Needed for surface texture support. | 45 // Needed for surface texture support. |
| 45 ui::gl::android::RegisterJni(env); | 46 ui::gl::android::RegisterJni(env); |
| 46 media::RegisterJni(env); | 47 media::RegisterJni(env); |
| 48 media::RegisterCaptureJni(env); |
| 47 | 49 |
| 48 if (media::MediaCodecUtil::IsMediaCodecAvailable()) | 50 if (media::MediaCodecUtil::IsMediaCodecAvailable()) |
| 49 media::EnablePlatformDecoderSupport(); | 51 media::EnablePlatformDecoderSupport(); |
| 50 #endif | 52 #endif |
| 51 | 53 |
| 52 // Run this here instead of main() to ensure an AtExitManager is already | 54 // Run this here instead of main() to ensure an AtExitManager is already |
| 53 // present. | 55 // present. |
| 54 media::InitializeMediaLibrary(); | 56 media::InitializeMediaLibrary(); |
| 55 media::SetUpFakeMediaResources(); | 57 media::SetUpFakeMediaResources(); |
| 56 | 58 |
| 57 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); | 59 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); |
| 58 } | 60 } |
| 59 | 61 |
| 60 int main(int argc, char** argv) { | 62 int main(int argc, char** argv) { |
| 61 TestSuiteNoAtExit test_suite(argc, argv); | 63 TestSuiteNoAtExit test_suite(argc, argv); |
| 62 | 64 |
| 63 return base::LaunchUnitTests( | 65 return base::LaunchUnitTests( |
| 64 argc, argv, base::Bind(&TestSuiteNoAtExit::Run, | 66 argc, argv, base::Bind(&TestSuiteNoAtExit::Run, |
| 65 base::Unretained(&test_suite))); | 67 base::Unretained(&test_suite))); |
| 66 } | 68 } |
| OLD | NEW |