summaryrefslogtreecommitdiff
path: root/src/tests/edje/edje_test_text.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/edje/edje_test_text.c')
-rw-r--r--src/tests/edje/edje_test_text.c239
1 files changed, 239 insertions, 0 deletions
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 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <unistd.h>
6#include <stdio.h>
7
8#define EFL_GFX_FILTER_BETA
9#define EFL_CANVAS_LAYOUT_BETA
10
11#include <Eina.h>
12#include <Edje.h>
13
14#include "edje_suite.h"
15#include "edje_tests_helpers.h"
16
17#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas"
18
19static const char *
20test_layout_get(const char *name)
21{
22 static char filename[PATH_MAX];
23
24 snprintf(filename, PATH_MAX, TESTS_BUILD_DIR"/data/%s", name);
25
26 return filename;
27}
28
29START_TEST(edje_test_text_ellipsis)
30{
31 Eo *evas = EDJE_TEST_INIT_EVAS();
32 Eo *layout;
33
34 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
35 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
36 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
37 fail_if(efl_file_load_error_get(layout));
38
39 efl_text_ellipsis_set(efl_part(layout, "text"), 1.0);
40
41 EDJE_TEST_FREE_EVAS();
42}
43END_TEST
44
45START_TEST(edje_test_text_wrap)
46{
47 Eo *evas = EDJE_TEST_INIT_EVAS();
48 Eo *layout;
49
50 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
51 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
52 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
53 fail_if(efl_file_load_error_get(layout));
54
55 efl_text_wrap_set(efl_part(layout, "text"), EFL_TEXT_FORMAT_WRAP_WORD);
56
57 EDJE_TEST_FREE_EVAS();
58}
59END_TEST
60
61START_TEST(edje_test_text_font)
62{
63 Eo *evas = EDJE_TEST_INIT_EVAS();
64 Eo *layout;
65
66 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
67 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
68 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
69 fail_if(efl_file_load_error_get(layout));
70
71 efl_text_font_set(efl_part(layout, "text"), "Sans", 14);
72
73 EDJE_TEST_FREE_EVAS();
74}
75END_TEST
76
77START_TEST(edje_test_text_color)
78{
79 Eo *evas = EDJE_TEST_INIT_EVAS();
80 Eo *layout;
81
82 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
83 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
84 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
85 fail_if(efl_file_load_error_get(layout));
86
87 efl_text_normal_color_set(efl_part(layout, "text"), 255, 255, 255, 255);
88
89 EDJE_TEST_FREE_EVAS();
90}
91END_TEST
92
93static void
94_basic_check(Eo *layout, Eina_Bool set)
95{
96 // Colors
97 {
98 unsigned char r, g, b, a;
99
100 // Just normal_color is enough
101 if (set)
102 {
103 efl_text_normal_color_set(efl_part(layout, "text"),
104 255, 255, 255, 255);
105 efl_text_backing_color_set(efl_part(layout, "text"),
106 255, 255, 255, 255);
107 efl_text_glow_color_set(efl_part(layout, "text"),
108 255, 255, 255, 255);
109 efl_text_glow2_color_set(efl_part(layout, "text"),
110 255, 255, 255, 255);
111 efl_text_outline_color_set(efl_part(layout, "text"),
112 255, 255, 255, 255);
113 efl_text_shadow_color_set(efl_part(layout, "text"),
114 255, 255, 255, 255);
115 efl_text_strikethrough_color_set(efl_part(layout, "text"),
116 255, 255, 255, 255);
117 efl_text_underline_color_set(efl_part(layout, "text"),
118 255, 255, 255, 255);
119 efl_text_underline2_color_set(efl_part(layout, "text"),
120 255, 255, 255, 255);
121 efl_text_underline_dashed_color_set(efl_part(layout, "text"),
122 255, 255, 255, 255);
123 }
124
125 efl_text_normal_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
126 ck_assert_int_eq(r, 255);
127 ck_assert_int_eq(g, 255);
128 ck_assert_int_eq(b, 255);
129 ck_assert_int_eq(a, 255);
130
131 efl_text_backing_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
132 ck_assert_int_eq(r, 255);
133 ck_assert_int_eq(g, 255);
134 ck_assert_int_eq(b, 255);
135 ck_assert_int_eq(a, 255);
136
137 efl_text_glow_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
138 ck_assert_int_eq(r, 255);
139 ck_assert_int_eq(g, 255);
140 ck_assert_int_eq(b, 255);
141 ck_assert_int_eq(a, 255);
142
143 efl_text_glow2_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
144 ck_assert_int_eq(r, 255);
145 ck_assert_int_eq(g, 255);
146 ck_assert_int_eq(b, 255);
147 ck_assert_int_eq(a, 255);
148
149 efl_text_outline_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
150 ck_assert_int_eq(r, 255);
151 ck_assert_int_eq(g, 255);
152 ck_assert_int_eq(b, 255);
153 ck_assert_int_eq(a, 255);
154
155 efl_text_shadow_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
156 ck_assert_int_eq(r, 255);
157 ck_assert_int_eq(g, 255);
158 ck_assert_int_eq(b, 255);
159 ck_assert_int_eq(a, 255);
160
161 efl_text_strikethrough_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
162 ck_assert_int_eq(r, 255);
163 ck_assert_int_eq(g, 255);
164 ck_assert_int_eq(b, 255);
165 ck_assert_int_eq(a, 255);
166
167 efl_text_underline_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
168 ck_assert_int_eq(r, 255);
169 ck_assert_int_eq(g, 255);
170 ck_assert_int_eq(b, 255);
171 ck_assert_int_eq(a, 255);
172
173 efl_text_underline2_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
174 ck_assert_int_eq(r, 255);
175 ck_assert_int_eq(g, 255);
176 ck_assert_int_eq(b, 255);
177 ck_assert_int_eq(a, 255);
178
179 efl_text_underline_dashed_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
180 ck_assert_int_eq(r, 255);
181 ck_assert_int_eq(g, 255);
182 ck_assert_int_eq(b, 255);
183 ck_assert_int_eq(a, 255);
184 }
185
186 // Rest of api
187 {
188 Efl_Text_Format_Wrap wrap;
189 double ellipsis;
190 const char *font;
191 Efl_Font_Size size;
192
193 if (set)
194 {
195 efl_text_wrap_set(efl_part(layout, "text"), EFL_TEXT_FORMAT_WRAP_WORD);
196 efl_text_ellipsis_set(efl_part(layout, "text"), 1.0);
197 efl_text_font_set(efl_part(layout, "text"), "Sans", 12);
198 }
199
200 wrap = efl_text_wrap_get(efl_part(layout, "text"));
201 ck_assert_int_eq(wrap, EFL_TEXT_FORMAT_WRAP_WORD);
202
203 ellipsis = efl_text_ellipsis_get(efl_part(layout, "text"));
204 ck_assert(EINA_DBL_EQ(ellipsis, 1.0));
205
206 efl_text_font_get(efl_part(layout, "text"), &font, &size);
207 ck_assert_str_eq(font, "Sans");
208 ck_assert_int_eq(size, 12);
209 }
210}
211
212START_TEST(edje_test_text_part)
213{
214 Eo *evas = EDJE_TEST_INIT_EVAS();
215 Eo *layout;
216
217 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
218 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
219
220 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
221 fail_if(efl_file_load_error_get(layout));
222 _basic_check(layout, EINA_TRUE);
223
224 // Load again and check persistance
225 efl_file_set(layout, test_layout_get("test_text.edj"), "test2");
226 fail_if(efl_file_load_error_get(layout));
227 _basic_check(layout, EINA_FALSE);
228
229 EDJE_TEST_FREE_EVAS();
230}
231END_TEST
232void edje_test_text(TCase *tc)
233{
234 tcase_add_test(tc, edje_test_text_ellipsis);
235 tcase_add_test(tc, edje_test_text_wrap);
236 tcase_add_test(tc, edje_test_text_font);
237 tcase_add_test(tc, edje_test_text_color);
238 tcase_add_test(tc, edje_test_text_part);
239}