From 4effc37ab0bc7e4174381206ab0287df7f36f45b Mon Sep 17 00:00:00 2001 From: Daniel Zaoui Date: Wed, 23 Mar 2016 11:42:47 +0200 Subject: [PATCH] Support reference timestamp An issue due to timing happens when applying scenarios on applications. The first event is directly treated, even if the recorder waited a few seconds without any action. The reason is that Exactness saves in the .rec file a timestamp that is the uptime value, i.e an absolute value. A better choice would have been to save the number of ms relative to the launch of the application. Because of this, Exactness doesnt have any way to know when the first event has to be treated and consumes it whenever possible, i.e at the beginning. This patch adds to the recording file a timestamp reference, corresponding to the uptime at ecore_init. When applying the scenario, this timestamp is checked and gives an idea of a delay to wait before consuming the first event. --- src/lib/tsuite_evas_hook.c | 37 ++++++++++++++++++++++++++++++++++--- src/lib/tsuite_file_data.c | 2 ++ src/lib/tsuite_file_data.h | 1 + 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/lib/tsuite_evas_hook.c b/src/lib/tsuite_evas_hook.c index 7021578..fdb4ac3 100644 --- a/src/lib/tsuite_evas_hook.c +++ b/src/lib/tsuite_evas_hook.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include "tsuite_file_data.h" #include "exactness_private.h" @@ -152,7 +153,15 @@ tsuite_evas_hook_init(void) if (!shot_key) shot_key = SHOT_KEY_STR; if (!vr_list) - vr_list = calloc(1, sizeof(*vr_list)); + { + struct sysinfo s_info; + sysinfo(&s_info); + vr_list = calloc(1, sizeof(*vr_list)); + vr_list->first_timestamp = s_info.uptime * 1000; +#ifdef DEBUG_TSUITE + printf("Uptime=<%u>\n", vr_list->first_timestamp); +#endif + } } EAPI void @@ -612,14 +621,36 @@ ecore_main_loop_begin(void) if (!_hook_setting->recording && _hook_setting->file_name) { + double diff_time = 0; /* Time to wait before feeding the first event */ ts.td = calloc(1, sizeof(Timer_Data)); #ifdef DEBUG_TSUITE printf("<%s> rec file is <%s>\n", __func__, _hook_setting->file_name); #endif vr_list = read_events(_hook_setting->file_name, ts.td); if (ts.td->current_event) - { /* Got first event in list, run test */ - tsuite_feed_event(ts.td); + { + /* Got first event in list, run test */ + + /* Calculate the time to wait before feeding the first event */ + unsigned int current_event_time = evt_time_get(0, eina_list_data_get(ts.td->current_event)); + if (current_event_time > vr_list->first_timestamp) + diff_time = (current_event_time - vr_list->first_timestamp) / 1000.0; + +#ifdef DEBUG_TSUITE + printf("%s first_time_stamp=<%u> current_event_time=<%u>\n", __func__, vr_list->first_timestamp, current_event_time); +#endif + + if (diff_time) + { +#ifdef DEBUG_TSUITE + printf(" Waiting <%f>\n", diff_time); +#endif + ecore_timer_add(diff_time, tsuite_feed_event, ts.td); + } + else + { + tsuite_feed_event(ts.td); + } } } diff --git a/src/lib/tsuite_file_data.c b/src/lib/tsuite_file_data.c index 6863e73..5afe7d7 100644 --- a/src/lib/tsuite_file_data.c +++ b/src/lib/tsuite_file_data.c @@ -803,6 +803,8 @@ data_desc *_data_descriptors_init(void) EET_DATA_DESCRIPTOR_ADD_VARIANT(desc->_variant_descriptor, Variant_st, "data", data, t, desc->_variant_unified_descriptor); + EET_DATA_DESCRIPTOR_ADD_BASIC(desc->_lists_descriptor, + Lists_st, "first_timestamp", first_timestamp, EET_T_UINT); EET_DATA_DESCRIPTOR_ADD_LIST(desc->_lists_descriptor, Lists_st, "variant_list", variant_list, desc->_variant_descriptor); diff --git a/src/lib/tsuite_file_data.h b/src/lib/tsuite_file_data.h index 3bea482..8f53856 100644 --- a/src/lib/tsuite_file_data.h +++ b/src/lib/tsuite_file_data.h @@ -177,6 +177,7 @@ typedef struct _mouse_in_mouse_out take_screenshot; struct _Lists_st { Eina_List *variant_list; + unsigned int first_timestamp; }; typedef struct _Lists_st Lists_st;