Add objects information support

master
Daniel Zaoui 5 years ago
parent 1497fa7336
commit fbd75a4356
  1. 7
      src/bin/exactness.c
  2. 136
      src/bin/inspect.c
  3. 49
      src/bin/player.c
  4. 70
      src/lib/tsuite_file_data.c
  5. 24
      src/lib/tsuite_file_data.h

@ -34,6 +34,7 @@ static char *_base_dir;
static char *_dest_dir;
static char *_wrap_command;
static int _verbose = 0;
static Eina_Bool _scan_objs = EINA_FALSE;
static Run_Mode _mode;
static List_Entry *_next_test_to_run = NULL;
@ -69,6 +70,7 @@ _run_command_prepare(const List_Entry *ent, char *buf)
CONFIG, _wrap_command ? _wrap_command : "",
_mode == RUN_SIMULATION ? "-s" : "",
_verbose ? "-" : "", _verbose, "vvvvvvvvvv",
_scan_objs ? "--scan-objects " : "",
scn_path
);
if (_mode == RUN_PLAY)
@ -366,6 +368,7 @@ static const Ecore_Getopt optdesc = {
ECORE_GETOPT_STORE_TRUE('p', "play", "Run in play mode."),
ECORE_GETOPT_STORE_TRUE('i', "init", "Run in init mode."),
ECORE_GETOPT_STORE_TRUE('s', "simulation", "Run in simulation mode."),
ECORE_GETOPT_STORE_TRUE(0, "scan-objects", "Extract information of all the objects at every shot."),
ECORE_GETOPT_COUNT('v', "verbose", "Turn verbose messages on."),
ECORE_GETOPT_LICENSE('L', "license"),
@ -385,7 +388,7 @@ main(int argc, char *argv[])
const char *list_file = "";
char tmp[EXACTNESS_PATH_MAX];
Eina_Bool mode_play = EINA_FALSE, mode_init = EINA_FALSE, mode_simulation = EINA_FALSE;
Eina_Bool want_quit = EINA_FALSE;
Eina_Bool want_quit = EINA_FALSE, scan_objs = EINA_FALSE;
Ecore_Getopt_Value values[] = {
ECORE_GETOPT_VALUE_STR(_base_dir),
ECORE_GETOPT_VALUE_STR(_dest_dir),
@ -394,6 +397,7 @@ main(int argc, char *argv[])
ECORE_GETOPT_VALUE_BOOL(mode_play),
ECORE_GETOPT_VALUE_BOOL(mode_init),
ECORE_GETOPT_VALUE_BOOL(mode_simulation),
ECORE_GETOPT_VALUE_BOOL(scan_objs),
ECORE_GETOPT_VALUE_INT(_verbose),
ECORE_GETOPT_VALUE_BOOL(want_quit),
@ -411,6 +415,7 @@ main(int argc, char *argv[])
_wrap_command = "";
_max_jobs = 1;
_verbose = 0;
_scan_objs = scan_objs;
args = ecore_getopt_parse(&optdesc, values, argc, argv);
if (args < 0)

@ -23,6 +23,8 @@ static Eina_List *_units = NULL;
static Elm_Genlist_Item_Class *_grp_itc = NULL, *_scn_itc = NULL, *_img_itc = NULL;
static Elm_Genlist_Item_Class *_comp_scn_itc = NULL, *_comp_img_itc = NULL;
static Elm_Genlist_Item_Class *_objs_itc = NULL, *_comp_objs_itc = NULL;
static Elm_Genlist_Item_Class *_obj_itc = NULL, *_comp_obj_itc = NULL;
static const char *
_event_name_get(const Variant_st *v)
@ -234,6 +236,12 @@ _pixels_compare(Exactness_Image *img1, Exactness_Image *img2, Eina_Bool *has_dif
return imgO;
}
void
_win_del(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
efl_exit(0); /* exit the program's main loop that runs in elm_run() */
}
static void
_gui_win_create()
{
@ -241,6 +249,7 @@ _gui_win_create()
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
win = elm_win_add(NULL, "Window", ELM_WIN_BASIC);
evas_object_smart_callback_add(win, "delete,request", _win_del, NULL);
elm_win_maximized_set(win, EINA_TRUE);
elm_win_autodel_set(win, EINA_TRUE);
elm_win_title_set(win, "Exactness Inspector");
@ -356,6 +365,23 @@ _comp_img_content_get(void *data, Evas_Object *obj, const char *part)
return img;
}
static char *
_objs_text_get(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
return strdup("Shot");
}
static char *
_obj_text_get(void *data, Evas_Object *obj EINA_UNUSED, const char *part EINA_UNUSED)
{
Exactness_Object *e_obj = data;
char text[1024];
sprintf(text, "0x%.8llX (%s) x = %d y = %d w = %d h = %d",
e_obj->id, e_obj->kl_name,
e_obj->x, e_obj->y, e_obj->w, e_obj->h);
return strdup(text);
}
static void
_itc_init()
{
@ -393,6 +419,34 @@ _itc_init()
_comp_img_itc->item_style = "full";
_comp_img_itc->func.content_get = _comp_img_content_get;
}
if (!_objs_itc)
{
_objs_itc = elm_genlist_item_class_new();
_objs_itc->item_style = "default";
_objs_itc->func.text_get = _objs_text_get;
}
if (!_comp_objs_itc)
{
_comp_objs_itc = elm_genlist_item_class_new();
_comp_objs_itc->item_style = "default";
//_comp_objs_itc->func.text_get = _comp_objs_text_get;
}
if (!_obj_itc)
{
_obj_itc = elm_genlist_item_class_new();
_obj_itc->item_style = "default";
_obj_itc->func.text_get = _obj_text_get;
}
if (!_comp_obj_itc)
{
_comp_obj_itc = elm_genlist_item_class_new();
_comp_obj_itc->item_style = "default";
//_comp_obj_itc->func.text_get = _comp_obj_text_get;
}
}
static void
@ -409,6 +463,59 @@ _comp_gl_dragged_cb(Evas_Object *obj, void *data EINA_UNUSED)
}
}
static void
_gl_expand_request_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Elm_Object_Item *glit = event_info;
elm_genlist_item_expanded_set(glit, EINA_TRUE);
}
static void
_gl_contract_request_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Elm_Object_Item *glit = event_info;
elm_genlist_item_expanded_set(glit, EINA_FALSE);
}
static void
_gl_expanded_cb(void *_data EINA_UNUSED, Evas_Object *gl, void *event_info)
{
Elm_Object_Item *glit = event_info;
const Elm_Genlist_Item_Class *itc = elm_genlist_item_item_class_get(glit);
if (itc == _objs_itc)
{
Exactness_Objects *e_objs = elm_object_item_data_get(glit);
Eina_List *itr;
Exactness_Object *e_obj;
EINA_LIST_FOREACH(e_objs->main_objs, itr, e_obj)
{
elm_genlist_item_append(gl, _obj_itc, e_obj, glit,
e_obj->children ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE,
NULL, NULL);
}
}
else if (itc == _obj_itc)
{
Exactness_Object *e_obj = elm_object_item_data_get(glit), *e_obj2;
Eina_List *itr;
EINA_LIST_FOREACH(e_obj->children, itr, e_obj2)
{
elm_genlist_item_append(gl, _obj_itc, e_obj2, glit,
e_obj2->children ? ELM_GENLIST_ITEM_TREE : ELM_GENLIST_ITEM_NONE,
NULL, NULL);
}
}
}
static void
_gl_contracted_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
Elm_Object_Item *glit = event_info;
elm_genlist_item_subitems_clear(glit);
}
static void
_gui_unit_display(Exactness_Unit *unit1, Exactness_Unit *unit2, int position)
{
@ -422,6 +529,11 @@ _gui_unit_display(Exactness_Unit *unit1, Exactness_Unit *unit2, int position)
efl_gfx_visible_set(gl, EINA_TRUE);
_gls = eina_list_append(_gls, gl);
evas_object_smart_callback_add(gl, "expand,request", _gl_expand_request_cb, NULL);
evas_object_smart_callback_add(gl, "contract,request", _gl_contract_request_cb, NULL);
evas_object_smart_callback_add(gl, "expanded", _gl_expanded_cb, NULL);
evas_object_smart_callback_add(gl, "contracted", _gl_contracted_cb, NULL);
if (position == -1) elm_box_pack_end(_main_box, gl);
else if (position == 0) elm_box_pack_start(_main_box, gl);
else
@ -485,6 +597,30 @@ _gui_unit_display(Exactness_Unit *unit1, Exactness_Unit *unit2, int position)
if (itr1) itr1 = eina_list_next(itr1);
if (itr2) itr2 = eina_list_next(itr2);
}
itr1 = unit1 ? unit1->objs : NULL;
itr2 = unit2 ? unit2->objs : NULL;
if (itr1)
elm_genlist_item_append(gl, _grp_itc, unit2 ? "Objects comparison" : "Objects", NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL);
while (itr1 || itr2)
{
Exactness_Objects *objs1 = itr1 ? eina_list_data_get(itr1) : NULL;
if (unit2)
{
Exactness_Objects *objs2 = itr2 ? eina_list_data_get(itr2) : NULL;
_Two_Ptrs *vv = malloc(sizeof(*vv));
vv->p1 = objs1->objs;
vv->p2 = objs2->objs;
elm_genlist_item_append(gl, _comp_objs_itc, vv, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
}
else
{
elm_genlist_item_append(gl, _objs_itc, objs1, NULL, ELM_GENLIST_ITEM_TREE, NULL, NULL);
}
if (itr1) itr1 = eina_list_next(itr1);
if (itr2) itr2 = eina_list_next(itr2);
}
}
static Exactness_Image *

@ -54,6 +54,7 @@ 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;
static void
_printf(int verbose, const char *fmt, ...)
@ -128,6 +129,44 @@ _shot_do(Evas *e)
_dest_unit->imgs = eina_list_append(_dest_unit->imgs, ex_img);
_dest_unit->nb_shots++;
_printf(1, "Shot taken (in %s).\n", _dest);
if (_scan_objects)
{
Eina_Iterator *iter;
Eo *obj;
Exactness_Objects *e_objs = calloc(1, sizeof(*e_objs));
iter = eo_objects_iterator_new();
EINA_ITERATOR_FOREACH(iter, obj)
{
if (!efl_isa(obj, EFL_CANVAS_OBJECT_CLASS) &&
!efl_isa(obj, EFL_CANVAS_SCENE_INTERFACE)) continue;
Exactness_Object *e_obj = calloc(1, sizeof(*e_obj));
Eo *parent = efl_parent_get(obj);
e_obj->id = (long long) obj;
if (efl_isa(parent, EFL_CANVAS_OBJECT_CLASS) ||
efl_isa(parent, EFL_CANVAS_SCENE_INTERFACE))
{
e_obj->parent_id = (long long) efl_parent_get(obj);
}
else
{
e_obj->parent_id = 0;
}
e_obj->kl_name = eina_stringshare_add(efl_class_name_get(obj));
if (efl_isa(obj, EFL_CANVAS_OBJECT_CLASS))
{
Eina_Size2D sz = efl_gfx_entity_size_get(obj);
e_obj->w = sz.w;
e_obj->h = sz.h;
Eina_Position2D pos = efl_gfx_entity_position_get(obj);
e_obj->x = pos.x;
e_obj->y = pos.y;
}
e_objs->objs = eina_list_append(e_objs->objs, e_obj);
}
eina_iterator_free(iter);
_dest_unit->objs = eina_list_append(_dest_unit->objs, e_objs);
}
}
}
@ -566,6 +605,7 @@ static const Ecore_Getopt optdesc = {
" by the given test extension (resp. exu or rec)."),
ECORE_GETOPT_STORE_STR('t', "test", "Test to run on the given application"),
ECORE_GETOPT_STORE_TRUE('s', "show-on-screen", "Show on screen."),
ECORE_GETOPT_STORE_TRUE(0, "scan-objects", "Extract information of all the objects at every shot."),
ECORE_GETOPT_COUNT('v', "verbose", "Turn verbose messages on."),
ECORE_GETOPT_LICENSE('L', "license"),
@ -587,6 +627,7 @@ int main(int argc, char **argv)
ECORE_GETOPT_VALUE_STR(dest),
ECORE_GETOPT_VALUE_STR(src),
ECORE_GETOPT_VALUE_BOOL(show_on_screen),
ECORE_GETOPT_VALUE_BOOL(_scan_objects),
ECORE_GETOPT_VALUE_INT(_verbose),
ECORE_GETOPT_VALUE_BOOL(want_quit),
@ -680,7 +721,13 @@ int main(int argc, char **argv)
if (dot) *dot = '\0';
}
if (show_on_screen) setenv("ELM_ENGINE", "buffer", 1);
if (_scan_objects && _dest_type != FTYPE_EXU)
{
fprintf(stderr, "Scan objects options is available only if the destination is a EXU file\n");
goto end;
}
if (!show_on_screen) setenv("ELM_ENGINE", "buffer", 1);
if (!argv[opt_args])
{
fprintf(stderr, "no program specified\nUse -h for more information\n");

@ -736,28 +736,6 @@ multi_move_desc_make(void)
return _d;
}
Eet_Data_Descriptor *
object_info_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
static Eet_Data_Descriptor *info_d = NULL;
if (!info_d)
{
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Object_Info);
info_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(info_d, Object_Info, "kl_name", kl_name, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(info_d, Object_Info, "id", id, EET_T_UINT);
EET_DATA_DESCRIPTOR_ADD_LIST(info_d, Object_Info, "children", children, info_d);
/* Evas stuff */
EET_DATA_DESCRIPTOR_ADD_BASIC(info_d, Object_Info, "x", x, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(info_d, Object_Info, "y", y, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(info_d, Object_Info, "w", w, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(info_d, Object_Info, "h", h, EET_T_INT);
}
return info_d;
}
#define INFO_CHECK(i1, i2, obj_path, var) \
({ \
Eina_Bool _ret = EINA_TRUE; \
@ -770,6 +748,7 @@ object_info_desc_make(void)
})
#if 0
static Eina_Bool
_object_info_compare(Object_Info *info1, Object_Info *info2, Eina_Bool verbose, const char *path)
{
@ -821,7 +800,7 @@ objects_files_compare(const char *filename1, const char *filename2, Eina_Bool ve
f1 = eet_open(filename1, EET_FILE_MODE_READ);
f2 = eet_open(filename2, EET_FILE_MODE_READ);
desc = object_info_desc_make();
desc = _object_info_desc_make();
if (!f1 || !f2)
{
if (verbose) fprintf(stderr, "Can't open %s\n", !f1?filename1:filename2);
@ -836,13 +815,14 @@ objects_files_compare(const char *filename1, const char *filename2, Eina_Bool ve
goto end;
}
ret = _object_info_compare(lst1, lst2, verbose, NULL);
// ret = _object_info_compare(lst1, lst2, verbose, NULL);
end:
if (desc) eet_data_descriptor_free(desc);
if (f1) eet_close(f1);
if (f2) eet_close(f2);
return ret;
}
#endif
/* declaring types */
data_desc *_data_descriptors_init(void)
@ -958,7 +938,26 @@ _unit_desc_make(void)
{
Eet_Data_Descriptor_Class eddc;
static Eet_Data_Descriptor *unit_d = NULL;
static Eet_Data_Descriptor *obj_d = NULL;
static Eet_Data_Descriptor *objs_d = NULL;
_data_descriptors_init();
if (!obj_d)
{
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Object);
obj_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "kl_name", kl_name, EET_T_STRING);
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "id", id, EET_T_ULONG_LONG);
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "parent_id", parent_id, EET_T_ULONG_LONG);
/* Evas stuff */
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "x", x, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "y", y, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "w", w, EET_T_INT);
EET_DATA_DESCRIPTOR_ADD_BASIC(obj_d, Exactness_Object, "h", h, EET_T_INT);
EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Exactness_Objects);
objs_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_LIST(objs_d, Exactness_Objects, "objs", objs, obj_d);
}
if (!unit_d)
{
/* Exactness_Unit */
@ -966,6 +965,8 @@ _unit_desc_make(void)
unit_d = eet_data_descriptor_stream_new(&eddc);
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit,
"events", events, _desc->_variant_descriptor);
EET_DATA_DESCRIPTOR_ADD_LIST(unit_d, Exactness_Unit,
"objs", objs, objs_d);
EET_DATA_DESCRIPTOR_ADD_BASIC(unit_d, Exactness_Unit,
"nb_shots", nb_shots, EET_T_UINT);
}
@ -978,6 +979,9 @@ EAPI Exactness_Unit *
unit_eet_read(const char *filename)
{
int i;
Eina_List *itr, *itr2;
Exactness_Objects *e_objs;
Exactness_Object *e_obj, *e_parent;
Exactness_Unit *unit = NULL;
Eet_File *file = eet_open(filename, EET_FILE_MODE_READ);
if (!file)
@ -996,6 +1000,24 @@ unit_eet_read(const char *filename)
NULL, NULL, NULL);
unit->imgs = eina_list_append(unit->imgs, ex_img);
}
EINA_LIST_FOREACH(unit->objs, itr, e_objs)
{
e_objs->hash = eina_hash_pointer_new(NULL);
EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj)
{
eina_hash_set(e_objs->hash, &(e_obj->id), e_obj);
}
EINA_LIST_FOREACH(e_objs->objs, itr2, e_obj)
{
if (!e_obj->parent_id)
e_objs->main_objs = eina_list_append(e_objs->main_objs, e_obj);
else
{
e_parent = eina_hash_find(e_objs->hash, &(e_obj->parent_id));
if (e_parent) e_parent->children = eina_list_append(e_parent->children, e_obj);
}
}
}
eet_close(file);
return unit;
}

@ -245,28 +245,29 @@ data_desc *_data_descriptors_init(void);
void _data_descriptors_shutdown(void);
/* END Event struct descriptors */
/* START Objects */
/* START Unit desc */
typedef struct
{
Eo *object;
Eo *parent;
long long id;
long long parent_id;
const char *kl_name;
Eina_List *children;
int id;
Eina_List *children; /* NOT EET */
/* Evas stuff */
int x;
int y;
int w;
int h;
} Object_Info;
Eet_Data_Descriptor *object_info_desc_make(void);
} Exactness_Object;
EAPI Eina_Bool objects_files_compare(const char *filename1, const char *filename2, Eina_Bool verbose);
/* END Objects */
typedef struct
{
Eina_List *objs;
Eina_List *main_objs; /* NOT EET */
Eina_Hash *hash; /* NOT EET */
} Exactness_Objects;
/* START Unit desc */
typedef struct
{
unsigned int w;
@ -279,6 +280,7 @@ typedef struct
{
Eina_List *events; /* List of Variant_st */
Eina_List *imgs; /* List of Exactness_Image */
Eina_List *objs; /* List of Exactness_Objects */
int nb_shots;
} Exactness_Unit;

Loading…
Cancel
Save