| 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_suite.h" | 8 #include "base/test/test_suite.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "media/base/media.h" | 10 #include "media/base/media.h" |
| 11 #include "media/base/media_switches.h" | 11 #include "media/base/media_switches.h" |
| 12 | 12 |
| 13 #if defined(OS_ANDROID) | 13 #if defined(OS_ANDROID) |
| 14 #include "base/android/jni_android.h" | 14 #include "base/android/jni_android.h" |
| 15 #include "media/base/android/media_codec_bridge.h" |
| 15 #include "media/base/android/media_jni_registrar.h" | 16 #include "media/base/android/media_jni_registrar.h" |
| 16 #include "ui/gl/android/gl_jni_registrar.h" | 17 #include "ui/gl/android/gl_jni_registrar.h" |
| 17 #endif | 18 #endif |
| 18 | 19 |
| 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 |
| 19 class TestSuiteNoAtExit : public base::TestSuite { | 22 class TestSuiteNoAtExit : public base::TestSuite { |
| 20 public: | 23 public: |
| 21 TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {} | 24 TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {} |
| 22 virtual ~TestSuiteNoAtExit() {} | 25 virtual ~TestSuiteNoAtExit() {} |
| 23 protected: | 26 protected: |
| 24 virtual void Initialize() OVERRIDE; | 27 virtual void Initialize() OVERRIDE; |
| 25 }; | 28 }; |
| 26 | 29 |
| 27 void TestSuiteNoAtExit::Initialize() { | 30 void TestSuiteNoAtExit::Initialize() { |
| 28 // Run TestSuite::Initialize first so that logging is initialized. | 31 // Run TestSuite::Initialize first so that logging is initialized. |
| 29 base::TestSuite::Initialize(); | 32 base::TestSuite::Initialize(); |
| 30 | 33 |
| 31 #if defined(OS_ANDROID) | 34 #if defined(OS_ANDROID) |
| 35 if (!MediaCodecBridge::IsAvailable()) { |
| 36 base::TestSuite::DisableTests("MediaCodecBridgeTest.*"); |
| 37 base::TestSuite::DisableTests("MediaSourcePlayerTest.*"); |
| 38 } |
| 39 |
| 32 // Register JNI bindings for android. | 40 // Register JNI bindings for android. |
| 33 JNIEnv* env = base::android::AttachCurrentThread(); | 41 JNIEnv* env = base::android::AttachCurrentThread(); |
| 34 // Needed for surface texture support. | 42 // Needed for surface texture support. |
| 35 ui::gl::android::RegisterJni(env); | 43 ui::gl::android::RegisterJni(env); |
| 36 media::RegisterJni(env); | 44 media::RegisterJni(env); |
| 37 #endif | 45 #endif |
| 38 | 46 |
| 39 // Run this here instead of main() to ensure an AtExitManager is already | 47 // Run this here instead of main() to ensure an AtExitManager is already |
| 40 // present. | 48 // present. |
| 41 media::InitializeMediaLibraryForTesting(); | 49 media::InitializeMediaLibraryForTesting(); |
| 42 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 50 CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 43 cmd_line->AppendSwitch(switches::kEnableMP3StreamParser); | 51 cmd_line->AppendSwitch(switches::kEnableMP3StreamParser); |
| 44 | 52 |
| 45 // Enable Opus support for all media tests. | 53 // Enable Opus support for all media tests. |
| 46 // TODO(vigneshv): Remove this once the Opus flag is removed or negated. | 54 // TODO(vigneshv): Remove this once the Opus flag is removed or negated. |
| 47 cmd_line->AppendSwitch(switches::kEnableOpusPlayback); | 55 cmd_line->AppendSwitch(switches::kEnableOpusPlayback); |
| 48 } | 56 } |
| 49 | 57 |
| 50 int main(int argc, char** argv) { | 58 int main(int argc, char** argv) { |
| 51 TestSuiteNoAtExit test_suite(argc, argv); | 59 TestSuiteNoAtExit test_suite(argc, argv); |
| 52 | 60 |
| 53 return base::LaunchUnitTests( | 61 return base::LaunchUnitTests( |
| 54 argc, argv, base::Bind(&TestSuiteNoAtExit::Run, | 62 argc, argv, base::Bind(&TestSuiteNoAtExit::Run, |
| 55 base::Unretained(&test_suite))); | 63 base::Unretained(&test_suite))); |
| 56 } | 64 } |
| OLD | NEW |