summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-02-18 16:06:11 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-02-20 13:27:42 +0900
commite797f7f4c4c54bdb92d2860d3aafd128f139d731 (patch)
treeb092124f0010ff3e061398bb02653161a2e5b44a /src
parent78c7931575c5828179cc442f29525bb1d171eb0f (diff)
Evas filters: Add more test cases
Set filter on a text object and check the object's geometry. Get the padding and the geometry so we're sure they match. Also, pad_get would return 0 if the filter did not compile, so this checks that these filters are valid.
Diffstat (limited to 'src')
-rw-r--r--src/tests/evas/evas_test_filters.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/tests/evas/evas_test_filters.c b/src/tests/evas/evas_test_filters.c
index 2fc9fcdb8d..58f682c769 100644
--- a/src/tests/evas/evas_test_filters.c
+++ b/src/tests/evas/evas_test_filters.c
@@ -76,9 +76,11 @@ START_TEST(evas_filter_parser)
76 CHKBAAD("blend(blend());"); 76 CHKBAAD("blend(blend());");
77 CHKGOOD("blend(); blend();"); 77 CHKGOOD("blend(); blend();");
78 CHKGOOD("buffer:a;blend();"); 78 CHKGOOD("buffer:a;blend();");
79 CHKGOOD("buffer:a();blend();");
79 CHKGOOD("buffer:a(alpha);blend();"); 80 CHKGOOD("buffer:a(alpha);blend();");
80 CHKGOOD("buffer:a(rgba);blend();"); 81 CHKGOOD("buffer:a(rgba);blend();");
81 CHKBAAD("buffer:a(BAAD);blend();"); 82 CHKBAAD("buffer:a(BAAD);blend();");
83 CHKGOOD("buffer:a(src=partname);blend();");
82 CHKBAAD("buffer a(alpha);blend();"); 84 CHKBAAD("buffer a(alpha);blend();");
83 CHKGOOD("blend();blur();fill();"); 85 CHKGOOD("blend();blur();fill();");
84 CHKGOOD("grow(10);"); 86 CHKGOOD("grow(10);");
@@ -90,6 +92,15 @@ START_TEST(evas_filter_parser)
90 CHKGOOD("transform(output);"); 92 CHKGOOD("transform(output);");
91 CHKBAAD("unknown_command();"); 93 CHKBAAD("unknown_command();");
92 CHKBAAD("blend(unknown_buffer);"); 94 CHKBAAD("blend(unknown_buffer);");
95 CHKGOOD("//comment\nblend();");
96 CHKBAAD("blend(); /* unterminated comment section");
97 CHKGOOD("blend(/* we want yellow */ color = yellow);");
98 CHKGOOD("/* blend ();\n this is still a comment\n*/\n blend();");
99 CHKBAAD("blend(ox = 1/2);");
100 CHKBAAD("blend();!@#$%^&*");
101 CHKBAAD("blend(invalid=hello);");
102 CHKBAAD("buffer:a(alpha);buffer:a(rgba);blend();");
103 CHKBAAD("buffer:a(alpha,src=partname);");
93 104
94 // Case sensitivity 105 // Case sensitivity
95 CHKGOOD("BLEND();"); 106 CHKGOOD("BLEND();");
@@ -199,12 +210,64 @@ START_TEST(evas_filter_parser)
199} 210}
200END_TEST 211END_TEST
201 212
213START_TEST(evas_filter_text_padding_test)
214{
215 START_FILTER_TEST();
216 const char *buf = "Tests";
217 const char *font = TEST_FONT_NAME;
218 Evas_Font_Size size = 14;
219 Evas_Coord x, y, w, h, W, H;
220 int l, r, t, b;
221
222 evas_object_move(to, 0, 0);
223 evas_object_text_text_set(to, buf);
224 evas_object_text_font_set(to, font, size);
225 evas_object_geometry_get(to, &x, &y, &w, &h);
226 printf("Geometry: %dx%d+%d,%d\n", w, h, x, y);
227
228#define CHKPAD(_l, _r, _t, _b, _code) \
229 l = r = t = b = 0; \
230 eo_do(to, evas_obj_text_filter_program_set(_code)); \
231 evas_object_text_style_pad_get(to, &l, &r, &t, &b); \
232 evas_object_geometry_get(to, NULL, NULL, &W, &H); \
233 printf("Line %d: %dx%d for padding %d,%d,%d,%d\n", __LINE__, W, H, l, r, t, b); \
234 fail_if((l != _l) || (r != _r) || (t != _t) || (b != _b)); \
235 fail_if((W != (_l + _r + w)) || (H != (_t + _b + h)));
236
237 // Single filters
238 // In some scripts, a first blend is used to make sure all buffers are valid
239 CHKPAD(0, 0, 0, 0, "blend();");
240 CHKPAD(7, 0, 11, 0, "blend(ox = -7, oy = -11);");
241 CHKPAD(0, 7, 0, 11, "blend(ox = 7, oy = 11);");
242 CHKPAD(5, 5, 7, 7, "blur(rx = 5, ry = 7);");
243 CHKPAD(0, 0, 5, 5, "blur(rx = 0, ry = 5);");
244 CHKPAD(5, 5, 0, 0, "blur(rx = 5, ry = 0);");
245 CHKPAD(0, 15, 7, 0, "blur(rx = 5, ry = 0, ox = 10, oy = -7);");
246 CHKPAD(5, 5, 5, 5, "grow(5);");
247 CHKPAD(0, 0, 0, 0, "buffer:a(alpha);blend(dst=a);curve(0:0-255:255,src=a,dst=a);");
248 CHKPAD(0, 0, 0, 0, "fill();");
249 CHKPAD(0, 0, 0, 0, "buffer:a(rgba);blend(dst=a);mask(a);");
250 CHKPAD(0, 0, 0, 0, "buffer:a(alpha);blend(dst=a);bump(a);");
251 CHKPAD(7, 7, 7, 7, "buffer:a(rgba);blend(dst=a);displace(a,7);");
252 CHKPAD(0, 0, 0, 40, "buffer:a(alpha);blend(dst=a);transform(a,vflip,oy=20);blend(src=a);");
253
254 // Filter combos. TODO: Add some more tricky cases :)
255 CHKPAD(3, 5, 7, 11, "blend(ox = -3, oy = 11); blend(ox = 5, oy = -7);");
256 CHKPAD(15, 15, 15, 15, "buffer:a(rgba);grow(10,dst=a);blur(5,src=a);");
257 CHKPAD(10, 15, 10, 17, "buffer:a(alpha);blend(dst=a,ox=5,oy=7);blur(10,src=a);blend(ox=-6,oy=-9);");
258 CHKPAD(5, 5, 5, 5, "buffer:a(alpha);blur(5,dst=a);bump(a,azimuth=45.0,color=yellow);");
259
260 END_FILTER_TEST();
261}
262END_TEST
263
202#endif // BUILD_FILTER_TESTS 264#endif // BUILD_FILTER_TESTS
203 265
204void evas_test_filters(TCase *tc) 266void evas_test_filters(TCase *tc)
205{ 267{
206#if BUILD_FILTER_TESTS 268#if BUILD_FILTER_TESTS
207 tcase_add_test(tc, evas_filter_parser); 269 tcase_add_test(tc, evas_filter_parser);
270 tcase_add_test(tc, evas_filter_text_padding_test);
208#else 271#else
209 (void) tc; 272 (void) tc;
210#endif 273#endif