[PATCH wfits] test_dayselector: Add user test
Eoff, Ullysses A
ullysses.a.eoff at intel.com
Fri May 31 15:04:07 PDT 2013
> -----Original Message-----
> From: wayland-devel-bounces+ullysses.a.eoff=intel.com at lists.freedesktop.org [mailto:wayland-devel-
> bounces+ullysses.a.eoff=intel.com at lists.freedesktop.org] On Behalf Of Brian Lovin
> Sent: Friday, May 31, 2013 1:02 PM
> To: wayland-devel at lists.freedesktop.org
> Cc: Lovin, Brian J
> Subject: [PATCH wfits] test_dayselector: Add user test
>
> Signed-off-by: Brian Lovin <brian.j.lovin at intel.com>
> ---
> src/test/efl/test_dayselector.cpp | 114 +++++++++++++++++++++++++++++++++++++-
> 1 file changed, 113 insertions(+), 1 deletion(-)
>
> diff --git a/src/test/efl/test_dayselector.cpp b/src/test/efl/test_dayselector.cpp
> index 254991f..c8f4e35 100644
> --- a/src/test/efl/test_dayselector.cpp
> +++ b/src/test/efl/test_dayselector.cpp
> @@ -21,12 +21,14 @@
> */
>
> #include <Elementary.h>
> +#include <boost/lexical_cast.hpp>
> #include <boost/bind.hpp>
>
> +#include <string>
> #include <vector>
>
> -#include "window.h"
>
> +#include "window.h"
> #include "elmtestharness.h"
> #include "templates.h"
>
> @@ -149,6 +151,115 @@ private:
> EvasObject control_;
> };
>
> +class DayselectorUserTest : public ElmTestHarness
> +{
> +public:
> + DayselectorUserTest()
> + : ElmTestHarness::ElmTestHarness()
> + , window_("DayselectorUserTest", "Dayselector User Test", 350, 120)
> + , dayselector_(elm_dayselector_add(window_))
> + , rendered_(false)
> + , changed_(false)
> + {
> + return;
> + }
> +
> + void setup()
> + {
> + evas_object_size_hint_weight_set(dayselector_, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
> + elm_win_resize_object_add(window_, dayselector_);
> +
> + evas_event_callback_add(
> + evas_object_evas_get(window_),
> + EVAS_CALLBACK_RENDER_POST,
> + onPostRender, this
> + );
> +
> + evas_object_smart_callback_add(dayselector_, "dayselector,changed", onDayselectorChanged, this);
> +
> + window_.show();
> + dayselector_.show();
> +
> + queueStep(boost::bind(&DayselectorUserTest::test, boost::ref(*this)));
> + }
> +
> + void test(){
> + YIELD_UNTIL(rendered_);
> +
> + for(unsigned i(0); i <= 5; ++i) {
> + std::string dayStr("day");
> + dayStr += boost::lexical_cast<std::string>(i);
> +
> + changed_ = false;
> + clickDay(dayStr);
> + YIELD_UNTIL(changed_);
> +
> + Eina_Bool ret = elm_dayselector_day_selected_get(dayselector_, (Elm_Dayselector_Day)(i+1));
Please always use C++-style casts, e.g. static_cast<Elm_Dayselector_Day>(i+1);
> + FAIL_IF(ret == EINA_FALSE);
> + }
> +
> + //This is done outside the loop because ELM_DAYSELECTOR_SUN=0
> + changed_ = false;
> + clickDay("day6");
> + YIELD_UNTIL(changed_);
> + Eina_Bool ret = elm_dayselector_day_selected_get(dayselector_, ELM_DAYSELECTOR_SUN);
> + FAIL_IF(ret == EINA_FALSE);
> +
> + //Test all are clicked.
> + testAllSelected();
> + }
> +
> + void clickDay(std::string str)
"const std::string &str" would probably be better here.
> + {
> + Application::yield(0.01*1e6);
Why do you need this yield?? Perhaps it's better to yield until some condition is met or
event occurs. Arbitrarily timed yields don't always work... it's a race and can cause intermittent
failures. Now if you're only calling yield to ensure one iteration of the loop is executed, then
discard the timeout parameter. Either way, put a comment here to explain why you need to use
it.
> +
> + EvasObject currentDay(elm_layout_content_get(dayselector_, str.c_str()), false);
> + Geometry gc(currentDay.getGeometry());
> + Geometry gw(getSurfaceGeometry(window_.get_wl_surface()));
> + Geometry gf(window_.getFramespaceGeometry());
> + Geometry gb(dayselector_.getGeometry());
> +
> + setGlobalPointerPosition(
> + gw.x + gf.x + gc.x + gc.width / 2,
> + gw.y + gf.y + gc.y + gc.height / 2
> + );
> +
> + inputKeySend(BTN_LEFT, 1);
> + inputKeySend(BTN_LEFT, 0);
> + }
> +
> + void testAllSelected()
> + {
> + for(unsigned i(0); i <= 6; ++i) {
> + Elm_Dayselector_Day day = (Elm_Dayselector_Day)(i);
Use a C++-style cast here, too.
> + Eina_Bool ret = elm_dayselector_day_selected_get(dayselector_, day);
> + FAIL_IF(ret == EINA_FALSE);
> + }
> + }
> +
> + static void onPostRender(void *data, Evas *e, void *info)
> + {
> + evas_event_callback_del(e, EVAS_CALLBACK_RENDER_POST, onPostRender);
> +
> + DayselectorUserTest *test = static_cast<DayselectorUserTest*>(data);
> + test->rendered_ = true;
> + std::cout << "...received post render event" << std::endl;
> + }
> +
> + static void onDayselectorChanged(void *data, Evas *e, void *info)
> + {
> + DayselectorUserTest *test = static_cast<DayselectorUserTest*>(data);
> + test->changed_ = true;
> + std::cout << "...received changed event" << std::endl;
> + }
> +
> +private:
> + Window window_;
> + EvasObject dayselector_;
> + bool rendered_;
> + bool changed_;
> +};
> +
> typedef ResizeObjectTest<Dayselector> DayselectorResizeTest;
> typedef PositionObjectTest<Dayselector> DayselectorPositionTest;
> typedef VisibleObjectTest<Dayselector> DayselectorVisibilityTest;
> @@ -159,6 +270,7 @@ WFITS_EFL_HARNESS_TEST_CASE(DayselectorVisibilityTest)
> WFITS_EFL_HARNESS_TEST_CASE(DayselectorDayTest)
> WFITS_EFL_HARNESS_TEST_CASE(DayselectorLocaleTest)
>
> +WFITS_EFL_HARNESS_TEST_CASE(DayselectorUserTest)
> } // namespace efl
> } // namespace test
> } // namespace wfits
> --
> 1.8.1.2
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list