| 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_suite.h" | 9 #include "base/test/test_suite.h" |
| 9 #include "build/build_config.h" | 10 #include "build/build_config.h" |
| 10 #include "media/base/media.h" | 11 #include "media/base/media.h" |
| 11 #include "media/base/media_switches.h" | 12 #include "media/base/media_switches.h" |
| 12 | 13 |
| 13 #if defined(OS_ANDROID) | 14 #if defined(OS_ANDROID) |
| 14 #include "base/android/jni_android.h" | 15 #include "base/android/jni_android.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 |
| 19 class TestSuiteNoAtExit : public base::TestSuite { | 20 class TestSuiteNoAtExit : public base::TestSuite { |
| 20 public: | 21 public: |
| 21 TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {} | 22 TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {} |
| 22 ~TestSuiteNoAtExit() override {} | 23 ~TestSuiteNoAtExit() override {} |
| 23 | 24 |
| 24 protected: | 25 protected: |
| 25 void Initialize() override; | 26 void Initialize() override; |
| 27 |
| 28 private: |
| 29 base::TestDiscardableMemoryAllocator discardable_memory_allocator_; |
| 26 }; | 30 }; |
| 27 | 31 |
| 28 void TestSuiteNoAtExit::Initialize() { | 32 void TestSuiteNoAtExit::Initialize() { |
| 29 // Run TestSuite::Initialize first so that logging is initialized. | 33 // Run TestSuite::Initialize first so that logging is initialized. |
| 30 base::TestSuite::Initialize(); | 34 base::TestSuite::Initialize(); |
| 31 | 35 |
| 32 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 36 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 33 command_line->AppendSwitch(switches::kEnableInbandTextTracks); | 37 command_line->AppendSwitch(switches::kEnableInbandTextTracks); |
| 34 | 38 |
| 35 #if defined(OS_ANDROID) | 39 #if defined(OS_ANDROID) |
| 36 // Register JNI bindings for android. | 40 // Register JNI bindings for android. |
| 37 JNIEnv* env = base::android::AttachCurrentThread(); | 41 JNIEnv* env = base::android::AttachCurrentThread(); |
| 38 // Needed for surface texture support. | 42 // Needed for surface texture support. |
| 39 ui::gl::android::RegisterJni(env); | 43 ui::gl::android::RegisterJni(env); |
| 40 media::RegisterJni(env); | 44 media::RegisterJni(env); |
| 41 #endif | 45 #endif |
| 42 | 46 |
| 43 // 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 |
| 44 // present. | 48 // present. |
| 45 media::InitializeMediaLibrary(); | 49 media::InitializeMediaLibrary(); |
| 50 |
| 51 base::DiscardableMemoryAllocator::SetInstance(&discardable_memory_allocator_); |
| 46 } | 52 } |
| 47 | 53 |
| 48 int main(int argc, char** argv) { | 54 int main(int argc, char** argv) { |
| 49 TestSuiteNoAtExit test_suite(argc, argv); | 55 TestSuiteNoAtExit test_suite(argc, argv); |
| 50 | 56 |
| 51 return base::LaunchUnitTests( | 57 return base::LaunchUnitTests( |
| 52 argc, argv, base::Bind(&TestSuiteNoAtExit::Run, | 58 argc, argv, base::Bind(&TestSuiteNoAtExit::Run, |
| 53 base::Unretained(&test_suite))); | 59 base::Unretained(&test_suite))); |
| 54 } | 60 } |
| OLD | NEW |