testsuite: Add serialize-deserialize tests
Check that we can successfully deserialize a node, then serialize it again and serialize that result once more.
This commit is contained in:
@@ -26,6 +26,14 @@ node_parser = executable(
|
||||
install_dir: testexecdir
|
||||
)
|
||||
|
||||
serialize_deserialize = executable(
|
||||
'serialize-deserialize',
|
||||
['serialize-deserialize.c'],
|
||||
dependencies: libgtk_dep,
|
||||
install: get_option('install-tests'),
|
||||
install_dir: testexecdir,
|
||||
)
|
||||
|
||||
test('nodes (cairo)', test_render_nodes,
|
||||
args: [ '--tap', '-k' ],
|
||||
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
|
||||
@@ -102,9 +110,9 @@ foreach renderer : renderers
|
||||
endforeach
|
||||
|
||||
node_parser_tests = [
|
||||
'crash1',
|
||||
'crash2',
|
||||
'crash3',
|
||||
'crash1.invalid',
|
||||
'crash2.invalid',
|
||||
'crash3.invalid',
|
||||
]
|
||||
|
||||
foreach test : node_parser_tests
|
||||
@@ -121,6 +129,27 @@ foreach test : node_parser_tests
|
||||
suite: 'gsk')
|
||||
endforeach
|
||||
|
||||
serialize_deserialize_tests = [
|
||||
'color.valid',
|
||||
'border.valid',
|
||||
'testswitch.valid',
|
||||
]
|
||||
|
||||
foreach test : serialize_deserialize_tests
|
||||
test('serialize-deserialize ' + test, serialize_deserialize,
|
||||
args: [join_paths(meson.current_source_dir(), 'nodeparser', test + '.node')],
|
||||
env: [ 'GIO_USE_VOLUME_MONITOR=unix',
|
||||
'GSETTINGS_BACKEND=memory',
|
||||
'GTK_CSD=1',
|
||||
'G_ENABLE_DIAGNOSTIC=0',
|
||||
'G_TEST_SRCDIR=@0@'.format(meson.current_source_dir()),
|
||||
'G_TEST_BUILDDIR=@0@'.format(meson.current_build_dir()),
|
||||
'GSK_RENDERER=opengl'
|
||||
],
|
||||
suite: 'gsk')
|
||||
endforeach
|
||||
|
||||
|
||||
if have_vulkan
|
||||
test('nodes (vulkan)', test_render_nodes,
|
||||
args: [ '--tap', '-k' ],
|
||||
|
||||
5
testsuite/gsk/nodeparser/border.valid.node
Normal file
5
testsuite/gsk/nodeparser/border.valid.node
Normal file
@@ -0,0 +1,5 @@
|
||||
border {
|
||||
outline: -1 -1 50 26 / 13;
|
||||
widths: 1 1 1 1;
|
||||
colors: rgba(213, 208, 204, 1) rgba(213, 208, 204, 1) rgba(213, 208, 204, 1) rgba(213, 208, 204, 1);
|
||||
}
|
||||
4
testsuite/gsk/nodeparser/color.valid.node
Normal file
4
testsuite/gsk/nodeparser/color.valid.node
Normal file
@@ -0,0 +1,4 @@
|
||||
color {
|
||||
bounds: 100 100 200 300;
|
||||
color: red;
|
||||
}
|
||||
389
testsuite/gsk/nodeparser/testswitch.valid.node
Normal file
389
testsuite/gsk/nodeparser/testswitch.valid.node
Normal file
@@ -0,0 +1,389 @@
|
||||
transform {
|
||||
transform: translate(0, 0);
|
||||
child: container {
|
||||
color {
|
||||
bounds: 0 0 404 204;
|
||||
color: rgb(246,245,244);
|
||||
}
|
||||
container {
|
||||
container {
|
||||
transform {
|
||||
transform: translate(1, 1);
|
||||
child: container {
|
||||
rounded-clip {
|
||||
clip: -1 -1 50 26 / 13;
|
||||
child: color {
|
||||
bounds: -1 -1 50 26;
|
||||
color: rgb(225,222,219);
|
||||
}
|
||||
}
|
||||
border {
|
||||
outline: -1 -1 50 26 / 13;
|
||||
widths: 1 1 1 1;
|
||||
colors: rgb(205,199,194) rgb(205,199,194) rgb(205,199,194) rgb(205,199,194);
|
||||
}
|
||||
container {
|
||||
container {
|
||||
outset-shadow {
|
||||
outline: -1 -1 26 26 / 13;
|
||||
color: rgba(0,0,0,0.1);
|
||||
dx: 0;
|
||||
dy: 1;
|
||||
spread: 0;
|
||||
blur: 0;
|
||||
}
|
||||
outset-shadow {
|
||||
outline: -1 -1 26 26 / 13;
|
||||
color: rgba(0,0,0,0.07);
|
||||
dx: 0;
|
||||
dy: 1;
|
||||
spread: 0;
|
||||
blur: 2;
|
||||
}
|
||||
rounded-clip {
|
||||
clip: -1 -1 26 26 / 13;
|
||||
child: linear-gradient {
|
||||
bounds: 0 0 24 24;
|
||||
start: 12 0;
|
||||
end: 12 24;
|
||||
stops: 0.2 rgb(255,255,255),0.9 rgb(246,245,244);
|
||||
}
|
||||
}
|
||||
inset-shadow {
|
||||
outline: 0 0 24 24 / 12;
|
||||
color: rgb(255,255,255);
|
||||
dx: 0;
|
||||
dy: 1;
|
||||
spread: 0;
|
||||
blur: 0;
|
||||
}
|
||||
}
|
||||
border {
|
||||
outline: -1 -1 26 26 / 13;
|
||||
widths: 1 1 1 1;
|
||||
colors: rgb(191,184,177) rgb(191,184,177) rgb(191,184,177) rgb(191,184,177);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
transform {
|
||||
transform: translate(56, 0);
|
||||
child: text {
|
||||
font: "Cantarell 11";
|
||||
x: 145;
|
||||
y: 18;
|
||||
color: rgb(46,52,54);
|
||||
glyphs: 37 11264 0 0 1, 324 4096 0 0 1, 417 7168 0 0 1, 244 8192 0 0 1, 272 8192 0 0 1, 349 4096 0 0 1, 287 8192 0 0 1, 280 8192 0 0 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
transform {
|
||||
transform: translate(0, 38);
|
||||
child: container {
|
||||
transform {
|
||||
transform: translate(1, 1);
|
||||
child: container {
|
||||
rounded-clip {
|
||||
clip: -1 -1 50 26 / 13;
|
||||
child: color {
|
||||
bounds: -1 -1 50 26;
|
||||
color: rgb(53,132,228);
|
||||
}
|
||||
}
|
||||
border {
|
||||
outline: -1 -1 50 26 / 13;
|
||||
widths: 1 1 1 1;
|
||||
colors: rgb(24,95,180) rgb(24,95,180) rgb(24,95,180) rgb(24,95,180);
|
||||
}
|
||||
transform {
|
||||
transform: translate(24, 0);
|
||||
child: container {
|
||||
container {
|
||||
outset-shadow {
|
||||
outline: -1 -1 26 26 / 13;
|
||||
color: rgba(0,0,0,0.1);
|
||||
dx: 0;
|
||||
dy: 1;
|
||||
spread: 0;
|
||||
blur: 0;
|
||||
}
|
||||
outset-shadow {
|
||||
outline: -1 -1 26 26 / 13;
|
||||
color: rgba(0,0,0,0.07);
|
||||
dx: 0;
|
||||
dy: 1;
|
||||
spread: 0;
|
||||
blur: 2;
|
||||
}
|
||||
rounded-clip {
|
||||
clip: -1 -1 26 26 / 13;
|
||||
child: cross-fade {
|
||||
progress: 0.756154;
|
||||
start: cross-fade {
|
||||
progress: 0.788575;
|
||||
start: color {
|
||||
bounds: 0 0 24 24;
|
||||
color: rgb(246,245,244);
|
||||
}
|
||||
end: linear-gradient {
|
||||
bounds: 0 0 24 24;
|
||||
start: 12 0;
|
||||
end: 12 24;
|
||||
stops: 0.2 rgb(255,255,255),0.9 rgb(246,245,244);
|
||||
}
|
||||
}
|
||||
end: linear-gradient {
|
||||
bounds: 0 0 24 24;
|
||||
start: 12 0;
|
||||
end: 12 24;
|
||||
stops: 0.1 rgb(255,255,255),0.9 rgb(255,255,255);
|
||||
}
|
||||
}
|
||||
}
|
||||
inset-shadow {
|
||||
outline: 0 0 24 24 / 12;
|
||||
color: rgb(255,255,255);
|
||||
dx: 0;
|
||||
dy: 1;
|
||||
spread: 0;
|
||||
blur: 0;
|
||||
}
|
||||
}
|
||||
border {
|
||||
outline: -1 -1 26 26 / 13;
|
||||
widths: 1 1 1 1;
|
||||
colors: rgb(24,95,180) rgb(24,95,180) rgb(24,95,180) rgb(24,95,180);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
transform {
|
||||
transform: translate(56, 0);
|
||||
child: text {
|
||||
font: "Cantarell 11";
|
||||
x: 147;
|
||||
y: 18;
|
||||
color: rgb(46,52,54);
|
||||
glyphs: 45 9216 0 0 1, 360 8192 0 0 1, 244 8192 0 0 1, 272 8192 0 0 1, 349 4096 0 0 1, 287 8192 0 0 1, 280 8192 0 0 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
transform {
|
||||
transform: translate(0, 76);
|
||||
child: container {
|
||||
transform {
|
||||
transform: translate(1, 1);
|
||||
child: container {
|
||||
rounded-clip {
|
||||
clip: -1 -1 50 26 / 13;
|
||||
child: color {
|
||||
bounds: -1 -1 50 26;
|
||||
color: rgb(250,249,248);
|
||||
}
|
||||
}
|
||||
border {
|
||||
outline: -1 -1 50 26 / 13;
|
||||
widths: 1 1 1 1;
|
||||
colors: rgb(205,199,194) rgb(205,199,194) rgb(205,199,194) rgb(205,199,194);
|
||||
}
|
||||
container {
|
||||
rounded-clip {
|
||||
clip: -1 -1 26 26 / 13;
|
||||
child: color {
|
||||
bounds: 0 0 24 24;
|
||||
color: rgb(250,249,248);
|
||||
}
|
||||
}
|
||||
border {
|
||||
outline: -1 -1 26 26 / 13;
|
||||
widths: 1 1 1 1;
|
||||
colors: rgb(205,199,194) rgb(205,199,194) rgb(205,199,194) rgb(205,199,194);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
transform {
|
||||
transform: translate(56, 0);
|
||||
child: text {
|
||||
font: "Cantarell 11";
|
||||
x: 145;
|
||||
y: 18;
|
||||
color: rgb(46,52,54);
|
||||
glyphs: 37 11264 0 0 1, 324 4096 0 0 1, 417 7168 0 0 1, 244 8192 0 0 1, 272 8192 0 0 1, 349 4096 0 0 1, 287 8192 0 0 1, 280 8192 0 0 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
transform {
|
||||
transform: translate(0, 114);
|
||||
child: container {
|
||||
transform {
|
||||
transform: translate(1, 1);
|
||||
child: container {
|
||||
rounded-clip {
|
||||
clip: -1 -1 50 26 / 13;
|
||||
child: color {
|
||||
bounds: -1 -1 50 26;
|
||||
color: rgb(250,249,248);
|
||||
}
|
||||
}
|
||||
border {
|
||||
outline: -1 -1 50 26 / 13;
|
||||
widths: 1 1 1 1;
|
||||
colors: rgb(205,199,194) rgb(205,199,194) rgb(205,199,194) rgb(205,199,194);
|
||||
}
|
||||
transform {
|
||||
transform: translate(24, 0);
|
||||
child: container {
|
||||
rounded-clip {
|
||||
clip: -1 -1 26 26 / 13;
|
||||
child: color {
|
||||
bounds: 0 0 24 24;
|
||||
color: rgb(250,249,248);
|
||||
}
|
||||
}
|
||||
border {
|
||||
outline: -1 -1 26 26 / 13;
|
||||
widths: 1 1 1 1;
|
||||
colors: rgb(205,199,194) rgb(205,199,194) rgb(205,199,194) rgb(205,199,194);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
transform {
|
||||
transform: translate(56, 0);
|
||||
child: text {
|
||||
font: "Cantarell 11";
|
||||
x: 147;
|
||||
y: 18;
|
||||
color: rgb(46,52,54);
|
||||
glyphs: 45 9216 0 0 1, 360 8192 0 0 1, 244 8192 0 0 1, 272 8192 0 0 1, 349 4096 0 0 1, 287 8192 0 0 1, 280 8192 0 0 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
transform {
|
||||
transform: translate(0, 152);
|
||||
child: container {
|
||||
transform {
|
||||
transform: translate(1, 1);
|
||||
child: container {
|
||||
rounded-clip {
|
||||
clip: -1 -1 50 26 / 13;
|
||||
child: color {
|
||||
bounds: -1 -1 50 26;
|
||||
color: rgb(225,222,219);
|
||||
}
|
||||
}
|
||||
border {
|
||||
outline: -1 -1 50 26 / 13;
|
||||
widths: 1 1 1 1;
|
||||
colors: rgb(205,199,194) rgb(205,199,194) rgb(205,199,194) rgb(205,199,194);
|
||||
}
|
||||
container {
|
||||
container {
|
||||
outset-shadow {
|
||||
outline: -1 -1 26 26 / 13;
|
||||
color: rgba(0,0,0,0.1);
|
||||
dx: 0;
|
||||
dy: 1;
|
||||
spread: 0;
|
||||
blur: 0;
|
||||
}
|
||||
outset-shadow {
|
||||
outline: -1 -1 26 26 / 13;
|
||||
color: rgba(0,0,0,0.07);
|
||||
dx: 0;
|
||||
dy: 1;
|
||||
spread: 0;
|
||||
blur: 2;
|
||||
}
|
||||
rounded-clip {
|
||||
clip: -1 -1 26 26 / 13;
|
||||
child: linear-gradient {
|
||||
bounds: 0 0 24 24;
|
||||
start: 12 0;
|
||||
end: 12 24;
|
||||
stops: 0.2 rgb(255,255,255),0.9 rgb(246,245,244);
|
||||
}
|
||||
}
|
||||
inset-shadow {
|
||||
outline: 0 0 24 24 / 12;
|
||||
color: rgb(255,255,255);
|
||||
dx: 0;
|
||||
dy: 1;
|
||||
spread: 0;
|
||||
blur: 0;
|
||||
}
|
||||
}
|
||||
border {
|
||||
outline: -1 -1 26 26 / 13;
|
||||
widths: 1 1 1 1;
|
||||
colors: rgb(191,184,177) rgb(191,184,177) rgb(191,184,177) rgb(191,184,177);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
transform {
|
||||
transform: translate(78, 0);
|
||||
child: text {
|
||||
font: "Cantarell 11";
|
||||
x: 123;
|
||||
y: 18;
|
||||
color: rgb(46,52,54);
|
||||
glyphs: 37 11264 0 0 1, 324 4096 0 0 1, 417 7168 0 0 1, 244 8192 0 0 1, 272 8192 0 0 1, 349 4096 0 0 1, 287 8192 0 0 1, 280 8192 0 0 1;
|
||||
}
|
||||
}
|
||||
transform {
|
||||
transform: translate(388, 0);
|
||||
child: transform {
|
||||
transform: translate(1, 6);
|
||||
child: container {
|
||||
container {
|
||||
outset-shadow {
|
||||
outline: -1 -1 16 16 / 3;
|
||||
color: rgba(0,0,0,0.1);
|
||||
dx: 0;
|
||||
dy: 1;
|
||||
spread: 0;
|
||||
blur: 0;
|
||||
}
|
||||
outset-shadow {
|
||||
outline: -1 -1 16 16 / 3;
|
||||
color: rgba(0,0,0,0.07);
|
||||
dx: 0;
|
||||
dy: 1;
|
||||
spread: 0;
|
||||
blur: 2;
|
||||
}
|
||||
linear-gradient {
|
||||
bounds: 0 0 14 14;
|
||||
start: 7 0;
|
||||
end: 7 14;
|
||||
stops: 0.2 rgb(255,255,255),0.9 rgb(246,245,244);
|
||||
}
|
||||
inset-shadow {
|
||||
outline: 0 0 14 14 / 2;
|
||||
color: rgb(255,255,255);
|
||||
dx: 0;
|
||||
dy: 1;
|
||||
spread: 0;
|
||||
blur: 0;
|
||||
}
|
||||
}
|
||||
border {
|
||||
outline: -1 -1 16 16 / 3;
|
||||
widths: 1 1 1 1;
|
||||
colors: rgb(191,184,177) rgb(191,184,177) rgb(191,184,177) rgb(191,184,177);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
43
testsuite/gsk/serialize-deserialize.c
Normal file
43
testsuite/gsk/serialize-deserialize.c
Normal file
@@ -0,0 +1,43 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GskRenderNode *node;
|
||||
GskRenderNode *deserialized;
|
||||
GBytes *bytes;
|
||||
GFile *file;
|
||||
|
||||
g_assert (argc == 2);
|
||||
|
||||
gtk_init ();
|
||||
|
||||
file = g_file_new_for_commandline_arg (argv[1]);
|
||||
bytes = g_file_load_bytes (file, NULL, NULL, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert (bytes != NULL);
|
||||
|
||||
node = gsk_render_node_deserialize (bytes, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
/* Now serialize */
|
||||
g_bytes_unref (bytes);
|
||||
bytes = gsk_render_node_serialize (node);
|
||||
/* and deserialize again... */
|
||||
deserialized = gsk_render_node_deserialize (bytes, &error);
|
||||
g_assert_no_error (error);
|
||||
|
||||
/* And check if that all worked. */
|
||||
g_assert_cmpint (gsk_render_node_get_node_type (deserialized), ==,
|
||||
gsk_render_node_get_node_type (node));
|
||||
|
||||
|
||||
g_clear_error (&error);
|
||||
g_clear_pointer (&node, gsk_render_node_unref);
|
||||
g_clear_pointer (&deserialized, gsk_render_node_unref);
|
||||
g_bytes_unref (bytes);
|
||||
g_object_unref (file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user