forked from enlightenment/efl
Evas test: Update filters test (Lua) - part 1
This commit is contained in:
parent
8c8816aca6
commit
4c4d65c388
|
@ -14,14 +14,6 @@
|
||||||
#include "Ecore_Evas.h"
|
#include "Ecore_Evas.h"
|
||||||
#include "../../lib/evas/include/evas_filter.h"
|
#include "../../lib/evas/include/evas_filter.h"
|
||||||
|
|
||||||
#if !defined(EFL_EO_API_SUPPORT) || !defined(EFL_BETA_API_SUPPORT)
|
|
||||||
# define BUILD_FILTER_TESTS 0
|
|
||||||
#else
|
|
||||||
# define BUILD_FILTER_TESTS 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if BUILD_FILTER_TESTS
|
|
||||||
|
|
||||||
#define TEST_FONT_NAME "DejaVuSans,UnDotum"
|
#define TEST_FONT_NAME "DejaVuSans,UnDotum"
|
||||||
#define TEST_FONT_SOURCE TESTS_SRC_DIR "/TestFont.eet"
|
#define TEST_FONT_SOURCE TESTS_SRC_DIR "/TestFont.eet"
|
||||||
|
|
||||||
|
@ -70,84 +62,89 @@ START_TEST(evas_filter_parser)
|
||||||
{
|
{
|
||||||
Evas_Filter_Program *pgm;
|
Evas_Filter_Program *pgm;
|
||||||
|
|
||||||
|
// It's practically impossible to test all combinations since the language
|
||||||
|
// itself is full featured. Let's just ensure that our main functions exist
|
||||||
|
// and that calling them (kinda) works.
|
||||||
|
|
||||||
#define CHECK_FILTER(_a, _v) do { \
|
#define CHECK_FILTER(_a, _v) do { \
|
||||||
pgm = evas_filter_program_new("evas_suite", EINA_TRUE); \
|
pgm = evas_filter_program_new("evas_suite", EINA_TRUE); \
|
||||||
fail_if(evas_filter_program_parse(pgm, _a) != _v); \
|
if (evas_filter_program_parse(pgm, _a) != _v) \
|
||||||
|
fail("Filter test failed (result should be %s):\n%s", # _v, _a); \
|
||||||
evas_filter_program_del(pgm); \
|
evas_filter_program_del(pgm); \
|
||||||
} while (0)
|
} while (0)
|
||||||
#define CHKGOOD(_a) CHECK_FILTER(_a, EINA_TRUE)
|
#define CHKGOOD(_a) CHECK_FILTER(_a, EINA_TRUE)
|
||||||
#define CHKBAAD(_a) CHECK_FILTER(_a, EINA_FALSE)
|
#define CHKBAAD(_a) CHECK_FILTER(_a, EINA_FALSE)
|
||||||
|
|
||||||
// Basic syntax errors
|
static const char *good [] = {
|
||||||
fail_if(evas_filter_program_parse(NULL, "blend();"));
|
// Single command names
|
||||||
CHKBAAD(NULL);
|
"blend()",
|
||||||
CHKBAAD("");
|
"blur()",
|
||||||
CHKBAAD(" \t \n ");
|
"grow(10)",
|
||||||
CHKBAAD("blend");
|
"fill()",
|
||||||
CHKBAAD("blend()");
|
"curve('0:0-255:255')",
|
||||||
CHKBAAD("blend;");
|
"padding_set(10)",
|
||||||
|
"transform(output)",
|
||||||
|
// Buffer modes
|
||||||
|
"a = buffer() blend()",
|
||||||
|
"a = buffer('alpha') blend()",
|
||||||
|
"a = buffer('rgba') blend()",
|
||||||
|
"a = buffer{src = 'partname'} blend()",
|
||||||
|
// Lua comments
|
||||||
|
"blend() -- comment",
|
||||||
|
"--comment\n blend()",
|
||||||
|
"--[[ long comment\n blend() continues --]] blend()",
|
||||||
|
// Combinations
|
||||||
|
"blend() blend()",
|
||||||
|
"m = buffer() transform({ m, op = 'vflip', src = input, oy = 0 })",
|
||||||
|
// All default commands
|
||||||
|
"blend ({ src = input, dst = output, ox = 0, oy = 0, color = 'white', fillmode = 'none' })",
|
||||||
|
"blur ({ rx = 3, ry = nil, type = 'default', ox = 0, oy = 0, color = 'white', src = input, dst = output })",
|
||||||
|
"bump ({ map, azimuth = 135.0, elevation = 45.0, depth = 8.0, specular = 0.0,"
|
||||||
|
"color = 'white', compensate = false, src = input, dst = output,"
|
||||||
|
"black = 'black', white = 'white', fillmode = 'repeat' })",
|
||||||
|
"curve ({ points, interpolation = 'linear', channel = 'rgb', src = input, dst = output })",
|
||||||
|
"m = buffer ('rgba') displace ({ m, intensity = 10, flags = 'default', src = input, dst = output, fillmode = 'repeat' })",
|
||||||
|
"fill ({ dst = output, color = 'transparent', l = 0, r = 0, t = 0, b = 0 })",
|
||||||
|
"grow ({ radius, smooth = true, src = input, dst = output })",
|
||||||
|
"m = buffer('alpha') mask ({ m, src = input, dst = output, color = 'white', fillmode = 'repeat' })",
|
||||||
|
"transform ({ output, op = 'vflip', src = input, oy = 0 })",
|
||||||
|
"padding_set ({ 1, 2, 3, 4 })",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
// Known & unknown instructions + some syntax errors
|
static const char *bad[] = {
|
||||||
CHKGOOD("blend();");
|
"", // Empty filters should fail
|
||||||
CHKBAAD("blend()\nblend();");
|
"function run () blend () end", // run() won't be called, filter is empty
|
||||||
CHKBAAD("blend(blend());");
|
// All default commands with one extra invalid argument
|
||||||
CHKGOOD("blend(); blend();");
|
"blend ({ src = input, dst = output, ox = 0, oy = 0, color = 'white', fillmode = 'none', invalid = 42 })",
|
||||||
CHKGOOD("buffer:a;blend();");
|
"blur ({ rx = 3, ry = nil, type = 'default', ox = 0, oy = 0, color = 'white', src = input, dst = output, invalid = 42 })",
|
||||||
CHKGOOD("buffer:a();blend();");
|
"bump ({ map, azimuth = 135.0, elevation = 45.0, depth = 8.0, specular = 0.0,"
|
||||||
CHKGOOD("buffer:a(alpha);blend();");
|
"color = 'white', compensate = false, src = input, dst = output,"
|
||||||
CHKGOOD("buffer:a(rgba);blend();");
|
"black = 'black', white = 'white', fillmode = 'repeat', invalid = 42 })",
|
||||||
CHKBAAD("buffer:a(BAAD);blend();");
|
"curve ({ points, interpolation = 'linear', channel = 'rgb', src = input, dst = output, invalid = 42 })",
|
||||||
CHKGOOD("buffer:a(src=partname);blend();");
|
"m = buffer ('rgba') displace ({ m, intensity = 10, flags = 'default', src = input, dst = output, fillmode = 'repeat', invalid = 42 })",
|
||||||
CHKBAAD("buffer a(alpha);blend();");
|
"fill ({ dst = output, color = 'transparent', l = 0, r = 0, t = 0, b = 0, invalid = 42 })",
|
||||||
CHKGOOD("blend();blur();fill();");
|
"grow ({ radius, smooth = true, src = input, dst = output, invalid = 42 })",
|
||||||
CHKGOOD("grow(10);");
|
"m = buffer('alpha') mask ({ m, src = input, dst = output, color = 'white', fillmode = 'repeat', invalid = 42 })",
|
||||||
CHKGOOD("curve(0:0 - 255:255);");
|
"transform ({ output, op = 'vflip', src = input, oy = 0, invalid = 42 })",
|
||||||
CHKGOOD("buffer:a(alpha);mask(a);");
|
"padding_set ({ 1, 2, 3, 4, invalid = 42 })",
|
||||||
CHKGOOD("buffer:a(rgba);mask(a);");
|
// Some early check failures
|
||||||
CHKGOOD("buffer:a(rgba);bump(a);");
|
//"m = buffer ('alpha') displace ({ m, intensity = 10, flags = 'default', src = input, dst = output, fillmode = 'repeat' })",
|
||||||
CHKGOOD("buffer:a(rgba);displace(a);");
|
"m = buffer ('rgba') displace ({ m, intensity = 10, flags = 'invalid', src = input, dst = output, fillmode = 'repeat' })",
|
||||||
CHKGOOD("transform(output);");
|
NULL
|
||||||
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);");
|
|
||||||
CHKGOOD("padding_set(0);blend();");
|
|
||||||
CHKGOOD("padding_set(l=1,r=2,t=3,b=4);blend();");
|
|
||||||
|
|
||||||
// Case sensitivity
|
fail_if(evas_filter_program_parse(NULL, "blend()"));
|
||||||
CHKGOOD("BLEND();");
|
|
||||||
CHKGOOD("Blend();");
|
|
||||||
CHKGOOD("bLeNd();");
|
|
||||||
CHKGOOD("buffer : lowercase; blend (lowercase);");
|
|
||||||
CHKGOOD("buffer : UPPERCASE; blend (UPPERCASE);");
|
|
||||||
CHKBAAD("buffer : CamelCase; blend (cAMELcASE);");
|
|
||||||
|
|
||||||
// Full sequential arguments (default values)
|
pgm = evas_filter_program_new("evas_suite", EINA_TRUE);
|
||||||
CHKGOOD("blend(input, output, 0, 0, color = white, fillmode = none);");
|
fail_if(evas_filter_program_parse(NULL, NULL));
|
||||||
CHKGOOD("blur(3, -1, default, 0, 0, color = white, src = input, dst = output);");
|
evas_filter_program_del(pgm);
|
||||||
CHKGOOD("buffer : m (alpha); "
|
|
||||||
"bump(m, 135.0, 45.0, 8.0, 0.0, color = white, compensate = true, "
|
for (int k = 0; good[k]; k++)
|
||||||
"src = input, dst = output, black = black, white = white, fillmode = repeat);");
|
CHKGOOD(good[k]);
|
||||||
CHKGOOD("curve(0:0 - 255:255, linear, rgb, src = input, dst = output);");
|
|
||||||
CHKGOOD("curve(128:0 - 0:0 - 255:255, linear, rgb, src = input, dst = output);"); // invalid
|
for (int k = 0; bad[k]; k++)
|
||||||
CHKGOOD("buffer:a(rgba);blend(dst=a);curve(0:0-255:255,src=a,channel=r);");
|
CHKBAAD(bad[k]);
|
||||||
CHKGOOD("buffer:a(rgba);blend(dst=a);curve(0:128-255:128,src=a,channel=g);");
|
|
||||||
CHKGOOD("buffer:a(rgba);blend(dst=a);curve(0:255-255:0,src=a,channel=b,interpolation=none);");
|
|
||||||
CHKGOOD("buffer : m (rgba); "
|
|
||||||
"displace(m, 10, default, src = input, dst = output, fillmode = repeat);");
|
|
||||||
CHKGOOD("fill(output, transparent, 0, 0, 0, 0);");
|
|
||||||
CHKGOOD("grow(0, smooth = yes, src = input, dst = output);");
|
|
||||||
CHKGOOD("buffer : m (alpha); "
|
|
||||||
"mask(m, src = input, dst = output, color = white, fillmode = none);");
|
|
||||||
CHKGOOD("buffer : m (alpha); "
|
|
||||||
"transform(m, op = vflip, src = input, oy = 0);");
|
|
||||||
|
|
||||||
// All colors
|
// All colors
|
||||||
static const char *colors [] = {
|
static const char *colors [] = {
|
||||||
|
@ -189,43 +186,14 @@ START_TEST(evas_filter_parser)
|
||||||
for (size_t c = 0; c < sizeof(colors) / sizeof(colors[0]); c++)
|
for (size_t c = 0; c < sizeof(colors) / sizeof(colors[0]); c++)
|
||||||
{
|
{
|
||||||
char buf[64];
|
char buf[64];
|
||||||
sprintf(buf, "blend(color = %s);", colors[c]);
|
sprintf(buf, "blend { color = '%s' }", colors[c]);
|
||||||
CHKGOOD(buf);
|
CHKGOOD(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t c = 0; c < sizeof(colors_bad) / sizeof(colors_bad[0]); c++)
|
for (size_t c = 0; c < sizeof(colors_bad) / sizeof(colors_bad[0]); c++)
|
||||||
{
|
{
|
||||||
char buf[64];
|
char buf[64];
|
||||||
sprintf(buf, "blend(color = %s);", colors_bad[c]);
|
sprintf(buf, "blend { color = '%s' }", colors_bad[c]);
|
||||||
CHKBAAD(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
// All booleans
|
|
||||||
static const char *booleans[] = {
|
|
||||||
"1", "0",
|
|
||||||
"yes", "no",
|
|
||||||
"on", "off",
|
|
||||||
"enable", "disable",
|
|
||||||
"enabled", "disabled",
|
|
||||||
"true", "false",
|
|
||||||
"YES", "Yes"
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char *booleans_bad[] = {
|
|
||||||
"o", "oui", "10"
|
|
||||||
};
|
|
||||||
|
|
||||||
for (size_t c = 0; c < sizeof(booleans) / sizeof(booleans[0]); c++)
|
|
||||||
{
|
|
||||||
char buf[64];
|
|
||||||
sprintf(buf, "grow(10, smooth = %s);", booleans[c]);
|
|
||||||
CHKGOOD(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t c = 0; c < sizeof(booleans_bad) / sizeof(booleans_bad[0]); c++)
|
|
||||||
{
|
|
||||||
char buf[64];
|
|
||||||
sprintf(buf, "grow(10, smooth = %s);", booleans_bad[c]);
|
|
||||||
CHKBAAD(buf);
|
CHKBAAD(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,19 +412,11 @@ START_TEST(evas_filter_text_render_test)
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
#endif // BUILD_FILTER_TESTS
|
|
||||||
|
|
||||||
void evas_test_filters(TCase *tc)
|
void evas_test_filters(TCase *tc)
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
// FIXME: The test suite is disabled for now since we should
|
|
||||||
// now test with proper Lua language. The legacy script should
|
|
||||||
// not even be tested.
|
|
||||||
//#if BUILD_FILTER_TESTS
|
|
||||||
tcase_add_test(tc, evas_filter_parser);
|
tcase_add_test(tc, evas_filter_parser);
|
||||||
|
#if 0
|
||||||
tcase_add_test(tc, evas_filter_text_padding_test);
|
tcase_add_test(tc, evas_filter_text_padding_test);
|
||||||
tcase_add_test(tc, evas_filter_text_render_test);
|
tcase_add_test(tc, evas_filter_text_render_test);
|
||||||
#else
|
|
||||||
(void) tc;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue