EFL: Test generator macros
authorJoe Konno <joe.konno@intel.com>
Fri, 20 Jul 2012 01:08:12 +0000 (18:08 -0700)
committerJoe Konno <joe.konno@intel.com>
Fri, 20 Jul 2012 01:32:54 +0000 (18:32 -0700)
These are the beginnings of "boilerplate" test generating macros. For each
control, adding a few macros can yield common evas-level tests.

Easier to maintain centrally, and will improve velocity of test writing.

For reference, actionslider and button tests were aggressively refactored to
take advantage of these conveniences.

XXX: Getting bitten by an arcane preprocessor issue, otherwise I would
uncomment the EFL_BASIC_TESTS macro. It would appear to be a whitespace issue,
but tabling for now.

Signed-off-by: Joe Konno <joe.konno@intel.com>
src/efl/evasobject.cpp
src/efl/evasobject.h
src/efl/templates.h [new file with mode: 0644]
src/efl/test_actionslider.cpp
src/efl/test_button.cpp

index 4d35d6d..2016abf 100644 (file)
@@ -48,6 +48,11 @@ void EvasObject::show()
        evas_object_show(*this);
 }
 
+void EvasObject::hide()
+{
+       evas_object_hide(*this);
+}
+
 const int EvasObject::getX()
 {
        int x;
@@ -99,3 +104,8 @@ void EvasObject::checkVisible(const Eina_Bool isVisible)
 {
        BOOST_CHECK_EQUAL(this->isVisible(), isVisible);
 }
+
+void EvasObject::checkHidden(const Eina_Bool isHidden)
+{
+       BOOST_CHECK_EQUAL(this->isVisible(), (isHidden == EINA_TRUE ? EINA_FALSE : EINA_TRUE));
+}
index df9e003..b80a8e8 100644 (file)
@@ -11,6 +11,7 @@ public:
        void setSize(int w, int h);
        void setPosition(int x, int y);
        void show();
+       void hide();
 
        const int getWidth();
        const int getHeight();
@@ -25,13 +26,14 @@ public:
        void checkSize(const int width, const int height);
        void checkPosition(const int x, const int y);
        void checkVisible(const Eina_Bool isVisible);
+       void checkHidden(const Eina_Bool isHidden);
 
 private:
        Evas_Object*    obj_;
 
 };
 
-#define SET_CHECK_SIZE(obj, w, h)\
+#define EFL_CHECK_SIZE(obj, w, h)\
                queueCallback( \
                        ModifyCheckCallback( \
                                boost::bind(&EvasObject::setSize, boost::ref(obj), w, h), \
@@ -39,7 +41,7 @@ private:
                        ) \
                )
 
-#define SET_CHECK_POSITION(obj, x, y) \
+#define EFL_CHECK_POSITION(obj, x, y) \
                queueCallback( \
                        ModifyCheckCallback( \
                                boost::bind(&EvasObject::setPosition, boost::ref(obj), x, y), \
@@ -47,7 +49,7 @@ private:
                        ) \
                )
 
-#define SET_CHECK_SHOW(obj) \
+#define EFL_CHECK_SHOW(obj) \
                queueCallback( \
                        ModifyCheckCallback( \
                                boost::bind(&EvasObject::show, boost::ref(obj)), \
@@ -55,4 +57,12 @@ private:
                        ) \
                )
 
+#define EFL_CHECK_HIDE(obj) \
+               queueCallback( \
+                       ModifyCheckCallback( \
+                               boost::bind(&EvasObject::hide, boost::ref(obj)), \
+                               boost::bind(&EvasObject::checkHidden, boost::ref(obj), EINA_TRUE) \
+                       ) \
+               )
+
 #endif
diff --git a/src/efl/templates.h b/src/efl/templates.h
new file mode 100644 (file)
index 0000000..c0a6531
--- /dev/null
@@ -0,0 +1,133 @@
+#include <Elementary.h>
+#include <boost/bind.hpp>
+
+#include "evasobject.h"
+#include "window.h"
+#include "elmtestharness.h"
+#include "application.h"
+
+#ifndef __WAYLAND_EFL_TEMPLATES_H__
+#define __WAYLAND_EFL_TEMPLATES_H__
+
+
+
+#define EFL_RESIZE_TEST(_suite, _obj, _w1, _h1, _w2, _h2) \
+class _suite ## ResizeTest : public ElmTestHarness \
+{ \
+public: \
+       \
+       _suite ## ResizeTest() \
+               : ElmTestHarness::ElmTestHarness() \
+               , window_(#_suite "ResizeTest", #_suite "Resize Test") \
+               , control_(elm_ ## _obj ## _add(window_)) \
+       { \
+               return; \
+       } \
+       \
+       void setup() \
+       { \
+               window_.show(); \
+               control_.show(); \
+               \
+               EFL_CHECK_SIZE(control_, _w1, _h1); \
+               EFL_CHECK_SIZE(control_, _w2, _h2); \
+       } \
+       \
+private: \
+       Window          window_; \
+       EvasObject      control_; \
+}; \
+BOOST_AUTO_TEST_SUITE(EFL) \
+       BOOST_AUTO_TEST_SUITE(_suite) \
+               WAYLAND_ELM_HARNESS_TEST_CASE(_suite ## ResizeTest) \
+       BOOST_AUTO_TEST_SUITE_END() \
+BOOST_AUTO_TEST_SUITE_END() \
+
+
+
+#define EFL_POSITION_TEST(_suite, _obj, _x1, _y1, _x2, _y2) \
+class _suite ## PositionTest : public ElmTestHarness \
+{ \
+public: \
+       \
+       _suite ## PositionTest() \
+               : ElmTestHarness::ElmTestHarness() \
+               , window_(#_suite "PositionTest", #_suite "Position Test") \
+               , control_(elm_ ## _obj ## _add(window_)) \
+       { \
+               return; \
+       } \
+       \
+       void setup() \
+       { \
+               window_.show(); \
+               control_.show(); \
+               \
+               EFL_CHECK_POSITION(control_, _x1, _x1); \
+               EFL_CHECK_POSITION(control_, _x2, _x2); \
+       } \
+       \
+private: \
+       Window          window_; \
+       EvasObject      control_; \
+}; \
+BOOST_AUTO_TEST_SUITE(EFL) \
+       BOOST_AUTO_TEST_SUITE(_suite) \
+               WAYLAND_ELM_HARNESS_TEST_CASE(_suite ## PositionTest) \
+       BOOST_AUTO_TEST_SUITE_END() \
+BOOST_AUTO_TEST_SUITE_END() \
+
+
+
+#define EFL_VISIBILITY_TEST(_suite, _obj) \
+class _suite ## VisibilityTest : public ElmTestHarness \
+{ \
+public: \
+       \
+       _suite ## VisibilityTest() \
+               : ElmTestHarness::ElmTestHarness() \
+               , window_(#_suite "VisibilityTest", #_suite "Visibility Test") \
+               , control_(elm_ ## _obj ## _add(window_)) \
+       { \
+               return; \
+       } \
+       \
+       void setup() \
+       { \
+               window_.show(); \
+               \
+               EFL_CHECK_SHOW(control_); \
+               EFL_CHECK_HIDE(control_); \
+       } \
+       \
+private: \
+       Window          window_; \
+       EvasObject      control_; \
+}; \
+BOOST_AUTO_TEST_SUITE(EFL) \
+       BOOST_AUTO_TEST_SUITE(_suite) \
+               WAYLAND_ELM_HARNESS_TEST_CASE(_suite ## VisibilityTest) \
+       BOOST_AUTO_TEST_SUITE_END() \
+BOOST_AUTO_TEST_SUITE_END() \
+
+
+/* XXX: For now, keep it regular-- when BASIC_TESTS is uncommented and working,
+ * XXX: makes it easier to replace across files
+ */
+// Basic suite START
+//EFL_RESIZE_TEST(suite, obj, 300, 200, 200, 100)
+//EFL_POSITION_TEST(suite, obj, 100, 50, 150, 100)
+//EFL_VISIBILITY_TEST(suite, obj)
+// Basic suite END
+
+
+/* XXX
+#define EFL_BASIC_TESTS(suite, obj) \
+       EFL_RESIZE_TEST(suite, obj, 300, 200, 200, 100) \
+       EFL_POSITION_TEST(suite, obj, 100, 50, 150, 100) \
+       EFL_VISIBILITY_TEST(suite, obj) \
+*/
+
+
+#endif
+
index 2fd0bf8..81353f2 100644 (file)
@@ -1,21 +1,23 @@
-#include <Elementary.h>
-#include <boost/bind.hpp>
-
 #include <vector>
 
-#include "window.h"
-#include "evasobject.h"
-#include "elmtestharness.h"
+#include "templates.h"
 
 using std::vector;
 
-class ActionsliderPosTest : public ElmTestHarness
+
+// Basic suite START
+EFL_RESIZE_TEST(Actionslider, actionslider, 300, 200, 200, 100)
+EFL_POSITION_TEST(Actionslider, actionslider, 100, 50, 150, 100)
+EFL_VISIBILITY_TEST(Actionslider, actionslider)
+// Basic suite END
+
+class ActionsliderIndicatorTest : public ElmTestHarness
 {
 public:
 
-       ActionsliderPosTest()
+       ActionsliderIndicatorTest()
                : ElmTestHarness::ElmTestHarness()
-               , window_("ActionsliderPosTest", "Actionslider Position Test")
+               , window_("ActionsliderIndicatorTest", "Actionslider Position Test")
                , control_(elm_actionslider_add(window_))
        {
                positions_.push_back(ELM_ACTIONSLIDER_LEFT);
@@ -23,14 +25,18 @@ public:
                positions_.push_back(ELM_ACTIONSLIDER_LEFT);
                positions_.push_back(ELM_ACTIONSLIDER_RIGHT);
                positions_.push_back(ELM_ACTIONSLIDER_CENTER);
+               positions_.push_back(ELM_ACTIONSLIDER_RIGHT);
+               positions_.push_back(ELM_ACTIONSLIDER_LEFT);
+               positions_.push_back(ELM_ACTIONSLIDER_RIGHT);
+               positions_.push_back(ELM_ACTIONSLIDER_CENTER);
 
                return;
        }
 
        void setup()
        {
-               SET_CHECK_SHOW(window_);
-               SET_CHECK_SHOW(control_);
+               window_.show();
+               control_.show();
 
                control_.setSize(200, 100);
                control_.setPosition(50, 10);
@@ -41,7 +47,7 @@ public:
                        queueCallback(
                                ModifyCheckCallback(
                                        boost::bind(elm_actionslider_indicator_pos_set, boost::ref(control_), *it),
-                                       boost::bind(&ActionsliderPosTest::checkPos, boost::ref(*this), *it)
+                                       boost::bind(&ActionsliderIndicatorTest::checkPos, boost::ref(*this), *it)
                                )
                        );
                }
@@ -62,7 +68,7 @@ BOOST_AUTO_TEST_SUITE(EFL)
 
        BOOST_AUTO_TEST_SUITE(ActionSlider)
        
-               WAYLAND_ELM_HARNESS_TEST_CASE(ActionsliderPosTest)
+               WAYLAND_ELM_HARNESS_TEST_CASE(ActionsliderIndicatorTest)
        
        BOOST_AUTO_TEST_SUITE_END()
 
index 06e1811..f0dc1fd 100644 (file)
@@ -1,68 +1,10 @@
-#include <Elementary.h>
-#include <boost/bind.hpp>
+#include "templates.h"
 
-#include "window.h"
-#include "evasobject.h"
-#include "elmtestharness.h"
+// Basic suite START
+EFL_RESIZE_TEST(Button, button, 300, 200, 200, 100)
 
-class ButtonResizeTest : public ElmTestHarness
-{
-public:
+EFL_POSITION_TEST(Button, button, 100, 50, 150, 100)
 
-       ButtonResizeTest()
-               : ElmTestHarness::ElmTestHarness()
-               , window_("ButtonResizeTest", "Button Resize Test")
-               , button_(elm_button_add(window_))
-       {
-               return;
-       }
+EFL_VISIBILITY_TEST(Button, button)
+// Basic suite END
 
-       void setup()
-       {
-               window_.show();
-               button_.show();
-
-               SET_CHECK_SIZE(button_, 75, 75);
-               SET_CHECK_SIZE(button_, 120, 30);
-       }
-
-private:
-       Window          window_;
-       EvasObject      button_;
-};
-
-class ButtonMoveTest : public ElmTestHarness
-{
-public:
-       ButtonMoveTest()
-               : ElmTestHarness::ElmTestHarness()
-               , window_("ButtonMoveTest", "Button Move Test")
-               , button_(elm_button_add(window_))
-       {
-               return;
-       }
-
-       void setup()
-       {
-               window_.show();
-               button_.show();
-
-               SET_CHECK_POSITION(button_, 60, 15);
-               SET_CHECK_POSITION(button_, 10, 10);
-       }
-
-private:
-       Window          window_;
-       EvasObject      button_;
-};
-
-BOOST_AUTO_TEST_SUITE(EFL)
-
-       BOOST_AUTO_TEST_SUITE(Button)
-       
-               WAYLAND_ELM_HARNESS_TEST_CASE(ButtonResizeTest)
-               WAYLAND_ELM_HARNESS_TEST_CASE(ButtonMoveTest)
-       
-       BOOST_AUTO_TEST_SUITE_END()
-
-BOOST_AUTO_TEST_SUITE_END()