Revert of Roll src/third_party/WebKit e0eac24:489c548 (svn 193311:193320) (patchset...
[chromium-blink-merge.git] / media / blink / run_all_unittests.cc
blob7608420dea0a152dbf339db7b51d9712d1e73bbc
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 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
19 #include "gin/public/isolate_holder.h"
20 #endif
22 class TestBlinkPlatformSupport : NON_EXPORTED_BASE(public blink::Platform) {
23 public:
24 virtual ~TestBlinkPlatformSupport();
26 virtual void cryptographicallyRandomValues(unsigned char* buffer,
27 size_t length) override;
28 virtual const unsigned char* getTraceCategoryEnabledFlag(
29 const char* categoryName) override;
32 TestBlinkPlatformSupport::~TestBlinkPlatformSupport() {}
34 void TestBlinkPlatformSupport::cryptographicallyRandomValues(
35 unsigned char* buffer,
36 size_t length) {
39 const unsigned char* TestBlinkPlatformSupport::getTraceCategoryEnabledFlag(
40 const char* categoryName) {
41 static const unsigned char tracingIsDisabled = 0;
42 return &tracingIsDisabled;
45 class BlinkMediaTestSuite : public base::TestSuite {
46 public:
47 BlinkMediaTestSuite(int argc, char** argv);
48 ~BlinkMediaTestSuite() override;
50 protected:
51 void Initialize() override;
53 private:
54 scoped_ptr<TestBlinkPlatformSupport> blink_platform_support_;
57 BlinkMediaTestSuite::BlinkMediaTestSuite(int argc, char** argv)
58 : TestSuite(argc, argv),
59 blink_platform_support_(new TestBlinkPlatformSupport()) {
62 BlinkMediaTestSuite::~BlinkMediaTestSuite() {}
64 void BlinkMediaTestSuite::Initialize() {
65 // Run TestSuite::Initialize first so that logging is initialized.
66 base::TestSuite::Initialize();
68 #if defined(OS_ANDROID)
69 // Register JNI bindings for android.
70 JNIEnv* env = base::android::AttachCurrentThread();
71 // Needed for surface texture support.
72 ui::gl::android::RegisterJni(env);
73 media::RegisterJni(env);
74 #endif
76 // Run this here instead of main() to ensure an AtExitManager is already
77 // present.
78 media::InitializeMediaLibraryForTesting();
80 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
81 gin::IsolateHolder::LoadV8Snapshot();
82 #endif
84 blink::initialize(blink_platform_support_.get());
87 int main(int argc, char** argv) {
88 BlinkMediaTestSuite test_suite(argc, argv);
90 return base::LaunchUnitTests(
91 argc, argv, base::Bind(&BlinkMediaTestSuite::Run,
92 base::Unretained(&test_suite)));