/* virtual */
Application::~Application()
{
- // FIXME: hmmm... doesn't behave nicely across muliple boost test instances
elm_shutdown();
}
+/* static */
void Application::setEngine(const Engine& engine)
{
std::string strEngine;
BOOST_ASSERT(strEngine == std::string(elm_config_engine_get()));
}
+/* static */
void Application::mainLoop()
{
elm_run();
}
+/* static */
void Application::yield()
{
ecore_main_loop_iterate();
- sleep(1);
+ usleep(0.1 * 1e6);
}
+/* static */
void Application::exit()
{
elm_exit();
}
+
+// only one instance per test binary
+BOOST_GLOBAL_FIXTURE(Application);
#ifndef __WAYLAND_EFL_APPLICATION_H__
#define __WAYLAND_EFL_APPLICATION_H__
+namespace boost {
+ namespace unit_test {
+ namespace ut_detail {
+ template<class F> class global_fixture_impl;
+ }
+ }
+}
+
class Application
{
public:
ENGINE_EGL
};
- Application();
virtual ~Application();
- void setEngine(const Engine&);
- void mainLoop();
- void yield();
- void exit();
+ static void setEngine(const Engine&);
+ static void mainLoop();
+ static void yield();
+ static void exit();
+
+private:
+ friend class ::boost::unit_test::ut_detail::global_fixture_impl<Application>;
+ Application();
};
#endif
#include "window.h"
#include "../test.h"
-//TODO: The application should be a singleton
-//TODO: We could probably iterate over each engine in a global fixture.
#define TEST_ALL_ENGINES(name) \
\
-void name##_test_run(Application&); \
+void name##_test_run(); \
\
BOOST_AUTO_TEST_CASE(name##_shm_engine) \
{ \
- Application app; \
- app.setEngine(Application::ENGINE_SHM); \
- name##_test_run(app); \
+ Application::setEngine(Application::ENGINE_SHM); \
+ name##_test_run(); \
} \
\
BOOST_AUTO_TEST_CASE(name##_egl_engine) \
{ \
- Application app; \
- app.setEngine(Application::ENGINE_EGL); \
- name##_test_run(app); \
+ Application::setEngine(Application::ENGINE_EGL); \
+ name##_test_run(); \
} \
\
-void name##_test_run(Application& app)
+void name##_test_run()
TEST_ALL_ENGINES(efl_window_resize_move)
win.setSize(400, 200);
win.setPosition(10, 20);
- app.yield();
+ Application::yield();
BOOST_CHECK_EQUAL(win.getWidth(), 400);
BOOST_CHECK_EQUAL(win.getHeight(), 200);
win.setSize(100, 120);
win.setPosition(15, 25);
- app.yield();
+ Application::yield();
BOOST_CHECK_EQUAL(win.getWidth(), 100);
BOOST_CHECK_EQUAL(win.getHeight(), 120);
btn.setSize(120, 30);
btn.setPosition(60, 15);
- app.yield();
+ Application::yield();
BOOST_CHECK_EQUAL(btn.getWidth(), 120);
BOOST_CHECK_EQUAL(btn.getHeight(), 30);
btn.setSize(75, 75);
btn.setPosition(10, 10);
- app.yield();
+ Application::yield();
BOOST_CHECK_EQUAL(btn.getWidth(), 75);
BOOST_CHECK_EQUAL(btn.getHeight(), 75);