summaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2019-08-19 14:31:57 -0400
committerCedric BAIL <cedric.bail@free.fr>2019-08-19 16:47:08 -0700
commit1114106f09fd98e7e4330befb9a15387817cc043 (patch)
tree84d534f5e7b071a4a4b26b4914b1982d1733d961 /src/tests
parent187425e12ccc355e9fb58074b72c786535d5aa23 (diff)
tests/elm: add util functions for triggering wheel events
Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9633
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/elementary/suite_helpers.c64
-rw-r--r--src/tests/elementary/suite_helpers.h3
2 files changed, 63 insertions, 4 deletions
diff --git a/src/tests/elementary/suite_helpers.c b/src/tests/elementary/suite_helpers.c
index 44c34e58ae..5c89446a47 100644
--- a/src/tests/elementary/suite_helpers.c
+++ b/src/tests/elementary/suite_helpers.c
@@ -400,11 +400,10 @@ enum
400 BOTTOM = 1 << 3, 400 BOTTOM = 1 << 3,
401}; 401};
402 402
403static void 403static Eina_Position2D
404click_object_internal(Eo *obj, int dir) 404attempt_to_find_the_right_point_for_mouse_positioning(Eo *obj, int dir)
405{ 405{
406 int x, y; 406 int x, y;
407 Evas *e = evas_object_evas_get(obj);
408 Eina_Rect r = efl_gfx_entity_geometry_get(obj); 407 Eina_Rect r = efl_gfx_entity_geometry_get(obj);
409 if (dir & LEFT) 408 if (dir & LEFT)
410 x = r.x + (.1 * r.w); 409 x = r.x + (.1 * r.w);
@@ -418,7 +417,15 @@ click_object_internal(Eo *obj, int dir)
418 y = r.y + (.9 * r.h); 417 y = r.y + (.9 * r.h);
419 else 418 else
420 y = r.y + r.h / 2; 419 y = r.y + r.h / 2;
421 evas_event_feed_mouse_move(e, x, y, 0, NULL); 420 return EINA_POSITION2D(x, y);
421}
422
423static void
424click_object_internal(Eo *obj, int dir)
425{
426 Evas *e = evas_object_evas_get(obj);
427 Eina_Position2D pos = attempt_to_find_the_right_point_for_mouse_positioning(obj, dir);
428 evas_event_feed_mouse_move(e, pos.x, pos.y, 0, NULL);
422 evas_event_feed_mouse_down(e, 1, 0, 0, NULL); 429 evas_event_feed_mouse_down(e, 1, 0, 0, NULL);
423 evas_event_feed_mouse_up(e, 1, 0, 0, NULL); 430 evas_event_feed_mouse_up(e, 1, 0, 0, NULL);
424} 431}
@@ -457,6 +464,47 @@ click_part(Eo *obj, const char *part)
457 efl_unref(part_obj); 464 efl_unref(part_obj);
458} 465}
459 466
467static void
468wheel_object_internal(Eo *obj, int dir, Eina_Bool horiz, Eina_Bool down)
469{
470 Eina_Position2D pos = attempt_to_find_the_right_point_for_mouse_positioning(obj, dir);
471 wheel_object_at(obj, pos.x, pos.y, horiz, down);
472}
473
474void
475wheel_object(Eo *obj, Eina_Bool horiz, Eina_Bool down)
476{
477 wheel_object_internal(obj, NONE, horiz, down);
478}
479
480void
481wheel_part(Eo *obj, const char *part, Eina_Bool horiz, Eina_Bool down)
482{
483 Efl_Part *part_obj = efl_ref(efl_part(obj, part));
484 Eo *content;
485 int dir = 0;
486
487 if (efl_canvas_layout_part_type_get(part_obj) == EFL_CANVAS_LAYOUT_PART_TYPE_SWALLOW)
488 content = efl_content_get(part_obj);
489 else
490 {
491 content = part_obj;
492 if (strstr(part, "left"))
493 dir |= LEFT;
494 else if (strstr(part, "right"))
495 dir |= RIGHT;
496 if (strstr(part, "top"))
497 dir |= TOP;
498 else if (strstr(part, "bottom"))
499 dir |= BOTTOM;
500 }
501 wheel_object_internal(content, dir, horiz, down);
502 if (efl_isa(content, EFL_LAYOUT_SIGNAL_INTERFACE))
503 edje_object_message_signal_process(content);
504 edje_object_message_signal_process(obj);
505 efl_unref(part_obj);
506}
507
460void 508void
461event_callback_that_is_called_exactly_one_time_and_sets_a_single_int_data_pointer_when_called(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 509event_callback_that_is_called_exactly_one_time_and_sets_a_single_int_data_pointer_when_called(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
462{ 510{
@@ -480,3 +528,11 @@ click_object_at(Eo *obj, int x, int y)
480 evas_event_feed_mouse_down(e, 1, 0, 0, NULL); 528 evas_event_feed_mouse_down(e, 1, 0, 0, NULL);
481 evas_event_feed_mouse_up(e, 1, 0, 0, NULL); 529 evas_event_feed_mouse_up(e, 1, 0, 0, NULL);
482} 530}
531
532void
533wheel_object_at(Eo *obj, int x, int y, Eina_Bool horiz, Eina_Bool down)
534{
535 Evas *e = evas_object_evas_get(obj);
536 evas_event_feed_mouse_move(e, x, y, 0, NULL);
537 evas_event_feed_mouse_wheel(e, horiz, down, 0, NULL);
538}
diff --git a/src/tests/elementary/suite_helpers.h b/src/tests/elementary/suite_helpers.h
index a063869f2b..26cadf1c79 100644
--- a/src/tests/elementary/suite_helpers.h
+++ b/src/tests/elementary/suite_helpers.h
@@ -14,6 +14,9 @@ void get_me_to_those_events(Eo *obj);
14void click_object(Eo *obj); 14void click_object(Eo *obj);
15void click_part(Eo *obj, const char *part); 15void click_part(Eo *obj, const char *part);
16void click_object_at(Eo *obj, int x, int y); 16void click_object_at(Eo *obj, int x, int y);
17void wheel_object(Eo *obj, Eina_Bool horiz, Eina_Bool down);
18void wheel_part(Eo *obj, const char *part, Eina_Bool horiz, Eina_Bool down);
19void wheel_object_at(Eo *obj, int x, int y, Eina_Bool horiz, Eina_Bool down);
17void event_callback_that_is_called_exactly_one_time_and_sets_a_single_int_data_pointer_when_called(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED); 20void event_callback_that_is_called_exactly_one_time_and_sets_a_single_int_data_pointer_when_called(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED);
18void event_callback_that_quits_the_main_loop_when_called(); 21void event_callback_that_quits_the_main_loop_when_called();
19#endif 22#endif