2011-09-14 12:02:07 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2015-06-25 17:09:03 -07:00
|
|
|
#define EFL_GFX_FILTER_BETA
|
|
|
|
|
2011-09-14 12:02:07 -07:00
|
|
|
#include <Eina.h>
|
|
|
|
#include <Edje.h>
|
|
|
|
|
|
|
|
#include "edje_suite.h"
|
2013-02-21 00:39:09 -08:00
|
|
|
#include "edje_tests_helpers.h"
|
2011-09-14 12:02:07 -07:00
|
|
|
|
2015-07-29 04:00:35 -07:00
|
|
|
#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas"
|
|
|
|
|
2011-09-14 12:02:07 -07:00
|
|
|
START_TEST(edje_test_edje_init)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = edje_init();
|
|
|
|
fail_if(ret != 1);
|
|
|
|
|
|
|
|
ret = edje_shutdown();
|
|
|
|
fail_if(ret != 0);
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2013-02-19 08:00:38 -08:00
|
|
|
START_TEST(edje_test_edje_load)
|
|
|
|
{
|
|
|
|
Evas *evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
Edje_Load_Error error;
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
obj = edje_object_add(evas);
|
|
|
|
edje_object_file_set(obj, "blaoeuaeoueoaua.edj", "test");
|
|
|
|
error = edje_object_load_error_get(obj);
|
|
|
|
fail_if(error != EDJE_LOAD_ERROR_DOES_NOT_EXIST);
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2013-03-12 23:23:23 -07:00
|
|
|
static const char *
|
2013-06-27 09:49:56 -07:00
|
|
|
test_layout_get(const char *name)
|
2013-03-12 23:23:23 -07:00
|
|
|
{
|
2013-06-28 03:04:21 -07:00
|
|
|
static char filename[PATH_MAX];
|
2013-06-27 09:49:56 -07:00
|
|
|
|
|
|
|
snprintf(filename, PATH_MAX, TESTS_BUILD_DIR"/data/%s", name);
|
|
|
|
|
|
|
|
return filename;
|
2013-03-12 23:23:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
START_TEST(edje_test_load_simple_layout)
|
2011-09-14 12:02:07 -07:00
|
|
|
{
|
2013-03-12 23:23:23 -07:00
|
|
|
Evas *evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
obj = edje_object_add(evas);
|
2013-06-27 09:49:56 -07:00
|
|
|
fail_unless(edje_object_file_set(obj, test_layout_get("test_layout.edj"), "test_group"));
|
2013-03-12 23:23:23 -07:00
|
|
|
|
|
|
|
fail_if(edje_object_part_exists(obj, "unexistant_part"));
|
|
|
|
fail_unless(edje_object_part_exists(obj, "background"));
|
|
|
|
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2013-06-27 09:51:30 -07:00
|
|
|
START_TEST(edje_test_simple_layout_geometry)
|
|
|
|
{
|
|
|
|
int x, y, w, h;
|
|
|
|
int r, g, b, a;
|
|
|
|
Evas *evas = EDJE_TEST_INIT_EVAS();
|
2014-03-05 21:24:25 -08:00
|
|
|
Evas_Object *obj;
|
|
|
|
const Evas_Object *bg;
|
2013-06-27 09:51:30 -07:00
|
|
|
|
|
|
|
obj = edje_object_add(evas);
|
|
|
|
fail_unless(edje_object_file_set(obj, test_layout_get("test_layout.edj"), "test_group"));
|
|
|
|
|
2013-06-27 09:53:48 -07:00
|
|
|
/* rel1.relative: 0.0 0.0;
|
|
|
|
* rel2.relative: 1.0 1.0; */
|
2013-06-27 09:51:30 -07:00
|
|
|
evas_object_resize(obj, 1000, 1000);
|
|
|
|
edje_object_part_geometry_get(obj, "background", &x, &y, &w, &h);
|
|
|
|
|
|
|
|
fail_if(x != 0 || y != 0);
|
|
|
|
fail_if(w != 1000 || h != 1000);
|
|
|
|
|
|
|
|
bg = edje_object_part_object_get(obj, "background");
|
|
|
|
fail_if(!bg);
|
|
|
|
|
|
|
|
evas_object_color_get(bg, &r, &g, &b, &a);
|
|
|
|
fail_if(r != 255 || g != 255 || b != 255 || a != 255);
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2013-06-27 09:53:48 -07:00
|
|
|
START_TEST(edje_test_complex_layout)
|
|
|
|
{
|
|
|
|
int x, y, w, h;
|
|
|
|
Evas *evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
obj = edje_object_add(evas);
|
|
|
|
fail_unless(edje_object_file_set(obj, test_layout_get("complex_layout.edj"), "test_group"));
|
|
|
|
evas_object_resize(obj, 1000, 1000);
|
|
|
|
|
|
|
|
/* Apparently rel2 offsets are retarded and you have to introduce off-by-one
|
|
|
|
* madness (rel2.offset: -1 -1; acts like there is zero offset...)
|
|
|
|
* Take that into account when checking w and h */
|
|
|
|
|
|
|
|
/* rel1.relative: 0.0 0.0; rel1.offset: 0 0;
|
|
|
|
* rel2.relative: 1.0 1.0; rel2.offset -1 -1; */
|
|
|
|
edje_object_part_geometry_get(obj, "background", &x, &y, &w, &h);
|
|
|
|
fail_if(x != 0 || y != 0);
|
|
|
|
fail_if(w != 1000-1 + 1 || h != 1000-1 + 1);
|
|
|
|
|
|
|
|
/* rel1.relative: 0.0 0.0; rel1.offset: 1 1;
|
|
|
|
* rel2.relative: 1.0 1.0; rel2.offset 0 0; */
|
|
|
|
edje_object_part_geometry_get(obj, "background2", &x, &y, &w, &h);
|
|
|
|
fail_if(x != 1 || y != 1);
|
|
|
|
fail_if(w != 1000-1 + 1 || h != 1000-1 + 1);
|
|
|
|
|
|
|
|
/* rel1.relative: 0.0 0.0; rel1.offset: 5 5;
|
|
|
|
* rel2.relative: 0.5 0.5; rel2.offset -2 -2; */
|
|
|
|
edje_object_part_geometry_get(obj, "ul", &x, &y, &w, &h);
|
|
|
|
fail_if(x != 5 || y != 5);
|
|
|
|
fail_if(w != 500-5-2 + 1 || h != 500-5-2 + 1);
|
|
|
|
|
|
|
|
/* rel1.relative: 0.5 0.0; rel1.offset: 2 5;
|
|
|
|
* rel2.relative: 1.0 0.5; rel2.offset -5 -2; */
|
|
|
|
edje_object_part_geometry_get(obj, "ur", &x, &y, &w, &h);
|
|
|
|
fail_if(x != 500+2 || y != 5);
|
|
|
|
fail_if(w != 500-5-2 + 1 || h != 500-5-2 + 1);
|
|
|
|
|
|
|
|
/* rel1.relative: 0.0 0.5; rel1.offset: 5 2;
|
|
|
|
* rel2.relative: 1.0 1.0; rel2.offset -5 -5; */
|
|
|
|
edje_object_part_geometry_get(obj, "l", &x, &y, &w, &h);
|
|
|
|
fail_if(x != 5 || y != 500+2);
|
2013-07-18 04:18:43 -07:00
|
|
|
fail_if(w != 1000-5-5 + 1 || h != 500-5-2 + 1);
|
2013-06-27 09:53:48 -07:00
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2015-05-29 09:11:49 -07:00
|
|
|
START_TEST(edje_test_calculate_parens)
|
|
|
|
{
|
|
|
|
int x, y, w, h;
|
|
|
|
Evas *evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
obj = edje_object_add(evas);
|
|
|
|
fail_unless(edje_object_file_set(obj, test_layout_get("test_parens.edj"), "test_group"));
|
|
|
|
|
|
|
|
evas_object_resize(obj, 100, 100);
|
|
|
|
edje_object_part_geometry_get(obj, "background", &x, &y, &w, &h);
|
|
|
|
fail_if(x != 0 || y != 0 || w != 100 || h != 100);
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2015-06-11 01:46:50 -07:00
|
|
|
START_TEST(edje_test_masking)
|
|
|
|
{
|
|
|
|
int x, y, w, h;
|
|
|
|
Evas *evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
const Evas_Object *sub, *clip2, *clip;
|
|
|
|
Evas_Object *obj;
|
|
|
|
|
|
|
|
obj = edje_object_add(evas);
|
|
|
|
fail_unless(edje_object_file_set(obj, test_layout_get("test_masking.edj"), "test_group"));
|
|
|
|
|
|
|
|
evas_object_resize(obj, 100, 100);
|
|
|
|
edje_object_part_geometry_get(obj, "background", &x, &y, &w, &h);
|
|
|
|
fail_if(x != 0 || y != 0 || w != 100 || h != 100);
|
|
|
|
|
|
|
|
clip = edje_object_part_object_get(obj, "clip2");
|
|
|
|
fail_if(!clip);
|
|
|
|
|
|
|
|
/* check value of no_render flag as seen from evas land */
|
|
|
|
sub = edje_object_part_object_get(obj, "mask");
|
2016-03-01 10:06:28 -08:00
|
|
|
fail_if(!evas_obj_no_render_get(sub));
|
2015-06-11 01:46:50 -07:00
|
|
|
|
|
|
|
/* check that text has a clip (based on description.clip_to) */
|
|
|
|
sub = edje_object_part_object_get(obj, "text");
|
2016-03-01 10:06:28 -08:00
|
|
|
fail_if(!evas_obj_clip_get(sub));
|
2015-06-11 01:46:50 -07:00
|
|
|
|
|
|
|
/* test description.clip_to override */
|
|
|
|
sub = edje_object_part_object_get(obj, "noclip");
|
2016-03-01 10:06:28 -08:00
|
|
|
clip2 = evas_obj_clip_get(sub);
|
2015-06-11 01:46:50 -07:00
|
|
|
fail_if(clip != clip2);
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2015-06-22 20:38:32 -07:00
|
|
|
START_TEST(edje_test_filters)
|
|
|
|
{
|
|
|
|
Evas *evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
const Evas_Object *text, *sub;
|
|
|
|
Evas_Object *obj, *src = NULL;
|
|
|
|
const char *prg, *name;
|
|
|
|
|
2015-07-29 04:00:35 -07:00
|
|
|
setenv("EVAS_DATA_DIR", EVAS_DATA_DIR, 1);
|
|
|
|
|
2015-06-22 20:38:32 -07:00
|
|
|
obj = edje_object_add(evas);
|
|
|
|
fail_unless(edje_object_file_set(obj, test_layout_get("test_filters.edj"), "test_group"));
|
|
|
|
|
|
|
|
evas_object_resize(obj, 200, 200);
|
|
|
|
|
|
|
|
/* check value of no_render flag as seen from evas land */
|
|
|
|
sub = edje_object_part_object_get(obj, "mask");
|
2016-03-01 10:06:28 -08:00
|
|
|
fail_if(!evas_obj_no_render_get(sub));
|
2015-06-22 20:38:32 -07:00
|
|
|
|
2015-10-01 20:21:56 -07:00
|
|
|
/* check no_render inheritance */
|
|
|
|
sub = edje_object_part_object_get(obj, "mask2");
|
2016-03-01 10:06:28 -08:00
|
|
|
fail_if(evas_obj_no_render_get(sub));
|
2015-10-01 20:21:56 -07:00
|
|
|
sub = edje_object_part_object_get(obj, "mask3");
|
2016-03-01 10:06:28 -08:00
|
|
|
fail_if(!evas_obj_no_render_get(sub));
|
2015-10-01 20:21:56 -07:00
|
|
|
|
2015-06-22 20:38:32 -07:00
|
|
|
/* text part: check filter status */
|
|
|
|
text = edje_object_part_object_get(obj, "text");
|
|
|
|
fail_if(!text);
|
|
|
|
|
2016-03-01 10:06:28 -08:00
|
|
|
efl_gfx_filter_program_get(text, &prg, &name);
|
2015-06-22 20:38:32 -07:00
|
|
|
fail_if(!prg);
|
|
|
|
fail_if(!name || strcmp(name, "filterfile"));
|
|
|
|
|
2016-03-01 10:06:28 -08:00
|
|
|
src = efl_gfx_filter_source_get(text, "mask");
|
2015-06-22 20:38:32 -07:00
|
|
|
fail_if(!src);
|
|
|
|
|
|
|
|
// TODO: Verify properly that the filter runs well
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2015-09-07 03:08:50 -07:00
|
|
|
START_TEST(edje_test_snapshot)
|
|
|
|
{
|
|
|
|
Evas *evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
const Evas_Object *sub;
|
2015-10-04 07:01:08 -07:00
|
|
|
Evas_Object *obj;
|
2015-09-07 03:08:50 -07:00
|
|
|
|
|
|
|
setenv("EVAS_DATA_DIR", EVAS_DATA_DIR, 1);
|
|
|
|
|
|
|
|
obj = edje_object_add(evas);
|
|
|
|
fail_unless(edje_object_file_set(obj, test_layout_get("test_snapshot.edj"), "test_group"));
|
|
|
|
|
|
|
|
evas_object_resize(obj, 200, 200);
|
|
|
|
|
|
|
|
/* check value of no_render flag as seen from evas land */
|
|
|
|
sub = edje_object_part_object_get(obj, "snap");
|
2016-03-07 21:22:54 -08:00
|
|
|
fail_if(!eo_isa(sub, EFL_CANVAS_SNAPSHOT_CLASS) &&
|
|
|
|
!evas_object_image_snapshot_get(sub));
|
2015-09-07 03:08:50 -07:00
|
|
|
|
|
|
|
// TODO: Verify that evas snapshot actually works (and has a filter)
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2015-12-15 21:53:59 -08:00
|
|
|
START_TEST(edje_test_size_class)
|
|
|
|
{
|
|
|
|
int minw, minh, minw2, minh2;
|
|
|
|
Evas *evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
Eina_List *l;
|
|
|
|
Eina_Stringshare *name;
|
|
|
|
Evas_Object *obj, *obj2;
|
|
|
|
Eina_Bool b;
|
|
|
|
|
|
|
|
obj = edje_object_add(evas);
|
|
|
|
fail_unless(edje_object_file_set(obj, test_layout_get("test_size_class.edj"), "test_group"));
|
|
|
|
|
|
|
|
obj2 = edje_object_add(evas);
|
|
|
|
fail_unless(edje_object_file_set(obj2, test_layout_get("test_size_class.edj"), "test_group"));
|
|
|
|
|
|
|
|
evas_object_resize(obj, 200, 200);
|
|
|
|
evas_object_resize(obj2, 200, 200);
|
|
|
|
|
|
|
|
/* check predefined min size of rect part by edc */
|
|
|
|
edje_object_part_geometry_get(obj, "rect", NULL, NULL, &minw, &minh);
|
|
|
|
fail_if(minw != 50 || minh != 50);
|
|
|
|
|
|
|
|
/* check that edje_size_class_set works */
|
|
|
|
b = edje_size_class_set("rect_size", 100, 100, -1, -1);
|
|
|
|
edje_object_part_geometry_get(obj, "rect", NULL, NULL, &minw, &minh);
|
|
|
|
edje_object_part_geometry_get(obj2, "rect", NULL, NULL, &minw2, &minh2);
|
|
|
|
fail_if(!b || minw != 100 || minh != 100 || minw2 != 100 || minh2 != 100);
|
|
|
|
|
|
|
|
/* check that edje_size_class_get works */
|
|
|
|
b = edje_size_class_get("rect_size", &minw, &minh, NULL, NULL);
|
|
|
|
fail_if(!b || minw != 100 || minh != 100);
|
|
|
|
|
|
|
|
/* check that edje_size_class_list works */
|
|
|
|
l = edje_size_class_list();
|
|
|
|
EINA_LIST_FREE(l, name)
|
|
|
|
{
|
|
|
|
fail_if(strcmp(name, "rect_size"));
|
|
|
|
eina_stringshare_del(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check that edje_object_size_class_set works */
|
|
|
|
b = edje_object_size_class_set(obj, "rect_size", 150, 150, -1, -1);
|
|
|
|
edje_object_part_geometry_get(obj, "rect", NULL, NULL, &minw, &minh);
|
|
|
|
edje_object_part_geometry_get(obj2, "rect", NULL, NULL, &minw2, &minh2);
|
|
|
|
fail_if(!b || minw != 150 || minh != 150 || minw2 != 100 || minh2 != 100);
|
|
|
|
|
|
|
|
/* check that edje_object_size_class_get works */
|
|
|
|
b = edje_object_size_class_get(obj, "rect_size", &minw, &minh, NULL, NULL);
|
|
|
|
fail_if(!b || minw != 150 || minh != 150);
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2016-02-04 22:51:31 -08:00
|
|
|
START_TEST(edje_test_color_class)
|
|
|
|
{
|
|
|
|
Evas *evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
|
|
|
|
Eina_File *f;
|
|
|
|
Eina_Iterator *it;
|
|
|
|
Edje_Color_Class *itcc, *cc = NULL;
|
|
|
|
char *filename;
|
|
|
|
|
|
|
|
filename = realpath(test_layout_get("test_color_class.edj"), NULL);
|
|
|
|
fail_if(!filename);
|
|
|
|
|
|
|
|
f = eina_file_open(filename, EINA_FALSE);
|
|
|
|
fail_if(!f);
|
|
|
|
|
|
|
|
it = edje_mmap_color_class_iterator_new(f);
|
|
|
|
fail_if(!it);
|
|
|
|
EINA_ITERATOR_FOREACH(it, itcc)
|
|
|
|
{
|
|
|
|
if (!strcmp(itcc->name, "test_color_class"))
|
|
|
|
{
|
|
|
|
cc = itcc;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fail_if((!cc) || (cc->r != 100) || (cc->g != 100) || (cc->b != 100) || (cc->a != 100));
|
|
|
|
|
|
|
|
eina_iterator_free(it);
|
|
|
|
eina_file_close(f);
|
|
|
|
free(filename);
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2016-04-15 09:45:52 -07:00
|
|
|
START_TEST(edje_test_swallows)
|
|
|
|
{
|
|
|
|
Evas *evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
Evas_Object *ly, *o1, *o2;
|
|
|
|
|
|
|
|
ly = eo_add(EDJE_OBJECT_CLASS, evas);
|
|
|
|
fail_unless(edje_object_file_set(ly, test_layout_get("test_swallows.edj"), "test_group"));
|
|
|
|
|
|
|
|
fail_unless(edje_object_part_exists(ly, "swallow"));
|
|
|
|
|
|
|
|
|
|
|
|
o1 = eo_add(EDJE_OBJECT_CLASS, ly);
|
2016-04-20 20:04:13 -07:00
|
|
|
fail_if(!edje_object_part_swallow(ly, "swallow", o1));
|
2016-04-15 09:45:52 -07:00
|
|
|
ck_assert_ptr_eq(eo_parent_get(o1), ly);
|
|
|
|
|
2016-04-20 20:04:13 -07:00
|
|
|
edje_object_part_unswallow(ly, o1);
|
2016-04-15 09:45:52 -07:00
|
|
|
ck_assert_ptr_eq(eo_parent_get(o1), evas_common_evas_get(o1));
|
|
|
|
|
2016-04-20 20:04:13 -07:00
|
|
|
fail_if(!edje_object_part_swallow(ly, "swallow", o1));
|
2016-04-15 09:45:52 -07:00
|
|
|
ck_assert_ptr_eq(eo_parent_get(o1), ly);
|
|
|
|
|
|
|
|
o2 = eo_add(EDJE_OBJECT_CLASS, ly);
|
2016-04-20 20:04:13 -07:00
|
|
|
fail_if(!edje_object_part_swallow(ly, "swallow", o2));
|
|
|
|
ck_assert_ptr_eq(eo_parent_get(o2), ly);
|
|
|
|
/* o1 is deleted at this point. */
|
|
|
|
ck_assert_ptr_eq(eo_parent_get(o1), evas_common_evas_get(o1));
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST(edje_test_swallows_eoapi)
|
|
|
|
{
|
|
|
|
Evas *evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
Evas_Object *ly, *o1, *o2;
|
|
|
|
|
|
|
|
ly = eo_add(EDJE_OBJECT_CLASS, evas);
|
|
|
|
fail_unless(edje_object_file_set(ly, test_layout_get("test_swallows.edj"), "test_group"));
|
|
|
|
|
|
|
|
fail_unless(edje_object_part_exists(ly, "swallow"));
|
|
|
|
|
|
|
|
|
|
|
|
o1 = eo_add(EDJE_OBJECT_CLASS, ly);
|
2016-05-24 04:40:18 -07:00
|
|
|
fail_if(!efl_content_set(efl_part(ly, "swallow"), o1));
|
2016-04-20 20:04:13 -07:00
|
|
|
ck_assert_ptr_eq(eo_parent_get(o1), ly);
|
|
|
|
|
|
|
|
efl_content_remove(ly, o1);
|
|
|
|
ck_assert_ptr_eq(eo_parent_get(o1), evas_common_evas_get(o1));
|
|
|
|
|
2016-05-24 04:40:18 -07:00
|
|
|
fail_if(!efl_content_set(efl_part(ly, "swallow"), o1));
|
2016-04-20 20:04:13 -07:00
|
|
|
ck_assert_ptr_eq(eo_parent_get(o1), ly);
|
|
|
|
|
|
|
|
o2 = eo_add(EDJE_OBJECT_CLASS, ly);
|
2016-05-24 04:40:18 -07:00
|
|
|
fail_if(!efl_content_set(efl_part(ly, "swallow"), o2));
|
2016-04-15 09:45:52 -07:00
|
|
|
ck_assert_ptr_eq(eo_parent_get(o2), ly);
|
|
|
|
/* o1 is deleted at this point. */
|
|
|
|
ck_assert_ptr_eq(eo_parent_get(o1), evas_common_evas_get(o1));
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2016-04-21 02:10:30 -07:00
|
|
|
START_TEST(edje_test_access)
|
|
|
|
{
|
|
|
|
Evas *evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
const char *name;
|
|
|
|
Evas_Object *obj;
|
|
|
|
Eina_Iterator *it;
|
|
|
|
Eina_List *list;
|
|
|
|
char buf[20];
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
obj = edje_object_add(evas);
|
|
|
|
fail_unless(edje_object_file_set(obj, test_layout_get("test_layout.edj"), "test_group"));
|
|
|
|
|
|
|
|
/* eo api */
|
|
|
|
it = edje_obj_access_part_iterate(obj);
|
|
|
|
fail_if(!it);
|
|
|
|
|
|
|
|
EINA_ITERATOR_FOREACH(it, name)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
sprintf(buf, "access_%d", i);
|
|
|
|
fail_if(!name || strcmp(name, buf) != 0);
|
|
|
|
}
|
|
|
|
fail_if(i != 2);
|
|
|
|
eina_iterator_free(it);
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
/* legacy api */
|
|
|
|
list = edje_object_access_part_list_get(obj);
|
|
|
|
fail_if(!list);
|
|
|
|
EINA_LIST_FREE(list, name)
|
|
|
|
{
|
|
|
|
i++;
|
|
|
|
sprintf(buf, "access_%d", i);
|
|
|
|
fail_if(!name || strcmp(name, buf) != 0);
|
|
|
|
}
|
|
|
|
fail_if(i != 2);
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2016-04-18 16:17:45 -07:00
|
|
|
START_TEST(edje_test_box)
|
|
|
|
{
|
|
|
|
Evas *evas;
|
|
|
|
Evas_Object *obj, *sobj, *sobjs[5];
|
|
|
|
const Evas_Object *box;
|
|
|
|
Eina_Iterator *it;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
|
|
|
|
obj = edje_object_add(evas);
|
|
|
|
fail_unless(edje_object_file_set(obj, test_layout_get("test_box.edj"), "test_group"));
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
sobjs[i] = evas_object_rectangle_add(evas);
|
|
|
|
fail_if(!sobjs[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
edje_object_part_box_append(obj, "box", sobjs[3]);
|
|
|
|
edje_object_part_box_prepend(obj, "box", sobjs[1]);
|
|
|
|
edje_object_part_box_insert_before(obj, "box", sobjs[0], sobjs[1]);
|
|
|
|
edje_object_part_box_insert_after(obj, "box", sobjs[4], sobjs[3]);
|
|
|
|
edje_object_part_box_insert_at(obj, "box", sobjs[2], 2);
|
|
|
|
|
|
|
|
box = edje_object_part_object_get(obj, "box");
|
|
|
|
it = evas_object_box_iterator_new(box);
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
EINA_ITERATOR_FOREACH(it, sobj)
|
|
|
|
{
|
|
|
|
fail_if(sobj != sobjs[i++]);
|
|
|
|
}
|
|
|
|
eina_iterator_free(it);
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2016-04-21 22:58:49 -07:00
|
|
|
START_TEST(edje_test_box_eoapi)
|
|
|
|
{
|
|
|
|
Evas *evas;
|
|
|
|
Evas_Object *obj, *sobj, *sobjs[5];
|
|
|
|
Eina_Iterator *it;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
|
|
|
|
obj = edje_object_add(evas);
|
|
|
|
fail_unless(edje_object_file_set(obj, test_layout_get("test_box.edj"), "test_group"));
|
|
|
|
|
|
|
|
for (i = 0; i < 5; i++)
|
|
|
|
{
|
|
|
|
sobjs[i] = evas_object_rectangle_add(evas);
|
|
|
|
fail_if(!sobjs[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* same test case as legacy api above */
|
2016-05-23 22:49:58 -07:00
|
|
|
efl_pack_end(efl_part(obj, "box"), sobjs[3]);
|
|
|
|
efl_pack_begin(efl_part(obj, "box"), sobjs[1]);
|
|
|
|
efl_pack_before(efl_part(obj, "box"), sobjs[0], sobjs[1]);
|
|
|
|
efl_pack_after(efl_part(obj, "box"), sobjs[4], sobjs[3]);
|
|
|
|
efl_pack_at(efl_part(obj, "box"), sobjs[2], 2);
|
|
|
|
fail_if(efl_content_count(efl_part(obj, "box")) != 5);
|
|
|
|
|
|
|
|
it = efl_content_iterate(efl_part(obj, "box"));
|
2016-04-21 22:58:49 -07:00
|
|
|
i = 0;
|
|
|
|
EINA_ITERATOR_FOREACH(it, sobj)
|
|
|
|
fail_if(sobj != sobjs[i++]);
|
|
|
|
fail_if(i != 5);
|
|
|
|
eina_iterator_free(it);
|
|
|
|
|
|
|
|
/* clear up and test a bit more */
|
2016-05-23 22:49:58 -07:00
|
|
|
efl_pack_unpack_all(efl_part(obj, "box"));
|
|
|
|
fail_if(efl_content_count(efl_part(obj, "box")) != 0);
|
2016-04-21 22:58:49 -07:00
|
|
|
|
2016-05-23 22:49:58 -07:00
|
|
|
efl_pack(efl_part(obj, "box"), sobjs[1]);
|
|
|
|
efl_pack_at(efl_part(obj, "box"), sobjs[0], 0);
|
|
|
|
efl_pack_at(efl_part(obj, "box"), sobjs[2], -1);
|
|
|
|
it = efl_content_iterate(efl_part(obj, "box"));
|
2016-04-21 22:58:49 -07:00
|
|
|
i = 0;
|
|
|
|
EINA_ITERATOR_FOREACH(it, sobj)
|
|
|
|
fail_if(sobj != sobjs[i++]);
|
|
|
|
fail_if(i != 3);
|
|
|
|
eina_iterator_free(it);
|
|
|
|
|
2016-05-23 22:49:58 -07:00
|
|
|
fail_if(!efl_content_remove(efl_part(obj, "box"), sobjs[0]));
|
|
|
|
fail_if(efl_content_count(efl_part(obj, "box")) != 2);
|
|
|
|
fail_if(!efl_pack_unpack_at(efl_part(obj, "box"), 1));
|
|
|
|
fail_if(efl_content_count(efl_part(obj, "box")) != 1);
|
|
|
|
fail_if(efl_pack_index_get(efl_part(obj, "box"), sobjs[1]) != 0);
|
2016-04-21 22:58:49 -07:00
|
|
|
|
2016-05-23 22:49:58 -07:00
|
|
|
efl_pack_clear(efl_part(obj, "box"));
|
|
|
|
fail_if(efl_content_count(efl_part(obj, "box")) != 0);
|
2016-04-21 22:58:49 -07:00
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2016-04-25 00:20:57 -07:00
|
|
|
START_TEST(edje_test_table)
|
|
|
|
{
|
|
|
|
Evas *evas;
|
|
|
|
Evas_Object *obj, *sobj, *sobjs[4];
|
|
|
|
int i, k, l, cols, rows;
|
|
|
|
|
|
|
|
evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
|
|
|
|
obj = edje_object_add(evas);
|
|
|
|
fail_unless(edje_object_file_set(obj, test_layout_get("test_table.edj"), "test_group"));
|
|
|
|
|
|
|
|
/* check items from EDC */
|
|
|
|
for (l = 0; l < 2; l++)
|
|
|
|
for (k = 0; k < 2; k++)
|
|
|
|
{
|
|
|
|
const char *txt;
|
|
|
|
char buf[20];
|
|
|
|
|
|
|
|
/* items have a text part "text" containing their position */
|
|
|
|
sprintf(buf, "%d,%d", k, l);
|
|
|
|
sobj = edje_object_part_table_child_get(obj, "table", k, l);
|
|
|
|
fail_if(!sobj);
|
|
|
|
txt = edje_object_part_text_get(sobj, "text");
|
|
|
|
fail_if(!txt);
|
|
|
|
fail_if(strcmp(txt, buf) != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add more items */
|
|
|
|
for (l = 0; l < 2; l++)
|
|
|
|
for (k = 0; k < 2; k++)
|
|
|
|
{
|
|
|
|
i = l*2 + k;
|
|
|
|
sobjs[i] = evas_object_rectangle_add(evas);
|
|
|
|
fail_if(!sobjs[i]);
|
|
|
|
edje_object_part_table_pack(obj, "table", sobjs[i], k, l + 2, 1, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (l = 0; l < 2; l++)
|
|
|
|
for (k = 0; k < 2; k++)
|
|
|
|
{
|
|
|
|
i = l*2 + k;
|
|
|
|
sobj = edje_object_part_table_child_get(obj, "table", k, l + 2);
|
|
|
|
fail_if(sobj != sobjs[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* table size and clear */
|
|
|
|
edje_object_part_table_col_row_size_get(obj, "table", &cols, &rows);
|
|
|
|
fail_if(cols != 2);
|
|
|
|
fail_if(rows != 4);
|
|
|
|
|
|
|
|
edje_object_part_table_clear(obj, "table", EINA_TRUE);
|
|
|
|
|
|
|
|
edje_object_part_table_col_row_size_get(obj, "table", &cols, &rows);
|
|
|
|
fail_if(cols != 2);
|
|
|
|
fail_if(rows != 2);
|
|
|
|
|
|
|
|
for (l = 0; l < 2; l++)
|
|
|
|
for (k = 0; k < 2; k++)
|
|
|
|
{
|
|
|
|
const char *txt;
|
|
|
|
char buf[20];
|
|
|
|
|
|
|
|
/* items have a text part "text" containing their position */
|
|
|
|
sprintf(buf, "%d,%d", k, l);
|
|
|
|
sobj = edje_object_part_table_child_get(obj, "table", k, l);
|
|
|
|
fail_if(!sobj);
|
|
|
|
txt = edje_object_part_text_get(sobj, "text");
|
|
|
|
fail_if(!txt);
|
|
|
|
fail_if(strcmp(txt, buf) != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
|
|
|
START_TEST(edje_test_table_eoapi)
|
|
|
|
{
|
|
|
|
Evas *evas;
|
2016-05-23 22:49:58 -07:00
|
|
|
Evas_Object *obj, *sobj, *sobjs[4], *proxy;
|
2016-04-25 00:20:57 -07:00
|
|
|
Eina_Iterator *it;
|
|
|
|
int i, k, l, cs, rs, cols, rows;
|
|
|
|
|
|
|
|
evas = EDJE_TEST_INIT_EVAS();
|
|
|
|
|
|
|
|
obj = edje_object_add(evas);
|
|
|
|
fail_unless(edje_object_file_set(obj, test_layout_get("test_table.edj"), "test_group"));
|
|
|
|
|
|
|
|
/* check items from EDC */
|
2016-05-23 22:49:58 -07:00
|
|
|
fail_if(efl_content_count(efl_part(obj, "table")) != 4);
|
2016-04-25 00:20:57 -07:00
|
|
|
for (l = 0; l < 2; l++)
|
|
|
|
for (k = 0; k < 2; k++)
|
|
|
|
{
|
|
|
|
const char *txt;
|
|
|
|
char buf[20];
|
|
|
|
|
|
|
|
/* items have a text part "text" containing their position */
|
|
|
|
sprintf(buf, "%d,%d", k, l);
|
2016-05-23 22:49:58 -07:00
|
|
|
sobj = efl_pack_grid_content_get(efl_part(obj, "table"), k, l);
|
2016-04-25 00:20:57 -07:00
|
|
|
fail_if(!sobj);
|
|
|
|
//txt = efl_part_text_get(sobj, "text");
|
|
|
|
txt = edje_object_part_text_get(sobj, "text");
|
|
|
|
fail_if(!txt);
|
|
|
|
fail_if(strcmp(txt, buf) != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add more items */
|
|
|
|
for (l = 0; l < 2; l++)
|
|
|
|
for (k = 0; k < 2; k++)
|
|
|
|
{
|
|
|
|
i = l*2 + k;
|
|
|
|
sobjs[i] = eo_add(EVAS_RECTANGLE_CLASS, evas);
|
|
|
|
fail_if(!sobjs[i]);
|
2016-05-23 22:49:58 -07:00
|
|
|
efl_pack_grid(efl_part(obj, "table"), sobjs[i], k, l + 2, 1, 1);
|
2016-04-25 00:20:57 -07:00
|
|
|
}
|
|
|
|
|
2016-05-23 22:49:58 -07:00
|
|
|
fail_if(efl_content_count(efl_part(obj, "table")) != 8);
|
2016-04-25 00:20:57 -07:00
|
|
|
|
|
|
|
i = 0;
|
2016-05-23 22:49:58 -07:00
|
|
|
it = efl_content_iterate(efl_part(obj, "table"));
|
2016-04-25 00:20:57 -07:00
|
|
|
EINA_ITERATOR_FOREACH(it, sobj)
|
|
|
|
{
|
2016-05-23 22:49:58 -07:00
|
|
|
efl_pack_grid_position_get(efl_part(obj, "table"), sobj, &k, &l, &cs, &rs);
|
2016-04-25 00:20:57 -07:00
|
|
|
fail_if(cs != 1);
|
|
|
|
fail_if(rs != 1);
|
|
|
|
if (l >= 2)
|
|
|
|
fail_if(sobj != sobjs[(l - 2)*2 + k]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
eina_iterator_free(it);
|
|
|
|
fail_if(i != 8);
|
|
|
|
|
|
|
|
/* table size and clear */
|
2016-05-23 22:49:58 -07:00
|
|
|
efl_pack_grid_size_get(efl_part(obj, "table"), &cols, &rows);
|
2016-04-25 00:20:57 -07:00
|
|
|
fail_if(cols != 2);
|
|
|
|
fail_if(rows != 4);
|
|
|
|
|
2016-05-23 22:49:58 -07:00
|
|
|
efl_pack_clear(efl_part(obj, "table"));
|
|
|
|
fail_if(efl_content_count(efl_part(obj, "table")) != 4);
|
2016-04-25 00:20:57 -07:00
|
|
|
|
2016-05-23 22:49:58 -07:00
|
|
|
efl_pack_grid_size_get(efl_part(obj, "table"), &cols, &rows);
|
2016-04-25 00:20:57 -07:00
|
|
|
fail_if(cols != 2);
|
|
|
|
fail_if(rows != 2);
|
|
|
|
|
2016-05-23 22:49:58 -07:00
|
|
|
/* test multiple ops on a proxy object */
|
|
|
|
proxy = eo_ref(efl_part(obj, "table"));
|
|
|
|
fail_if(!proxy);
|
|
|
|
fail_if(!efl_pack_clear(proxy));
|
2016-05-24 02:14:05 -07:00
|
|
|
fail_if(efl_content_count(efl_part(obj, "table")) != 4);
|
2016-05-23 22:49:58 -07:00
|
|
|
fail_if(!efl_pack_clear(proxy));
|
2016-05-24 02:14:05 -07:00
|
|
|
fail_if(efl_content_count(efl_part(obj, "table2")) != 1);
|
|
|
|
fail_if(efl_content_count(proxy) != 4);
|
Revert "Eo: Remove eo_del() and make eo_unref() the replacement."
This reverts commit 546ff7bbba788ec834c5608361c0834853f2d5d7.
It seems that eo_del() is useful and removing it was creating bugs.
The issue is that the way we defined parents in eo, both the parent and
the programmer share a reference to the object. When we eo_unref() that
reference as the programmer, eo has no way to know it's this specific
reference we are freeing, and not a general one, so in some
circumstances, for example:
eo_ref(child);
eo_unref(child); // trying to delete here
eo_unref(container); // container is deleted here
eo_unref(child); // child already has 0 refs before this point.
We would have an issue with references and objects being freed too soon
and in general, issue with the references.
Having eo_del() solves that, because this one explicitly unparents if
there is a parent, meaning the reference ownership is explicitly taken
by the programmer.
eo_del() is essentially a convenience function around "check if has
parent, and if so unparent, otherwise, unref". Which should be used when
you want to delete an object although it has a parent, and is equivalent
to eo_unref() when it doesn't have one.
2016-06-01 05:14:30 -07:00
|
|
|
eo_del(proxy);
|
2016-04-28 21:19:20 -07:00
|
|
|
|
2016-04-25 00:20:57 -07:00
|
|
|
EDJE_TEST_FREE_EVAS();
|
|
|
|
}
|
|
|
|
END_TEST
|
|
|
|
|
2013-03-12 23:23:23 -07:00
|
|
|
void edje_test_edje(TCase *tc)
|
2016-02-04 05:21:44 -08:00
|
|
|
{
|
2011-09-14 12:02:07 -07:00
|
|
|
tcase_add_test(tc, edje_test_edje_init);
|
2016-04-21 22:58:49 -07:00
|
|
|
tcase_add_test(tc, edje_test_load_simple_layout);
|
2013-02-21 00:39:09 -08:00
|
|
|
tcase_add_test(tc, edje_test_edje_load);
|
2013-06-27 09:51:30 -07:00
|
|
|
tcase_add_test(tc, edje_test_simple_layout_geometry);
|
2013-06-27 09:53:48 -07:00
|
|
|
tcase_add_test(tc, edje_test_complex_layout);
|
2015-05-29 09:11:49 -07:00
|
|
|
tcase_add_test(tc, edje_test_calculate_parens);
|
2015-06-11 01:46:50 -07:00
|
|
|
tcase_add_test(tc, edje_test_masking);
|
2015-06-22 20:38:32 -07:00
|
|
|
tcase_add_test(tc, edje_test_filters);
|
2015-09-07 03:08:50 -07:00
|
|
|
tcase_add_test(tc, edje_test_snapshot);
|
2015-12-15 21:53:59 -08:00
|
|
|
tcase_add_test(tc, edje_test_size_class);
|
2016-02-04 22:51:31 -08:00
|
|
|
tcase_add_test(tc, edje_test_color_class);
|
2016-04-15 09:45:52 -07:00
|
|
|
tcase_add_test(tc, edje_test_swallows);
|
2016-04-20 20:04:13 -07:00
|
|
|
tcase_add_test(tc, edje_test_swallows_eoapi);
|
2016-04-21 02:10:30 -07:00
|
|
|
tcase_add_test(tc, edje_test_access);
|
2016-04-18 16:17:45 -07:00
|
|
|
tcase_add_test(tc, edje_test_box);
|
2016-04-21 22:58:49 -07:00
|
|
|
tcase_add_test(tc, edje_test_box_eoapi);
|
2016-04-25 00:20:57 -07:00
|
|
|
tcase_add_test(tc, edje_test_table);
|
|
|
|
tcase_add_test(tc, edje_test_table_eoapi);
|
2011-09-14 12:02:07 -07:00
|
|
|
}
|