forked from enlightenment/efl
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.
This commit is contained in:
parent
78c7931575
commit
e797f7f4c4
|
@ -76,9 +76,11 @@ START_TEST(evas_filter_parser)
|
|||
CHKBAAD("blend(blend());");
|
||||
CHKGOOD("blend(); blend();");
|
||||
CHKGOOD("buffer:a;blend();");
|
||||
CHKGOOD("buffer:a();blend();");
|
||||
CHKGOOD("buffer:a(alpha);blend();");
|
||||
CHKGOOD("buffer:a(rgba);blend();");
|
||||
CHKBAAD("buffer:a(BAAD);blend();");
|
||||
CHKGOOD("buffer:a(src=partname);blend();");
|
||||
CHKBAAD("buffer a(alpha);blend();");
|
||||
CHKGOOD("blend();blur();fill();");
|
||||
CHKGOOD("grow(10);");
|
||||
|
@ -90,6 +92,15 @@ START_TEST(evas_filter_parser)
|
|||
CHKGOOD("transform(output);");
|
||||
CHKBAAD("unknown_command();");
|
||||
CHKBAAD("blend(unknown_buffer);");
|
||||
CHKGOOD("//comment\nblend();");
|
||||
CHKBAAD("blend(); /* unterminated comment section");
|
||||
CHKGOOD("blend(/* we want yellow */ color = yellow);");
|
||||
CHKGOOD("/* blend ();\n this is still a comment\n*/\n blend();");
|
||||
CHKBAAD("blend(ox = 1/2);");
|
||||
CHKBAAD("blend();!@#$%^&*");
|
||||
CHKBAAD("blend(invalid=hello);");
|
||||
CHKBAAD("buffer:a(alpha);buffer:a(rgba);blend();");
|
||||
CHKBAAD("buffer:a(alpha,src=partname);");
|
||||
|
||||
// Case sensitivity
|
||||
CHKGOOD("BLEND();");
|
||||
|
@ -199,12 +210,64 @@ START_TEST(evas_filter_parser)
|
|||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(evas_filter_text_padding_test)
|
||||
{
|
||||
START_FILTER_TEST();
|
||||
const char *buf = "Tests";
|
||||
const char *font = TEST_FONT_NAME;
|
||||
Evas_Font_Size size = 14;
|
||||
Evas_Coord x, y, w, h, W, H;
|
||||
int l, r, t, b;
|
||||
|
||||
evas_object_move(to, 0, 0);
|
||||
evas_object_text_text_set(to, buf);
|
||||
evas_object_text_font_set(to, font, size);
|
||||
evas_object_geometry_get(to, &x, &y, &w, &h);
|
||||
printf("Geometry: %dx%d+%d,%d\n", w, h, x, y);
|
||||
|
||||
#define CHKPAD(_l, _r, _t, _b, _code) \
|
||||
l = r = t = b = 0; \
|
||||
eo_do(to, evas_obj_text_filter_program_set(_code)); \
|
||||
evas_object_text_style_pad_get(to, &l, &r, &t, &b); \
|
||||
evas_object_geometry_get(to, NULL, NULL, &W, &H); \
|
||||
printf("Line %d: %dx%d for padding %d,%d,%d,%d\n", __LINE__, W, H, l, r, t, b); \
|
||||
fail_if((l != _l) || (r != _r) || (t != _t) || (b != _b)); \
|
||||
fail_if((W != (_l + _r + w)) || (H != (_t + _b + h)));
|
||||
|
||||
// Single filters
|
||||
// In some scripts, a first blend is used to make sure all buffers are valid
|
||||
CHKPAD(0, 0, 0, 0, "blend();");
|
||||
CHKPAD(7, 0, 11, 0, "blend(ox = -7, oy = -11);");
|
||||
CHKPAD(0, 7, 0, 11, "blend(ox = 7, oy = 11);");
|
||||
CHKPAD(5, 5, 7, 7, "blur(rx = 5, ry = 7);");
|
||||
CHKPAD(0, 0, 5, 5, "blur(rx = 0, ry = 5);");
|
||||
CHKPAD(5, 5, 0, 0, "blur(rx = 5, ry = 0);");
|
||||
CHKPAD(0, 15, 7, 0, "blur(rx = 5, ry = 0, ox = 10, oy = -7);");
|
||||
CHKPAD(5, 5, 5, 5, "grow(5);");
|
||||
CHKPAD(0, 0, 0, 0, "buffer:a(alpha);blend(dst=a);curve(0:0-255:255,src=a,dst=a);");
|
||||
CHKPAD(0, 0, 0, 0, "fill();");
|
||||
CHKPAD(0, 0, 0, 0, "buffer:a(rgba);blend(dst=a);mask(a);");
|
||||
CHKPAD(0, 0, 0, 0, "buffer:a(alpha);blend(dst=a);bump(a);");
|
||||
CHKPAD(7, 7, 7, 7, "buffer:a(rgba);blend(dst=a);displace(a,7);");
|
||||
CHKPAD(0, 0, 0, 40, "buffer:a(alpha);blend(dst=a);transform(a,vflip,oy=20);blend(src=a);");
|
||||
|
||||
// Filter combos. TODO: Add some more tricky cases :)
|
||||
CHKPAD(3, 5, 7, 11, "blend(ox = -3, oy = 11); blend(ox = 5, oy = -7);");
|
||||
CHKPAD(15, 15, 15, 15, "buffer:a(rgba);grow(10,dst=a);blur(5,src=a);");
|
||||
CHKPAD(10, 15, 10, 17, "buffer:a(alpha);blend(dst=a,ox=5,oy=7);blur(10,src=a);blend(ox=-6,oy=-9);");
|
||||
CHKPAD(5, 5, 5, 5, "buffer:a(alpha);blur(5,dst=a);bump(a,azimuth=45.0,color=yellow);");
|
||||
|
||||
END_FILTER_TEST();
|
||||
}
|
||||
END_TEST
|
||||
|
||||
#endif // BUILD_FILTER_TESTS
|
||||
|
||||
void evas_test_filters(TCase *tc)
|
||||
{
|
||||
#if BUILD_FILTER_TESTS
|
||||
tcase_add_test(tc, evas_filter_parser);
|
||||
tcase_add_test(tc, evas_filter_text_padding_test);
|
||||
#else
|
||||
(void) tc;
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue