replace "compare" utility with custom compare function using only EFL.
Summary: Signed-off-by: kabeer khan <kabeer.khan@samsung.com> Reviewers: cedric, tasn Reviewed By: cedric, tasn Subscribers: tasn Differential Revision: https://phab.enlightenment.org/D2684 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
bb051fce2b
commit
7989552b29
|
@ -79,6 +79,7 @@ main(int argc, char *argv[])
|
||||||
};
|
};
|
||||||
|
|
||||||
ecore_init();
|
ecore_init();
|
||||||
|
ecore_evas_init();
|
||||||
mode_record = mode_play = mode_init = mode_simulation = EINA_FALSE;
|
mode_record = mode_play = mode_init = mode_simulation = EINA_FALSE;
|
||||||
want_quit = EINA_FALSE;
|
want_quit = EINA_FALSE;
|
||||||
exactness_config.base_dir = "./recordings";
|
exactness_config.base_dir = "./recordings";
|
||||||
|
@ -250,6 +251,7 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
list_file_free(test_list);
|
list_file_free(test_list);
|
||||||
end:
|
end:
|
||||||
|
ecore_evas_shutdown();
|
||||||
ecore_shutdown();
|
ecore_shutdown();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define EXACTNESS_CONFIG_H
|
#define EXACTNESS_CONFIG_H
|
||||||
|
|
||||||
#include <Eina.h>
|
#include <Eina.h>
|
||||||
|
#include <Ecore_Evas.h>
|
||||||
|
|
||||||
typedef struct _Exactness_Config Exactness_Config;
|
typedef struct _Exactness_Config Exactness_Config;
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,11 @@
|
||||||
#include "exactness_private.h"
|
#include "exactness_private.h"
|
||||||
|
|
||||||
#define LIBEXACTNESS_PATH PACKAGE_LIBDIR "/exactness/libexactness.so"
|
#define LIBEXACTNESS_PATH PACKAGE_LIBDIR "/exactness/libexactness.so"
|
||||||
|
#define RED 0xffff0000
|
||||||
|
#define WHITE 0xffffffff
|
||||||
|
|
||||||
|
static Ecore_Evas *ee = NULL;
|
||||||
|
static Evas_Object *cur_img, *orig_img, *diff_img;
|
||||||
|
|
||||||
void
|
void
|
||||||
run_test_simulation(const List_Entry *ent, char *buf)
|
run_test_simulation(const List_Entry *ent, char *buf)
|
||||||
|
@ -67,6 +72,89 @@ run_test_init(const List_Entry *ent, char *buf)
|
||||||
run_test_prefix_rm(ORIG_SUBDIR, ent->name);
|
run_test_prefix_rm(ORIG_SUBDIR, ent->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Eina_Bool
|
||||||
|
compare(const char *filename1, const char *filename2, const char *diff_file)
|
||||||
|
{
|
||||||
|
Ecore_Evas *diff_ee;
|
||||||
|
Evas_Object *bg, *img;
|
||||||
|
unsigned int *pixels1 = NULL, *pixels2 = NULL, *pixels3 = NULL;
|
||||||
|
int w1, h1, w2, h2, err;
|
||||||
|
unsigned int *i1, *i2, *i3;
|
||||||
|
|
||||||
|
evas_object_image_file_set(cur_img, filename1, NULL);
|
||||||
|
err = evas_object_image_load_error_get(cur_img);
|
||||||
|
if (err != EVAS_LOAD_ERROR_NONE)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Cannot load image file %s\n", filename1);
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
evas_object_image_file_set(orig_img, filename2, NULL);
|
||||||
|
err = evas_object_image_load_error_get(orig_img);
|
||||||
|
if (err != EVAS_LOAD_ERROR_NONE)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Cannot load image file %s\n", filename2);
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixels1 = (unsigned int *)evas_object_image_data_get(cur_img, EINA_FALSE);
|
||||||
|
pixels2 = (unsigned int *)evas_object_image_data_get(orig_img, EINA_FALSE);
|
||||||
|
evas_object_image_size_get(cur_img, &w1, &h1);
|
||||||
|
evas_object_image_size_get(orig_img, &w2, &h2);
|
||||||
|
if (!pixels1 || !pixels2) goto on_error;
|
||||||
|
if (w1 != w2 || h1 != h2) goto on_error;
|
||||||
|
|
||||||
|
evas_object_image_size_set(diff_img, w1, h1);
|
||||||
|
evas_object_move(diff_img, 0, 0);
|
||||||
|
evas_object_resize(diff_img, w1, h1);
|
||||||
|
diff_ee = ecore_evas_object_ecore_evas_get(diff_img);
|
||||||
|
ecore_evas_resize(diff_ee, w1, h1);
|
||||||
|
|
||||||
|
bg = evas_object_image_add(ecore_evas_get(diff_ee));
|
||||||
|
if (!bg)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Cannot load image object");
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
evas_object_image_filled_set(bg, EINA_TRUE);
|
||||||
|
evas_object_image_size_set(bg, w1, h1);
|
||||||
|
evas_object_image_data_set(bg, pixels2);
|
||||||
|
evas_object_move(bg, 0, 0);
|
||||||
|
evas_object_resize(bg, w1, h1);
|
||||||
|
evas_object_show(bg);
|
||||||
|
|
||||||
|
img = evas_object_image_add(ecore_evas_get(diff_ee));
|
||||||
|
if (!img)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Cannot load image object");
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
evas_object_image_filled_set(img, EINA_TRUE);
|
||||||
|
evas_object_image_alpha_set(img, 1);
|
||||||
|
evas_object_image_size_set(img, w1, h1);
|
||||||
|
pixels3 = (unsigned int *)evas_object_image_data_get(img, EINA_TRUE);
|
||||||
|
if (!pixels3) goto on_error;
|
||||||
|
for (i1 = pixels1, i2 = pixels2, i3 = pixels3; *i1; i1++, i2++, i3++)
|
||||||
|
{
|
||||||
|
if (*i1 != *i2) *i3 = RED;
|
||||||
|
else *i3 = WHITE;
|
||||||
|
}
|
||||||
|
evas_object_move(img, 0, 0);
|
||||||
|
evas_object_resize(img, w1, h1);
|
||||||
|
evas_object_color_set(img, 128, 128, 128, 192);
|
||||||
|
evas_object_show(img);
|
||||||
|
|
||||||
|
ecore_evas_manual_render(diff_ee);
|
||||||
|
if (!evas_object_image_save(diff_img, diff_file, NULL, NULL))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Unable to save image %s\n", diff_file);
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
return EINA_TRUE;
|
||||||
|
|
||||||
|
on_error:
|
||||||
|
return EINA_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_file_sha1_get(const char *filename, unsigned char *result)
|
_file_sha1_get(const char *filename, unsigned char *result)
|
||||||
{
|
{
|
||||||
|
@ -114,7 +202,6 @@ _is_equal(const char *filename1, const char *filename2)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
if (!_file_sha1_get(filename2, res2))
|
if (!_file_sha1_get(filename2, res2))
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
return !memcmp(res1, res2, _DIGEST_SIZE);
|
return !memcmp(res1, res2, _DIGEST_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,18 +223,14 @@ _compare_list_cb(const char *name, const char *path EINA_UNUSED, void *data)
|
||||||
snprintf(filename2, EXACTNESS_PATH_MAX, "%s/%s/%s", exactness_config.dest_dir, ORIG_SUBDIR, name);
|
snprintf(filename2, EXACTNESS_PATH_MAX, "%s/%s/%s", exactness_config.dest_dir, ORIG_SUBDIR, name);
|
||||||
if (!_is_equal(filename1, filename2))
|
if (!_is_equal(filename1, filename2))
|
||||||
{
|
{
|
||||||
char buf[EXACTNESS_PATH_MAX];
|
char diff_file[EXACTNESS_PATH_MAX];
|
||||||
exactness_ctx.compare_errors =
|
exactness_ctx.compare_errors =
|
||||||
eina_list_append(exactness_ctx.compare_errors,
|
eina_list_append(exactness_ctx.compare_errors,
|
||||||
strdup(name));
|
strdup(name));
|
||||||
|
|
||||||
/* FIXME: Clean up. */
|
snprintf(diff_file, EXACTNESS_PATH_MAX, "%s/%s/comp_%s", exactness_config.dest_dir,
|
||||||
snprintf(buf, EXACTNESS_PATH_MAX,
|
CURRENT_SUBDIR, name);
|
||||||
"compare '%s' '%s' '%s/%s/comp_%s'",
|
if (compare(filename1, filename2, diff_file))
|
||||||
filename1, filename2,
|
|
||||||
exactness_config.dest_dir,
|
|
||||||
CURRENT_SUBDIR, name);
|
|
||||||
if (system(buf))
|
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed image comparing '%s'\n", name);
|
fprintf(stderr, "Failed image comparing '%s'\n", name);
|
||||||
}
|
}
|
||||||
|
@ -159,8 +242,23 @@ void
|
||||||
run_test_compare(const List_Entry *ent)
|
run_test_compare(const List_Entry *ent)
|
||||||
{
|
{
|
||||||
char origdir[EXACTNESS_PATH_MAX];
|
char origdir[EXACTNESS_PATH_MAX];
|
||||||
|
|
||||||
snprintf(origdir, EXACTNESS_PATH_MAX, "%s/%s", exactness_config.dest_dir, ORIG_SUBDIR);
|
snprintf(origdir, EXACTNESS_PATH_MAX, "%s/%s", exactness_config.dest_dir, ORIG_SUBDIR);
|
||||||
|
ee = ecore_evas_buffer_new(1, 1);
|
||||||
|
if (!ee) goto on_error;
|
||||||
|
cur_img = evas_object_image_add(ecore_evas_get(ee));
|
||||||
|
orig_img = evas_object_image_add(ecore_evas_get(ee));
|
||||||
|
diff_img = ecore_evas_object_image_new(ee);
|
||||||
|
if (!diff_img)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Cannot load image object\n");
|
||||||
|
goto on_error;
|
||||||
|
}
|
||||||
|
evas_object_image_filled_set(diff_img, EINA_TRUE);
|
||||||
eina_file_dir_list(origdir, 0, _compare_list_cb, ent->name);
|
eina_file_dir_list(origdir, 0, _compare_list_cb, ent->name);
|
||||||
|
|
||||||
|
on_error:
|
||||||
|
if (ee) ecore_evas_free(ee);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
Loading…
Reference in New Issue