Chromium Code Reviews| Index: ui/ozone/platform/drm/ozone_platform_gbm.cc |
| diff --git a/ui/ozone/platform/drm/ozone_platform_gbm.cc b/ui/ozone/platform/drm/ozone_platform_gbm.cc |
| index 5dfda4d555402f0598df137f0f51059588882818..621fa596ab0eb1907f87d19b8909e299c9ee65e2 100644 |
| --- a/ui/ozone/platform/drm/ozone_platform_gbm.cc |
| +++ b/ui/ozone/platform/drm/ozone_platform_gbm.cc |
| @@ -11,6 +11,9 @@ |
| #include "base/at_exit.h" |
| #include "base/bind.h" |
| #include "base/command_line.h" |
| +#include "base/message_loop/message_loop.h" |
| +#include "base/synchronization/waitable_event.h" |
| +#include "base/threading/thread.h" |
| #include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h" |
| #include "ui/events/ozone/device/device_manager.h" |
| #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| @@ -36,6 +39,7 @@ |
| #include "ui/ozone/public/cursor_factory_ozone.h" |
| #include "ui/ozone/public/gpu_platform_support.h" |
| #include "ui/ozone/public/gpu_platform_support_host.h" |
| +#include "ui/ozone/public/ozone_gpu_test_helper.h" |
| #include "ui/ozone/public/ozone_platform.h" |
| #include "ui/ozone/public/ozone_switches.h" |
| @@ -108,6 +112,10 @@ class GbmDeviceGenerator : public DrmDeviceGenerator { |
| DISALLOW_COPY_AND_ASSIGN(GbmDeviceGenerator); |
| }; |
| +void Noop(base::WaitableEvent* done) { |
| + done->Signal(); |
| +} |
| + |
| class OzonePlatformGbm : public OzonePlatform { |
| public: |
| OzonePlatformGbm(bool use_surfaceless) : use_surfaceless_(use_surfaceless) {} |
| @@ -190,7 +198,43 @@ class OzonePlatformGbm : public OzonePlatform { |
| buffer_generator_.get(), display_manager.Pass())); |
| } |
| + // Must initialize everything synchronously. It's why this method creates |
| + // |ui_thread_| and |gpu_ipc_thread_|, and then requests initialization, and |
| + // then waits for all initialization done. |
| + void InitializeTest() override { |
| + message_loop_for_test_.reset(new base::MessageLoopForUI); |
| + |
| + ui_thread_.reset(new base::Thread("test_ui_thread")); |
|
spang
2015/07/13 17:08:26
Creating a "UI thread" won't work because any call
|
| + ui_thread_->Start(); |
| + { |
| + base::WaitableEvent done(false, false); |
| + ui_thread_->task_runner()->PostTask( |
| + FROM_HERE, base::Bind(&OzonePlatformGbm::InitializeUIForTest, |
| + base::Unretained(this), &done)); |
| + done.Wait(); |
| + } |
| + |
| + InitializeGPU(); |
| + |
| + gpu_ipc_thread_.reset(new base::Thread("test_gpu_ipc_thread")); |
| + gpu_ipc_thread_->Start(); |
| + gpu_helper_.reset(new ui::OzoneGpuTestHelper); |
| + gpu_helper_->Initialize(ui_thread_->task_runner(), |
| + gpu_ipc_thread_->task_runner()); |
| + { |
| + base::WaitableEvent done(false, false); |
| + gpu_ipc_thread_->task_runner()->PostTask(FROM_HERE, |
| + base::Bind(&Noop, &done)); |
| + done.Wait(); |
| + } |
| + } |
| + |
| private: |
| + void InitializeUIForTest(base::WaitableEvent* done) { |
| + InitializeUI(); |
| + done->Signal(); |
| + } |
| + |
| // Objects in both processes. |
| bool use_surfaceless_; |
| @@ -212,6 +256,12 @@ class OzonePlatformGbm : public OzonePlatform { |
| scoped_ptr<DrmDisplayHostManager> display_manager_; |
| scoped_ptr<DrmOverlayManager> overlay_manager_; |
| + // for test |
| + scoped_ptr<base::MessageLoopForUI> message_loop_for_test_; |
| + scoped_ptr<base::Thread> ui_thread_; |
| + scoped_ptr<base::Thread> gpu_ipc_thread_; |
| + scoped_ptr<ui::OzoneGpuTestHelper> gpu_helper_; |
| + |
| #if defined(USE_XKBCOMMON) |
| XkbEvdevCodes xkb_evdev_code_converter_; |
| #endif |