Home | History | Annotate | Download | only in base
      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_suite.h"
      9 #include "build/build_config.h"
     10 #include "media/base/media.h"
     11 #include "media/base/media_switches.h"
     12 
     13 #if defined(OS_ANDROID)
     14 #include "base/android/jni_android.h"
     15 #include "media/base/android/media_jni_registrar.h"
     16 #include "ui/gl/android/gl_jni_registrar.h"
     17 #endif
     18 
     19 class TestSuiteNoAtExit : public base::TestSuite {
     20  public:
     21   TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {}
     22   virtual ~TestSuiteNoAtExit() {}
     23  protected:
     24   virtual void Initialize() OVERRIDE;
     25 };
     26 
     27 void TestSuiteNoAtExit::Initialize() {
     28   // Run TestSuite::Initialize first so that logging is initialized.
     29   base::TestSuite::Initialize();
     30 
     31 #if defined(OS_ANDROID)
     32   // Register JNI bindings for android.
     33   JNIEnv* env = base::android::AttachCurrentThread();
     34   // Needed for surface texture support.
     35   ui::gl::android::RegisterJni(env);
     36   media::RegisterJni(env);
     37 #endif
     38 
     39   // Run this here instead of main() to ensure an AtExitManager is already
     40   // present.
     41   media::InitializeMediaLibraryForTesting();
     42   CommandLine* cmd_line = CommandLine::ForCurrentProcess();
     43   cmd_line->AppendSwitch(switches::kEnableMP3StreamParser);
     44 }
     45 
     46 int main(int argc, char** argv) {
     47   TestSuiteNoAtExit test_suite(argc, argv);
     48 
     49   return base::LaunchUnitTests(
     50       argc, argv, base::Bind(&TestSuiteNoAtExit::Run,
     51                              base::Unretained(&test_suite)));
     52 }
     53