| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/test/launcher/unit_test_launcher.h" | 9 #include "base/test/launcher/unit_test_launcher.h" |
| 10 #include "base/test/test_suite.h" | 10 #include "base/test/test_suite.h" |
| 11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
| 12 #include "components/scheduler/child/scheduler_tqm_delegate_impl.h" | |
| 13 #include "components/scheduler/child/web_task_runner_impl.h" | |
| 14 #include "components/scheduler/renderer/renderer_scheduler_impl.h" | |
| 15 #include "components/scheduler/renderer/renderer_web_scheduler_impl.h" | |
| 16 #include "components/scheduler/test/lazy_scheduler_message_loop_delegate_for_tes
ts.h" | |
| 17 #include "media/base/media.h" | 12 #include "media/base/media.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "third_party/WebKit/public/platform/WebScheduler.h" | 14 #include "third_party/WebKit/public/platform/scheduler/renderer/renderer_schedul
er.h" |
| 20 #include "third_party/WebKit/public/platform/WebTaskRunner.h" | 15 #include "third_party/WebKit/public/platform/scheduler/test/renderer_scheduler_t
est_support.h" |
| 21 #include "third_party/WebKit/public/platform/WebThread.h" | |
| 22 #include "third_party/WebKit/public/web/WebKit.h" | 16 #include "third_party/WebKit/public/web/WebKit.h" |
| 23 | 17 |
| 24 #if defined(OS_ANDROID) | 18 #if defined(OS_ANDROID) |
| 25 #include "base/android/jni_android.h" | 19 #include "base/android/jni_android.h" |
| 26 #include "media/base/android/media_jni_registrar.h" | 20 #include "media/base/android/media_jni_registrar.h" |
| 27 #endif | 21 #endif |
| 28 | 22 |
| 29 #ifdef V8_USE_EXTERNAL_STARTUP_DATA | 23 #ifdef V8_USE_EXTERNAL_STARTUP_DATA |
| 30 #include "gin/v8_initializer.h" | 24 #include "gin/v8_initializer.h" |
| 31 #endif | 25 #endif |
| 32 | 26 |
| 33 class CurrentThreadMock : public blink::WebThread { | 27 class TestBlinkPlatformSupport : NON_EXPORTED_BASE(public blink::Platform) { |
| 34 public: | 28 public: |
| 35 CurrentThreadMock() | 29 TestBlinkPlatformSupport() |
| 36 : task_runner_delegate_( | 30 : renderer_scheduler_( |
| 37 scheduler::LazySchedulerMessageLoopDelegateForTests::Create()), | 31 blink::scheduler::CreateRendererSchedulerForTests()), |
| 38 scheduler_( | 32 main_thread_(renderer_scheduler_->CreateMainThread()) {} |
| 39 new scheduler::RendererSchedulerImpl(task_runner_delegate_.get())), | 33 ~TestBlinkPlatformSupport() override; |
| 40 web_scheduler_( | |
| 41 new scheduler::RendererWebSchedulerImpl(scheduler_.get())), | |
| 42 web_task_runner_( | |
| 43 new scheduler::WebTaskRunnerImpl(scheduler_->DefaultTaskRunner())) { | |
| 44 } | |
| 45 | 34 |
| 46 ~CurrentThreadMock() override { | 35 blink::WebThread* currentThread() override { |
| 47 scheduler_->Shutdown(); | 36 EXPECT_TRUE(main_thread_->isCurrentThread()); |
| 48 } | 37 return main_thread_.get(); |
| 49 | |
| 50 blink::WebTaskRunner* getWebTaskRunner() override { | |
| 51 return web_task_runner_.get(); | |
| 52 } | |
| 53 | |
| 54 bool isCurrentThread() const override { return true; } | |
| 55 | |
| 56 blink::PlatformThreadId threadId() const override { return 17; } | |
| 57 | |
| 58 blink::WebScheduler* scheduler() const override { | |
| 59 return web_scheduler_.get(); | |
| 60 } | 38 } |
| 61 | 39 |
| 62 private: | 40 private: |
| 63 scoped_refptr<scheduler::SchedulerTqmDelegate> task_runner_delegate_; | 41 std::unique_ptr<blink::scheduler::RendererScheduler> renderer_scheduler_; |
| 64 std::unique_ptr<scheduler::RendererSchedulerImpl> scheduler_; | 42 std::unique_ptr<blink::WebThread> main_thread_; |
| 65 std::unique_ptr<blink::WebScheduler> web_scheduler_; | |
| 66 std::unique_ptr<blink::WebTaskRunner> web_task_runner_; | |
| 67 }; | 43 }; |
| 68 | 44 |
| 69 class TestBlinkPlatformSupport : NON_EXPORTED_BASE(public blink::Platform) { | 45 TestBlinkPlatformSupport::~TestBlinkPlatformSupport() { |
| 70 public: | 46 renderer_scheduler_->Shutdown(); |
| 71 ~TestBlinkPlatformSupport() override; | 47 } |
| 72 | |
| 73 blink::WebThread* currentThread() override { return &m_currentThread; } | |
| 74 | |
| 75 private: | |
| 76 CurrentThreadMock m_currentThread; | |
| 77 }; | |
| 78 | |
| 79 TestBlinkPlatformSupport::~TestBlinkPlatformSupport() {} | |
| 80 | 48 |
| 81 class BlinkMediaTestSuite : public base::TestSuite { | 49 class BlinkMediaTestSuite : public base::TestSuite { |
| 82 public: | 50 public: |
| 83 BlinkMediaTestSuite(int argc, char** argv); | 51 BlinkMediaTestSuite(int argc, char** argv); |
| 84 ~BlinkMediaTestSuite() override; | 52 ~BlinkMediaTestSuite() override; |
| 85 | 53 |
| 86 protected: | 54 protected: |
| 87 void Initialize() override; | 55 void Initialize() override; |
| 88 | 56 |
| 89 private: | 57 private: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 blink::initialize(blink_platform_support_.get()); | 91 blink::initialize(blink_platform_support_.get()); |
| 124 } | 92 } |
| 125 | 93 |
| 126 int main(int argc, char** argv) { | 94 int main(int argc, char** argv) { |
| 127 BlinkMediaTestSuite test_suite(argc, argv); | 95 BlinkMediaTestSuite test_suite(argc, argv); |
| 128 | 96 |
| 129 return base::LaunchUnitTests( | 97 return base::LaunchUnitTests( |
| 130 argc, argv, base::Bind(&BlinkMediaTestSuite::Run, | 98 argc, argv, base::Bind(&BlinkMediaTestSuite::Run, |
| 131 base::Unretained(&test_suite))); | 99 base::Unretained(&test_suite))); |
| 132 } | 100 } |
| OLD | NEW |