summaryrefslogtreecommitdiff
path: root/src/tests/edje/edje_test_text.c
diff options
context:
space:
mode:
authorDaniel Hirt <hirt.danny@gmail.com>2018-11-06 16:52:53 +0200
committerDaniel Hirt <hirt.danny@gmail.com>2018-11-06 18:33:56 +0200
commitface90632e7796c146b18e31a93c164cbda43122 (patch)
tree9f562a695f47b8ffd639a9a71e4baed1bd757bc0 /src/tests/edje/edje_test_text.c
parent6285cfe366e7f60b862f19981062bdd2afe08c7c (diff)
Canvas layout: support more Efl.Text.* with efl_part
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/edje_test_text.c')
-rw-r--r--src/tests/edje/edje_test_text.c220
1 files changed, 219 insertions, 1 deletions
diff --git a/src/tests/edje/edje_test_text.c b/src/tests/edje/edje_test_text.c
index 0e975f3de7..c4ac3c8758 100644
--- a/src/tests/edje/edje_test_text.c
+++ b/src/tests/edje/edje_test_text.c
@@ -12,7 +12,6 @@
12 12
13#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas" 13#define EVAS_DATA_DIR TESTS_SRC_DIR "/../../lib/evas"
14 14
15
16EFL_START_TEST(edje_test_text_cursor) 15EFL_START_TEST(edje_test_text_cursor)
17{ 16{
18 Evas *evas; 17 Evas *evas;
@@ -115,8 +114,227 @@ EFL_START_TEST(edje_test_textblock)
115} 114}
116EFL_END_TEST 115EFL_END_TEST
117 116
117START_TEST(edje_test_text_ellipsis)
118{
119 Eo *evas;
120 Eo *layout;
121
122 evas = _setup_evas();
123
124 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
125 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
126 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
127 fail_if(efl_file_load_error_get(layout));
128
129 efl_text_ellipsis_set(efl_part(layout, "text"), 1.0);
130
131 evas_free(evas);
132}
133END_TEST
134
135START_TEST(edje_test_text_wrap)
136{
137 Eo *evas;
138 Eo *layout;
139
140 evas = _setup_evas();
141
142 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
143 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
144 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
145 fail_if(efl_file_load_error_get(layout));
146
147 efl_text_wrap_set(efl_part(layout, "text"), EFL_TEXT_FORMAT_WRAP_WORD);
148
149 evas_free(evas);
150}
151END_TEST
152
153START_TEST(edje_test_text_font)
154{
155 Eo *evas;
156 Eo *layout;
157
158 evas = _setup_evas();
159
160 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
161 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
162 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
163 fail_if(efl_file_load_error_get(layout));
164
165 efl_text_font_set(efl_part(layout, "text"), "Sans", 14);
166
167 evas_free(evas);
168}
169END_TEST
170
171START_TEST(edje_test_text_color)
172{
173 Eo *evas;
174 Eo *layout;
175
176 evas = _setup_evas();
177
178 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
179 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
180 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
181 fail_if(efl_file_load_error_get(layout));
182
183 efl_text_normal_color_set(efl_part(layout, "text"), 255, 255, 255, 255);
184
185 evas_free(evas);
186}
187END_TEST
188
189static void
190_basic_check(Eo *layout, Eina_Bool set)
191{
192 // Colors
193 {
194 unsigned char r, g, b, a;
195
196 // Just normal_color is enough
197 if (set)
198 {
199 efl_text_normal_color_set(efl_part(layout, "text"),
200 255, 255, 255, 255);
201 efl_text_backing_color_set(efl_part(layout, "text"),
202 255, 255, 255, 255);
203 efl_text_glow_color_set(efl_part(layout, "text"),
204 255, 255, 255, 255);
205 efl_text_glow2_color_set(efl_part(layout, "text"),
206 255, 255, 255, 255);
207 efl_text_outline_color_set(efl_part(layout, "text"),
208 255, 255, 255, 255);
209 efl_text_shadow_color_set(efl_part(layout, "text"),
210 255, 255, 255, 255);
211 efl_text_strikethrough_color_set(efl_part(layout, "text"),
212 255, 255, 255, 255);
213 efl_text_underline_color_set(efl_part(layout, "text"),
214 255, 255, 255, 255);
215 efl_text_underline2_color_set(efl_part(layout, "text"),
216 255, 255, 255, 255);
217 efl_text_underline_dashed_color_set(efl_part(layout, "text"),
218 255, 255, 255, 255);
219 }
220
221 efl_text_normal_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
222 ck_assert_int_eq(r, 255);
223 ck_assert_int_eq(g, 255);
224 ck_assert_int_eq(b, 255);
225 ck_assert_int_eq(a, 255);
226
227 efl_text_backing_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
228 ck_assert_int_eq(r, 255);
229 ck_assert_int_eq(g, 255);
230 ck_assert_int_eq(b, 255);
231 ck_assert_int_eq(a, 255);
232
233 efl_text_glow_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
234 ck_assert_int_eq(r, 255);
235 ck_assert_int_eq(g, 255);
236 ck_assert_int_eq(b, 255);
237 ck_assert_int_eq(a, 255);
238
239 efl_text_glow2_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
240 ck_assert_int_eq(r, 255);
241 ck_assert_int_eq(g, 255);
242 ck_assert_int_eq(b, 255);
243 ck_assert_int_eq(a, 255);
244
245 efl_text_outline_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
246 ck_assert_int_eq(r, 255);
247 ck_assert_int_eq(g, 255);
248 ck_assert_int_eq(b, 255);
249 ck_assert_int_eq(a, 255);
250
251 efl_text_shadow_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
252 ck_assert_int_eq(r, 255);
253 ck_assert_int_eq(g, 255);
254 ck_assert_int_eq(b, 255);
255 ck_assert_int_eq(a, 255);
256
257 efl_text_strikethrough_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
258 ck_assert_int_eq(r, 255);
259 ck_assert_int_eq(g, 255);
260 ck_assert_int_eq(b, 255);
261 ck_assert_int_eq(a, 255);
262
263 efl_text_underline_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
264 ck_assert_int_eq(r, 255);
265 ck_assert_int_eq(g, 255);
266 ck_assert_int_eq(b, 255);
267 ck_assert_int_eq(a, 255);
268
269 efl_text_underline2_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
270 ck_assert_int_eq(r, 255);
271 ck_assert_int_eq(g, 255);
272 ck_assert_int_eq(b, 255);
273 ck_assert_int_eq(a, 255);
274
275 efl_text_underline_dashed_color_get(efl_part(layout, "text"), &r, &g, &b, &a);
276 ck_assert_int_eq(r, 255);
277 ck_assert_int_eq(g, 255);
278 ck_assert_int_eq(b, 255);
279 ck_assert_int_eq(a, 255);
280 }
281
282 // Rest of api
283 {
284 Efl_Text_Format_Wrap wrap;
285 double ellipsis;
286 const char *font;
287 Efl_Font_Size size;
288
289 if (set)
290 {
291 efl_text_wrap_set(efl_part(layout, "text"), EFL_TEXT_FORMAT_WRAP_WORD);
292 efl_text_ellipsis_set(efl_part(layout, "text"), 1.0);
293 efl_text_font_set(efl_part(layout, "text"), "Sans", 12);
294 }
295
296 wrap = efl_text_wrap_get(efl_part(layout, "text"));
297 ck_assert_int_eq(wrap, EFL_TEXT_FORMAT_WRAP_WORD);
298
299 ellipsis = efl_text_ellipsis_get(efl_part(layout, "text"));
300 ck_assert(EINA_DBL_EQ(ellipsis, 1.0));
301
302 efl_text_font_get(efl_part(layout, "text"), &font, &size);
303 ck_assert_str_eq(font, "Sans");
304 ck_assert_int_eq(size, 12);
305 }
306}
307
308START_TEST(edje_test_text_part)
309{
310 Eo *evas;
311 Eo *layout;
312
313 evas = _setup_evas();
314
315 layout = efl_add(EFL_CANVAS_LAYOUT_CLASS, evas,
316 efl_gfx_size_hint_min_set(efl_added, EINA_SIZE2D(160, 40)));
317
318 efl_file_set(layout, test_layout_get("test_text.edj"), "test");
319 fail_if(efl_file_load_error_get(layout));
320 _basic_check(layout, EINA_TRUE);
321
322 // Load again and check persistance
323 efl_file_set(layout, test_layout_get("test_text.edj"), "test2");
324 fail_if(efl_file_load_error_get(layout));
325 _basic_check(layout, EINA_FALSE);
326
327 evas_free(evas);
328}
329END_TEST
330
118void edje_test_text(TCase *tc) 331void edje_test_text(TCase *tc)
119{ 332{
120 tcase_add_test(tc, edje_test_text_cursor); 333 tcase_add_test(tc, edje_test_text_cursor);
121 tcase_add_test(tc, edje_test_textblock); 334 tcase_add_test(tc, edje_test_textblock);
335 tcase_add_test(tc, edje_test_text_ellipsis);
336 tcase_add_test(tc, edje_test_text_wrap);
337 tcase_add_test(tc, edje_test_text_font);
338 tcase_add_test(tc, edje_test_text_color);
339 tcase_add_test(tc, edje_test_text_part);
122} 340}