From 1733924ab388e9c69abba5f7ced51392d68a9707 Mon Sep 17 00:00:00 2001 From: Joe Konno Date: Mon, 9 Jul 2012 15:17:43 -0700 Subject: [PATCH] EFL: clock widget tests Signed-off-by: Joe Konno --- src/efl/Makefile.am | 1 + src/efl/test_clock.cpp | 203 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 src/efl/test_clock.cpp diff --git a/src/efl/Makefile.am b/src/efl/Makefile.am index 42c7b1b..23a8c05 100644 --- a/src/efl/Makefile.am +++ b/src/efl/Makefile.am @@ -37,6 +37,7 @@ wayland_efl_test_SOURCES = \ test_background.cpp \ test_bubble.cpp \ test_check.cpp \ + test_clock.cpp \ ../testmain.cpp endif diff --git a/src/efl/test_clock.cpp b/src/efl/test_clock.cpp new file mode 100644 index 0000000..be51f01 --- /dev/null +++ b/src/efl/test_clock.cpp @@ -0,0 +1,203 @@ +#include +#include + +#include "window.h" +#include "evasobject.h" +#include "elmtestharness.h" + + +class ClockTimeTest : public ElmTestHarness +{ +public: + + ClockTimeTest() + : ElmTestHarness::ElmTestHarness() + , window_("ClockTimeTest", "Clock Time Test") + , clock_(elm_clock_add(window_)) + { + window_.setSize(600, 400); + clock_.setSize(500, 100); + clock_.setPosition(50, 50); + return; + } + + void setup() + { + clock_.show(); + window_.show(); + + queueCallback( + ModifyCheckCallback( + boost::bind(elm_clock_show_am_pm_set, boost::ref(clock_), EINA_FALSE), + boost::bind(&ClockTimeTest::checkAmPm, boost::ref(*this), EINA_FALSE) + ) + ); + + queueCallback( + ModifyCheckCallback( + boost::bind(elm_clock_show_am_pm_set, boost::ref(clock_), EINA_TRUE), + boost::bind(&ClockTimeTest::checkAmPm, boost::ref(*this), EINA_TRUE) + ) + ); + + queueCallback( + ModifyCheckCallback( + boost::bind(elm_clock_show_seconds_set, boost::ref(clock_), EINA_FALSE), + boost::bind(&ClockTimeTest::checkSecs, boost::ref(*this), EINA_FALSE) + ) + ); + + queueCallback( + ModifyCheckCallback( + boost::bind(elm_clock_show_seconds_set, boost::ref(clock_), EINA_TRUE), + boost::bind(&ClockTimeTest::checkSecs, boost::ref(*this), EINA_TRUE) + ) + ); + + queueCallback( + ModifyCheckCallback( + boost::bind(elm_clock_time_set, boost::ref(clock_), 6, 42, 12), + boost::bind(&ClockTimeTest::checkTime, boost::ref(*this), 6, 42, 12) + ) + ); + + } + + void checkAmPm(Eina_Bool ampm) + { + BOOST_CHECK_EQUAL(elm_clock_show_am_pm_get(clock_), ampm); + } + + void checkSecs(Eina_Bool secs) + { + BOOST_CHECK_EQUAL(elm_clock_show_seconds_get(clock_), secs); + } + + void checkTime(int h, int m, int s) + { + int hr, min, sec; + elm_clock_time_get(clock_, &hr, &min, &sec); + BOOST_CHECK(h == hr && m == min && s == sec); + } + +private: + Window window_; + EvasObject clock_; +}; + +class ClockEditionTest : public ElmTestHarness +{ +public: + + ClockEditionTest() + : ElmTestHarness::ElmTestHarness() + , window_("ClockEditionTest", "Clock Edition Test") + , clock_(elm_clock_add(window_)) + { + window_.setSize(600, 400); + clock_.setSize(500, 100); + clock_.setPosition(50, 50); + elm_clock_show_seconds_set(clock_, EINA_TRUE); + return; + } + + void setup() + { + clock_.show(); + window_.show(); + + queueCallback( + ModifyCheckCallback( + boost::bind(elm_clock_edit_set, boost::ref(clock_), EINA_TRUE), + boost::bind(&ClockEditionTest::checkEdit, boost::ref(*this), EINA_TRUE) + ) + ); + + queueCallback( + ModifyCheckCallback( + boost::bind(elm_clock_edit_set, boost::ref(clock_), EINA_FALSE), + boost::bind(&ClockEditionTest::checkEdit, boost::ref(*this), EINA_FALSE) + ) + ); + } + + void checkEdit(Eina_Bool edit) + { + BOOST_CHECK_EQUAL(elm_clock_edit_get(clock_), edit); + } + +private: + Window window_; + EvasObject clock_; +}; + +class ClockDigitEditionTest : public ElmTestHarness +{ +public: + + ClockDigitEditionTest() + : ElmTestHarness::ElmTestHarness() + , window_("ClockDigitEditionTest", "Clock Edition Test") + , clock_(elm_clock_add(window_)) + { + window_.setSize(600, 400); + clock_.setSize(500, 100); + clock_.setPosition(50, 50); + elm_clock_edit_set(clock_, EINA_TRUE); + elm_clock_show_seconds_set(clock_, EINA_TRUE); + return; + } + + void setup() + { + clock_.show(); + window_.show(); + + Elm_Clock_Edit_Mode edition[] = { + ELM_CLOCK_EDIT_HOUR_DECIMAL, + ELM_CLOCK_EDIT_HOUR_UNIT, + ELM_CLOCK_EDIT_MIN_DECIMAL, + ELM_CLOCK_EDIT_MIN_UNIT, + ELM_CLOCK_EDIT_SEC_DECIMAL, + ELM_CLOCK_EDIT_SEC_UNIT }; + + Elm_Clock_Edit_Mode mask = ELM_CLOCK_EDIT_DEFAULT; + for (unsigned int i = 0; i < (sizeof(edition) / sizeof(unsigned int)); ++i) + { + queueCallback( + ModifyCheckCallback( + boost::bind(elm_clock_edit_mode_set, boost::ref(clock_), edition[i]), + boost::bind(&ClockDigitEditionTest::checkEdit, boost::ref(*this), edition[i]) + ) + ); + + mask = (Elm_Clock_Edit_Mode) (mask | edition[i]); + if (mask == edition[i]) + continue; + + queueCallback( + ModifyCheckCallback( + boost::bind(elm_clock_edit_mode_set, boost::ref(clock_), mask), + boost::bind(&ClockDigitEditionTest::checkEdit, boost::ref(*this), mask) + ) + ); + } + } + + void checkEdit(Elm_Clock_Edit_Mode mask) + { + BOOST_CHECK_EQUAL(elm_clock_edit_mode_get(clock_), mask); + } + +private: + Window window_; + EvasObject clock_; +}; +BOOST_AUTO_TEST_SUITE(Wayland_EFL_Clock_Suite) + + WAYLAND_ELM_HARNESS_TEST_CASE(ClockTimeTest) + WAYLAND_ELM_HARNESS_TEST_CASE(ClockEditionTest) + WAYLAND_ELM_HARNESS_TEST_CASE(ClockDigitEditionTest) + +BOOST_AUTO_TEST_SUITE_END() + -- 2.7.4