add some efl tests
authorU. Artie Eoff <ullysses.a.eoff@intel.com>
Wed, 30 May 2012 16:51:40 +0000 (09:51 -0700)
committerU. Artie Eoff <ullysses.a.eoff@intel.com>
Wed, 30 May 2012 16:51:40 +0000 (09:51 -0700)
Signed-off-by: U. Artie Eoff <ullysses.a.eoff@intel.com>
12 files changed:
Makefile.am
configure.ac
src/Makefile.am
src/efl/Makefile.am [new file with mode: 0644]
src/efl/application.cpp [new file with mode: 0644]
src/efl/application.h [new file with mode: 0644]
src/efl/test_engine_set.cpp [new file with mode: 0644]
src/efl/test_window_size.cpp [new file with mode: 0644]
src/efl/window.cpp [new file with mode: 0644]
src/efl/window.h [new file with mode: 0644]
src/test-harness
src/testmain.cpp

index 3a7ce7e..86f16e2 100644 (file)
@@ -1,3 +1,3 @@
-SUBDIRS = src
+SUBDIRS = src src/efl
 
 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
index da7ab8c..d894d96 100644 (file)
@@ -1,7 +1,7 @@
 AC_PREREQ([2.64])
 
 AC_INIT([wayland-test],
-        [0.89],
+        [0.95],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=wayland],
         [wayland-test],
         [http://wayland.freedesktop.org/])
@@ -21,7 +21,10 @@ LT_INIT
 
 PKG_CHECK_MODULES(CAIRO, [cairo >= 1.10.0])
 PKG_CHECK_MODULES(WAYLAND, [wayland-client wayland-egl])
+PKG_CHECK_MODULES(EFL, [elementary ecore evas], [have_efl=yes], [have_efl=no])
+AM_CONDITIONAL(BUILD_EFL_TESTS, test x$have_efl = xyes)
 
 AC_CONFIG_FILES([Makefile
-                src/Makefile])
+                src/Makefile
+                src/efl/Makefile])
 AC_OUTPUT
index 82b9cad..a05b9a4 100644 (file)
@@ -2,7 +2,11 @@
 TESTS = wayland-test
 TESTS_ENVIRONMENT = $(SHELL) test-harness
 
-CXXFLAGS = -std=gnu++0x $(CAIRO_CFLAGS) $(WAYLAND_CFLAGS)
+CXXFLAGS =                     \
+       -std=gnu++0x            \
+       $(CAIRO_CFLAGS)         \
+       $(WAYLAND_CFLAGS)
+
 LDFLAGS =                      \
        $(CAIRO_LIBS)           \
        $(WAYLAND_LIBS)         \
@@ -13,3 +17,5 @@ bin_PROGRAMS = $(TESTS)
 wayland_test_SOURCES =                 \
        test_bind_interface.cpp         \
        testmain.cpp
+
+wayland_test_CXXFLAGS = -DTESTLOG='"@abs_builddir@/wayland-test.log"'
diff --git a/src/efl/Makefile.am b/src/efl/Makefile.am
new file mode 100644 (file)
index 0000000..ae6eda4
--- /dev/null
@@ -0,0 +1,30 @@
+
+if BUILD_EFL_TESTS
+
+TESTS = wayland-efl-test
+TESTS_ENVIRONMENT = $(SHELL) ../test-harness
+
+CXXFLAGS +=                    \
+       -std=gnu++0x            \
+       $(CAIRO_CFLAGS)         \
+       $(WAYLAND_CFLAGS)       \
+       @EFL_CFLAGS@
+
+LDFLAGS +=                     \
+       $(CAIRO_LIBS)           \
+       $(WAYLAND_LIBS)         \
+       @EFL_LIBS@              \
+       -lboost_unit_test_framework
+
+bin_PROGRAMS = $(TESTS)
+
+wayland_efl_test_SOURCES =     \
+       application.cpp         \
+       window.cpp              \
+       test_window_size.cpp    \
+       test_engine_set.cpp     \
+       ../testmain.cpp
+
+wayland_efl_test_CXXFLAGS = -DTESTLOG='"@abs_builddir@/wayland-efl-test.log"'
+
+endif
diff --git a/src/efl/application.cpp b/src/efl/application.cpp
new file mode 100644 (file)
index 0000000..9f49306
--- /dev/null
@@ -0,0 +1,54 @@
+#include <Elementary.h>
+
+#include "../test.h"
+#include "application.h"
+
+Application::Application()
+{
+       elm_init(
+               boost::unit_test::framework::master_test_suite().argc,
+               boost::unit_test::framework::master_test_suite().argv
+       );
+       setEngine(ENGINE_SHM);
+}
+
+/* virtual */
+Application::~Application()
+{
+       // FIXME: hmmm... doesn't behave nicely across muliple boost test instances
+       elm_shutdown();
+}
+
+void Application::setEngine(const Engine& engine)
+{
+       std::string strEngine = "software_x11";
+       switch (engine) {
+               case ENGINE_EGL:
+                       strEngine = "wayland_egl";
+                       break;
+               case ENGINE_SHM:
+               default:
+                       strEngine = "wayland_shm";
+       }
+
+       elm_config_preferred_engine_set(strEngine.c_str()); // override's ELM_ENGINE user environment setting
+       elm_config_engine_set(strEngine.c_str());
+       BOOST_ASSERT(strEngine == std::string(elm_config_preferred_engine_get()));
+       BOOST_ASSERT(strEngine == std::string(elm_config_engine_get()));
+}
+
+void Application::mainLoop()
+{
+       elm_run();
+}
+
+void Application::yield()
+{
+       ecore_main_loop_iterate();
+       sleep(1);
+}
+
+void Application::exit()
+{
+       elm_exit();
+}
diff --git a/src/efl/application.h b/src/efl/application.h
new file mode 100644 (file)
index 0000000..3965829
--- /dev/null
@@ -0,0 +1,21 @@
+#ifndef __WAYLAND_EFL_APPLICATION_H__
+#define __WAYLAND_EFL_APPLICATION_H__
+
+class Application
+{
+public:
+       enum Engine {
+               ENGINE_SHM,
+               ENGINE_EGL
+       };
+
+       Application();
+       virtual ~Application();
+
+       void setEngine(const Engine&);
+       void mainLoop();
+       void yield();
+       void exit();
+};
+
+#endif
diff --git a/src/efl/test_engine_set.cpp b/src/efl/test_engine_set.cpp
new file mode 100644 (file)
index 0000000..1ce844b
--- /dev/null
@@ -0,0 +1,22 @@
+#include <Elementary.h>
+#include "../test.h"
+
+BOOST_AUTO_TEST_CASE(elm_engine_set_wayland_shm)
+{
+       elm_init(
+               boost::unit_test::framework::master_test_suite().argc,
+               boost::unit_test::framework::master_test_suite().argv
+       );
+       elm_config_engine_set("wayland_shm");
+       BOOST_CHECK_EQUAL("wayland_shm", elm_config_engine_get());
+}
+
+BOOST_AUTO_TEST_CASE(elm_engine_set_wayland_egl)
+{
+       elm_init(
+               boost::unit_test::framework::master_test_suite().argc,
+               boost::unit_test::framework::master_test_suite().argv
+       );
+       elm_config_engine_set("wayland_egl");
+       BOOST_CHECK_EQUAL("wayland_egl", elm_config_engine_get());
+}
diff --git a/src/efl/test_window_size.cpp b/src/efl/test_window_size.cpp
new file mode 100644 (file)
index 0000000..a32f019
--- /dev/null
@@ -0,0 +1,37 @@
+#include <Elementary.h>
+#include <Ecore.h>
+
+#include "application.h"
+#include "window.h"
+#include "../test.h"
+
+BOOST_AUTO_TEST_CASE(efl_window_size_shm)
+{
+       Application app;
+       app.setEngine(Application::ENGINE_SHM);
+       Window win("shm-size", "SHM Size");
+       win.setSize(400, 400);
+       win.setPosition(0, 0);
+       win.show();
+
+       app.yield();
+
+       BOOST_CHECK_EQUAL(win.getWidth(), 400);
+       BOOST_CHECK_EQUAL(win.getHeight(), 400);
+}
+
+BOOST_AUTO_TEST_CASE(efl_window_size_egl)
+{
+       Application app;
+       app.setEngine(Application::ENGINE_EGL);
+       Window win("egl-size", "EGL Size");
+       win.setSize(400, 400);
+       win.setPosition(0, 0);
+       win.show();
+
+       app.yield();
+
+       BOOST_CHECK_EQUAL(win.getWidth(), 400);
+       BOOST_CHECK_EQUAL(win.getHeight(), 400);
+}
+
diff --git a/src/efl/window.cpp b/src/efl/window.cpp
new file mode 100644 (file)
index 0000000..b5ef373
--- /dev/null
@@ -0,0 +1,43 @@
+#include <Elementary.h>
+
+#include "window.h"
+
+Window::Window(const std::string& name, const std::string& title)
+{
+       win_ = elm_win_util_standard_add(name.c_str(), title.c_str());
+}
+
+/* virtual */
+Window::~Window()
+{
+       win_ = NULL;
+}
+
+void Window::setSize(int w, int h)
+{
+       evas_object_resize(win_, w, h);
+}
+
+void Window::setPosition(int x, int y)
+{
+       evas_object_move(win_, x, y);
+}
+
+void Window::show()
+{
+       evas_object_show(win_);
+}
+
+int Window::getWidth()
+{
+       int x, y, w, h;
+       evas_object_geometry_get(win_, &x, &y, &w, &h);
+       return w;
+}
+
+int Window::getHeight()
+{
+       int x, y, w, h;
+       evas_object_geometry_get(win_, &x, &y, &w, &h);
+       return h;
+}
diff --git a/src/efl/window.h b/src/efl/window.h
new file mode 100644 (file)
index 0000000..b2beb98
--- /dev/null
@@ -0,0 +1,24 @@
+#ifndef __WAYLAND_EFL_WINDOW_H__
+#define __WAYLAND_EFL_WINDOW_H__
+
+#include <string>
+
+// typename Evas_Object;
+
+class Window
+{
+public:
+       Window(const std::string&, const std::string&);
+       virtual ~Window();
+
+       void setSize(int w, int h);
+       void setPosition(int x, int y);
+       void show();
+
+       int getWidth();
+       int getHeight();
+private:
+       Evas_Object*    win_;
+};
+
+#endif
index f7096ea..96c3086 100644 (file)
@@ -1,21 +1,11 @@
 #!/bin/sh
 
-RESULT_LOG=${1}.xml
-
-rm -rf ${RESULT_LOG}
-
 $WLD/install/bin/weston & sleep 2 # allow time for weston to initialize
 
-${1} --log_level=all --log_format=xml --report_level=detailed > ${RESULT_LOG}
+${1} --log_level=all --log_format=xml --report_level=detailed
 
 RESULT=$?
 
 kill -15 %1
 
-if [ -f ${RESULT_LOG} ]
-then
-       xmllint ${RESULT_LOG} --format -o ${RESULT_LOG}
-       echo "See full results in `readlink -f ${RESULT_LOG}`"
-fi
-
 exit ${RESULT}
\ No newline at end of file
index 4b59246..6afdce6 100644 (file)
@@ -3,4 +3,37 @@
 #define TESTING_PROGRAM
 #define BOOST_AUTO_TEST_MAIN
 
+#include <fstream>
 #include "test.h"
+
+
+/**
+ *
+ * See http://www.boost.org/doc/libs/1_47_0/libs/test/doc/html/index.html
+ *
+ */
+
+struct GlobalFixture
+{
+       GlobalFixture()
+       {
+               std::string log(TESTLOG);
+               if (getenv("TESTS_LOGFILE"))
+               {
+                       log = std::string(getenv("TESTS_LOGFILE"));
+               }
+               testLog = new std::ofstream(log);
+               boost::unit_test::unit_test_log.set_stream( *testLog );
+       }
+
+       ~GlobalFixture()
+       {
+               return;
+       }
+
+       static std::ofstream* testLog;
+};
+
+std::ofstream* GlobalFixture::testLog;
+
+BOOST_GLOBAL_FIXTURE( GlobalFixture );
\ No newline at end of file