BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / media / blink / run_all_unittests.cc
blob7162cd502f8ed65a319613a88cb23be8570e227b
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 "testing/gtest/include/gtest/gtest.h"
12 #include "third_party/WebKit/public/platform/WebScheduler.h"
13 #include "third_party/WebKit/public/platform/WebTaskRunner.h"
14 #include "third_party/WebKit/public/platform/WebThread.h"
15 #include "third_party/WebKit/public/web/WebKit.h"
17 #if defined(OS_ANDROID)
18 #include "base/android/jni_android.h"
19 #include "media/base/android/media_jni_registrar.h"
20 #include "ui/gl/android/gl_jni_registrar.h"
21 #endif
23 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
24 #include "gin/v8_initializer.h"
25 #endif
27 class SimpleWebTaskRunner : public blink::WebTaskRunner {
28 public:
29 virtual void postTask(const blink::WebTraceLocation& ignored, Task* task) {
30 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind(&RunIt, task));
33 void postDelayedTask(const blink::WebTraceLocation&,
34 Task* task,
35 long long delayMs) override {
36 base::MessageLoop::current()->PostDelayedTask(
37 FROM_HERE, base::Bind(&RunIt, base::Owned(task)),
38 base::TimeDelta::FromMilliseconds(delayMs));
41 private:
42 static void RunIt(Task* task) { task->run(); }
45 class SimpleWebScheduler : public blink::WebScheduler {
46 public:
47 SimpleWebScheduler(blink::WebTaskRunner* task_runner)
48 : task_runner_(task_runner) {}
49 blink::WebTaskRunner* loadingTaskRunner() override { return task_runner_; }
51 blink::WebTaskRunner* timerTaskRunner() override { return task_runner_; }
53 private:
54 blink::WebTaskRunner* task_runner_;
57 class CurrentThreadMock : public blink::WebThread {
58 public:
59 CurrentThreadMock() : m_taskRunner(), m_webScheduler(&m_taskRunner) {}
61 ~CurrentThreadMock() override {}
63 blink::WebTaskRunner* taskRunner() override { return &m_taskRunner; }
65 bool isCurrentThread() const override { return true; }
67 blink::PlatformThreadId threadId() const override { return 17; }
69 blink::WebScheduler* scheduler() const override { return &m_webScheduler; }
71 private:
72 SimpleWebTaskRunner m_taskRunner;
73 mutable SimpleWebScheduler m_webScheduler;
76 class TestBlinkPlatformSupport : NON_EXPORTED_BASE(public blink::Platform) {
77 public:
78 virtual ~TestBlinkPlatformSupport();
80 virtual void cryptographicallyRandomValues(unsigned char* buffer,
81 size_t length) override;
82 virtual const unsigned char* getTraceCategoryEnabledFlag(
83 const char* categoryName) override;
84 blink::WebThread* currentThread() override { return &m_currentThread; }
86 private:
87 CurrentThreadMock m_currentThread;
90 TestBlinkPlatformSupport::~TestBlinkPlatformSupport() {}
92 void TestBlinkPlatformSupport::cryptographicallyRandomValues(
93 unsigned char* buffer,
94 size_t length) {
97 const unsigned char* TestBlinkPlatformSupport::getTraceCategoryEnabledFlag(
98 const char* categoryName) {
99 static const unsigned char tracingIsDisabled = 0;
100 return &tracingIsDisabled;
103 class BlinkMediaTestSuite : public base::TestSuite {
104 public:
105 BlinkMediaTestSuite(int argc, char** argv);
106 ~BlinkMediaTestSuite() override;
108 protected:
109 void Initialize() override;
111 private:
112 scoped_ptr<TestBlinkPlatformSupport> blink_platform_support_;
115 BlinkMediaTestSuite::BlinkMediaTestSuite(int argc, char** argv)
116 : TestSuite(argc, argv),
117 blink_platform_support_(new TestBlinkPlatformSupport()) {
120 BlinkMediaTestSuite::~BlinkMediaTestSuite() {}
122 void BlinkMediaTestSuite::Initialize() {
123 // Run TestSuite::Initialize first so that logging is initialized.
124 base::TestSuite::Initialize();
126 #if defined(OS_ANDROID)
127 // Register JNI bindings for android.
128 JNIEnv* env = base::android::AttachCurrentThread();
129 // Needed for surface texture support.
130 ui::gl::android::RegisterJni(env);
131 media::RegisterJni(env);
132 #endif
134 // Run this here instead of main() to ensure an AtExitManager is already
135 // present.
136 media::InitializeMediaLibrary();
138 #ifdef V8_USE_EXTERNAL_STARTUP_DATA
139 gin::V8Initializer::LoadV8Snapshot();
140 gin::V8Initializer::LoadV8Natives();
141 #endif
143 // Dummy task runner is initialized here because the blink::initialize creates
144 // IsolateHolder which needs the current task runner handle. There should be
145 // no task posted to this task runner.
146 scoped_ptr<base::MessageLoop> message_loop;
147 if (!base::MessageLoop::current())
148 message_loop.reset(new base::MessageLoop());
149 blink::initialize(blink_platform_support_.get());
152 int main(int argc, char** argv) {
153 BlinkMediaTestSuite test_suite(argc, argv);
155 return base::LaunchUnitTests(
156 argc, argv, base::Bind(&BlinkMediaTestSuite::Run,
157 base::Unretained(&test_suite)));