summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJean-Philippe Andre <jp.andre@samsung.com>2014-02-19 18:33:22 +0900
committerJean-Philippe Andre <jp.andre@samsung.com>2014-02-20 13:27:43 +0900
commit2fe5656b639072880f2e1de9e1ab99852bf99e74 (patch)
tree1af87d0fa76834ba9e19a0d07f4151919aef4712 /src
parent18a7939f414affcbd114e5dc456a7a2d155b93bb (diff)
Evas filters: Improve test coverage of the filters
LCOV reports > 80% of coverage in evas/filters.
Diffstat (limited to 'src')
-rw-r--r--src/tests/evas/evas_test_filters.c125
1 files changed, 95 insertions, 30 deletions
diff --git a/src/tests/evas/evas_test_filters.c b/src/tests/evas/evas_test_filters.c
index f2f6c08e46..8500840e8a 100644
--- a/src/tests/evas/evas_test_filters.c
+++ b/src/tests/evas/evas_test_filters.c
@@ -134,6 +134,10 @@ START_TEST(evas_filter_parser)
134 "bump(m, 135.0, 45.0, 8.0, 0.0, color = white, compensate = true, " 134 "bump(m, 135.0, 45.0, 8.0, 0.0, color = white, compensate = true, "
135 "src = input, dst = output, black = black, white = white, fillmode = repeat);"); 135 "src = input, dst = output, black = black, white = white, fillmode = repeat);");
136 CHKGOOD("curve(0:0 - 255:255, linear, rgb, src = input, dst = output);"); 136 CHKGOOD("curve(0:0 - 255:255, linear, rgb, src = input, dst = output);");
137 CHKGOOD("curve(128:0 - 0:0 - 255:255, linear, rgb, src = input, dst = output);"); // invalid
138 CHKGOOD("buffer:a(rgba);blend(dst=a);curve(0:0-255:255,src=a,channel=r);");
139 CHKGOOD("buffer:a(rgba);blend(dst=a);curve(0:128-255:128,src=a,channel=g);");
140 CHKGOOD("buffer:a(rgba);blend(dst=a);curve(0:255-255:0,src=a,channel=b,interpolation=none);");
137 CHKGOOD("buffer : m (rgba); " 141 CHKGOOD("buffer : m (rgba); "
138 "displace(m, 10, default, src = input, dst = output, fillmode = repeat);"); 142 "displace(m, 10, default, src = input, dst = output, fillmode = repeat);");
139 CHKGOOD("fill(output, transparent, 0, 0, 0, 0);"); 143 CHKGOOD("fill(output, transparent, 0, 0, 0, 0);");
@@ -230,37 +234,75 @@ END_TEST
230struct Filter_Test_Case { 234struct Filter_Test_Case {
231 int l, r, t, b; 235 int l, r, t, b;
232 const char *code; 236 const char *code;
237 const char *source;
233}; 238};
234 239
240/*
241 * The following test case are tailored to cover as much code as possible in
242 * evas/filters. This is a bit artificial, but at least we'll verify that all
243 * filters produce something and not garbage data.
244 *
245 * NOTE: If the filters fail to link (program_use()), then Evas_Object_Text
246 * will fallback to normal rendering. As a consequence, the pixels will look
247 * fine, and there won't be an error.
248 */
235static struct Filter_Test_Case _test_cases[] = { 249static struct Filter_Test_Case _test_cases[] = {
236 // Single filters 250 // Single filters. Blend can be used to ensure all filters are valid.
237 // In some scripts, a first blend is used to make sure all buffers are valid 251 { 0, 0, 0, 0, "blend();", NULL },
238 { 0, 0, 0, 0, "blend();" }, 252 { 7, 0, 11, 0, "blend(ox = -7, oy = -11);", NULL },
239 { 7, 0, 11, 0, "blend(ox = -7, oy = -11);" }, 253 { 0, 7, 0, 11, "blend(ox = 7, oy = 11);", NULL },
240 { 0, 7, 0, 11, "blend(ox = 7, oy = 11);" }, 254 { 0, 0, 0, 0, "buffer:a(rgba);buffer:b(alpha);blend(dst=a);blend(src=a,dst=b);blend(b);", NULL },
241 { 5, 5, 7, 7, "blur(rx = 5, ry = 7);" }, 255
242 { 0, 0, 5, 5, "blur(rx = 0, ry = 5);" }, 256 { 5, 5, 7, 7, "blur(rx = 5, ry = 7);", NULL },
243 { 5, 5, 0, 0, "blur(rx = 5, ry = 0);" }, 257 { 0, 0, 5, 5, "blur(rx = 0, ry = 5, type = box);", NULL },
244 { 0, 15, 7, 0, "blur(rx = 5, ry = 0, ox = 10, oy = -7);" }, 258 { 0, 0, 5, 5, "buffer : a (rgba); blend(dst = a); blur(src = a,rx = 0, ry = 5, type = box);", NULL },
245 { 5, 5, 5, 5, "grow(5);" }, 259 { 5, 5, 0, 0, "blur(rx = 5, ry = 0, type = gaussian);", NULL },
246 { 0, 0, 0, 0, "buffer:a(alpha);blend(dst=a);curve(0:0-255:255,src=a,dst=a);blend(a);" }, 260 { 5, 15, 7, 0, "blur(rx = 5, ry = 0, ox = 10, oy = -7, type = default);", NULL },
247 { 0, 0, 0, 0, "buffer:a(alpha);blend(dst=a);curve(0:0-255:255,dst=a);blend(a);" }, 261
248 { 0, 0, 0, 0, "buffer:a(rgba);blend(dst=a);curve(0:0-255:255,src=a,channel=r);" }, 262 { 5, 5, 5, 5, "grow(5);", NULL },
249 { 0, 0, 0, 0, "buffer:a(rgba);blend(dst=a);curve(0:128-255:128,src=a,channel=g);" }, 263
250 { 0, 0, 0, 0, "buffer:a(rgba);blend(dst=a);curve(0:255-255:0,src=a,channel=b);" }, 264 { 0, 0, 0, 0, "buffer:a(alpha);blend(dst=a);curve(0:0-255:255,src=a,dst=a);blend(a);", NULL },
251 { 0, 0, 0, 0, "fill(color=red);" }, 265 { 0, 0, 0, 0, "buffer:a(alpha);blend(dst=a);curve(0:0-255:255,dst=a);blend(a);", NULL },
252 { 0, 0, 0, 0, "buffer:a(rgba);blend(dst=a);mask(a);" }, 266 { 0, 0, 0, 0, "buffer:a(rgba);blend(dst=a);curve(0:0-255:255,src=a,channel=r);", NULL },
253 { 0, 0, 0, 0, "buffer:a(alpha);blend(dst=a);bump(a);" }, 267 { 0, 0, 0, 0, "buffer:a(rgba);blend(dst=a);curve(0:128-128:0,src=a,channel=rgb,interpolation=none);", NULL },
254 { 7, 7, 7, 7, "buffer:a(rgba);blend(dst=a);displace(a,7);" }, 268
255 { 0, 0, 0, 40, "buffer:a(alpha);transform(a,vflip,oy=20);blend(src=a);" }, 269 { 0, 0, 0, 0, "fill(color=red);", NULL },
256 { 0, 0, 40, 0, "buffer:a(alpha);transform(a,vflip,oy=-20);blend(src=a);" }, 270
257 { 0, 0, 0, 40, "buffer:a(alpha);blend(dst=a);transform(a,vflip,oy=20,src=a);blend(src=a);" }, 271 { 0, 0, 0, 0, "buffer:a(alpha);blend(dst=a);mask(a);", NULL },
272 { 0, 0, 0, 0, "buffer:a(alpha);buffer:b(alpha);blend(dst=a);mask(a,dst=b);blend(b);", NULL },
273 { 0, 0, 0, 0, "buffer:a(rgba);blend(dst=a);mask(a);", NULL },
274 { 0, 0, 0, 0, "buffer:a(rgba);blend(dst=a);mask(mask=input,src=a);", NULL },
275 { 0, 0, 0, 0, "buffer:a(rgba);buffer:b(rgba);blend(dst=b,color=red);blend(dst=a);mask(a,src=b);", NULL },
276
277 // Note: Alpha bump is not tested. Its render quality must be improved first.
278 { 0, 0, 0, 0, "buffer:a(alpha);blend(dst=a);bump(a);", NULL },
279 { 0, 0, 0, 0, "buffer:a(alpha);blend(dst=a);bump(a,compensate=yes,specular=10.0);", NULL },
280
281 { 7, 7, 7, 7, "buffer:a(alpha);buffer:b(rgba);blend(dst=b,color=#330);displace(map=b,src=input,dst=a,intensity=7);blend(a);", NULL },
282 { 7, 7, 7, 7, "buffer:a(alpha);buffer:b(rgba);blend(dst=b,color=#330);blend(dst=a);displace(map=b,src=a,intensity=7);", NULL },
283 { 7, 7, 7, 7, "buffer:a(rgba);buffer:b(rgba);blend(dst=b,color=#330);blend(dst=a);displace(map=b,src=a,intensity=7);", NULL },
284 { 7, 7, 7, 7, "buffer:a(rgba);buffer:b(rgba);blend(dst=b,color=#330);blend(dst=a);displace(map=b,src=a,intensity=7,flags=default);", NULL },
285 { 7, 7, 7, 7, "buffer:a(rgba);buffer:b(rgba);blend(dst=b,color=#330);blend(dst=a);displace(map=b,src=a,intensity=7,flags=nearest);", NULL },
286 { 7, 7, 7, 7, "buffer:a(rgba);buffer:b(rgba);blend(dst=b,color=#330);blend(dst=a);displace(map=b,src=a,intensity=7,flags=smooth);", NULL },
287 { 7, 7, 7, 7, "buffer:a(rgba);buffer:b(rgba);blend(dst=b,color=#330);blend(dst=a);displace(map=b,src=a,intensity=7,flags=nearest_stretch);", NULL },
288 { 7, 7, 7, 7, "buffer:a(rgba);buffer:b(rgba);blend(dst=b,color=#330);blend(dst=a);displace(map=b,src=a,intensity=7,flags=smooth_stretch);", NULL },
289
290 { 0, 0, 0, 40, "buffer:a(alpha);transform(a,vflip,oy=20);blend(src=a);", NULL },
291 { 0, 0, 40, 0, "buffer:a(alpha);transform(a,vflip,oy=-20);blend(src=a);", NULL },
292 { 0, 0, 0, 40, "buffer:a(alpha);blend(dst=a);transform(a,vflip,oy=20,src=a);blend(src=a);", NULL },
258 293
259 // Filter combos. TODO: Add some more tricky cases :) 294 // Filter combos. TODO: Add some more tricky cases :)
260 { 3, 5, 7, 11, "blend(ox = -3, oy = 11); blend(ox = 5, oy = -7);" }, 295 { 3, 5, 7, 11, "blend(ox = -3, oy = 11); blend(ox = 5, oy = -7);", NULL },
261 { 15, 15, 15, 15, "buffer:a(rgba);grow(10,dst=a);blur(5,src=a);" }, 296 { 15, 15, 15, 15, "buffer:a(rgba);grow(10,dst=a);blur(5,src=a);", NULL },
262 { 10, 15, 10, 17, "buffer:a(alpha);blend(dst=a,ox=5,oy=7);blur(10,src=a);blend(ox=-6,oy=-9);" }, 297 { 10, 15, 10, 17, "buffer:a(alpha);blend(dst=a,ox=5,oy=7);blur(10,src=a);blend(ox=-6,oy=-9);", NULL },
263 { 5, 5, 5, 5, "buffer:a(alpha);blur(5,dst=a);bump(a,azimuth=45.0,color=yellow);" } 298 { 5, 5, 5, 5, "buffer:a(alpha);blur(5,dst=a);bump(a,azimuth=45.0,color=yellow);", NULL },
299
300 // Proxy tests (RECT as a proxy object)
301 { 0, 0, 0, 0, "buffer:m(src=rect);mask(m,fillmode=none);", "rect" },
302 { 0, 0, 0, 0, "buffer:m(src=rect);mask(m,fillmode=repeat_x_stretch_y);", "rect" },
303 { 0, 0, 0, 0, "buffer:m(src=rect);mask(m,fillmode=repeat);", "rect" },
304 { 0, 0, 0, 0, "buffer:m(src=rect);mask(m,fillmode=stretch);", "rect" },
305 { 0, 0, 0, 0, "buffer:m(src=rect);buffer:b(rgba);blend(m,dst=b,fillmode=repeat_x_stretch_y);blend();", "rect" }
264}; 306};
265 307
266static const int _test_cases_count = sizeof(_test_cases) / sizeof(_test_cases[0]); 308static const int _test_cases_count = sizeof(_test_cases) / sizeof(_test_cases[0]);
@@ -279,6 +321,9 @@ START_TEST(evas_filter_text_padding_test)
279 struct Filter_Test_Case *tc = &(_test_cases[k]); 321 struct Filter_Test_Case *tc = &(_test_cases[k]);
280 l = r = t = b = 0; 322 l = r = t = b = 0;
281 323
324 // Don't test proxy cases here.
325 if (tc->source) continue;
326
282 eo_do(to, evas_obj_text_filter_program_set(tc->code)); 327 eo_do(to, evas_obj_text_filter_program_set(tc->code));
283 evas_object_text_style_pad_get(to, &l, &r, &t, &b); 328 evas_object_text_style_pad_get(to, &l, &r, &t, &b);
284 evas_object_geometry_get(to, NULL, NULL, &W, &H); 329 evas_object_geometry_get(to, NULL, NULL, &W, &H);
@@ -330,6 +375,8 @@ _ecore_evas_pixels_check(Ecore_Evas *ee)
330 375
331START_TEST(evas_filter_text_render_test) 376START_TEST(evas_filter_text_render_test)
332{ 377{
378 Evas_Filter_Program *pgm;
379
333 /* FIXME: 380 /* FIXME:
334 * START_FILTER_TEST should be here instead of in the for loop 381 * START_FILTER_TEST should be here instead of in the for loop
335 * But there seems to be a problem with ecore_evas_buffer as the second 382 * But there seems to be a problem with ecore_evas_buffer as the second
@@ -340,7 +387,7 @@ START_TEST(evas_filter_text_render_test)
340 { 387 {
341 START_FILTER_TEST(); 388 START_FILTER_TEST();
342 389
343 Evas_Object *rect; 390 Evas_Object *rect, *o = NULL;
344 Evas_Coord w, h; 391 Evas_Coord w, h;
345 392
346 ecore_evas_alpha_set(ee, EINA_TRUE); 393 ecore_evas_alpha_set(ee, EINA_TRUE);
@@ -355,9 +402,25 @@ START_TEST(evas_filter_text_render_test)
355 struct Filter_Test_Case *tc = &(_test_cases[k]); 402 struct Filter_Test_Case *tc = &(_test_cases[k]);
356 w = h = 0; 403 w = h = 0;
357 404
358 eo_do(to, 405 CHKGOOD(tc->code);
359 evas_obj_color_set(255, 255, 255, 255), 406 if (tc->source)
360 evas_obj_text_filter_program_set(tc->code)); 407 {
408 o = evas_object_rectangle_add(evas);
409 evas_object_color_set(o, 0, 255, 0, 255);
410 evas_object_move(o, -999, -9999);
411 evas_object_resize(o, 10, 10);
412 evas_object_show(o);
413 eo_do(to,
414 evas_obj_color_set(255, 255, 255, 255),
415 evas_obj_text_filter_source_set(tc->source, o),
416 evas_obj_text_filter_program_set(tc->code));
417 }
418 else
419 {
420 eo_do(to,
421 evas_obj_color_set(255, 255, 255, 255),
422 evas_obj_text_filter_program_set(tc->code));
423 }
361 424
362 evas_object_geometry_get(to, NULL, NULL, &w, &h); 425 evas_object_geometry_get(to, NULL, NULL, &w, &h);
363 ecore_evas_resize(ee, w, h); 426 ecore_evas_resize(ee, w, h);
@@ -368,6 +431,8 @@ START_TEST(evas_filter_text_render_test)
368 if (!_ecore_evas_pixels_check(ee)) 431 if (!_ecore_evas_pixels_check(ee))
369 fail("Render test failed with: [%dx%d] '%s'", w, h, tc->code); 432 fail("Render test failed with: [%dx%d] '%s'", w, h, tc->code);
370 433
434 evas_object_del(o);
435 evas_object_del(rect);
371 END_FILTER_TEST(); 436 END_FILTER_TEST();
372 } 437 }
373 438