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