meson: add tytest.{c,h} to improve testing with ENABLE_TEST_UI

This commit is contained in:
Boris Faure 2020-05-03 13:19:01 +02:00
parent 00bb99f3f0
commit 3be01d8b8b
Signed by: borisfaure
GPG Key ID: 35C0410516166BE8
5 changed files with 42 additions and 31 deletions

View File

@ -38,6 +38,7 @@ terminology_sources = ['private.h',
'extns.c', 'extns.h',
'gravatar.c', 'gravatar.h',
'tty_keys.h',
'tytest.c', 'tytest.h',
'sb.c', 'sb.h']
tybg_sources = ['tycommon.c', 'tycommon.h', 'tybg.c']

View File

@ -2009,7 +2009,11 @@ _mouse_selection_scroll(void *data)
if (!sd->pty->selection.makesel)
return EINA_FALSE;
#if defined(ENABLE_TESTS) || defined(ENABLE_TEST_UI)
test_pointer_canvas_xy_get(NULL, &my);
#else
evas_pointer_canvas_xy_get(evas_object_evas_get(sd->self), NULL, &my);
#endif
termio_object_geometry_get(sd, NULL, &oy, NULL, NULL);
fcy = (my - oy) / (float)sd->font.chh;
cy = fcy;

View File

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

View File

@ -1,10 +1,10 @@
#include "private.h"
#if defined(ENABLE_TESTS)
#define TYTEST 1
#include "tyfuzz.c"
static const char *_cursor_shape = "undefined";
static Evas_Textgrid_Cell *_cells;
static int _mx;
static int _my;
typedef struct _Termpty_Tests
{
@ -73,23 +73,6 @@ 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)
{
@ -206,3 +189,25 @@ tytest_shutdown(void)
{
free(_cells);
}
#endif
#if defined(ENABLE_TESTS) || defined(ENABLE_TEST_UI)
static int _mx;
static int _my;
void
test_set_mouse_pointer(int mx, int my)
{
_mx = mx;
_my = my;
}
void
test_pointer_canvas_xy_get(int *mx, int *my)
{
if (mx)
*mx = _mx;
if (my)
*my = _my;
}
#endif

View File

@ -16,19 +16,20 @@ test_textgrid_palette_get(const Evas_Object *obj,
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);
void tytest_init(void);
void tytest_shutdown(void);
#endif
#if defined(ENABLE_TESTS) || defined(ENABLE_TEST_UI)
void
test_pointer_canvas_xy_get(int *mx,
int *my);
void test_set_mouse_pointer(int mx, int my);
#endif
#endif
#endif