Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: ui/ozone/platform/drm/ozone_platform_gbm.cc

Issue 1208603002: content: implement unittests backend for Ozone GBM Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix NavigationControllerTest failure Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698