void TestHarness::runNextStep()
{
- steps_.front()();
+ TestStep step(steps_.front());
steps_.pop_front();
+ step();
}
void runNextStep();
bool haveStep() const;
-private:
+protected:
TestSteps steps_;
};
elmtestharness.cpp \
evasobject.cpp \
window.cpp \
+ wayland-fits.cpp \
test_actionslider.cpp \
test_background.cpp \
test_bubble.cpp \
test_panel.cpp \
test_popup.cpp \
test_progressbar.cpp \
- test_window.cpp
+ test_window.cpp \
+ $(top_srcdir)/src/extensions/protocol/wayland-fits-protocol.c
libwfits_efl_la_LIBADD = \
$(top_builddir)/src/common/libwfits-common.la \
: TestHarness::TestHarness()
, eventType_(ecore_event_type_new())
, handler_(NULL)
+ , wfits_()
{
return;
}
elm_run();
}
+
+
+void ElmTestHarness::geometryDone(QueryRequest* request, GeometryCallback callback)
+{
+ if (not request->done) {
+ steps_.push_front(boost::bind(&ElmTestHarness::geometryDone, boost::ref(*this), request, callback));
+ } else {
+ Geometry *geometry = static_cast<Geometry*>(request->data);
+ steps_.push_front(boost::bind(callback, *geometry));
+ delete request;
+ delete geometry;
+ }
+}
+
+void ElmTestHarness::getSurfaceGeometry(wl_surface* surface, GeometryCallback callback)
+{
+ QueryRequest* request = wfits_.makeGeometryRequest(surface);
+ geometryDone(request, callback);
+}
+
/*static*/
Eina_Bool ElmTestHarness::idleSetup(void* data)
{
#include <Elementary.h>
#include "common/harness.h"
#include "application.h"
+#include "wayland-fits.h"
class ElmTestHarness : public TestHarness
{
public:
+ typedef WaylandFits::Geometry Geometry;
+ typedef WaylandFits::QueryRequest QueryRequest;
+
+ typedef boost::function<void (Geometry)> GeometryCallback;
+
/**
* Construct the test harness.
**/
void run();
+ void getSurfaceGeometry(wl_surface*, GeometryCallback);
+
private:
static Eina_Bool idleSetup(void*);
static Eina_Bool doSetup(void*, int, void*);
static Eina_Bool idleTeardown(void*);
static Eina_Bool doTeardown(void*, int, void*);
+ void geometryDone(QueryRequest*, GeometryCallback);
+
int eventType_; /// custom event type
Ecore_Event_Handler* handler_;
+ WaylandFits wfits_;
};
#define WAYLAND_ELM_HARNESS_EGL_TEST_CASE(Harness, suite) \
WindowResizeTest()
: ElmTestHarness::ElmTestHarness()
, window_("WindowResizeTest", "Window Resize Test")
+ , sizes_()
+ , resizeDone_(false)
{
return;
}
{
window_.show();
- queueStep(boost::bind(&Window::setSize, boost::ref(window_), 400, 200));
- queueStep(boost::bind(&Window::checkSize, boost::ref(window_), 400, 200));
- queueStep(boost::bind(&Window::setSize, boost::ref(window_), 100, 120));
- queueStep(boost::bind(&Window::checkSize, boost::ref(window_), 100, 120));
+ sizes_.push_back(Size(-10, -10));
+ sizes_.push_back(Size(-1, 10));
+ sizes_.push_back(Size(10, -1));
+ sizes_.push_back(Size(0, 0));
+
+ for (int w(1); w <= 400; w += 89)
+ for (int h(3); h <= 400; h += 91)
+ sizes_.push_back(Size(w, h));
+
+ sizes_.push_back(Size(3000, 3000));
+
+ evas_object_event_callback_add(window_, EVAS_CALLBACK_RESIZE, &onResize, this);
+
+ nextResize();
+ }
+
+ static void onResize(void *data, Evas*, Evas_Object*, void*)
+ {
+ WindowResizeTest *test = static_cast<WindowResizeTest*>(data);
+ test->resizeDone_ = true;
+ }
+
+ void nextResize() {
+ resizeDone_ = false;
+ if (not sizes_.empty()) {
+ Size size(sizes_.front());
+ sizes_.pop_front();
+ queueStep(boost::bind(&Window::setSize, boost::ref(window_), size.first, size.second));
+ queueStep(boost::bind(&WindowResizeTest::checkResize, boost::ref(*this), size.first, size.second, 20));
+ }
+ }
+
+ void checkResize(int w, int h, unsigned tries)
+ {
+ if (not resizeDone_) {
+ ASSERT(tries != 0);
+ queueStep(boost::bind(&WindowResizeTest::checkResize, boost::ref(*this), w, h, --tries));
+ } else {
+ window_.checkSize(std::max(1, w), std::max(1, h));
+ checkServerSize(Geometry(), 20);
+ }
+ }
+
+ void checkServerSize(Geometry geometry, unsigned tries) {
+ bool sizeMatch(
+ window_.getWidth() == geometry.width
+ and window_.getHeight() == geometry.height);
+
+ if (not sizeMatch) {
+ ASSERT(tries != 0);
+ GeometryCallback cb = boost::bind(&WindowResizeTest::checkServerSize, boost::ref(*this), _1, --tries);
+ getSurfaceGeometry(elm_win_wl_window_get(window_)->surface, cb);
+ } else {
+ FAIL_UNLESS(sizeMatch);
+ nextResize();
+ }
}
private:
+ typedef std::pair<int, int> Size;
+ typedef std::deque<Size> Sizes;
+
Window window_;
+ Sizes sizes_;
+ bool resizeDone_;
};
class WindowMoveTest : public ElmTestHarness
--- /dev/null
+#include "common/test.h"
+#include "wayland-fits.h"
+
+WaylandFits::WaylandFits()
+ : wfits_input_(NULL)
+ , wfits_query_(NULL)
+{
+ ecore_wl_init(NULL);
+
+ Ecore_Wl_Global *global;
+ wl_registry *registry = ecore_wl_registry_get();
+ wl_list *globals = ecore_wl_globals_get();
+
+ ASSERT(registry != NULL);
+ ASSERT(globals != NULL);
+
+ wl_list_for_each(global, globals, link) {
+ if (std::string(global->interface) == "wfits_input") {
+ wfits_input_ = static_cast<wfits_input*>(
+ wl_registry_bind(
+ registry,
+ global->id,
+ &wfits_input_interface,
+ global->version));
+ } else if (std::string(global->interface) == "wfits_query") {
+ wfits_query_ = static_cast<wfits_query*>(
+ wl_registry_bind(
+ registry,
+ global->id,
+ &wfits_query_interface,
+ global->version));
+ }
+ }
+ ASSERT(wfits_input_ != NULL);
+ ASSERT(wfits_query_ != NULL);
+}
+
+/*virtual*/ WaylandFits::~WaylandFits()
+{
+ wfits_input_destroy(wfits_input_);
+ wfits_query_destroy(wfits_query_);
+ ecore_wl_shutdown();
+}
+
+WaylandFits::Geometry::Geometry()
+ : x(-1)
+ , y(-1)
+ , width(-1)
+ , height(-1)
+{
+ return;
+}
+
+WaylandFits::QueryRequest::QueryRequest()
+ : done(false)
+ , data(NULL)
+{
+ return;
+}
+
+static void
+query_result_surface_geometry(void *data, wfits_query_result *result,
+ wl_fixed_t x, wl_fixed_t y, int32_t w, int32_t h)
+{
+ WaylandFits::QueryRequest* qr = static_cast<WaylandFits::QueryRequest*>(data);
+ WaylandFits::Geometry* g = static_cast<WaylandFits::Geometry*>(qr->data);
+ g->x = wl_fixed_to_int(x);
+ g->y = wl_fixed_to_int(y);
+ g->width = w;
+ g->height = h;
+ qr->done = true;
+
+ wfits_query_result_destroy(result);
+}
+
+WaylandFits::QueryRequest* WaylandFits::makeGeometryRequest(wl_surface* surface) const
+{
+ QueryRequest* request(new QueryRequest);
+ request->data = new Geometry;
+
+ static const wfits_query_result_listener listener = {
+ query_result_surface_geometry,
+ };
+
+ wfits_query_result* result = wfits_query_surface_geometry(wfits_query_, surface);
+ wfits_query_result_add_listener(result, &listener, request);
+
+ return request;
+}
--- /dev/null
+#ifndef __WAYLAND_EFL_WAYLAND_FITS_H__
+#define __WAYLAND_EFL_WAYLAND_FITS_H__
+
+#include <Ecore.h>
+#include <Ecore_Wayland.h>
+#include "extensions/protocol/wayland-fits-client-protocol.h"
+
+class WaylandFits
+{
+public:
+ WaylandFits();
+
+ virtual ~WaylandFits();
+
+ class Geometry
+ {
+ public:
+ Geometry();
+ int32_t x;
+ int32_t y;
+ int32_t width;
+ int32_t height;
+ };
+
+ class QueryRequest
+ {
+ public:
+ QueryRequest();
+ bool done;
+ void* data;
+ };
+
+ QueryRequest* makeGeometryRequest(wl_surface*) const;
+private:
+ wfits_input* wfits_input_;
+ wfits_query* wfits_query_;
+};
+
+#endif