aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/edje
diff options
context:
space:
mode:
authorDaniel Hirt <hirt.danny@gmail.com>2018-06-05 21:02:43 +0300
committerDaniel Hirt <hirt.danny@gmail.com>2018-06-20 15:18:00 +0300
commit88e16b338823dcfbc21cbe88056dc31895036bd1 (patch)
tree653cb584dc730655832858f52387d5513c291913 /src/tests/edje
parentCanvas text: share common style strings in style_set (diff)
downloadefl-devs/herdsman/edje_part_next.tar.gz
Canvas layout: support more Efl.Text.* with efl_partdevs/herdsman/edje_part_next
This adds many Efl.Text.* that are useful for manipulating the underlying TEXTBLOCK object's propeties using efl_part. This has been implemented as part of the "user-defined" properties of the layout part, so that the changes on the part persist across load of different groups. Note that text styles have precedence over the TEXTBLOCK (Canvas.Text) object's properties. if an edc provides a style, the properties it manipulates as part of the "base:" string would not be affected by this API. In general, this helps reducing the amount of styles for objects (or modes of the same objects) that share the same setup, but are different in some properties (e.g. ellipsis, wrap etc). @feature Canvas layout: add text part "expand" property This adds "expansion modes", which are essentially the same as min/max hints in the edje part's 'description.text' fields. The user can then customize his widget to different modes without being forced to create a new edje group in the theme. Note that there is an added check in case one of the min/max text flags are provided from the theme. In such case, all flags from this new API will be ignored. This fortifies misuse where the flags are set both in theme and the API. @feature
Diffstat (limited to 'src/tests/edje')
-rw-r--r--src/tests/edje/data/test_text.edc41
-rw-r--r--src/tests/edje/edje_suite.c1
-rw-r--r--src/tests/edje/edje_suite.h1
-rw-r--r--src/tests/edje/edje_test_text.c239
4 files changed, 282 insertions, 0 deletions
diff --git a/src/tests/edje/data/test_text.edc b/src/tests/edje/data/test_text.edc
new file mode 100644
index 0000000000..9395a2d4de
--- /dev/null
+++ b/src/tests/edje/data/test_text.edc
@@ -0,0 +1,41 @@
+collections {
+ styles {
+ style { name: "tbstyle";
+ base: "";
+ }
+ }
+ group { name: "test";
+ parts {
+ textblock { "text"; nomouse;
+ desc { "default";
+ rel1.relative: 0.0 0.0;
+ rel2.relative: 1.0 1.0;
+ text {
+ style: "tbstyle";
+ font: FN; size: 10;
+ align: 0.5 0.5;
+ min: 0 0;
+ }
+ visible: 1;
+ }
+ }
+ }
+ }
+ group { name: "test2";
+ parts {
+ textblock { "text"; nomouse;
+ desc { "default";
+ rel1.relative: 0.0 0.0;
+ rel2.relative: 1.0 1.0;
+ text {
+ style: "tbstyle";
+ font: FN; size: 10;
+ align: 0.5 0.5;
+ min: 0 0;
+ }
+ visible: 1;
+ }
+ }
+ }
+ }
+}
diff --git a/src/tests/edje/edje_suite.c b/src/tests/edje/edje_suite.c
index 80cb84a8f6..cac6982874 100644
--- a/src/tests/edje/edje_suite.c
+++ b/src/tests/edje/edje_suite.c
@@ -8,6 +8,7 @@
static const Efl_Test_Case etc[] = {
{ "Edje", edje_test_edje },
+ { "Edje Text", edje_test_text },
{ NULL, NULL }
};
diff --git a/src/tests/edje/edje_suite.h b/src/tests/edje/edje_suite.h
index a6f1354fec..85574ed928 100644
--- a/src/tests/edje/edje_suite.h
+++ b/src/tests/edje/edje_suite.h
@@ -4,6 +4,7 @@
#include <check.h>
#include "../efl_check.h"
void edje_test_edje(TCase *tc);
+void edje_test_text(TCase *tc);
#endif /* _EDJE_SUITE_H */
diff --git a/src/tests/edje/edje_test_text.c b/src/tests/edje/edje_test_text.c
new file mode 100644
index 0000000000..7d878a6153
--- /dev/null
+++ b/src/tests/edje/edje_test_text.c
@@ -0,0 +1,239 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <unistd.h>
+#include <stdio.h>
+
+#define EFL_GFX_FILTER_BETA
+#define EFL_CANVAS_LAYOUT_BETA
+
+#include <Eina.h>
+#include <Edje.h>
+
+#include "edje_suite.h"
+#include "edje_tests_helpers.h"
+
+#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas"
+
+static const char *
+test_layout_get(const char *name)
+{
+ static char filename[PATH_MAX];
+
+ snprintf(filename, PATH_MAX, TESTS_BUILD_DIR"/data/%s", name);
+
+ return filename;
+}
+
+START_TEST(edje_test_text_ellipsis)
+{
+ Eo *evas = EDJE_TEST_INIT_EVAS();
+ Eo *layout;
+
+ layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
+ efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
+ efl_file_set(layout, test_layout_get("test_text.edj"), "test");
+ fail_if(efl_file_load_error_get(layout));
+
+ efl_text_ellipsis_set(efl_part(layout, "text"), 1.0);
+
+ EDJE_TEST_FREE_EVAS();
+}
+END_TEST
+
+START_TEST(edje_test_text_wrap)
+{
+ Eo *evas = EDJE_TEST_INIT_EVAS();
+ Eo *layout;
+
+ layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
+ efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
+ efl_file_set(layout, test_layout_get("test_text.edj"), "test");
+ fail_if(efl_file_load_error_get(layout));
+
+ efl_text_wrap_set(efl_part(layout, "text"), EFL_TEXT_FORMAT_WRAP_WORD);
+
+ EDJE_TEST_FREE_EVAS();
+}
+END_TEST
+
+START_TEST(edje_test_text_font)
+{
+ Eo *evas = EDJE_TEST_INIT_EVAS();
+ Eo *layout;
+
+ layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
+ efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
+ efl_file_set(layout, test_layout_get("test_text.edj"), "test");
+ fail_if(efl_file_load_error_get(layout));
+
+ efl_text_font_set(efl_part(layout, "text"), "Sans", 14);
+
+ EDJE_TEST_FREE_EVAS();
+}
+END_TEST
+
+START_TEST(edje_test_text_color)
+{
+ Eo *evas = EDJE_TEST_INIT_EVAS();
+ Eo *layout;
+
+ layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
+ efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
+ efl_file_set(layout, test_layout_get("test_text.edj"), "test");
+ fail_if(efl_file_load_error_get(layout));
+
+ efl_text_normal_color_set(efl_part(layout, "text"), 255, 255, 255, 255);
+
+ EDJE_TEST_FREE_EVAS();
+}
+END_TEST
+
+static void
+_basic_check(Eo *layout, Eina_Bool set)
+{
+ // Colors
+ {
+ unsigned char r, g, b, a;
+
+ // Just normal_color is enough
+ if (set)
+ {
+ efl_text_normal_color_set(efl_part(layout, "text"),
+ 255, 255, 255, 255);
+ efl_text_backing_color_set(efl_part(layout, "text"),
+ 255, 255, 255, 255);
+ efl_text_glow_color_set(efl_part(layout, "text"),
+ 255, 255, 255, 255);
+ efl_text_glow2_color_set(efl_part(layout, "text"),
+ 255, 255, 255, 255);
+ efl_text_outline_color_set(efl_part(layout, "text"),
+ 255, 255, 255, 255);
+ efl_text_shadow_color_set(efl_part(layout, "text"),
+ 255, 255, 255, 255);
+ efl_text_strikethrough_color_set(efl_part(layout, "text"),
+ 255, 255, 255, 255);
+ efl_text_underline_color_set(efl_part(layout, "text"),
+ 255, 255, 255, 255);
+ efl_text_underline2_color_set(efl_part(layout, "text"),
+ 255, 255, 255, 255);
+ efl_text_underline_dashed_color_set(efl_part(layout, "text"),
+ 255, 255, 255, 255);
+ }
+
+ efl_text_normal_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
+ ck_assert_int_eq(r, 255);
+ ck_assert_int_eq(g, 255);
+ ck_assert_int_eq(b, 255);
+ ck_assert_int_eq(a, 255);
+
+ efl_text_backing_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
+ ck_assert_int_eq(r, 255);
+ ck_assert_int_eq(g, 255);
+ ck_assert_int_eq(b, 255);
+ ck_assert_int_eq(a, 255);
+
+ efl_text_glow_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
+ ck_assert_int_eq(r, 255);
+ ck_assert_int_eq(g, 255);
+ ck_assert_int_eq(b, 255);
+ ck_assert_int_eq(a, 255);
+
+ efl_text_glow2_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
+ ck_assert_int_eq(r, 255);
+ ck_assert_int_eq(g, 255);
+ ck_assert_int_eq(b, 255);
+ ck_assert_int_eq(a, 255);
+
+ efl_text_outline_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
+ ck_assert_int_eq(r, 255);
+ ck_assert_int_eq(g, 255);
+ ck_assert_int_eq(b, 255);
+ ck_assert_int_eq(a, 255);
+
+ efl_text_shadow_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
+ ck_assert_int_eq(r, 255);
+ ck_assert_int_eq(g, 255);
+ ck_assert_int_eq(b, 255);
+ ck_assert_int_eq(a, 255);
+
+ efl_text_strikethrough_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
+ ck_assert_int_eq(r, 255);
+ ck_assert_int_eq(g, 255);
+ ck_assert_int_eq(b, 255);
+ ck_assert_int_eq(a, 255);
+
+ efl_text_underline_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
+ ck_assert_int_eq(r, 255);
+ ck_assert_int_eq(g, 255);
+ ck_assert_int_eq(b, 255);
+ ck_assert_int_eq(a, 255);
+
+ efl_text_underline2_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
+ ck_assert_int_eq(r, 255);
+ ck_assert_int_eq(g, 255);
+ ck_assert_int_eq(b, 255);
+ ck_assert_int_eq(a, 255);
+
+ efl_text_underline_dashed_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
+ ck_assert_int_eq(r, 255);
+ ck_assert_int_eq(g, 255);
+ ck_assert_int_eq(b, 255);
+ ck_assert_int_eq(a, 255);
+ }
+
+ // Rest of api
+ {
+ Efl_Text_Format_Wrap wrap;
+ double ellipsis;
+ const char *font;
+ Efl_Font_Size size;
+
+ if (set)
+ {
+ efl_text_wrap_set(efl_part(layout, "text"), EFL_TEXT_FORMAT_WRAP_WORD);
+ efl_text_ellipsis_set(efl_part(layout, "text"), 1.0);
+ efl_text_font_set(efl_part(layout, "text"), "Sans", 12);
+ }
+
+ wrap = efl_text_wrap_get(efl_part(layout, "text"));
+ ck_assert_int_eq(wrap, EFL_TEXT_FORMAT_WRAP_WORD);
+
+ ellipsis = efl_text_ellipsis_get(efl_part(layout, "text"));
+ ck_assert(EINA_DBL_EQ(ellipsis, 1.0));
+
+ efl_text_font_get(efl_part(layout, "text"), &font, &size);
+ ck_assert_str_eq(font, "Sans");
+ ck_assert_int_eq(size, 12);
+ }
+}
+
+START_TEST(edje_test_text_part)
+{
+ Eo *evas = EDJE_TEST_INIT_EVAS();
+ Eo *layout;
+
+ layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
+ efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
+
+ efl_file_set(layout, test_layout_get("test_text.edj"), "test");
+ fail_if(efl_file_load_error_get(layout));
+ _basic_check(layout, EINA_TRUE);
+
+ // Load again and check persistance
+ efl_file_set(layout, test_layout_get("test_text.edj"), "test2");
+ fail_if(efl_file_load_error_get(layout));
+ _basic_check(layout, EINA_FALSE);
+
+ EDJE_TEST_FREE_EVAS();
+}
+END_TEST
+void edje_test_text(TCase *tc)
+{
+ tcase_add_test(tc, edje_test_text_ellipsis);
+ tcase_add_test(tc, edje_test_text_wrap);
+ tcase_add_test(tc, edje_test_text_font);
+ tcase_add_test(tc, edje_test_text_color);
+ tcase_add_test(tc, edje_test_text_part);
+}