diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-03 17:20:05 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-03 17:20:05 +0000 |
commit | b565adfaffe3c55628ce085d35bde258acc58602 (patch) | |
tree | a3c01240936da0c597ff9d9cfcd8709bf0a82f1a /ui | |
parent | 2a6dda2f45d680ef5fc002c5a3e29cfc3d78773a (diff) | |
download | chromium_src-b565adfaffe3c55628ce085d35bde258acc58602.zip chromium_src-b565adfaffe3c55628ce085d35bde258acc58602.tar.gz chromium_src-b565adfaffe3c55628ce085d35bde258acc58602.tar.bz2 |
Makes layer_unittests run on linux
Added test_compositor_host_linux implementation for linux.
Review URL: http://codereview.chromium.org/8060047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103730 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gfx/compositor/compositor.gyp | 8 | ||||
-rw-r--r-- | ui/gfx/compositor/layer_unittest.cc | 10 | ||||
-rw-r--r-- | ui/gfx/compositor/test_compositor_host_linux.cc | 66 |
3 files changed, 58 insertions, 26 deletions
diff --git a/ui/gfx/compositor/compositor.gyp b/ui/gfx/compositor/compositor.gyp index 1c030b6..136ff3c 100644 --- a/ui/gfx/compositor/compositor.gyp +++ b/ui/gfx/compositor/compositor.gyp @@ -109,14 +109,6 @@ '<(SHARED_INTERMEDIATE_DIR)/ui/gfx/gfx_resources.rc', '<(SHARED_INTERMEDIATE_DIR)/ui/ui_resources/ui_resources.rc', ], - 'conditions': [ - ['OS=="linux"', { - 'sources!': [ - 'test_compositor_host.h', - 'test_compositor_host_linux.cc', - ], - }], - ], }, ], } diff --git a/ui/gfx/compositor/layer_unittest.cc b/ui/gfx/compositor/layer_unittest.cc index a0693ed..0c47926 100644 --- a/ui/gfx/compositor/layer_unittest.cc +++ b/ui/gfx/compositor/layer_unittest.cc @@ -10,17 +10,12 @@ #include "ui/gfx/compositor/compositor_observer.h" #include "ui/gfx/compositor/layer.h" #include "ui/gfx/compositor/test_compositor.h" - -// TestCompositorHost needs to be ported to linux for these to work. -#if !defined(OS_LINUX) #include "ui/gfx/compositor/test_compositor_host.h" -#endif namespace ui { namespace { -#if !defined(OS_LINUX) class LayerWithRealCompositorTest : public testing::Test { public: LayerWithRealCompositorTest() {} @@ -91,7 +86,6 @@ class LayerWithRealCompositorTest : public testing::Test { DISALLOW_COPY_AND_ASSIGN(LayerWithRealCompositorTest); }; -#endif // LayerDelegate that paints colors to the layer. class TestLayerDelegate : public LayerDelegate { @@ -164,8 +158,6 @@ class NullLayerDelegate : public LayerDelegate { } -#if !defined(OS_LINUX) - TEST_F(LayerWithRealCompositorTest, Draw) { scoped_ptr<Layer> layer(CreateColorLayer(SK_ColorRED, gfx::Rect(20, 20, 50, 50))); @@ -195,8 +187,6 @@ TEST_F(LayerWithRealCompositorTest, Hierarchy) { DrawTree(l1.get()); } -#endif - // LayerTest uses TestCompositor as the Compositor implementation. class LayerTest : public testing::Test { public: diff --git a/ui/gfx/compositor/test_compositor_host_linux.cc b/ui/gfx/compositor/test_compositor_host_linux.cc index fcca773..c6ea0c5 100644 --- a/ui/gfx/compositor/test_compositor_host_linux.cc +++ b/ui/gfx/compositor/test_compositor_host_linux.cc @@ -7,7 +7,15 @@ #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/logging.h" +#include "ui/base/x/x11_util.h" #include "ui/gfx/compositor/compositor.h" +#include "ui/gfx/rect.h" + +#include <X11/Xlib.h> + +#if defined(TOUCH_UI) || defined(USE_AURA) +#include "base/message_pump_x.h" +#endif namespace ui { @@ -26,33 +34,75 @@ class TestCompositorHostLinux : public TestCompositorHost, virtual void ScheduleDraw() OVERRIDE; // Overridden from MessagePumpDispatcher: - virtual bool Dispatch(GdkEvent* event); +#if defined(TOUCH_UI) || defined(USE_AURA) + virtual base::MessagePumpDispatcher::DispatchStatus + Dispatch(XEvent* xev) OVERRIDE; +#elif defined(TOOLKIT_USES_GTK) + virtual bool Dispatch(GdkEvent* event) OVERRIDE; +#endif + + gfx::Rect bounds_; + + scoped_refptr<ui::Compositor> compositor_; + + Display* display_; + + XID window_; DISALLOW_COPY_AND_ASSIGN(TestCompositorHostLinux); }; -TestCompositorHostLinux::TestCompositorHostLinux(const gfx::Rect& bounds) { +TestCompositorHostLinux::TestCompositorHostLinux(const gfx::Rect& bounds) + : bounds_(bounds) { } -TestCompositorHostLinux::~TestCompositorHostLinux() {} +TestCompositorHostLinux::~TestCompositorHostLinux() { + XDestroyWindow(display_, window_); +} void TestCompositorHostLinux::Show() { - NOTIMPLEMENTED(); + display_ = XOpenDisplay(NULL); + XSetWindowAttributes swa; + swa.event_mask = StructureNotifyMask | ExposureMask; + swa.override_redirect = True; + window_ = XCreateWindow( + display_, + RootWindow(display_, DefaultScreen(display_)), // parent + bounds_.x(), bounds_.y(), bounds_.width(), bounds_.height(), + 0, // border width + CopyFromParent, // depth + InputOutput, + CopyFromParent, // visual + CWEventMask | CWOverrideRedirect, &swa); + XMapWindow(display_, window_); + + while (1) { + XEvent event; + XNextEvent(display_, &event); + if (event.type == MapNotify && event.xmap.window == window_) + break; + } + compositor_ = ui::Compositor::Create(this, window_, bounds_.size()); } ui::Compositor* TestCompositorHostLinux::GetCompositor() { - NOTIMPLEMENTED(); - return NULL; + return compositor_; } void TestCompositorHostLinux::ScheduleDraw() { - NOTIMPLEMENTED(); + compositor_->Draw(false); } +#if defined(TOUCH_UI) || defined(USE_AURA) +base::MessagePumpDispatcher::DispatchStatus TestCompositorHostLinux::Dispatch( + XEvent* xev) { + return MessagePumpDispatcher::EVENT_IGNORED; +} +#elif defined(TOOLKIT_USES_GTK) bool TestCompositorHostLinux::Dispatch(GdkEvent*) { - NOTIMPLEMENTED(); return false; } +#endif // static TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) { |