exactness: Initial version of recording lib.

TODO: Need to refine, clean code. TODO: Later fix tests issues.

Signed-off-by: Aharon Hillel <a.hillel@partner.samsung.com>

SVN revision: 67921
devs/tasn/jenkins
Aharon Hillel 11 years ago committed by Tom Hacohen
parent 9c25a64c18
commit 034738063c
  1. 337
      src/bin/tsuite.c
  2. 8
      src/bin/tsuite.h
  3. 486
      src/lib/tsuite_evas_hook.c
  4. 27
      src/lib/tsuite_file_data.c
  5. 30
      src/lib/tsuite_file_data.h

@ -4,7 +4,6 @@
#include <Elementary.h>
#include "tsuite.h"
#define IMAGE_FILENAME_EXT ".png"
#include <dlfcn.h>
#include "tsuite_file_data.h"
#include <Ecore.h>
@ -105,24 +104,6 @@ void test_tooltip2(void);
static Lists_st *vr_list = NULL;
/* END - Some globals - may want to move these to Timer_Data struct later */
/**
* @internal
*
* @struct _Tsuite_Data
* Struct holds test-suite data-properties
*
* @ingroup Tsuite
*/
struct _Tsuite_Data
{
char *name; /**< Test Name */
int serial; /**< Serial number of currnen-file */
api_data *api;
Evas *e;
Evas_Object *win;
};
typedef struct _Tsuite_Data Tsuite_Data;
/**
* @internal
*
@ -139,9 +120,14 @@ struct _Test_Item
};
typedef struct _Test_Item Test_Item;
static Tsuite_Data ts;
/* static Tsuite_Data ts; moved to tsuite_evas_hook */
static int recording = 0;
static char *dest_dir = NULL;
void
tsuite_init(Evas_Object *win, char *name, api_data *d)
{
return;
}
Eina_List *
_add_test(Eina_List *list, char *n, void (* f) (void), Eina_Bool t)
@ -179,7 +165,7 @@ _init_recording_funcs(void)
_tsuite_evas_hook_init = dlsym(RTLD_DEFAULT, "tsuite_evas_hook_init");
_tsuite_evas_hook_reset = dlsym(RTLD_DEFAULT, "tsuite_evas_hook_reset");
}
#if 0
/**
* @internal
*
@ -234,12 +220,12 @@ tsuite_cleanup(void)
memset(&ts, 0, sizeof(ts));
}
char *tsuite_test_name_get()
{
return ts.name;
}
#endif
#if 0 /* moved to tsuite_evas_hook */
/**
* @internal
*
@ -305,274 +291,15 @@ tsuite_shot_do(Evas_Object *obj, char *name)
ecore_evas_free(ee);
free(filename);
}
static unsigned int
evt_time_get(unsigned int tm, Variant_st *v)
{
switch(tsuite_event_mapping_type_get(v->t.type))
{
case TSUITE_EVENT_MOUSE_IN:
{
mouse_in_mouse_out *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MOUSE_OUT:
{
mouse_in_mouse_out *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MOUSE_DOWN:
{
mouse_down_mouse_up *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MOUSE_UP:
{
mouse_down_mouse_up *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MOUSE_MOVE:
{
mouse_move *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MOUSE_WHEEL:
{
mouse_wheel *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MULTI_DOWN:
{
multi_event *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MULTI_UP:
{
multi_event *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MULTI_MOVE:
{
multi_move *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_KEY_DOWN:
{
key_down_key_up *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_KEY_UP:
{
key_down_key_up *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_TAKE_SHOT:
{
take_screenshot *t = v->data;
return t->timestamp;
}
default: /* All non-input events are not handeled */
return tm;
break;
}
}
static Eina_Bool
tsuite_feed_event(void *data)
{
static Ecore_Timer *tmr = NULL;
Timer_Data *td = data;
time_t evt_time;
if (!td)
return ECORE_CALLBACK_CANCEL;
Variant_st *v = eina_list_data_get(td->current_event);
switch(tsuite_event_mapping_type_get(v->t.type))
{
case TSUITE_EVENT_MOUSE_IN:
{
mouse_in_mouse_out *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_mouse_in timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_mouse_in(td->e, time(NULL), NULL);
break;
}
case TSUITE_EVENT_MOUSE_OUT:
{
mouse_in_mouse_out *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_mouse_out timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_mouse_out(td->e, time(NULL), NULL);
break;
}
case TSUITE_EVENT_MOUSE_DOWN:
{
mouse_down_mouse_up *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_mouse_down timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_mouse_down(td->e, t->b, t->flags, time(NULL),
NULL);
break;
}
case TSUITE_EVENT_MOUSE_UP:
{
mouse_down_mouse_up *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_mouse_up timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_mouse_up(td->e, t->b, t->flags, time(NULL),
NULL);
break;
}
case TSUITE_EVENT_MOUSE_MOVE:
{
mouse_move *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_mouse_move (x,y)=(%d,%d) timestamp=<%u>\n", __func__, t->x, t->y, t->timestamp);
#endif
evas_event_feed_mouse_move(td->e, t->x, t->y, time(NULL), NULL);
break;
}
case TSUITE_EVENT_MOUSE_WHEEL:
{
mouse_wheel *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_mouse_wheel timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_mouse_wheel(td->e, t->direction, t->z,
time(NULL), NULL);
break;
}
case TSUITE_EVENT_MULTI_DOWN:
{
multi_event *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_multi_down timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_multi_down(td->e, t->d, t->x, t->y, t->rad,
t->radx, t->rady, t->pres, t->ang, t->fx, t->fy,
t->flags, time(NULL), NULL);
break;
}
case TSUITE_EVENT_MULTI_UP:
{
multi_event *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_multi_up timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_multi_up(td->e, t->d, t->x, t->y, t->rad,
t->radx, t->rady, t->pres, t->ang, t->fx, t->fy,
t->flags, time(NULL), NULL);
break;
}
case TSUITE_EVENT_MULTI_MOVE:
{
multi_move *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_multi_move timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_multi_move(td->e, t->d, t->x, t->y, t->rad,
t->radx, t->rady, t->pres, t->ang, t->fx, t->fy,
time(NULL), NULL);
break;
}
case TSUITE_EVENT_KEY_DOWN:
{
key_down_key_up *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_key_down timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_key_down(td->e, t->keyname, t->key, t->string,
t->compose, time(NULL), NULL);
break;
}
case TSUITE_EVENT_KEY_UP:
{
key_down_key_up *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_key_up timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_key_up(td->e, t->keyname, t->key, t->string,
t->compose, time(NULL), NULL);
break;
}
case TSUITE_EVENT_TAKE_SHOT:
{
take_screenshot *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s take shot timestamp=<%u>\n", __func__, t->timestamp);
#endif
tsuite_shot_do(ts.win, NULL); /* Serial name based on test-name */
break;
}
default: /* All non-input events are not handeled */
evt_time = td->recent_event_time;
break;
}
double timer_time;
td->current_event = eina_list_next(td->current_event);
if (!td->current_event)
{ /* Finished reading all events */
elm_exit();
return ECORE_CALLBACK_CANCEL;
}
td->recent_event_time = evt_time;
unsigned int current_event_time = evt_time_get(evt_time, eina_list_data_get(td->current_event));
if (current_event_time < td->recent_event_time) /* Could happen with refeed event */
current_event_time = td->recent_event_time;
#ifdef DEBUG_TSUITE
printf("%s td->recent_event_time=<%u> current_event_time=<%u>\n", __func__, td->recent_event_time, current_event_time);
#endif
timer_time = (current_event_time - td->recent_event_time) / 1000.0;
if (!td->recent_event_time)
timer_time = 0.0;
#ifdef DEBUG_TSUITE
printf("%s timer_time=<%f>\n", __func__, timer_time);
#endif
tmr = ecore_timer_add(timer_time, tsuite_feed_event, td);
return ECORE_CALLBACK_CANCEL;
}
void
_test_close_win(void *data __UNUSED__, Evas_Object *obj __UNUSED__,
void *event_info __UNUSED__)
{
ts.win = NULL;
// ts.win = NULL;
elm_exit();
}
#if 0 /* Moved to tsuite_file_data */
static Lists_st *
free_events(Lists_st *st)
{
@ -599,26 +326,26 @@ free_events(Lists_st *st)
free(st); /* Allocated when reading data from EET file */
return NULL;
}
#endif
void
do_test(char *rec_dir, void (* func) (void))
{
char buf[1024];
char appname[1024];
vr_list = calloc(1, sizeof(*vr_list));
if (recording)
_tsuite_evas_hook_init(vr_list);
// vr_list = calloc(1, sizeof(*vr_list));
/* if (recording) done now in ecore_init() hook
_tsuite_evas_hook_init(vr_list); */
if (func)
{ /* Regular test with access func */
func();
sprintf(buf, "%s/%s.rec", rec_dir, ts.name);
sprintf(buf, "%s/%s.rec", rec_dir, "ts.name");
}
else
{ /* Application, compose rec-file path and fulll appname */
sprintf(buf, "%s/%s.rec", rec_dir, basename(ts.name));
sprintf(buf, "%s/%s.rec", rec_dir, "basename(ts.name)");
#if 0
if (basename(ts.name) == ts.name)
{ /* No PATH given, use cwd */
getcwd(appname, 1024);
@ -626,7 +353,8 @@ do_test(char *rec_dir, void (* func) (void))
strcat(appname, ts.name);
}
else
strcpy(appname, ts.name); /* PATH incuded in ts.name */
#endif
strcpy(appname, "ts.name"); /* PATH incuded in ts.name */
}
if (recording)
@ -641,13 +369,15 @@ do_test(char *rec_dir, void (* func) (void))
system(appname);
}
if (vr_list)
write_events(buf, vr_list);
/* if (vr_list)
write_events(buf, vr_list); */
}
else
{
Timer_Data *td = NULL;
if (func)
elm_run(); /* run the program now and handle all events etc */
#if 0
td = calloc(1, sizeof(Timer_Data));
#ifdef DEBUG_TSUITE
printf("rec file is <%s>\n", buf);
@ -667,16 +397,17 @@ do_test(char *rec_dir, void (* func) (void))
}
}
#endif
if (td)
free(td);
}
if (recording)
_tsuite_evas_hook_reset();
/* if (recording) done in ecore_shutdown() hook now
_tsuite_evas_hook_reset(); */
if (vr_list)
vr_list = free_events(vr_list);
/* if (vr_list) will be done in tsuite_evas_hook_reset()
vr_list = free_events(vr_list); */
}
EAPI int
@ -767,9 +498,9 @@ elm_main(int argc, char **argv)
elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
elm_app_info_set(elm_main, "elementary", "images/logo.png");
if (opt_destdir)
/* if (opt_destdir)
dest_dir = opt_destdir->data;
*/
if (opt_basedir)
rec_dir = opt_basedir->data;
@ -954,7 +685,7 @@ elm_main(int argc, char **argv)
EINA_LIST_FREE(tests, data)
free(data);
tsuite_cleanup();
// tsuite_cleanup();
/* if the mainloop that elm_run() runs exist - we exit the app */
elm_shutdown(); /* clean up and shut down */

@ -48,11 +48,11 @@ _test_close_win(void *data, Evas_Object *obj, void *event_info);
}
#define TEST_SHOT(x) \
tsuite_shot_do(win, x)
tsuite_shot_do(x)
void tsuite_init(Evas_Object *win, char *name, api_data *d);
void tsuite_cleanup(void);
void tsuite_shot_do(Evas_Object *obj, char *name);
void tsuite_shot_do(char *name);
char *tsuite_test_name_get();
Eina_Bool write_events_get(void);
void write_events_set(Eina_Bool val);
@ -99,7 +99,7 @@ struct _Variant_st
* for the field*/
};
typedef struct _Variant_st Variant_st;
/* Moved to tsuite_file_data.h
struct _Timer_Data
{
Eet_File *fp;
@ -108,6 +108,6 @@ struct _Timer_Data
Eina_List *current_event;
};
typedef struct _Timer_Data Timer_Data;
*/
void variant_list_append(Variant_st *v);
#endif

@ -10,7 +10,10 @@
#include "tsuite_file_data.h"
#include "tsuite.h"
#define TSUITE_MAX_PATH 1024
#define SHOT_KEY_STR "F2"
#define IMAGE_FILENAME_EXT ".png"
#define DEBUG_TSUITE 1
/* START - EET Handling code */
struct _Eet_Event_Type
{
@ -25,13 +28,230 @@ struct _evas_hook_setting
char *base_dir;
char *dest_dir;
char *test_name;
/* TODO: What about api-data? currently freed in tsuite_cleanup() */
char *file_name;
};
typedef struct _evas_hook_setting evas_hook_setting;
static char *shot_key = SHOT_KEY_STR;
static Lists_st *vr_list = NULL;
static evas_hook_setting *_hook_setting = NULL;
static Tsuite_Data ts;
/**
* @internal
*
* This function initiates Tsuite_Data
* @param name defines test-name
* @param Pointer_Event Pointer to PE.
*
* @ingroup Tsuite
*/
static unsigned int
evt_time_get(unsigned int tm, Variant_st *v)
{
switch(tsuite_event_mapping_type_get(v->t.type))
{
case TSUITE_EVENT_MOUSE_IN:
{
mouse_in_mouse_out *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MOUSE_OUT:
{
mouse_in_mouse_out *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MOUSE_DOWN:
{
mouse_down_mouse_up *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MOUSE_UP:
{
mouse_down_mouse_up *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MOUSE_MOVE:
{
mouse_move *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MOUSE_WHEEL:
{
mouse_wheel *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MULTI_DOWN:
{
multi_event *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MULTI_UP:
{
multi_event *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_MULTI_MOVE:
{
multi_move *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_KEY_DOWN:
{
key_down_key_up *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_KEY_UP:
{
key_down_key_up *t = v->data;
return t->timestamp;
}
case TSUITE_EVENT_TAKE_SHOT:
{
take_screenshot *t = v->data;
return t->timestamp;
}
default: /* All non-input events are not handeled */
return tm;
break;
}
}
void
tsuite_init(Evas_Object *win, char *name, api_data *d)
{
tsuite_cleanup();
if (!name)
return;
ts.name = strdup(name); /* Freed by tsuite_cleanup */
ts.win = win;
if (d)
{ /* This field is not used when testing APPs */
ts.api = d;
ts.api->win = win;
}
ts.e = evas_object_evas_get(ts.win);
}
/**
* @internal
*
* This function do cleanup for Tsuite
* @param Tsuite_Data * data for cleanup.
*
* @ingroup Tsuite
*/
void
tsuite_cleanup(void)
{
if (ts.name)
free(ts.name);
if (ts.api)
{
if (ts.api->data && ts.api->free_data)
free(ts.api->data);
free(ts.api);
}
/* if (ts.win)
evas_object_del(ts.win);
*/
memset(&ts, 0, sizeof(ts));
}
EAPI void
tsuite_evas_hook_init(void)
{ /* Pointer taken from tsuite.c */
shot_key = getenv("TSUITE_SHOT_KEY");
if (!shot_key) shot_key = SHOT_KEY_STR;
if (!vr_list)
vr_list = calloc(1, sizeof(*vr_list));
}
EAPI void
tsuite_evas_hook_reset(void)
{ /* tsuite.c informs us that vr_list is no longer valid */
if (vr_list)
vr_list = free_events(vr_list, _hook_setting->recording);
}
/**
* @internal
*
* This function takes actual shot and saves it in PNG
* @param data Tsuite_Data pointer initiated by user
* @param obj Window pointer
* @param obj name file name. Will use name_+serial if NULL
*
* @ingroup Tsuite
*/
void
tsuite_shot_do(char *name)
{
printf("<%s> --- 1 ---\n", __func__);
if (!ts.e)
return;
printf("<%s> --- 2 ---\n", __func__);
Ecore_Evas *ee, *ee_orig;
Evas_Object *o;
unsigned int *pixels;
int w, h,dir_name_len = 0;
char *filename;
if (_hook_setting->dest_dir)
dir_name_len = strlen(_hook_setting->dest_dir) + 1; /* includes space of a '/' */
if (name)
{
filename = malloc(strlen(name) + strlen(IMAGE_FILENAME_EXT) +
dir_name_len + 4);
if (_hook_setting->dest_dir)
sprintf(filename, "%s/", _hook_setting->dest_dir);
sprintf(filename + dir_name_len, "%s%s", name, IMAGE_FILENAME_EXT);
}
else
{
filename = malloc(strlen(ts.name) + strlen(IMAGE_FILENAME_EXT) +
dir_name_len + 8); /* also space for serial */
ts.serial++;
if (_hook_setting->dest_dir)
sprintf(filename, "%s/", _hook_setting->dest_dir);
sprintf(filename + dir_name_len, "%s_%d%s", ts.name ,ts.serial,
IMAGE_FILENAME_EXT);
}
printf("<%s> file=<%s>--- 3 ---\n", __func__, filename);
/* A bit hackish, get the ecore_evas from the Evas canvas */
ee_orig = evas_data_attach_get(ts.e);
ecore_evas_manual_render(ee_orig);
pixels = (void *)ecore_evas_buffer_pixels_get(ee_orig);
if (!pixels) return;
ecore_evas_geometry_get(ee_orig, NULL, NULL, &w, &h);
if ((w < 1) || (h < 1)) return;
ee = ecore_evas_buffer_new(1, 1);
o = evas_object_image_add(ecore_evas_get(ee));
evas_object_image_alpha_set(o, ecore_evas_alpha_get(ee_orig));
evas_object_image_size_set(o, w, h);
evas_object_image_data_set(o, pixels);
if (!evas_object_image_save(o, filename, NULL, NULL))
{
printf("Cannot save widget to <%s>\n", filename);
}
ecore_evas_free(ee);
free(filename);
}
EAPI int
ecore_init(void)
@ -42,12 +262,23 @@ ecore_init(void)
printf("<%s> Calling %s\n", __FILE__, __func__);
if (!_hook_setting)
{
printf("<%s> TSUITE_INI! %s\n", __FILE__, __func__);
_hook_setting = calloc(1, sizeof(evas_hook_setting));
_hook_setting->recording = getenv("TSUITE_RECORDING");
_hook_setting->base_dir = getenv("TSUITE_BASE_DIR");
_hook_setting->dest_dir = getenv("TSUITE_DEST_DIR");
_hook_setting->test_name = getenv("TSUITE_TEST_NAME");
_hook_setting->file_name = getenv("TSUITE_FILE_NAME");
printf("<%s> test_name=<%s>\n", __func__, _hook_setting->test_name);
printf("<%s> base_dir=<%s>\n", __func__, _hook_setting->base_dir);
printf("<%s> dest_dir=<%s>\n", __func__, _hook_setting->dest_dir);
printf("<%s> recording=<%s>\n", __func__, _hook_setting->recording);
printf("<%s> rec file is <%s>\n", __func__, _hook_setting->file_name);
if (_hook_setting->recording)
tsuite_evas_hook_init();
printf("<%s> TSUITE_INI! %s\n", __FILE__, __func__);
}
return _ecore_init();
@ -62,11 +293,20 @@ ecore_shutdown(void)
printf("<%s> Calling %s\n", __FILE__, __func__);
if (_hook_setting)
{
printf("<%s> TSUITE_SHUTDOWN! %s\n", __FILE__, __func__);
if (vr_list && _hook_setting->recording)
write_events(_hook_setting->file_name, vr_list);
tsuite_evas_hook_reset();
free(_hook_setting);
_hook_setting = NULL;
printf("<%s> TSUITE_SHUTDOWN! %s\n", __FILE__, __func__);
}
if (ts.td)
free(ts.td);
tsuite_cleanup();
return _ecore_shutdown();
}
@ -76,8 +316,213 @@ evas_new(void)
Evas * (*_evas_new)(void) =
dlsym(RTLD_NEXT, "evas_new");
ts.e = _evas_new();
printf("<%s> Calling %s\n", __FILE__, __func__);
return ts.e;
}
Evas_Object *
elm_win_add(Evas_Object *parent, const char *name, Elm_Win_Type type)
{
printf("<%s> Calling %s\n", __FILE__, __func__);
return _evas_new();
Evas_Object * (*_elm_win_add)(Evas_Object *, const char*, Elm_Win_Type) =
dlsym(RTLD_NEXT, "elm_win_add");
Evas_Object *win = _elm_win_add(parent, name, type);
ts.name = strdup(name); /* Freed by tsuite_cleanup */
ts.win = win;
// ts.e = evas_object_evas_get(ts.win);
return win;
}
static Eina_Bool
tsuite_feed_event(void *data)
{
static Ecore_Timer *tmr = NULL;
Timer_Data *td = data;
time_t evt_time;
if (!td)
return ECORE_CALLBACK_CANCEL;
Variant_st *v = eina_list_data_get(td->current_event);
switch(tsuite_event_mapping_type_get(v->t.type))
{
case TSUITE_EVENT_MOUSE_IN:
{
mouse_in_mouse_out *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_mouse_in timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_mouse_in(td->e, time(NULL), NULL);
break;
}
case TSUITE_EVENT_MOUSE_OUT:
{
mouse_in_mouse_out *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_mouse_out timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_mouse_out(td->e, time(NULL), NULL);
break;
}
case TSUITE_EVENT_MOUSE_DOWN:
{
mouse_down_mouse_up *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_mouse_down timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_mouse_down(td->e, t->b, t->flags, time(NULL),
NULL);
break;
}
case TSUITE_EVENT_MOUSE_UP:
{
mouse_down_mouse_up *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_mouse_up timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_mouse_up(td->e, t->b, t->flags, time(NULL),
NULL);
break;
}
case TSUITE_EVENT_MOUSE_MOVE:
{
mouse_move *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_mouse_move (x,y)=(%d,%d) timestamp=<%u>\n", __func__, t->x, t->y, t->timestamp);
#endif
evas_event_feed_mouse_move(td->e, t->x, t->y, time(NULL), NULL);
break;
}
case TSUITE_EVENT_MOUSE_WHEEL:
{
mouse_wheel *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_mouse_wheel timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_mouse_wheel(td->e, t->direction, t->z,
time(NULL), NULL);
break;
}
case TSUITE_EVENT_MULTI_DOWN:
{
multi_event *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_multi_down timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_multi_down(td->e, t->d, t->x, t->y, t->rad,
t->radx, t->rady, t->pres, t->ang, t->fx, t->fy,
t->flags, time(NULL), NULL);
break;
}
case TSUITE_EVENT_MULTI_UP:
{
multi_event *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_multi_up timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_multi_up(td->e, t->d, t->x, t->y, t->rad,
t->radx, t->rady, t->pres, t->ang, t->fx, t->fy,
t->flags, time(NULL), NULL);
break;
}
case TSUITE_EVENT_MULTI_MOVE:
{
multi_move *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_multi_move timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_multi_move(td->e, t->d, t->x, t->y, t->rad,
t->radx, t->rady, t->pres, t->ang, t->fx, t->fy,
time(NULL), NULL);
break;
}
case TSUITE_EVENT_KEY_DOWN:
{
key_down_key_up *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_key_down timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_key_down(td->e, t->keyname, t->key, t->string,
t->compose, time(NULL), NULL);
break;
}
case TSUITE_EVENT_KEY_UP:
{
key_down_key_up *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s evas_event_feed_key_up timestamp=<%u>\n", __func__, t->timestamp);
#endif
evas_event_feed_key_up(td->e, t->keyname, t->key, t->string,
t->compose, time(NULL), NULL);
break;
}
case TSUITE_EVENT_TAKE_SHOT:
{
take_screenshot *t = v->data;
evt_time = t->timestamp;
#ifdef DEBUG_TSUITE
printf("%s take shot timestamp=<%u>\n", __func__, t->timestamp);
#endif
tsuite_shot_do(NULL); /* Serial name based on test-name */
break;
}
default: /* All non-input events are not handeled */
evt_time = td->recent_event_time;
break;
}
double timer_time;
td->current_event = eina_list_next(td->current_event);
if (!td->current_event)
{ /* Finished reading all events */
elm_exit();
return ECORE_CALLBACK_CANCEL;
}
td->recent_event_time = evt_time;
unsigned int current_event_time = evt_time_get(evt_time, eina_list_data_get(td->current_event));
if (current_event_time < td->recent_event_time) /* Could happen with refeed event */
current_event_time = td->recent_event_time;
#ifdef DEBUG_TSUITE
printf("%s td->recent_event_time=<%u> current_event_time=<%u>\n", __func__, td->recent_event_time, current_event_time);
#endif
timer_time = (current_event_time - td->recent_event_time) / 1000.0;
if (!td->recent_event_time)
timer_time = 0.0;
#ifdef DEBUG_TSUITE
printf("%s timer_time=<%f>\n", __func__, timer_time);
#endif
tmr = ecore_timer_add(timer_time, tsuite_feed_event, td);
return ECORE_CALLBACK_CANCEL;
}
void
@ -86,31 +531,28 @@ ecore_main_loop_begin(void)
void (*_ecore_main_loop_begin)(void) =
dlsym(RTLD_NEXT, "ecore_main_loop_begin");
printf("<%s> Calling %s\n", __FILE__, __func__);
return _ecore_main_loop_begin();
}
EAPI void
tsuite_evas_hook_init(void)
{ /* Pointer taken from tsuite.c */
vr_list = calloc(1, sizeof(*vr_list));
shot_key = getenv("TSUITE_SHOT_KEY");
if (!shot_key) shot_key = SHOT_KEY_STR;
}
EAPI void
tsuite_evas_hook_reset(void)
{ /* tsuite.c informs us that vr_list is no longer valid */
if (vr_list)
free(vr_list);
if (!_hook_setting->recording && _hook_setting->file_name)
{
ts.td = calloc(1, sizeof(Timer_Data));
#ifdef DEBUG_TSUITE
printf("<%s> rec file is <%s>\n", _hook_setting->file_name);
#endif
vr_list = read_events(_hook_setting->file_name, ts.e, ts.td);
if (ts.td->current_event)
{ /* Got first event in list, run test */
tsuite_feed_event(ts.td);
}
}
vr_list = NULL;
printf("<%s> Calling %s\n", __FILE__, __func__);
return _ecore_main_loop_begin();
}
/* Adding variant to list, this list is later written to EET file */
#define ADD_TO_LIST(EVT_TYPE, EVT_STRUCT_NAME, INFO) \
do { /* This macro will add event to EET data list */ \
if (vr_list) \
if (vr_list && _hook_setting->recording) \
{ \
Variant_st *v = malloc(sizeof(Variant_st)); \
v->data = malloc(sizeof(EVT_STRUCT_NAME)); \

@ -48,6 +48,33 @@ tsuite_event_mapping_type_str_get(Tsuite_Event_Type t)
return NULL;
}
Lists_st *
free_events(Lists_st *st, char *recording)
{
Variant_st *v;
EINA_LIST_FREE(st->variant_list, v)
{
if (recording)
{
Tsuite_Event_Type e = tsuite_event_mapping_type_get(v->t.type);
if ((e == TSUITE_EVENT_KEY_DOWN) || (e == TSUITE_EVENT_KEY_UP))
{ /* Allocated in tsuite_evas_hook.c */
key_down_key_up *t = v->data;
eina_stringshare_del(t->keyname);
eina_stringshare_del(t->key);
eina_stringshare_del(t->string);
eina_stringshare_del(t->compose);
}
}
free(v->data);
free(v);
}
free(st); /* Allocated when reading data from EET file */
return NULL;
}
void
write_events(const char *filename, Lists_st *vr_list)
{

@ -5,6 +5,34 @@
#define CACHE_FILE_ENTRY "cache"
struct _Timer_Data
{
Eet_File *fp;
unsigned int recent_event_time;
Evas *e;
Eina_List *current_event;
};
typedef struct _Timer_Data Timer_Data;
/**
* @internal
*
* @struct _Tsuite_Data
* Struct holds test-suite data-properties
*
* @ingroup Tsuite
*/
struct _Tsuite_Data
{
char *name; /**< Test Name */
int serial; /**< Serial number of currnen-file */
api_data *api;
Evas *e;
Evas_Object *win;
Timer_Data *td;
};
typedef struct _Tsuite_Data Tsuite_Data;
struct _mouse_in_mouse_out
{
unsigned int timestamp;
@ -94,7 +122,6 @@ typedef struct _mouse_in_mouse_out take_screenshot;
#define TSUITE_EVENT_KEY_UP_STR "tsuite_event_key_up"
#define TSUITE_EVENT_TAKE_SHOT_STR "tsuite_event_take_shot"
struct _Lists_st
{
Eina_List *variant_list;
@ -138,6 +165,7 @@ const char * tsuite_event_mapping_type_str_get(Tsuite_Event_Type t);
const char * _variant_type_get(const void *data, Eina_Bool *unknow);
Eina_Bool _variant_type_set(const char *type, void *data, Eina_Bool unknow);
Lists_st * free_events(Lists_st *st, char *recording);
void write_events(const char *filename, Lists_st *vr_list);
Lists_st *read_events(char *filename, Evas *e, Timer_Data *td);
#endif

Loading…
Cancel
Save