#ifndef _WAYLAND_TEST_TEST_H_
#define _WAYLAND_TEST_TEST_H_
+#include <iostream>
#include <boost/foreach.hpp>
#include <map>
#include <vector>
#define TEST(name, suite) \
class class_ ## name { \
public: \
- START_TEST(name) \
+ START_TEST(ck_ ## name) \
{ \
run(); \
} \
static void run(); \
static bool registered; \
}; \
- bool class_ ## name::registered = TheGlobalTestSuite::instance().registerTest(class_ ## name::name, suite "/" # name); \
+ bool class_ ## name::registered = TheGlobalTestSuite::instance().registerTest(class_ ## name::ck_ ## name, suite "/" # name); \
void class_ ## name::run()
#endif
harness.cpp \
test_bind_interface.cpp \
test_cursor.cpp \
- test_display_data.cpp
+ test_display_data.cpp \
+ test_shm_data.cpp
libwfits_core_la_LIBADD = \
$(top_builddir)/src/common/libwfits-common.la \
Tests tests_;
};
-#define WFITS_CORE_HARNESS_TEST_CASE(Harness, suite) \
+#define WFITS_CORE_HARNESS_TEST_CASE(HarnessClass, suite) \
\
-TEST(Harness, "Core/" suite) \
+TEST(HarnessClass, "Core/" suite) \
{ \
- ::Harness().run(); \
+ HarnessClass().run(); \
}
#endif
#include "harness.h"
-class SetDataTest : public CoreTestHarness
+class DisplayDataTest : public CoreTestHarness
{
public:
void setup()
{
queueTest(
- boost::bind(&SetDataTest::test, boost::ref(*this))
+ boost::bind(&DisplayDataTest::test, boost::ref(*this))
);
}
d = static_cast<std::string*>(wl_display_get_user_data(*this));
FAIL_UNLESS_EQUAL(d, &p);
FAIL_UNLESS_EQUAL(*d, p);
- std::cout << "SANITY" << std::endl;
}
};
-WFITS_CORE_HARNESS_TEST_CASE(SetDataTest, "Display");
\ No newline at end of file
+WFITS_CORE_HARNESS_TEST_CASE(DisplayDataTest, "Display");
\ No newline at end of file
--- /dev/null
+#include "harness.h"
+
+class ShmDataTest : public CoreTestHarness
+{
+public:
+ void handleGlobal(uint32_t id, const std::string& iface, uint32_t version)
+ {
+ if (iface == "wl_shm")
+ {
+ shm_ = static_cast<wl_shm*>(wl_display_bind(*this, id, &wl_shm_interface));
+ FAIL_IF_EQUAL(shm_, NULL);
+ }
+ }
+
+ void setup()
+ {
+ queueTest(
+ boost::bind(&ShmDataTest::test, boost::ref(*this))
+ );
+ }
+
+ void test()
+ {
+ int a = random();
+ int *r;
+ for (unsigned i(0); i < 1000; ++i)
+ {
+ wl_shm_set_user_data(shm_, &a);
+ r = static_cast<int*>(wl_shm_get_user_data(shm_));
+ FAIL_UNLESS_EQUAL(r, &a);
+ FAIL_UNLESS_EQUAL(*r, a);
+ a = random();
+ }
+
+ std::string *d, p("This is my data");
+ wl_shm_set_user_data(shm_, &p);
+ d = static_cast<std::string*>(wl_shm_get_user_data(shm_));
+ FAIL_UNLESS_EQUAL(d, &p);
+ FAIL_UNLESS_EQUAL(*d, p);
+ }
+private:
+ wl_shm* shm_;
+};
+
+WFITS_CORE_HARNESS_TEST_CASE(ShmDataTest, "Shm");
\ No newline at end of file