Allow the externalfile scheme to be whitelisted as an allowed scheme for component...
[chromium-blink-merge.git] / media / blink / run_all_unittests.cc
blob83c75d6c4ec957713bbe00316c9bac39e03c471d
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
3 // found in the LICENSE file.
5 #include "base/bind.h"
6 #include "base/test/launcher/unit_test_launcher.h"
7 #include "base/test/test_suite.h"
8 #include "build/build_config.h"
9 #include "media/base/media.h"
10 #include "third_party/WebKit/public/web/WebKit.h"
12 #if defined(OS_ANDROID)
13 #include "base/android/jni_android.h"
14 #include "media/base/android/media_jni_registrar.h"
15 #include "ui/gl/android/gl_jni_registrar.h"
16 #endif
18 class TestBlinkPlatformSupport : NON_EXPORTED_BASE(public blink::Platform) {
19 public:
20 virtual ~TestBlinkPlatformSupport();
22 virtual void cryptographicallyRandomValues(unsigned char* buffer,
23 size_t length) override;
24 virtual const unsigned char* getTraceCategoryEnabledFlag(
25 const char* categoryName) override;
28 TestBlinkPlatformSupport::~TestBlinkPlatformSupport() {}
30 void TestBlinkPlatformSupport::cryptographicallyRandomValues(
31 unsigned char* buffer,
32 size_t length) {
35 const unsigned char* TestBlinkPlatformSupport::getTraceCategoryEnabledFlag(
36 const char* categoryName) {
37 static const unsigned char tracingIsDisabled = 0;
38 return &tracingIsDisabled;
41 class BlinkMediaTestSuite : public base::TestSuite {
42 public:
43 BlinkMediaTestSuite(int argc, char** argv);
44 virtual ~BlinkMediaTestSuite();
46 protected:
47 virtual void Initialize() override;
49 private:
50 scoped_ptr<TestBlinkPlatformSupport> blink_platform_support_;
53 BlinkMediaTestSuite::BlinkMediaTestSuite(int argc, char** argv)
54 : TestSuite(argc, argv),
55 blink_platform_support_(new TestBlinkPlatformSupport()) {
58 BlinkMediaTestSuite::~BlinkMediaTestSuite() {}
60 void BlinkMediaTestSuite::Initialize() {
61 // Run TestSuite::Initialize first so that logging is initialized.
62 base::TestSuite::Initialize();
64 #if defined(OS_ANDROID)
65 // Register JNI bindings for android.
66 JNIEnv* env = base::android::AttachCurrentThread();
67 // Needed for surface texture support.
68 ui::gl::android::RegisterJni(env);
69 media::RegisterJni(env);
70 #endif
72 // Run this here instead of main() to ensure an AtExitManager is already
73 // present.
74 media::InitializeMediaLibraryForTesting();
76 blink::initialize(blink_platform_support_.get());
79 int main(int argc, char** argv) {
80 BlinkMediaTestSuite test_suite(argc, argv);
82 return base::LaunchUnitTests(
83 argc, argv, base::Bind(&BlinkMediaTestSuite::Run,
84 base::Unretained(&test_suite)));