Store delays instead of timestamps in the scenario

master
Daniel Zaoui 5 years ago
parent 9c3fe1b118
commit 2858adbd8d
  1. 26
      src/bin/injector.c
  2. 23
      src/bin/inspect.c
  3. 31
      src/bin/player.c
  4. 9
      src/bin/recorder.c
  5. 2
      src/lib/Exactness.h
  6. 19
      src/lib/tsuite_file_data.c
  7. 2
      src/lib/unit.c

@ -99,7 +99,6 @@ static int _verbose = 0;
static Eina_Debug_Session *_session = NULL;
static int _cid = -1, _pid = -1;
static Eina_List *_cur_event_list = NULL;
static unsigned int _last_event_time = 0;
static int _all_apps_get_op = EINA_DEBUG_OPCODE_INVALID;
static int _mouse_in_op = EINA_DEBUG_OPCODE_INVALID;
@ -261,7 +260,6 @@ _feed_event_timer_cb(void *data EINA_UNUSED)
{
Exactness_Action *act = eina_list_data_get(_cur_event_list);
_feed_event(act->type, act->n_evas, act->data);
time_t evt_time = act->timestamp;
_cur_event_list = eina_list_next(_cur_event_list);
@ -272,21 +270,8 @@ _feed_event_timer_cb(void *data EINA_UNUSED)
}
else
{
double timer_time;
Exactness_Action *cur_act = eina_list_data_get(_cur_event_list);
unsigned int current_event_time = cur_act->timestamp;
_last_event_time = evt_time;
if (current_event_time < _last_event_time) /* Could happen with refeed event */
current_event_time = _last_event_time;
_printf(2, " %s _last_event_time=<%u> current_event_time=<%u>\n", __func__, _last_event_time, current_event_time);
timer_time = (current_event_time - _last_event_time) / 1000.0;
if (!_last_event_time) timer_time = 0.0;
_printf(2, " %s timer_time=<%f>\n", __func__, timer_time);
ecore_timer_add(timer_time, _feed_event_timer_cb, NULL);
ecore_timer_add(cur_act->delay_ms / 1000.0, _feed_event_timer_cb, NULL);
}
return ECORE_CALLBACK_CANCEL;
}
@ -309,15 +294,10 @@ _src_open()
_cur_event_list = _src_unit->actions;
Exactness_Action *act = eina_list_data_get(_cur_event_list);
/* Calculate the time to wait before feeding the first event */
unsigned int current_event_time = act->timestamp;
_printf(2, "%s current_event_time=<%u>\n", __func__, current_event_time);
if (current_event_time)
if (act->delay_ms)
{
_printf(2, " Waiting <%f>\n", diff_time);
ecore_timer_add(current_event_time / 1000.0, _feed_event_timer_cb, NULL);
ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL);
}
else
{

@ -360,8 +360,8 @@ _scn_text_get(void *data, Evas_Object *gl, const char *part EINA_UNUSED)
if (!a1 ^ !a2) return strdup("XXXXX");
if (a1->timestamp != a2->timestamp) eina_strbuf_append_printf(buf, "["LDIFF(%.3f)"/"RDIFF(%.3f)"]: ", a1->timestamp/1000.0, a2->timestamp/1000.0);
else eina_strbuf_append_printf(buf, "%.3f: ", a1->timestamp / 1000.0);
if (a1->delay_ms != a2->delay_ms) eina_strbuf_append_printf(buf, "[+"LDIFF(%.3f)"/+"RDIFF(%.3f)"]: ", a1->delay_ms/1000.0, a2->delay_ms/1000.0);
else eina_strbuf_append_printf(buf, "+%.3f: ", a1->delay_ms / 1000.0);
if (a1->type != a2->type)
eina_strbuf_append_printf(buf, "["LDIFF(%s)"/"RDIFF(%s)"] - XXXXXX", _action_name_get(a1), _action_name_get(a2));
@ -388,7 +388,7 @@ _scn_text_get(void *data, Evas_Object *gl, const char *part EINA_UNUSED)
char specific_output[1024];
if (act)
{
eina_strbuf_append_printf(buf, "%.3f: ", act->timestamp / 1000.0);
eina_strbuf_append_printf(buf, "+%.3f: ", act->delay_ms / 1000.0);
eina_strbuf_append_printf(buf, "%s", _action_name_get(act));
_action_specific_info_get(act, specific_output);
if (*specific_output) eina_strbuf_append_printf(buf, " - %s", specific_output);
@ -1247,23 +1247,15 @@ main(int argc, char *argv[])
Eina_List *itr, *itr2;
EINA_LIST_FOREACH_SAFE(unit->actions, itr, itr2, act)
{
if (!act->timestamp)
if (_is_hook_duplicate(act, eina_list_data_get(eina_list_prev(itr))))
unit->actions = eina_list_remove_list(unit->actions, itr);
else
{
if (_is_hook_duplicate(act, eina_list_data_get(eina_list_prev(itr))))
unit->actions = eina_list_remove_list(unit->actions, itr);
}
}
write_file = EINA_TRUE;
}
if (delay)
{
if (!shot)
{
}
else
if (shot)
{
Exactness_Action *act;
Eina_List *itr;
@ -1275,7 +1267,7 @@ main(int argc, char *argv[])
cur_shot++;
if (cur_shot == shot)
{
act->timestamp += delay;
act->delay_ms = delay;
break;
}
}
@ -1291,8 +1283,7 @@ main(int argc, char *argv[])
EINA_LIST_FOREACH(unit->actions, itr, act)
{
char specific_output[1024];
unsigned int timestamp = act->timestamp;
printf("%.3f: %s", timestamp / 1000.0, _action_name_get(act));
printf("+%.3f: %s", act->delay_ms / 1000.0, _action_name_get(act));
_action_specific_info_get(act, specific_output);
if (*specific_output) printf(" - %s", specific_output);
printf("\n");

@ -121,7 +121,6 @@ static int _ignore_evas_creation = 0;
static Eina_List *_evas_list = NULL;
static Eina_List *_cur_event_list = NULL;
static unsigned int _last_event_time = 0;
static int _cur_shot_id = 0;
static Eina_Bool _scan_objects = EINA_FALSE;
@ -388,7 +387,6 @@ _feed_event_timer_cb(void *data EINA_UNUSED)
{
Exactness_Action *act = eina_list_data_get(_cur_event_list);
_feed_event(act->type, act->n_evas, act->data);
time_t evt_time = act->timestamp;
_cur_event_list = eina_list_next(_cur_event_list);
@ -398,21 +396,8 @@ _feed_event_timer_cb(void *data EINA_UNUSED)
}
else
{
double timer_time;
Exactness_Action *cur_act = eina_list_data_get(_cur_event_list);
unsigned int current_event_time = cur_act->timestamp;
_last_event_time = evt_time;
if (current_event_time < _last_event_time) /* Could happen with refeed event */
current_event_time = _last_event_time;
_printf(2, " %s _last_event_time=<%u> current_event_time=<%u>\n", __func__, _last_event_time, current_event_time);
timer_time = (current_event_time - _last_event_time) / 1000.0;
if (!_last_event_time) timer_time = 0.0;
_printf(2, " %s timer_time=<%f>\n", __func__, timer_time);
ecore_timer_add(timer_time, _feed_event_timer_cb, NULL);
_printf(2, " %s timer_time=<%f>\n", __func__, act->delay_ms / 1000.0);
ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL);
}
return ECORE_CALLBACK_CANCEL;
}
@ -577,7 +562,6 @@ _src_open()
{
if (_src_type != FTYPE_REMOTE)
{
double diff_time = 0; /* Time to wait before feeding the first event */
_printf(2, "<%s> Source file is <%s>\n", __func__, _src_filename);
if (_src_type == FTYPE_EXU)
{
@ -591,15 +575,10 @@ _src_open()
_cur_event_list = _src_unit->actions;
Exactness_Action *act = eina_list_data_get(_cur_event_list);
/* Calculate the time to wait before feeding the first event */
unsigned int current_event_time = act->timestamp;
_printf(2, "%s current_event_time=<%u>\n", __func__, current_event_time);
if (current_event_time)
if (act->delay_ms)
{
_printf(2, " Waiting <%f>\n", diff_time);
ecore_timer_add(current_event_time / 1000.0, _feed_event_timer_cb, NULL);
_printf(2, " Waiting <%f>\n", act->delay_ms / 1000.0);
ecore_timer_add(act->delay_ms / 1000.0, _feed_event_timer_cb, NULL);
}
else
{

@ -39,7 +39,7 @@ static unsigned int _last_evas_id = 0;
static Exactness_Unit *_unit = NULL;
static char *_shot_key = NULL;
static unsigned int _first_timestamp = 0.0;
static unsigned int _last_timestamp = 0.0;
static void
_printf(int verbose, const char *fmt, ...)
@ -82,7 +82,7 @@ _add_to_list(Exactness_Action_Type type, unsigned int n_evas, unsigned int times
if (prev_v)
{
if (prev_v->type == type &&
prev_v->timestamp + _first_timestamp == timestamp &&
timestamp == _last_timestamp &&
prev_v->n_evas == n_evas &&
(!len || !memcmp(prev_v->data, data, len))) return;
}
@ -90,7 +90,8 @@ _add_to_list(Exactness_Action_Type type, unsigned int n_evas, unsigned int times
Exactness_Action *act = malloc(sizeof(*act));
act->type = type;
act->n_evas = n_evas;
act->timestamp = timestamp - _first_timestamp;
act->delay_ms = timestamp - _last_timestamp;
_last_timestamp = timestamp;
if (len)
{
act->data = malloc(len);
@ -472,7 +473,7 @@ int main(int argc, char **argv)
}
ecore_evas_callback_new_set(_my_evas_new);
_first_timestamp = ecore_time_get() * 1000;
_last_timestamp = ecore_time_get() * 1000;
pret = _prg_invoke(_prg_full_path_guess(argv[0]), argc - opt_args, argv);
_output_write();

@ -129,7 +129,7 @@ typedef struct
{
Exactness_Action_Type type; /**< The action type */
unsigned int n_evas; /**< The evas number on which the action has to be applied */
unsigned int timestamp; /**< The timestamp of the action */
unsigned int delay_ms; /**< The delay (in ms) to wait for this action */
void *data; /**< The specific action data */
} Exactness_Action;

@ -302,7 +302,7 @@ legacy_rec_file_read(const char *filename)
{
Lists_st *vr_list;
Eina_List *itr;
Variant_st *v;
Variant_st *v, *prev_v = NULL;
Exactness_Unit *unit = NULL;
Eet_File *fp = eet_open(filename, EET_FILE_MODE_READ);
if (!fp)
@ -323,6 +323,8 @@ legacy_rec_file_read(const char *filename)
{
Exactness_Action *act = calloc(1, sizeof(*act));
Tsuite_Event_Type old_type = tsuite_event_mapping_type_get(v->t.type);
unsigned int vtm = evt_time_get(0, v);
if (!vtm) continue;
switch (old_type)
{
case TSUITE_EVENT_MOUSE_IN:
@ -464,8 +466,21 @@ legacy_rec_file_read(const char *filename)
}
default: break;
}
act->timestamp = evt_time_get(0, v) - vr_list->first_timestamp;
if (!prev_v)
{
if (vr_list->first_timestamp)
act->delay_ms = evt_time_get(0, v) - vr_list->first_timestamp;
else
act->delay_ms = 0;
}
else
{
if (vtm > evt_time_get(0, prev_v))
act->delay_ms = vtm - evt_time_get(0, prev_v);
else act->delay_ms = 0;
}
unit->actions = eina_list_append(unit->actions, act);
prev_v = v;
}
#ifdef DEBUG_TSUITE
printf("%s number of actions in the scenario <%d>\n", __func__, eina_list_count(unit->actions));

@ -209,7 +209,7 @@ _unit_desc_make(void)
_mapping[EXACTNESS_ACTION_TAKE_SHOT], _dummy_desc_make());
EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "n_evas", n_evas, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "timestamp", timestamp, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_BASIC(action_d, Exactness_Action, "delay_ms", delay_ms, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_VARIANT(action_d, Exactness_Action, "data", data, type, action_variant_d);
/* Exactness_Unit */

Loading…
Cancel
Save