From 73f461e28101873c64fb63ebc011de4dacadfc79 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Mon, 11 Feb 2019 22:44:16 +0100 Subject: [PATCH] tytest: add test_textgrid_cellrow_get() to mock evas_object_textgrid_cellrow_get() --- src/bin/tyfuzz.c | 9 +++++++++ src/bin/tytest.c | 24 +++++++++++++++++++++++- src/bin/tytest.h | 8 ++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/bin/tyfuzz.c b/src/bin/tyfuzz.c index db278907..9785df1d 100644 --- a/src/bin/tyfuzz.c +++ b/src/bin/tyfuzz.c @@ -262,6 +262,11 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED) eina_init(); +#ifdef TYTEST + tytest_init(); +#endif + + _log_domain = eina_log_domain_register( #ifdef TYTEST "tytest", @@ -348,6 +353,10 @@ main(int argc EINA_UNUSED, char **argv EINA_UNUSED) _termpty_shutdown(&_ty); +#ifdef TYTEST + tytest_shutdown(); +#endif + eina_shutdown(); free(_config); diff --git a/src/bin/tytest.c b/src/bin/tytest.c index 9c907bf9..bfecd047 100644 --- a/src/bin/tytest.c +++ b/src/bin/tytest.c @@ -1,7 +1,8 @@ #define TYTEST 1 #include "tyfuzz.c" -const char *_cursor_shape = "undefined"; +static const char *_cursor_shape = "undefined"; +static Evas_Textgrid_Cell *_cells; typedef struct _Termpty_Tests { @@ -151,3 +152,24 @@ _tytest_checksum(Termpty *ty) md5out[2 * MD5_HASHBYTES] = '\0'; printf("%s", md5out); } + +Evas_Textgrid_Cell * +test_textgrid_cellrow_get(Evas_Object *obj EINA_UNUSED, int y) +{ + assert (y >= 0 && y < TY_H); + return &_cells[y * TY_W]; +} + + +void +tytest_init(void) +{ + _cells = calloc(TY_H * TY_W, sizeof(Evas_Textgrid_Cell)); + assert(_cells != NULL); +} + +void +tytest_shutdown(void) +{ + free(_cells); +} diff --git a/src/bin/tytest.h b/src/bin/tytest.h index e702cec5..ad02d142 100644 --- a/src/bin/tytest.h +++ b/src/bin/tytest.h @@ -11,5 +11,13 @@ test_textgrid_palette_get(const Evas_Object *obj, int *g, int *b, int *a); + +#define evas_object_textgrid_cellrow_get test_textgrid_cellrow_get +Evas_Textgrid_Cell * +test_textgrid_cellrow_get(Evas_Object *obj, int y); + +void tytest_init(void); +void tytest_shutdown(void); + #endif #endif