downloads.ItemView -> downloads.Item
[chromium-blink-merge.git] / media / blink / run_all_unittests.cc
blob8af78f7cdd056985c5a759991d1a92e9c2f68142
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/message_loop/message_loop.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 "third_party/WebKit/public/web/WebKit.h"
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
19 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
20 #include "gin/v8_initializer.h"
21 #endif
23 class TestBlinkPlatformSupport : NON_EXPORTED_BASE(public blink::Platform) {
24 public:
25 virtual ~TestBlinkPlatformSupport();
27 virtual void cryptographicallyRandomValues(unsigned char* buffer,
28 size_t length) override;
29 virtual const unsigned char* getTraceCategoryEnabledFlag(
30 const char* categoryName) override;
33 TestBlinkPlatformSupport::~TestBlinkPlatformSupport() {}
35 void TestBlinkPlatformSupport::cryptographicallyRandomValues(
36 unsigned char* buffer,
37 size_t length) {
40 const unsigned char* TestBlinkPlatformSupport::getTraceCategoryEnabledFlag(
41 const char* categoryName) {
42 static const unsigned char tracingIsDisabled = 0;
43 return &tracingIsDisabled;
46 class BlinkMediaTestSuite : public base::TestSuite {
47 public:
48 BlinkMediaTestSuite(int argc, char** argv);
49 ~BlinkMediaTestSuite() override;
51 protected:
52 void Initialize() override;
54 private:
55 scoped_ptr<TestBlinkPlatformSupport> blink_platform_support_;
58 BlinkMediaTestSuite::BlinkMediaTestSuite(int argc, char** argv)
59 : TestSuite(argc, argv),
60 blink_platform_support_(new TestBlinkPlatformSupport()) {
63 BlinkMediaTestSuite::~BlinkMediaTestSuite() {}
65 void BlinkMediaTestSuite::Initialize() {
66 // Run TestSuite::Initialize first so that logging is initialized.
67 base::TestSuite::Initialize();
69 #if defined(OS_ANDROID)
70 // Register JNI bindings for android.
71 JNIEnv* env = base::android::AttachCurrentThread();
72 // Needed for surface texture support.
73 ui::gl::android::RegisterJni(env);
74 media::RegisterJni(env);
75 #endif
77 // Run this here instead of main() to ensure an AtExitManager is already
78 // present.
79 media::InitializeMediaLibrary();
81 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
82 gin::V8Initializer::LoadV8Snapshot();
83 gin::V8Initializer::LoadV8Natives();
84 #endif
86 // Dummy task runner is initialized here because the blink::initialize creates
87 // IsolateHolder which needs the current task runner handle. There should be
88 // no task posted to this task runner.
89 scoped_ptr<base::MessageLoop> message_loop;
90 if (!base::MessageLoop::current())
91 message_loop.reset(new base::MessageLoop());
92 blink::initialize(blink_platform_support_.get());
95 int main(int argc, char** argv) {
96 BlinkMediaTestSuite test_suite(argc, argv);
98 return base::LaunchUnitTests(
99 argc, argv, base::Bind(&BlinkMediaTestSuite::Run,
100 base::Unretained(&test_suite)));