forked from AuroraMiddleware/gtk
gsk: Improve test coverage
This commit is contained in:
parent
a4c6517d06
commit
5064a8eac0
@ -25,6 +25,7 @@ test_can_diff_basic (void)
|
|||||||
{
|
{
|
||||||
GskRenderNode *container1, *container2;
|
GskRenderNode *container1, *container2;
|
||||||
GskRenderNode *color1, *color2;
|
GskRenderNode *color1, *color2;
|
||||||
|
GskRenderNode *debug1, *debug2;
|
||||||
|
|
||||||
color1 = gsk_color_node_new (&(GdkRGBA){0, 1, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, 10, 10));
|
color1 = gsk_color_node_new (&(GdkRGBA){0, 1, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, 10, 10));
|
||||||
color2 = gsk_color_node_new (&(GdkRGBA){1, 1, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, 10, 10));
|
color2 = gsk_color_node_new (&(GdkRGBA){1, 1, 0, 1 }, &GRAPHENE_RECT_INIT (0, 0, 10, 10));
|
||||||
@ -32,10 +33,15 @@ test_can_diff_basic (void)
|
|||||||
container1 = gsk_container_node_new (&color1, 1);
|
container1 = gsk_container_node_new (&color1, 1);
|
||||||
container2 = gsk_container_node_new (&color2, 1);
|
container2 = gsk_container_node_new (&color2, 1);
|
||||||
|
|
||||||
|
debug1 = gsk_debug_node_new (color1, g_strdup ("Debug node!"));
|
||||||
|
debug2 = gsk_debug_node_new (color2, g_strdup ("Debug node!"));
|
||||||
|
|
||||||
/* We can diff two color nodes */
|
/* We can diff two color nodes */
|
||||||
g_assert_true (gsk_render_node_can_diff (color1, color2));
|
g_assert_true (gsk_render_node_can_diff (color1, color2));
|
||||||
/* We can diff two container nodes */
|
/* We can diff two container nodes */
|
||||||
g_assert_true (gsk_render_node_can_diff (container1, container2));
|
g_assert_true (gsk_render_node_can_diff (container1, container2));
|
||||||
|
/* We can diff two debug nodes */
|
||||||
|
g_assert_true (gsk_render_node_can_diff (debug1, debug2));
|
||||||
/* We can diff container nodes against anything else */
|
/* We can diff container nodes against anything else */
|
||||||
g_assert_true (gsk_render_node_can_diff (container1, color2));
|
g_assert_true (gsk_render_node_can_diff (container1, color2));
|
||||||
g_assert_true (gsk_render_node_can_diff (color1, container2));
|
g_assert_true (gsk_render_node_can_diff (color1, container2));
|
||||||
@ -45,6 +51,9 @@ test_can_diff_basic (void)
|
|||||||
|
|
||||||
gsk_render_node_unref (container1);
|
gsk_render_node_unref (container1);
|
||||||
gsk_render_node_unref (container2);
|
gsk_render_node_unref (container2);
|
||||||
|
|
||||||
|
gsk_render_node_unref (debug1);
|
||||||
|
gsk_render_node_unref (debug2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -129,6 +129,8 @@ node_parser_tests = [
|
|||||||
'blend.node',
|
'blend.node',
|
||||||
'border.node',
|
'border.node',
|
||||||
'color.node',
|
'color.node',
|
||||||
|
'conic-gradient.node',
|
||||||
|
'conic-gradient.ref.node',
|
||||||
'crash1.errors',
|
'crash1.errors',
|
||||||
'crash1.node',
|
'crash1.node',
|
||||||
'crash1.ref.node',
|
'crash1.ref.node',
|
||||||
@ -141,6 +143,9 @@ node_parser_tests = [
|
|||||||
'crash4.node',
|
'crash4.node',
|
||||||
'crash4.ref.node',
|
'crash4.ref.node',
|
||||||
'debug.node',
|
'debug.node',
|
||||||
|
'debug-fail.node',
|
||||||
|
'debug-fail.ref.node',
|
||||||
|
'debug-fail.errors',
|
||||||
'empty-blend.node',
|
'empty-blend.node',
|
||||||
'empty-blend.ref.node',
|
'empty-blend.ref.node',
|
||||||
'empty-blur.node',
|
'empty-blur.node',
|
||||||
@ -181,9 +186,33 @@ node_parser_tests = [
|
|||||||
'empty-texture.ref.node',
|
'empty-texture.ref.node',
|
||||||
'empty-transform.node',
|
'empty-transform.node',
|
||||||
'empty-transform.ref.node',
|
'empty-transform.ref.node',
|
||||||
|
'glshader.node',
|
||||||
|
'glshader.ref.node',
|
||||||
|
'glshader.errors',
|
||||||
|
'gradient-fail.node',
|
||||||
|
'gradient-fail.ref.node',
|
||||||
|
'gradient-fail.errors',
|
||||||
|
'radial-gradient.node',
|
||||||
|
'radial-gradient.ref.node',
|
||||||
|
'repeating-linear-gradient.node',
|
||||||
|
'repeating-linear-gradient.ref.node',
|
||||||
|
'repeating-radial-gradient.node',
|
||||||
|
'repeating-radial-gradient.ref.node',
|
||||||
'rounded-rect.node',
|
'rounded-rect.node',
|
||||||
'shadow.node',
|
'shadow.node',
|
||||||
|
'shadow-fail.node',
|
||||||
|
'shadow-fail.ref.node',
|
||||||
|
'shadow-fail.errors',
|
||||||
'testswitch.node',
|
'testswitch.node',
|
||||||
|
'text-fail.node',
|
||||||
|
'text-fail.ref.node',
|
||||||
|
'text-fail.errors',
|
||||||
|
'texture-fail.node',
|
||||||
|
'texture-fail.ref.node',
|
||||||
|
'texture-fail.ref.errors',
|
||||||
|
'transform-fail.node',
|
||||||
|
'transform-fail.ref.node',
|
||||||
|
'transform-fail.errors',
|
||||||
'widgetfactory.node',
|
'widgetfactory.node',
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -205,7 +234,6 @@ foreach test : node_parser_tests
|
|||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
tests = [
|
tests = [
|
||||||
['rounded-rect'],
|
|
||||||
['transform'],
|
['transform'],
|
||||||
['shader'],
|
['shader'],
|
||||||
]
|
]
|
||||||
@ -242,6 +270,8 @@ endforeach
|
|||||||
internal_tests = [
|
internal_tests = [
|
||||||
[ 'diff' ],
|
[ 'diff' ],
|
||||||
[ 'half-float' ],
|
[ 'half-float' ],
|
||||||
|
['rounded-rect'],
|
||||||
|
['misc'],
|
||||||
]
|
]
|
||||||
|
|
||||||
foreach t : internal_tests
|
foreach t : internal_tests
|
||||||
|
96
testsuite/gsk/misc.c
Normal file
96
testsuite/gsk/misc.c
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#include <gtk/gtk.h>
|
||||||
|
#include "gsk/gskrendernodeprivate.h"
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_rendernode_gvalue (void)
|
||||||
|
{
|
||||||
|
GValue value = G_VALUE_INIT;
|
||||||
|
GskRenderNode *node, *node2;
|
||||||
|
|
||||||
|
g_assert_false (GSK_VALUE_HOLDS_RENDER_NODE (&value));
|
||||||
|
g_value_init (&value, GSK_TYPE_RENDER_NODE);
|
||||||
|
g_assert_true (GSK_VALUE_HOLDS_RENDER_NODE (&value));
|
||||||
|
|
||||||
|
node = gsk_value_get_render_node (&value);
|
||||||
|
g_assert_null (node);
|
||||||
|
|
||||||
|
node = gsk_color_node_new (&(GdkRGBA){0,1,1,1}, &GRAPHENE_RECT_INIT (0, 0, 50, 50));
|
||||||
|
gsk_value_set_render_node (&value, node);
|
||||||
|
|
||||||
|
node2 = gsk_value_dup_render_node (&value);
|
||||||
|
g_assert_true (node == node2);
|
||||||
|
|
||||||
|
g_value_reset (&value);
|
||||||
|
gsk_value_take_render_node (&value, node);
|
||||||
|
|
||||||
|
g_value_unset (&value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_bordernode_uniform (void)
|
||||||
|
{
|
||||||
|
GskRenderNode *node;
|
||||||
|
GskRoundedRect rect;
|
||||||
|
GdkRGBA colors[4] = {
|
||||||
|
{ 0, 0, 0, 1 },
|
||||||
|
{ 0, 0, 0, 1 },
|
||||||
|
{ 0, 0, 0, 1 },
|
||||||
|
{ 0, 0, 0, 1 },
|
||||||
|
};
|
||||||
|
|
||||||
|
gsk_rounded_rect_init (&rect,
|
||||||
|
&GRAPHENE_RECT_INIT (0, 0, 50, 50),
|
||||||
|
&GRAPHENE_SIZE_INIT (10, 10),
|
||||||
|
&GRAPHENE_SIZE_INIT (10, 10),
|
||||||
|
&GRAPHENE_SIZE_INIT (10, 10),
|
||||||
|
&GRAPHENE_SIZE_INIT (10, 10));
|
||||||
|
|
||||||
|
node = gsk_border_node_new (&rect, (const float[]){ 1, 1, 1, 1}, colors);
|
||||||
|
|
||||||
|
g_assert_true (gsk_border_node_get_uniform (node));
|
||||||
|
g_assert_true (gsk_border_node_get_uniform_color (node));
|
||||||
|
|
||||||
|
gsk_render_node_unref (node);
|
||||||
|
|
||||||
|
node = gsk_border_node_new (&rect, (const float[]){ 1, 2, 3, 4}, colors);
|
||||||
|
|
||||||
|
g_assert_false (gsk_border_node_get_uniform (node));
|
||||||
|
g_assert_true (gsk_border_node_get_uniform_color (node));
|
||||||
|
|
||||||
|
gsk_render_node_unref (node);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DEG_TO_RAD(x) ((x) * (G_PI / 180.f))
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_conic_gradient_angle (void)
|
||||||
|
{
|
||||||
|
GskRenderNode *node;
|
||||||
|
GskColorStop stops[] = {
|
||||||
|
{ 0.f, (GdkRGBA) { 0, 0, 0, 1} },
|
||||||
|
{ 1.f, (GdkRGBA) { 1, 0, 1, 1} },
|
||||||
|
};
|
||||||
|
|
||||||
|
node = gsk_conic_gradient_node_new (&GRAPHENE_RECT_INIT (0, 0, 50, 50),
|
||||||
|
&GRAPHENE_POINT_INIT (10, 20),
|
||||||
|
33.f,
|
||||||
|
stops,
|
||||||
|
G_N_ELEMENTS (stops));
|
||||||
|
|
||||||
|
g_assert_cmpfloat_with_epsilon (gsk_conic_gradient_node_get_angle (node), DEG_TO_RAD (90.f - 33.f), 0.001);
|
||||||
|
|
||||||
|
gsk_render_node_unref (node);
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main (int argc, char *argv[])
|
||||||
|
{
|
||||||
|
(g_test_init) (&argc, &argv, NULL);
|
||||||
|
gtk_init ();
|
||||||
|
|
||||||
|
g_test_add_func ("/rendernode/gvalue", test_rendernode_gvalue);
|
||||||
|
g_test_add_func ("/rendernode/border/uniform", test_bordernode_uniform);
|
||||||
|
g_test_add_func ("/rendernode/conic-gradient/angle", test_conic_gradient_angle);
|
||||||
|
|
||||||
|
return g_test_run ();
|
||||||
|
}
|
6
testsuite/gsk/nodeparser/conic-gradient.node
Normal file
6
testsuite/gsk/nodeparser/conic-gradient.node
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
conic-gradient {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
center: 20 30;
|
||||||
|
rotation: 25;
|
||||||
|
stops: 0 #444, 0.2 #0F0, 1 #F0A;
|
||||||
|
}
|
6
testsuite/gsk/nodeparser/conic-gradient.ref.node
Normal file
6
testsuite/gsk/nodeparser/conic-gradient.ref.node
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
conic-gradient {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
center: 20 30;
|
||||||
|
rotation: 25;
|
||||||
|
stops: 0 rgb(68,68,68), 0.2 rgb(0,255,0), 1 rgb(255,0,170);
|
||||||
|
}
|
2
testsuite/gsk/nodeparser/debug-fail.errors
Normal file
2
testsuite/gsk/nodeparser/debug-fail.errors
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<data>:5:10-11: error: GTK_CSS_PARSER_WARNING_SYNTAX
|
||||||
|
<data>:6:8-9: error: GTK_CSS_PARSER_WARNING_SYNTAX
|
8
testsuite/gsk/nodeparser/debug-fail.node
Normal file
8
testsuite/gsk/nodeparser/debug-fail.node
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
debug {
|
||||||
|
message: "I'm a debug node.";
|
||||||
|
child: container {
|
||||||
|
}
|
||||||
|
message: "With repeating message and child.";
|
||||||
|
child: container {
|
||||||
|
}
|
||||||
|
}
|
5
testsuite/gsk/nodeparser/debug-fail.ref.node
Normal file
5
testsuite/gsk/nodeparser/debug-fail.ref.node
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
debug {
|
||||||
|
message: "With repeating message and child.";
|
||||||
|
child: container {
|
||||||
|
}
|
||||||
|
}
|
1
testsuite/gsk/nodeparser/glshader.errors
Normal file
1
testsuite/gsk/nodeparser/glshader.errors
Normal file
@ -0,0 +1 @@
|
|||||||
|
<data>:10:43-47: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
11
testsuite/gsk/nodeparser/glshader.node
Normal file
11
testsuite/gsk/nodeparser/glshader.node
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
glshader {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
sourcecode: "uniform vec3 iResolution;\A\
|
||||||
|
uniform vec4 another;\A\
|
||||||
|
uniform vec2 point;\A\
|
||||||
|
uniform int iii;\A\
|
||||||
|
uniform uint uuu;\A\
|
||||||
|
uniform bool bbb;\A\
|
||||||
|
uniform float num;";
|
||||||
|
args: 10 20 30, 1 2 3 4, -1 -2, 0, 100, true, 3.1415;
|
||||||
|
}
|
11
testsuite/gsk/nodeparser/glshader.ref.node
Normal file
11
testsuite/gsk/nodeparser/glshader.ref.node
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
glshader {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
sourcecode: "uniform vec3 iResolution;\A\
|
||||||
|
uniform vec4 another;\A\
|
||||||
|
uniform vec2 point;\A\
|
||||||
|
uniform int iii;\A\
|
||||||
|
uniform uint uuu;\A\
|
||||||
|
uniform bool bbb;\A\
|
||||||
|
uniform float num;";
|
||||||
|
args: 10 20 30, 1 2 3 4, -1 -2, 0, 100, 0, 0;
|
||||||
|
}
|
1
testsuite/gsk/nodeparser/gradient-fail.errors
Normal file
1
testsuite/gsk/nodeparser/gradient-fail.errors
Normal file
@ -0,0 +1 @@
|
|||||||
|
<data>:3:8-9: error: GTK_CSS_PARSER_WARNING_SYNTAX
|
4
testsuite/gsk/nodeparser/gradient-fail.node
Normal file
4
testsuite/gsk/nodeparser/gradient-fail.node
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
repeating-linear-gradient {
|
||||||
|
stops: 0 #FF0, 0.25 #F0A, 1 #0FF;
|
||||||
|
stops: 0 #FF0, 0.25 #F0A, 1 #0FF;
|
||||||
|
}
|
6
testsuite/gsk/nodeparser/gradient-fail.ref.node
Normal file
6
testsuite/gsk/nodeparser/gradient-fail.ref.node
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
repeating-linear-gradient {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
start: 0 0;
|
||||||
|
end: 0 50;
|
||||||
|
stops: 0 rgb(255,255,0), 0.25 rgb(255,0,170), 1 rgb(0,255,255);
|
||||||
|
}
|
9
testsuite/gsk/nodeparser/radial-gradient.node
Normal file
9
testsuite/gsk/nodeparser/radial-gradient.node
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
radial-gradient {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
center: 20 20;
|
||||||
|
hradius: 10;
|
||||||
|
vradius: 20;
|
||||||
|
start: 0.25;
|
||||||
|
end: 0.75;
|
||||||
|
stops: 0 #FF0, 0.5 #ABC, 1 #F0F;
|
||||||
|
}
|
9
testsuite/gsk/nodeparser/radial-gradient.ref.node
Normal file
9
testsuite/gsk/nodeparser/radial-gradient.ref.node
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
radial-gradient {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
center: 20 20;
|
||||||
|
hradius: 10;
|
||||||
|
vradius: 20;
|
||||||
|
start: 0.25;
|
||||||
|
end: 0.75;
|
||||||
|
stops: 0 rgb(255,255,0), 0.5 rgb(170,187,204), 1 rgb(255,0,255);
|
||||||
|
}
|
6
testsuite/gsk/nodeparser/repeating-linear-gradient.node
Normal file
6
testsuite/gsk/nodeparser/repeating-linear-gradient.node
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
repeating-linear-gradient {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
start: 50 0;
|
||||||
|
end: 25 25;
|
||||||
|
stops: 0 #FF0, 0.25 #F0A, 1 #0FF;
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
repeating-linear-gradient {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
start: 50 0;
|
||||||
|
end: 25 25;
|
||||||
|
stops: 0 rgb(255,255,0), 0.25 rgb(255,0,170), 1 rgb(0,255,255);
|
||||||
|
}
|
9
testsuite/gsk/nodeparser/repeating-radial-gradient.node
Normal file
9
testsuite/gsk/nodeparser/repeating-radial-gradient.node
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
repeating-radial-gradient {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
center: 20 30;
|
||||||
|
hradius: 30;
|
||||||
|
vradius: 20;
|
||||||
|
start: 0.25;
|
||||||
|
end: 0.75;
|
||||||
|
stops: 0 #F0F, 1 #0F0;
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
repeating-radial-gradient {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
center: 20 30;
|
||||||
|
hradius: 30;
|
||||||
|
vradius: 20;
|
||||||
|
start: 0.25;
|
||||||
|
end: 0.75;
|
||||||
|
stops: 0 rgb(255,0,255), 1 rgb(0,255,0);
|
||||||
|
}
|
9
testsuite/gsk/nodeparser/shadow-fail.errors
Normal file
9
testsuite/gsk/nodeparser/shadow-fail.errors
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<data>:2:11-13: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
||||||
|
<data>:2:11-13: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
|
||||||
|
<data>:2:13-14: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
||||||
|
<data>:2:13-14: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
|
||||||
|
<data>:3:9-10: error: GTK_CSS_PARSER_WARNING_SYNTAX
|
||||||
|
<data>:3:11-13: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
||||||
|
<data>:3:11-13: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
|
||||||
|
<data>:3:13-14: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
||||||
|
<data>:3:13-14: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
|
4
testsuite/gsk/nodeparser/shadow-fail.node
Normal file
4
testsuite/gsk/nodeparser/shadow-fail.node
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
shadow {
|
||||||
|
shadows: 22;
|
||||||
|
shadows: 22;
|
||||||
|
}
|
7
testsuite/gsk/nodeparser/shadow-fail.ref.node
Normal file
7
testsuite/gsk/nodeparser/shadow-fail.ref.node
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
shadow {
|
||||||
|
shadows: rgb(0,0,0) 22 0, rgb(0,0,0) 22 0;
|
||||||
|
child: color {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
color: rgb(255,0,204);
|
||||||
|
}
|
||||||
|
}
|
3
testsuite/gsk/nodeparser/text-fail.errors
Normal file
3
testsuite/gsk/nodeparser/text-fail.errors
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<data>:4:7-8: error: GTK_CSS_PARSER_WARNING_SYNTAX
|
||||||
|
<data>:6:9-10: error: GTK_CSS_PARSER_WARNING_SYNTAX
|
||||||
|
<data>:8:1-2: error: GTK_CSS_PARSER_ERROR_UNKNOWN_VALUE
|
8
testsuite/gsk/nodeparser/text-fail.node
Normal file
8
testsuite/gsk/nodeparser/text-fail.node
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
text {
|
||||||
|
color: rgb(50,50,50);
|
||||||
|
font: "";
|
||||||
|
font: "";
|
||||||
|
glyphs: "N";
|
||||||
|
glyphs: "N";
|
||||||
|
offset: 0 32.0186;
|
||||||
|
}
|
4
testsuite/gsk/nodeparser/text-fail.ref.node
Normal file
4
testsuite/gsk/nodeparser/text-fail.ref.node
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
color {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
color: rgb(255,0,204);
|
||||||
|
}
|
1
testsuite/gsk/nodeparser/texture-fail.errors
Normal file
1
testsuite/gsk/nodeparser/texture-fail.errors
Normal file
@ -0,0 +1 @@
|
|||||||
|
<data>:2:12-14: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
3
testsuite/gsk/nodeparser/texture-fail.node
Normal file
3
testsuite/gsk/nodeparser/texture-fail.node
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
texture {
|
||||||
|
texture: 22;
|
||||||
|
}
|
6
testsuite/gsk/nodeparser/texture-fail.ref.node
Normal file
6
testsuite/gsk/nodeparser/texture-fail.ref.node
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
texture {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
texture: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAKUlEQVQYlWP8z3DmPwMaYGQwYUQX\
|
||||||
|
Y0IXwAUGUCGGoxkYGBiweXAoeAYAz44F3e3U1xUAAAAASUVORK5CYII=\
|
||||||
|
");
|
||||||
|
}
|
1
testsuite/gsk/nodeparser/transform-fail.errors
Normal file
1
testsuite/gsk/nodeparser/transform-fail.errors
Normal file
@ -0,0 +1 @@
|
|||||||
|
<data>:2:14-16: error: GTK_CSS_PARSER_ERROR_SYNTAX
|
3
testsuite/gsk/nodeparser/transform-fail.node
Normal file
3
testsuite/gsk/nodeparser/transform-fail.node
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
transform {
|
||||||
|
transform: 22;
|
||||||
|
}
|
6
testsuite/gsk/nodeparser/transform-fail.ref.node
Normal file
6
testsuite/gsk/nodeparser/transform-fail.ref.node
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
transform {
|
||||||
|
child: color {
|
||||||
|
bounds: 0 0 50 50;
|
||||||
|
color: rgb(255,0,204);
|
||||||
|
}
|
||||||
|
}
|
@ -20,6 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <gsk/gskroundedrectprivate.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_contains_rect (void)
|
test_contains_rect (void)
|
||||||
@ -114,6 +115,51 @@ test_contains_point (void)
|
|||||||
g_assert_true (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (10, 95)));
|
g_assert_true (gsk_rounded_rect_contains_point (&rect, &GRAPHENE_POINT_INIT (10, 95)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_is_circular (void)
|
||||||
|
{
|
||||||
|
GskRoundedRect rect;
|
||||||
|
|
||||||
|
gsk_rounded_rect_init (&rect,
|
||||||
|
&GRAPHENE_RECT_INIT (0, 0, 100, 100),
|
||||||
|
&GRAPHENE_SIZE_INIT (0, 0),
|
||||||
|
&GRAPHENE_SIZE_INIT (10, 10),
|
||||||
|
&GRAPHENE_SIZE_INIT (10, 20),
|
||||||
|
&GRAPHENE_SIZE_INIT (20, 10));
|
||||||
|
|
||||||
|
g_assert_false (gsk_rounded_rect_is_circular (&rect));
|
||||||
|
|
||||||
|
gsk_rounded_rect_init (&rect,
|
||||||
|
&GRAPHENE_RECT_INIT (0, 0, 100, 100),
|
||||||
|
&GRAPHENE_SIZE_INIT (0, 0),
|
||||||
|
&GRAPHENE_SIZE_INIT (10, 10),
|
||||||
|
&GRAPHENE_SIZE_INIT (20, 20),
|
||||||
|
&GRAPHENE_SIZE_INIT (30, 30));
|
||||||
|
|
||||||
|
g_assert_true (gsk_rounded_rect_is_circular (&rect));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_to_float (void)
|
||||||
|
{
|
||||||
|
GskRoundedRect rect;
|
||||||
|
float flt[12];
|
||||||
|
|
||||||
|
gsk_rounded_rect_init (&rect,
|
||||||
|
&GRAPHENE_RECT_INIT (0, 11, 22, 33),
|
||||||
|
&GRAPHENE_SIZE_INIT (4, 5),
|
||||||
|
&GRAPHENE_SIZE_INIT (6, 7),
|
||||||
|
&GRAPHENE_SIZE_INIT (8, 9),
|
||||||
|
&GRAPHENE_SIZE_INIT (10, 11));
|
||||||
|
|
||||||
|
gsk_rounded_rect_to_float (&rect, flt);
|
||||||
|
g_assert_true (flt[0] == 0. && flt[1] == 11. && flt[2] == 22. && flt[3] == 33.);
|
||||||
|
g_assert_true (flt[4] == 4. && flt[5] == 6.);
|
||||||
|
g_assert_true (flt[6] == 8. && flt[7] == 10.);
|
||||||
|
g_assert_true (flt[8] == 5. && flt[9] == 7.);
|
||||||
|
g_assert_true (flt[10] == 9. && flt[11] == 11.);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc,
|
main (int argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
@ -123,6 +169,8 @@ main (int argc,
|
|||||||
g_test_add_func ("/rounded-rect/contains-rect", test_contains_rect);
|
g_test_add_func ("/rounded-rect/contains-rect", test_contains_rect);
|
||||||
g_test_add_func ("/rounded-rect/intersects-rect", test_intersects_rect);
|
g_test_add_func ("/rounded-rect/intersects-rect", test_intersects_rect);
|
||||||
g_test_add_func ("/rounded-rect/contains-point", test_contains_point);
|
g_test_add_func ("/rounded-rect/contains-point", test_contains_point);
|
||||||
|
g_test_add_func ("/rounded-rect/is-circular", test_is_circular);
|
||||||
|
g_test_add_func ("/rounded-rect/to-float", test_to_float);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
@ -76,6 +76,7 @@ test_create_simple (void)
|
|||||||
{
|
{
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
GskGLShader *shader;
|
GskGLShader *shader;
|
||||||
|
GBytes *source;
|
||||||
|
|
||||||
bytes = g_bytes_new_static (shader1, sizeof (shader1));
|
bytes = g_bytes_new_static (shader1, sizeof (shader1));
|
||||||
shader = gsk_gl_shader_new_from_bytes (bytes);
|
shader = gsk_gl_shader_new_from_bytes (bytes);
|
||||||
@ -100,19 +101,48 @@ test_create_simple (void)
|
|||||||
g_assert_cmpstr (gsk_gl_shader_get_uniform_name (shader, 7), ==, "test5");
|
g_assert_cmpstr (gsk_gl_shader_get_uniform_name (shader, 7), ==, "test5");
|
||||||
g_assert_cmpint (gsk_gl_shader_get_uniform_type (shader, 7), ==, GSK_GL_UNIFORM_TYPE_VEC4);
|
g_assert_cmpint (gsk_gl_shader_get_uniform_type (shader, 7), ==, GSK_GL_UNIFORM_TYPE_VEC4);
|
||||||
|
|
||||||
|
g_assert_cmpint (gsk_gl_shader_find_uniform_by_name (shader, "progress"), ==, 0);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_find_uniform_by_name (shader, "dots"), ==, 1);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_find_uniform_by_name (shader, "center"), ==, 2);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_find_uniform_by_name (shader, "test1"), ==, 3);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_find_uniform_by_name (shader, "test2"), ==, 4);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_find_uniform_by_name (shader, "test3"), ==, 5);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_find_uniform_by_name (shader, "test4"), ==, 6);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_find_uniform_by_name (shader, "test5"), ==, 7);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_find_uniform_by_name (shader, "nosucharg"), ==, -1);
|
||||||
|
|
||||||
|
g_assert_cmpint (gsk_gl_shader_get_uniform_offset (shader, 0), ==, 0);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_get_uniform_offset (shader, 1), >, 0);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_get_uniform_offset (shader, 2), >, 0);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_get_uniform_offset (shader, 3), >, 0);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_get_uniform_offset (shader, 4), >, 0);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_get_uniform_offset (shader, 5), >, 0);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_get_uniform_offset (shader, 6), >, 0);
|
||||||
|
g_assert_cmpint (gsk_gl_shader_get_uniform_offset (shader, 7), >, 0);
|
||||||
|
|
||||||
|
g_assert_null (gsk_gl_shader_get_resource (shader));
|
||||||
|
|
||||||
|
g_object_get (shader, "source", &source, NULL);
|
||||||
|
g_assert_true (g_bytes_equal (source, bytes));
|
||||||
|
|
||||||
g_object_unref (shader);
|
g_object_unref (shader);
|
||||||
g_bytes_unref (bytes);
|
g_bytes_unref (bytes);
|
||||||
|
g_bytes_unref (source);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_create_data (void)
|
test_create_data (void)
|
||||||
{
|
{
|
||||||
GBytes *bytes;
|
GBytes *bytes;
|
||||||
|
GBytes *bytes2;
|
||||||
GskGLShader *shader;
|
GskGLShader *shader;
|
||||||
GskShaderArgsBuilder *builder;
|
GskShaderArgsBuilder *builder;
|
||||||
|
GskShaderArgsBuilder *builder2;
|
||||||
graphene_vec2_t v2, vv2;
|
graphene_vec2_t v2, vv2;
|
||||||
graphene_vec3_t v3, vv3;
|
graphene_vec3_t v3, vv3;
|
||||||
graphene_vec4_t v4, vv4;
|
graphene_vec4_t v4, vv4;
|
||||||
|
GskRenderNode *node;
|
||||||
|
GskRenderNode *children[2];
|
||||||
|
|
||||||
bytes = g_bytes_new_static (shader1, sizeof (shader1));
|
bytes = g_bytes_new_static (shader1, sizeof (shader1));
|
||||||
shader = gsk_gl_shader_new_from_bytes (bytes);
|
shader = gsk_gl_shader_new_from_bytes (bytes);
|
||||||
@ -150,6 +180,31 @@ test_create_data (void)
|
|||||||
gsk_gl_shader_get_arg_vec4 (shader, bytes, 7, &vv4);
|
gsk_gl_shader_get_arg_vec4 (shader, bytes, 7, &vv4);
|
||||||
g_assert_true (graphene_vec4_equal (&v4, &vv4));
|
g_assert_true (graphene_vec4_equal (&v4, &vv4));
|
||||||
|
|
||||||
|
children[0] = gsk_color_node_new (&(GdkRGBA){0,0,0,1}, &GRAPHENE_RECT_INIT (0, 0, 50, 50));
|
||||||
|
children[1] = gsk_color_node_new (&(GdkRGBA){1,0,0,1}, &GRAPHENE_RECT_INIT (0, 0, 50, 50));
|
||||||
|
node = gsk_gl_shader_node_new (shader,
|
||||||
|
&GRAPHENE_RECT_INIT (0, 0, 50, 50),
|
||||||
|
bytes,
|
||||||
|
children,
|
||||||
|
2);
|
||||||
|
|
||||||
|
g_assert_true (gsk_gl_shader_node_get_shader (node) == shader);
|
||||||
|
g_assert_cmpuint (gsk_gl_shader_node_get_n_children (node), ==, 2);
|
||||||
|
g_assert_true (gsk_gl_shader_node_get_child (node, 0) == children[0]);
|
||||||
|
g_assert_true (gsk_gl_shader_node_get_child (node, 1) == children[1]);
|
||||||
|
|
||||||
|
gsk_render_node_unref (children[0]);
|
||||||
|
gsk_render_node_unref (children[1]);
|
||||||
|
gsk_render_node_unref (node);
|
||||||
|
|
||||||
|
builder2 = gsk_shader_args_builder_new (shader, bytes);
|
||||||
|
gsk_shader_args_builder_ref (builder2);
|
||||||
|
bytes2 = gsk_shader_args_builder_free_to_args (builder2);
|
||||||
|
gsk_shader_args_builder_unref (builder2);
|
||||||
|
|
||||||
|
g_assert_true (g_bytes_equal (bytes, bytes2));
|
||||||
|
|
||||||
|
g_bytes_unref (bytes2);
|
||||||
g_bytes_unref (bytes);
|
g_bytes_unref (bytes);
|
||||||
|
|
||||||
gsk_shader_args_builder_unref (builder);
|
gsk_shader_args_builder_unref (builder);
|
||||||
|
@ -655,6 +655,19 @@ test_to_2d (void)
|
|||||||
g_assert_cmpfloat (yy, ==, 1);
|
g_assert_cmpfloat (yy, ==, 1);
|
||||||
g_assert_cmpfloat (dx, ==, 0.0);
|
g_assert_cmpfloat (dx, ==, 0.0);
|
||||||
g_assert_cmpfloat (dy, ==, 0.0);
|
g_assert_cmpfloat (dy, ==, 0.0);
|
||||||
|
|
||||||
|
transform = gsk_transform_translate (NULL, &GRAPHENE_POINT_INIT (10.0, 5.0));
|
||||||
|
transform = gsk_transform_rotate (transform, 33.0);
|
||||||
|
|
||||||
|
gsk_transform_to_2d (transform, &xx, &yx, &xy, &yy, &dx, &dy);
|
||||||
|
gsk_transform_unref (transform);
|
||||||
|
|
||||||
|
g_assert_cmpfloat (xx, ==, 0.838670552f);
|
||||||
|
g_assert_cmpfloat (yx, ==, 0.544639051f);
|
||||||
|
g_assert_cmpfloat (xy, ==, -0.544639051f);
|
||||||
|
g_assert_cmpfloat (yy, ==, 0.838670552f);
|
||||||
|
g_assert_cmpfloat (dx, ==, 10.f);
|
||||||
|
g_assert_cmpfloat (dy, ==, 5.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -735,6 +748,101 @@ test_transform_point (void)
|
|||||||
gsk_transform_unref (t2);
|
gsk_transform_unref (t2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_skew_transform (void)
|
||||||
|
{
|
||||||
|
GskTransform *t1, *t2, *t3;
|
||||||
|
char *string;
|
||||||
|
gboolean res;
|
||||||
|
GskTransform *x;
|
||||||
|
|
||||||
|
t1 = gsk_transform_skew (NULL, 30, 60);
|
||||||
|
t2 = gsk_transform_skew (NULL, 0, 30);
|
||||||
|
t3 = gsk_transform_skew (NULL, 0, -30);
|
||||||
|
|
||||||
|
g_assert_true (gsk_transform_get_category (t1) == GSK_TRANSFORM_CATEGORY_2D);
|
||||||
|
g_assert_true (gsk_transform_get_category (t2) == GSK_TRANSFORM_CATEGORY_2D);
|
||||||
|
g_assert_false (gsk_transform_equal (t1, t2));
|
||||||
|
|
||||||
|
t2 = gsk_transform_invert (t2);
|
||||||
|
graphene_assert_fuzzy_transform_equal (t2, t3, EPSILON);
|
||||||
|
|
||||||
|
string = gsk_transform_to_string (t1);
|
||||||
|
res = gsk_transform_parse (string, &x);
|
||||||
|
g_assert_true (res);
|
||||||
|
g_assert_true (gsk_transform_equal (t1, x));
|
||||||
|
|
||||||
|
gsk_transform_unref (t1);
|
||||||
|
gsk_transform_unref (t2);
|
||||||
|
gsk_transform_unref (t3);
|
||||||
|
g_free (string);
|
||||||
|
gsk_transform_unref (x);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_perspective_transform (void)
|
||||||
|
{
|
||||||
|
GskTransform *t1, *t2;
|
||||||
|
|
||||||
|
t1 = gsk_transform_perspective (NULL, 1000);
|
||||||
|
t2 = gsk_transform_perspective (NULL, 300);
|
||||||
|
|
||||||
|
g_assert_true (gsk_transform_get_category (t1) == GSK_TRANSFORM_CATEGORY_ANY);
|
||||||
|
g_assert_true (gsk_transform_get_category (t2) == GSK_TRANSFORM_CATEGORY_ANY);
|
||||||
|
g_assert_false (gsk_transform_equal (t1, t2));
|
||||||
|
|
||||||
|
t2 = gsk_transform_perspective (t2, 700);
|
||||||
|
|
||||||
|
g_assert_true (gsk_transform_equal (t1, t2));
|
||||||
|
|
||||||
|
gsk_transform_unref (t1);
|
||||||
|
gsk_transform_unref (t2);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_rotate_transform (void)
|
||||||
|
{
|
||||||
|
GskTransform *t1, *t2, *t3;
|
||||||
|
|
||||||
|
t1 = gsk_transform_rotate (NULL, 60);
|
||||||
|
t2 = gsk_transform_rotate (NULL, 20);
|
||||||
|
|
||||||
|
g_assert_true (gsk_transform_get_category (t1) == GSK_TRANSFORM_CATEGORY_2D);
|
||||||
|
g_assert_true (gsk_transform_get_category (t2) == GSK_TRANSFORM_CATEGORY_2D);
|
||||||
|
g_assert_false (gsk_transform_equal (t1, t2));
|
||||||
|
|
||||||
|
t2 = gsk_transform_rotate (t2, 40);
|
||||||
|
g_assert_true (gsk_transform_equal (t1, t2));
|
||||||
|
|
||||||
|
t1 = gsk_transform_invert (t1);
|
||||||
|
t3 = gsk_transform_rotate (NULL, -60);
|
||||||
|
g_assert_true (gsk_transform_equal (t1, t3));
|
||||||
|
|
||||||
|
gsk_transform_unref (t1);
|
||||||
|
gsk_transform_unref (t2);
|
||||||
|
gsk_transform_unref (t3);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_rotate3d_transform (void)
|
||||||
|
{
|
||||||
|
GskTransform *t1, *t2;
|
||||||
|
graphene_vec3_t vec;
|
||||||
|
|
||||||
|
t1 = gsk_transform_rotate_3d (NULL, 60, graphene_vec3_init (&vec, 1, 2, 3));
|
||||||
|
t2 = gsk_transform_rotate_3d (NULL, -60, graphene_vec3_init (&vec, 1, 2, 3));
|
||||||
|
|
||||||
|
g_assert_true (gsk_transform_get_category (t1) == GSK_TRANSFORM_CATEGORY_3D);
|
||||||
|
g_assert_true (gsk_transform_get_category (t2) == GSK_TRANSFORM_CATEGORY_3D);
|
||||||
|
g_assert_false (gsk_transform_equal (t1, t2));
|
||||||
|
|
||||||
|
t2 = gsk_transform_invert (t2);
|
||||||
|
g_assert_true (gsk_transform_equal (t1, t2));
|
||||||
|
|
||||||
|
gsk_transform_unref (t1);
|
||||||
|
gsk_transform_unref (t2);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc,
|
main (int argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
@ -753,6 +861,10 @@ main (int argc,
|
|||||||
g_test_add_func ("/transform/point", test_transform_point);
|
g_test_add_func ("/transform/point", test_transform_point);
|
||||||
g_test_add_func ("/transform/to-2d", test_to_2d);
|
g_test_add_func ("/transform/to-2d", test_to_2d);
|
||||||
g_test_add_func ("/transform/to-2d-components", test_to_2d_components);
|
g_test_add_func ("/transform/to-2d-components", test_to_2d_components);
|
||||||
|
g_test_add_func ("/transform/skew", test_skew_transform);
|
||||||
|
g_test_add_func ("/transform/perspective", test_perspective_transform);
|
||||||
|
g_test_add_func ("/transform/rotate", test_rotate_transform);
|
||||||
|
g_test_add_func ("/transform/rotate3d", test_rotate3d_transform);
|
||||||
|
|
||||||
return g_test_run ();
|
return g_test_run ();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user