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); _tytest_arg_get(buf, &value);
ev.flags = 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); termio_internal_mouse_down(sd, &ev, modifiers);
} }
@ -156,6 +159,9 @@ _handle_mouse_up(Termpty *ty,
_tytest_arg_get(buf, &value); _tytest_arg_get(buf, &value);
ev.flags = 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); termio_internal_mouse_up(sd, &ev, modifiers);
} }
@ -182,6 +188,9 @@ _handle_mouse_move(Termpty *ty,
/* MODIFIERS */ /* MODIFIERS */
_tytest_modifiers_get(buf, &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); termio_internal_mouse_move(sd, &ev, modifiers);
} }
@ -217,6 +226,9 @@ _handle_mouse_wheel(Termpty *ty,
/* MODIFIERS */ /* MODIFIERS */
_tytest_modifiers_get(buf, &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); termio_internal_mouse_wheel(sd, &ev, modifiers);
} }

View File

@ -3,6 +3,8 @@
static const char *_cursor_shape = "undefined"; static const char *_cursor_shape = "undefined";
static Evas_Textgrid_Cell *_cells; static Evas_Textgrid_Cell *_cells;
static int _mx;
static int _my;
typedef struct _Termpty_Tests 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 static void
_termpty_to_termpty_tests(Termpty *ty, Termpty_Tests *tt) _termpty_to_termpty_tests(Termpty *ty, Termpty_Tests *tt)
{ {

View File

@ -2,7 +2,7 @@
#define _TYTEST_H__ 1 #define _TYTEST_H__ 1
#if defined(ENABLE_TESTS) #if defined(ENABLE_TESTS)
#define evas_object_textgrid_palette_get test_textgrid_palette_get #define evas_object_textgrid_palette_get test_textgrid_palette_get
void void
test_textgrid_palette_get(const Evas_Object *obj, test_textgrid_palette_get(const Evas_Object *obj,
Evas_Textgrid_Palette pal, Evas_Textgrid_Palette pal,
@ -12,9 +12,18 @@ test_textgrid_palette_get(const Evas_Object *obj,
int *b, int *b,
int *a); int *a);
#define evas_object_textgrid_cellrow_get test_textgrid_cellrow_get #define evas_object_textgrid_cellrow_get test_textgrid_cellrow_get
Evas_Textgrid_Cell * Evas_Textgrid_Cell *
test_textgrid_cellrow_get(Evas_Object *obj, int y); 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 void
tytest_termio_resize(int w, int h); tytest_termio_resize(int w, int h);