From: U. Artie Eoff Date: Tue, 2 Apr 2013 20:07:31 +0000 (-0700) Subject: efl: add 'user' actionslider test X-Git-Tag: upstream/0.2.1~162 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f44332fe3c8c0e4f7d82ef60cdfe65c60e57cb89;p=test%2Fgeneric%2Fwayland-fits.git efl: add 'user' actionslider test Signed-off-by: U. Artie Eoff --- diff --git a/src/efl/test_actionslider.cpp b/src/efl/test_actionslider.cpp index a691981..471a65e 100644 --- a/src/efl/test_actionslider.cpp +++ b/src/efl/test_actionslider.cpp @@ -1,4 +1,6 @@ +#include #include +#include #include "templates.h" @@ -12,6 +14,16 @@ public: { return; } + + Geometry getButtonGeometry() const + { +#pragma GCC diagnostic ignored "-fpermissive" + ELM_ACTIONSLIDER_DATA_GET(*this, sd); +#pragma GCC diagnostic error "-fpermissive" + + EvasObject o(sd->drag_button_base, false); + return o.getGeometry(); + } }; class ActionsliderIndicatorTest : public ElmTestHarness @@ -58,6 +70,125 @@ private: vector positions_; }; +class ActionSliderUserTest : public ElmTestHarness +{ +public: + ActionSliderUserTest() + : ElmTestHarness::ElmTestHarness() + , window_("ActionSliderUserTest", "ActionSlider User Test") + , slider_(window_) + , position_() + , selection_() + { + return; + } + + void setup() + { + window_.show(); + + int w(200), h(50); + int x(window_.getWidth() / 2 - w / 2); + int y(window_.getHeight() / 2 - h / 2); + + slider_.setSize(w, h); + slider_.setPosition(x, y); + + elm_object_part_text_set(slider_, "left", "Left"); + elm_object_part_text_set(slider_, "center", "Center"); + elm_object_part_text_set(slider_, "right", "Right"); + + evas_object_smart_callback_add(slider_, "selected", onSelect, this); + evas_object_smart_callback_add(slider_, "pos_changed", onChange, this); + + slider_.show(); + + boost::function fn = + boost::bind(&ActionSliderUserTest::moveSliderTo, boost::ref(*this), _1); + + queueStep(boost::bind(fn, ELM_ACTIONSLIDER_CENTER)); + queueStep(boost::bind(fn, ELM_ACTIONSLIDER_RIGHT)); + queueStep(boost::bind(fn, ELM_ACTIONSLIDER_LEFT)); + queueStep(boost::bind(fn, ELM_ACTIONSLIDER_RIGHT)); + queueStep(boost::bind(fn, ELM_ACTIONSLIDER_CENTER)); + queueStep(boost::bind(fn, ELM_ACTIONSLIDER_LEFT)); + } + + void moveSliderTo(const Elm_Actionslider_Pos pos) + { + Application::yield(0.01*1e6); + + Geometry gw(getSurfaceGeometry(window_.get_wl_surface())); + Geometry gb(slider_.getButtonGeometry()); + Geometry gs(slider_.getGeometry()); + + setGlobalPointerPosition( + gw.x + gb.x + gb.width / 2, + gw.y + gb.y + gb.height / 2 + ); + pointerKeyPress(BTN_LEFT, 1); + + std::string position, selection; + int32_t x; + + switch (pos) { + case ELM_ACTIONSLIDER_LEFT: + position = "left"; + selection = "Left"; + x = gw.x + gs.x + gb.width / 2; + break; + case ELM_ACTIONSLIDER_CENTER: + position = "center"; + selection = "Center"; + x = gw.x + gs.x + gs.width / 2; + break; + default: + position = "right"; + selection = "Right"; + x = gw.x + gs.x + gs.width - gb.width / 2; + break; + } + + setGlobalPointerPosition(x, gw.y + gb.y + gb.height / 2); + + std::cout << "...checking for position changed event on '" + << position << "'" << std::endl; + while (position_ != position) { + Application::yield(); + } + + pointerKeyPress(BTN_LEFT, 0); + + std::cout << "...checking for selected event on '" + << selection << "'" << std::endl; + while (selection_ != selection) { + Application::yield(); + } + } + + static void onSelect(void* data, Evas_Object*, void* info) + { + ActionSliderUserTest *test = static_cast(data); + test->selection_ = std::string(static_cast(info)); + std::cout << "...received selected event on '" + << test->selection_ << "'" << std::endl; + } + + static void onChange(void* data, Evas_Object*, void* info) + { + ActionSliderUserTest *test = static_cast(data); + test->position_ = std::string(static_cast(info));; + std::cout << "...received position changed event on '" + << test->position_ << "'" << std::endl; + } + +private: + Window window_; + Actionslider slider_; + std::string position_; + std::string selection_; +}; + typedef ResizeObjectTest ActionsliderResizeTest; typedef PositionObjectTest ActionsliderPositionTest; typedef VisibleObjectTest ActionsliderVisibilityTest; @@ -66,4 +197,5 @@ WAYLAND_ELM_HARNESS_TEST_CASE(ActionsliderResizeTest, "ActionSlider") WAYLAND_ELM_HARNESS_TEST_CASE(ActionsliderPositionTest, "ActionSlider") WAYLAND_ELM_HARNESS_TEST_CASE(ActionsliderVisibilityTest, "ActionSlider") WAYLAND_ELM_HARNESS_TEST_CASE(ActionsliderIndicatorTest, "ActionSlider") +WAYLAND_ELM_HARNESS_TEST_CASE(ActionSliderUserTest, "ActionSlider")