[PATCH v2 wfits] test_dayselector: Add user test

Eoff, Ullysses A ullysses.a.eoff at intel.com
Tue Jun 4 10:25:22 PDT 2013


Thanks, committed.

U. Artie

> -----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: Tuesday, June 04, 2013 9:58 AM
> To: wayland-devel at lists.freedesktop.org
> Cc: Lovin, Brian J
> Subject: [PATCH v2 wfits] test_dayselector: Add user test
> 
> Signed-off-by: Brian Lovin <brian.j.lovin at intel.com>
> ---
>  src/test/efl/test_dayselector.cpp | 112 +++++++++++++++++++++++++++++++++++++-
>  1 file changed, 111 insertions(+), 1 deletion(-)
> 
> diff --git a/src/test/efl/test_dayselector.cpp b/src/test/efl/test_dayselector.cpp
> index 254991f..172926d 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,113 @@ 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_, 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(const std::string &str)
> +	{
> +		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 = static_cast<Elm_Dayselector_Day>((i));
> +			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 +268,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