From fd912d56941f8635a7fcffe2eca09b49698e35ee Mon Sep 17 00:00:00 2001 From: Joe Konno Date: Thu, 19 Jul 2012 16:18:58 -0700 Subject: [PATCH] EFL: aggressive refactor of actionslider test Utilize EvasObject utility macros. Remove the Actionslider class as there is not a compelling reason to "objectify" the Actionslider control. Should ease maintenance down the road. Signed-off-by: Joe Konno --- src/efl/Makefile.am | 1 - src/efl/actionslider.cpp | 38 ----------------------------- src/efl/actionslider.h | 23 ------------------ src/efl/test_actionslider.cpp | 46 ++++++++++++++++++++---------------- src/efl/test_dayselector.cpp | 1 - src/efl/test_entry.cpp | 1 - src/efl/test_fileselector.cpp | 1 - src/efl/test_fileselector_button.cpp | 1 - src/efl/test_fileselector_entry.cpp | 1 - 9 files changed, 26 insertions(+), 87 deletions(-) delete mode 100644 src/efl/actionslider.cpp delete mode 100644 src/efl/actionslider.h diff --git a/src/efl/Makefile.am b/src/efl/Makefile.am index 57bcced..e20c19f 100644 --- a/src/efl/Makefile.am +++ b/src/efl/Makefile.am @@ -24,7 +24,6 @@ LDFLAGS += \ bin_PROGRAMS = $(TESTS) wayland_efl_test_SOURCES = \ - actionslider.cpp \ application.cpp \ background.cpp \ elmtestharness.cpp \ diff --git a/src/efl/actionslider.cpp b/src/efl/actionslider.cpp deleted file mode 100644 index 66a407e..0000000 --- a/src/efl/actionslider.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "actionslider.h" - -Actionslider::Actionslider(Evas_Object *parent, const std::string& left, const bool leftOn, const std::string& center, const bool centerOn, const std::string& right, const bool rightOn) - : EvasObject::EvasObject( - elm_actionslider_add(parent) - ) - , parent(parent) -{ - elm_object_part_text_set(*this, "left", left.c_str()); - elm_object_part_text_set(*this, "center", center.c_str()); - elm_object_part_text_set(*this, "right", right.c_str()); - - unsigned int posEnabled = ELM_ACTIONSLIDER_NONE; - if (leftOn) - { - posEnabled |= ELM_ACTIONSLIDER_LEFT; - } - if (centerOn) - { - posEnabled |= ELM_ACTIONSLIDER_CENTER; - } - if (rightOn) - { - posEnabled |= ELM_ACTIONSLIDER_RIGHT; - } - elm_actionslider_enabled_pos_set(*this, static_cast(posEnabled)); -} - -void Actionslider::setPos(Elm_Actionslider_Pos pos) -{ - elm_actionslider_indicator_pos_set(*this, pos); -} - -Elm_Actionslider_Pos Actionslider::getPos() -{ - return elm_actionslider_indicator_pos_get(*this); -} - diff --git a/src/efl/actionslider.h b/src/efl/actionslider.h deleted file mode 100644 index a8b3f34..0000000 --- a/src/efl/actionslider.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __WAYLAND_EFL_ACTIONSLIDER_H__ -#define __WAYLAND_EFL_ACTIONSLIDER_H__ - -#include -#include - -#include "evasobject.h" - -class Actionslider : public EvasObject -{ -public: - Actionslider(Evas_Object *, const std::string& = "Left", const bool = true, const std::string& = "Center", const bool = true, const std::string& = "Right", const bool = true); - - void setPos(Elm_Actionslider_Pos pos); - - Elm_Actionslider_Pos getPos(); - -private: - Evas_Object *parent; -}; - -#endif - diff --git a/src/efl/test_actionslider.cpp b/src/efl/test_actionslider.cpp index 0048b48..2fd0bf8 100644 --- a/src/efl/test_actionslider.cpp +++ b/src/efl/test_actionslider.cpp @@ -1,11 +1,14 @@ #include #include +#include + #include "window.h" -#include "actionslider.h" #include "evasobject.h" #include "elmtestharness.h" +using std::vector; + class ActionsliderPosTest : public ElmTestHarness { public: @@ -13,43 +16,46 @@ public: ActionsliderPosTest() : ElmTestHarness::ElmTestHarness() , window_("ActionsliderPosTest", "Actionslider Position Test") - , control_(window_) + , control_(elm_actionslider_add(window_)) { + positions_.push_back(ELM_ACTIONSLIDER_LEFT); + positions_.push_back(ELM_ACTIONSLIDER_CENTER); + positions_.push_back(ELM_ACTIONSLIDER_LEFT); + positions_.push_back(ELM_ACTIONSLIDER_RIGHT); + positions_.push_back(ELM_ACTIONSLIDER_CENTER); + return; } void setup() { - elm_win_resize_object_add(window_, control_); - window_.show(); - control_.show(); - - const Elm_Actionslider_Pos position[] = { - ELM_ACTIONSLIDER_LEFT, - ELM_ACTIONSLIDER_CENTER, - ELM_ACTIONSLIDER_RIGHT - }; - - unsigned int p; - for (p = 0; p < (sizeof(position) / sizeof(Elm_Actionslider_Pos)); p++) + SET_CHECK_SHOW(window_); + SET_CHECK_SHOW(control_); + + control_.setSize(200, 100); + control_.setPosition(50, 10); + + vector::iterator it; + for (it = positions_.begin(); it != positions_.end(); it++) { queueCallback( ModifyCheckCallback( - boost::bind(&Actionslider::setPos, boost::ref(control_), position[p]), - boost::bind(&ActionsliderPosTest::checkPos, boost::ref(*this), position[p]) + boost::bind(elm_actionslider_indicator_pos_set, boost::ref(control_), *it), + boost::bind(&ActionsliderPosTest::checkPos, boost::ref(*this), *it) ) ); } } - void checkPos(Elm_Actionslider_Pos pos) + void checkPos(const Elm_Actionslider_Pos expected) { - BOOST_CHECK_EQUAL(control_.getPos(), pos); + BOOST_CHECK_EQUAL(elm_actionslider_indicator_pos_get(control_), expected); } private: - Window window_; - Actionslider control_; + Window window_; + EvasObject control_; + vector positions_; }; BOOST_AUTO_TEST_SUITE(EFL) diff --git a/src/efl/test_dayselector.cpp b/src/efl/test_dayselector.cpp index a6445d8..55bc967 100644 --- a/src/efl/test_dayselector.cpp +++ b/src/efl/test_dayselector.cpp @@ -4,7 +4,6 @@ #include #include "window.h" -#include "actionslider.h" #include "evasobject.h" #include "elmtestharness.h" diff --git a/src/efl/test_entry.cpp b/src/efl/test_entry.cpp index 3710081..4268f4d 100644 --- a/src/efl/test_entry.cpp +++ b/src/efl/test_entry.cpp @@ -5,7 +5,6 @@ #include #include "window.h" -#include "actionslider.h" #include "evasobject.h" #include "elmtestharness.h" diff --git a/src/efl/test_fileselector.cpp b/src/efl/test_fileselector.cpp index 251f97e..f22e045 100644 --- a/src/efl/test_fileselector.cpp +++ b/src/efl/test_fileselector.cpp @@ -4,7 +4,6 @@ #include #include "window.h" -#include "actionslider.h" #include "evasobject.h" #include "elmtestharness.h" diff --git a/src/efl/test_fileselector_button.cpp b/src/efl/test_fileselector_button.cpp index 93b2f30..c388b8d 100644 --- a/src/efl/test_fileselector_button.cpp +++ b/src/efl/test_fileselector_button.cpp @@ -4,7 +4,6 @@ #include #include "window.h" -#include "actionslider.h" #include "evasobject.h" #include "elmtestharness.h" diff --git a/src/efl/test_fileselector_entry.cpp b/src/efl/test_fileselector_entry.cpp index 5449c54..26d8df2 100644 --- a/src/efl/test_fileselector_entry.cpp +++ b/src/efl/test_fileselector_entry.cpp @@ -4,7 +4,6 @@ #include #include "window.h" -#include "actionslider.h" #include "evasobject.h" #include "elmtestharness.h" -- 2.7.4