OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/test/launcher/unit_test_launcher.h" | 6 #include "base/test/launcher/unit_test_launcher.h" |
7 #include "base/test/test_suite.h" | 7 #include "base/test/test_suite.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "media/base/media.h" | 9 #include "media/base/media.h" |
10 | 10 |
11 #if defined(OS_ANDROID) | |
12 #include "base/android/jni_android.h" | |
13 #include "media/base/android/media_jni_registrar.h" | |
14 #include "ui/gl/android/gl_jni_registrar.h" | |
15 #endif | |
16 | |
17 class TestSuiteNoAtExit : public base::TestSuite { | 11 class TestSuiteNoAtExit : public base::TestSuite { |
18 public: | 12 public: |
19 TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {} | 13 TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {} |
20 ~TestSuiteNoAtExit() override {} | 14 ~TestSuiteNoAtExit() override {} |
21 | 15 |
22 protected: | 16 protected: |
23 void Initialize() override; | 17 void Initialize() override; |
24 }; | 18 }; |
25 | 19 |
26 void TestSuiteNoAtExit::Initialize() { | 20 void TestSuiteNoAtExit::Initialize() { |
27 // Run TestSuite::Initialize first so that logging is initialized. | 21 // Run TestSuite::Initialize first so that logging is initialized. |
28 base::TestSuite::Initialize(); | 22 base::TestSuite::Initialize(); |
29 | 23 |
30 #if defined(OS_ANDROID) | |
31 // Register JNI bindings for android. | |
32 JNIEnv* env = base::android::AttachCurrentThread(); | |
33 // Needed for surface texture support. | |
34 ui::gl::android::RegisterJni(env); | |
35 media::RegisterJni(env); | |
36 #endif | |
37 | |
38 // Run this here instead of main() to ensure an AtExitManager is already | 24 // Run this here instead of main() to ensure an AtExitManager is already |
39 // present. | 25 // present. |
40 media::InitializeMediaLibrary(); | 26 media::InitializeMediaLibrary(); |
41 } | 27 } |
42 | 28 |
43 int main(int argc, char** argv) { | 29 int main(int argc, char** argv) { |
44 TestSuiteNoAtExit test_suite(argc, argv); | 30 TestSuiteNoAtExit test_suite(argc, argv); |
45 | 31 |
46 // Always run the perf tests serially, to avoid distorting | 32 // Always run the perf tests serially, to avoid distorting |
47 // perf measurements with randomness resulting from running | 33 // perf measurements with randomness resulting from running |
48 // in parallel. | 34 // in parallel. |
49 return base::LaunchUnitTestsSerially( | 35 return base::LaunchUnitTestsSerially( |
50 argc, argv, base::Bind(&TestSuiteNoAtExit::Run, | 36 argc, argv, base::Bind(&TestSuiteNoAtExit::Run, |
51 base::Unretained(&test_suite))); | 37 base::Unretained(&test_suite))); |
52 } | 38 } |
OLD | NEW |