From: Joe Konno Date: Tue, 24 Jul 2012 00:37:33 +0000 (-0700) Subject: EFL: Aggressive refactor with (true) templates X-Git-Tag: upstream/0.2.1~274 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f453cae365ec30825f40b5b0012abe983f4cf82b;p=test%2Fgeneric%2Fwayland-fits.git EFL: Aggressive refactor with (true) templates Signed-off-by: Joe Konno --- diff --git a/src/efl/elmtestharness.h b/src/efl/elmtestharness.h index 087055a..b854be4 100644 --- a/src/efl/elmtestharness.h +++ b/src/efl/elmtestharness.h @@ -4,6 +4,7 @@ #include #include +#include #include "application.h" class ElmTestHarness @@ -76,37 +77,5 @@ BOOST_AUTO_TEST_CASE(Harness##_shm_engine) \ // Harness().run(); \ //} \ -#define EFL_CHECK_SIZE(obj, w, h)\ - queueCallback( \ - ModifyCheckCallback( \ - boost::bind(&EvasObject::setSize, boost::ref(obj), w, h), \ - boost::bind(&EvasObject::checkSize, boost::ref(obj), w, h) \ - ) \ - ) - -#define EFL_CHECK_POSITION(obj, x, y) \ - queueCallback( \ - ModifyCheckCallback( \ - boost::bind(&EvasObject::setPosition, boost::ref(obj), x, y), \ - boost::bind(&EvasObject::checkPosition, boost::ref(obj), x, y) \ - ) \ - ) - -#define EFL_CHECK_SHOW(obj) \ - queueCallback( \ - ModifyCheckCallback( \ - boost::bind(&EvasObject::show, boost::ref(obj)), \ - boost::bind(&EvasObject::checkVisible, boost::ref(obj), EINA_TRUE) \ - ) \ - ) - -#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/macros.h b/src/efl/macros.h deleted file mode 100644 index 7f7905b..0000000 --- a/src/efl/macros.h +++ /dev/null @@ -1,134 +0,0 @@ -#ifndef __WAYLAND_EFL_TEMPLATES_H__ -#define __WAYLAND_EFL_TEMPLATES_H__ - -#include -#include - -#include "evasobject.h" -#include "window.h" -#include "elmtestharness.h" -#include "application.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 - diff --git a/src/efl/templates.h b/src/efl/templates.h new file mode 100644 index 0000000..869cafa --- /dev/null +++ b/src/efl/templates.h @@ -0,0 +1,233 @@ +#ifndef __WAYLAND_EFL_TEMPLATES_H__ +#define __WAYLAND_EFL_TEMPLATES_H__ + +#include +#include +#include + +#include + +#include "elmtestharness.h" +#include "evasobject.h" +#include "window.h" + +template +class ResizeObjectTest : public ElmTestHarness +{ + BOOST_STATIC_ASSERT( (boost::is_base_of::value) ); + +public: + ResizeObjectTest() + : ElmTestHarness::ElmTestHarness() + , window_("ResizeObjectTest", "Resize Test") + , object_(window_) + { + width_.push_back(300); + width_.push_back(200); + width_.push_back(101); + + height_.push_back(200); + height_.push_back(100); + height_.push_back(51); + return; + } + + void setup() + { + std::vector::iterator width_it, height_it; + for (width_it = width_.begin(); width_it != width_.end(); width_it++) + for (height_it = height_.begin(); height_it != height_.end(); height_it++) + { + queueCallback( + ModifyCheckCallback( + boost::bind(&T::setSize, boost::ref(object_), *width_it, *height_it), + boost::bind(&T::checkSize, boost::ref(object_), *width_it, *height_it) + ) + ); + } + } + +private: + Window window_; + T object_; + std::vector width_, height_; +}; + +template +class PositionObjectTest : public ElmTestHarness +{ + BOOST_STATIC_ASSERT( (boost::is_base_of::value) ); + +public: + PositionObjectTest() + : ElmTestHarness::ElmTestHarness() + , window_("PositionObjectTest", "Position Test") + , object_(window_) + { + x_.push_back(50); + x_.push_back(100); + x_.push_back(151); + + y_.push_back(10); + y_.push_back(50); + y_.push_back(101); + return; + } + + void setup() + { + std::vector::iterator x_it, y_it; + for (x_it = x_.begin(); x_it != x_.end(); x_it++) + for (y_it = y_.begin(); y_it != y_.end(); y_it++) + { + queueCallback( + ModifyCheckCallback( + boost::bind(&T::setPosition, boost::ref(object_), *x_it, *y_it), + boost::bind(&T::checkPosition, boost::ref(object_), *x_it, *y_it) + ) + ); + } + } + +private: + Window window_; + T object_; + std::vector x_, y_; +}; + + +template +class VisibleObjectTest : public ElmTestHarness +{ + BOOST_STATIC_ASSERT( (boost::is_base_of::value) ); + +public: + VisibleObjectTest() + : ElmTestHarness::ElmTestHarness() + , window_("VisibleObjectTest", "Visibility Test") + , object_(window_) + { + return; + } + + void setup() + { + queueCallback( + ModifyCheckCallback( + boost::bind(&T::show, boost::ref(object_)), + boost::bind(&T::checkVisible, boost::ref(object_), EINA_TRUE) + ) + ); + + queueCallback( + ModifyCheckCallback( + boost::bind(&T::hide, boost::ref(object_)), + boost::bind(&T::checkHidden, boost::ref(object_), EINA_TRUE) + ) + ); + + queueCallback( + ModifyCheckCallback( + boost::bind(&T::show, boost::ref(object_)), + boost::bind(&T::checkHidden, boost::ref(object_), EINA_TRUE) + ) + ); + } + +private: + Window window_; + T object_; +}; + +/* TODO: evasobject methods for color set/get/check +template +class ColorObjectTest : public ElmTestHarness +{ + BOOST_STATIC_ASSERT( (boost::is_base_of::value) ); + +public: + ColorObjectTest() + : ElmTestHarness::ElmTestHarness() + , window_("ColorObjectTest", "Color Test") + , object_(window_) + { + return; + } + + void setup() + { + queueCallback( + ModifyCheckCallback( + boost::bind(&T::setColor, boost::ref(object_), Tr1, Tg1, Tb1, Ta1), + boost::bind(&T::checkColor, boost::ref(object_), Tr1, Tg1, Tb1, Ta1) + ) + ); + + queueCallback( + ModifyCheckCallback( + boost::bind(&T::setColor, boost::ref(object_), Tr2, Tg2, Tb2, Ta2), + boost::bind(&T::checkColor, boost::ref(object_), Tr2, Tg2, Tb2, Ta2) + ) + ); + + queueCallback( + ModifyCheckCallback( + boost::bind(&T::setColor, boost::ref(object_), Tr1, Tg1, Tb1, Ta1), + boost::bind(&T::checkColor, boost::ref(object_), Tr1, Tg1, Tb1, Ta1) + ) + ); + } + +private: + Window window_; + T object_; +}; +*/ + +/* TODO: evasobject methods for raise/lower set/get/check +template +class RaiseLowerObjectTest : public ElmTestHarness +{ + BOOST_STATIC_ASSERT( (boost::is_base_of::value) ); + +public: + RaiseLowerObjectTest() + : ElmTestHarness::ElmTestHarness() + , window_("RaiseLowerObjectTest", "RaiseLower Test") + , object_(window_) + { + return; + } + + void setup() + { + queueCallback( + ModifyCheckCallback( + boost::bind(&T::raise, boost::ref(object_)), + boost::bind(&T::checkRisen, boost::ref(object_), EINA_TRUE) + ) + ); + + queueCallback( + ModifyCheckCallback( + boost::bind(&T::lower, boost::ref(object_)), + boost::bind(&T::checkLowered, boost::ref(object_), EINA_TRUE) + ) + ); + + queueCallback( + ModifyCheckCallback( + boost::bind(&T::raise, boost::ref(object_)), + boost::bind(&T::checkRisen, boost::ref(object_), EINA_TRUE) + ) + ); + } + +private: + Window window_; + T object_; +}; +*/ + +#endif + diff --git a/src/efl/test_actionslider.cpp b/src/efl/test_actionslider.cpp index 89d19d9..f589e90 100644 --- a/src/efl/test_actionslider.cpp +++ b/src/efl/test_actionslider.cpp @@ -1,15 +1,18 @@ #include -#include "macros.h" +#include "templates.h" using std::vector; - -// 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 Actionslider : public EvasObject +{ +public: + Actionslider(EvasObject &parent) + : EvasObject::EvasObject(elm_actionslider_add(parent)) + { + return; + } +}; class ActionsliderIndicatorTest : public ElmTestHarness { @@ -18,7 +21,7 @@ public: ActionsliderIndicatorTest() : ElmTestHarness::ElmTestHarness() , window_("ActionsliderIndicatorTest", "Actionslider Position Test") - , control_(elm_actionslider_add(window_)) + , control_(window_) { positions_.push_back(ELM_ACTIONSLIDER_LEFT); positions_.push_back(ELM_ACTIONSLIDER_CENTER); @@ -60,14 +63,21 @@ public: private: Window window_; - EvasObject control_; + Actionslider control_; vector positions_; }; +typedef ResizeObjectTest ActionsliderResizeTest; +typedef PositionObjectTest ActionsliderPositionTest; +typedef VisibleObjectTest ActionsliderVisibilityTest; + BOOST_AUTO_TEST_SUITE(EFL) BOOST_AUTO_TEST_SUITE(ActionSlider) - + + WAYLAND_ELM_HARNESS_TEST_CASE(ActionsliderResizeTest) + WAYLAND_ELM_HARNESS_TEST_CASE(ActionsliderPositionTest) + WAYLAND_ELM_HARNESS_TEST_CASE(ActionsliderVisibilityTest) WAYLAND_ELM_HARNESS_TEST_CASE(ActionsliderIndicatorTest) BOOST_AUTO_TEST_SUITE_END() diff --git a/src/efl/test_bubble.cpp b/src/efl/test_bubble.cpp index 23b9c25..cbe1d26 100644 --- a/src/efl/test_bubble.cpp +++ b/src/efl/test_bubble.cpp @@ -7,16 +7,20 @@ #include "window.h" #include "elmtestharness.h" -#include "macros.h" +#include "templates.h" using std::vector; using std::string; -// Basic suite START -EFL_RESIZE_TEST(Bubble, bubble, 300, 200, 200, 100) -EFL_POSITION_TEST(Bubble, bubble, 100, 50, 150, 100) -EFL_VISIBILITY_TEST(Bubble, bubble) -// Basic suite END +class Bubble : public EvasObject +{ +public: + Bubble(EvasObject &parent) + : EvasObject::EvasObject(elm_bubble_add(parent)) + { + return; + } +}; class BubbleCornerTest : public ElmTestHarness { @@ -112,10 +116,18 @@ private: vector sentinels_; }; + +typedef ResizeObjectTest BubbleResizeTest; +typedef PositionObjectTest BubblePositionTest; +typedef VisibleObjectTest BubbleVisibilityTest; + BOOST_AUTO_TEST_SUITE(EFL) BOOST_AUTO_TEST_SUITE(Bubble) + WAYLAND_ELM_HARNESS_TEST_CASE(BubbleResizeTest) + WAYLAND_ELM_HARNESS_TEST_CASE(BubblePositionTest) + WAYLAND_ELM_HARNESS_TEST_CASE(BubbleVisibilityTest) WAYLAND_ELM_HARNESS_TEST_CASE(BubbleCornerTest) WAYLAND_ELM_HARNESS_TEST_CASE(BubbleTextTest) diff --git a/src/efl/test_button.cpp b/src/efl/test_button.cpp index 3b5c286..8b7815c 100644 --- a/src/efl/test_button.cpp +++ b/src/efl/test_button.cpp @@ -1,10 +1,27 @@ -#include "macros.h" +#include "templates.h" -// Basic suite START -EFL_RESIZE_TEST(Button, button, 300, 200, 200, 100) +class Button : public EvasObject +{ +public: + Button(EvasObject &parent) + : EvasObject::EvasObject(elm_button_add(parent)) + { + return; + } +}; -EFL_POSITION_TEST(Button, button, 100, 50, 150, 100) +typedef ResizeObjectTest