15d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Copyright 2014 The Chromium Authors. All rights reserved. 25d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 35d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)// found in the LICENSE file. 45d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 55d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/bind.h" 65d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/test/launcher/unit_test_launcher.h" 75d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/test/test_suite.h" 85d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "build/build_config.h" 95d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "media/base/media.h" 105d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 115d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#if defined(OS_ANDROID) 125d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "base/android/jni_android.h" 135d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "media/base/android/media_jni_registrar.h" 145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#include "ui/gl/android/gl_jni_registrar.h" 155d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif 165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 175d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)class TestSuiteNoAtExit : public base::TestSuite { 185d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) public: 195d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) TestSuiteNoAtExit(int argc, char** argv) : TestSuite(argc, argv) {} 205d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual ~TestSuiteNoAtExit() {} 215d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) protected: 225d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) virtual void Initialize() OVERRIDE; 235d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)}; 245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 255d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)void TestSuiteNoAtExit::Initialize() { 265d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Run TestSuite::Initialize first so that logging is initialized. 275d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::TestSuite::Initialize(); 285d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 295d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#if defined(OS_ANDROID) 305d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Register JNI bindings for android. 315d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) JNIEnv* env = base::android::AttachCurrentThread(); 325d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Needed for surface texture support. 335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) ui::gl::android::RegisterJni(env); 345d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) media::RegisterJni(env); 355d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)#endif 365d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 375d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Run this here instead of main() to ensure an AtExitManager is already 385d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // present. 395d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) media::InitializeMediaLibraryForTesting(); 405d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 425d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)int main(int argc, char** argv) { 435d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) TestSuiteNoAtExit test_suite(argc, argv); 445d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) 455d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // Always run the perf tests serially, to avoid distorting 465d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // perf measurements with randomness resulting from running 475d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) // in parallel. 485d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) return base::LaunchUnitTestsSerially( 495d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) argc, argv, base::Bind(&TestSuiteNoAtExit::Run, 505d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles) base::Unretained(&test_suite))); 515d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)} 52