tests: store mouse pointer and fallback evas_pointer_canvas_xy_get()

This commit is contained in:
Boris Faure 2020-05-03 12:25:14 +02:00
parent 0df36aefc9
commit 00bb99f3f0
Signed by: borisfaure
GPG Key ID: 35C0410516166BE8
3 changed files with 42 additions and 2 deletions

View File

@ -122,6 +122,9 @@ _handle_mouse_down(Termpty *ty,
_tytest_arg_get(buf, &value);
ev.flags = value;
#if defined(ENABLE_TESTS)
test_set_mouse_pointer(ev.canvas.x, ev.canvas.y);
#endif
termio_internal_mouse_down(sd, &ev, modifiers);
}
@ -156,6 +159,9 @@ _handle_mouse_up(Termpty *ty,
_tytest_arg_get(buf, &value);
ev.flags = value;
#if defined(ENABLE_TESTS)
test_set_mouse_pointer(ev.canvas.x, ev.canvas.y);
#endif
termio_internal_mouse_up(sd, &ev, modifiers);
}
@ -182,6 +188,9 @@ _handle_mouse_move(Termpty *ty,
/* MODIFIERS */
_tytest_modifiers_get(buf, &modifiers);
#if defined(ENABLE_TESTS)
test_set_mouse_pointer(ev.cur.canvas.x, ev.cur.canvas.y);
#endif
termio_internal_mouse_move(sd, &ev, modifiers);
}
@ -217,6 +226,9 @@ _handle_mouse_wheel(Termpty *ty,
/* MODIFIERS */
_tytest_modifiers_get(buf, &modifiers);
#if defined(ENABLE_TESTS)
test_set_mouse_pointer(ev.canvas.x, ev.canvas.y);
#endif
termio_internal_mouse_wheel(sd, &ev, modifiers);
}

View File

@ -3,6 +3,8 @@
static const char *_cursor_shape = "undefined";
static Evas_Textgrid_Cell *_cells;
static int _mx;
static int _my;
typedef struct _Termpty_Tests
{
@ -71,6 +73,23 @@ termio_set_cursor_shape(Evas_Object *obj EINA_UNUSED,
}
}
void
test_set_mouse_pointer(int mx, int my)
{
_mx = mx;
_my = my;
}
void
test_pointer_canvas_xy_get(const Evas *e EINA_UNUSED,
int *mx, int *my)
{
if (mx)
*mx = _mx;
if (my)
*my = _my;
}
static void
_termpty_to_termpty_tests(Termpty *ty, Termpty_Tests *tt)
{

View File

@ -15,6 +15,15 @@ test_textgrid_palette_get(const Evas_Object *obj,
#define evas_object_textgrid_cellrow_get test_textgrid_cellrow_get
Evas_Textgrid_Cell *
test_textgrid_cellrow_get(Evas_Object *obj, int y);
#define evas_pointer_canvas_xy_get test_pointer_canvas_xy_get
void
test_pointer_canvas_xy_get(const Evas *e,
int *mx,
int *my);
void test_set_mouse_pointer(int mx, int my);
void
tytest_termio_resize(int w, int h);