mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 22:20:24 +00:00
compare-render: Run plain tests using new runner
Extend the runner so NULL is accepted as a method to create reference/test, in which case the unmodified original will be used.
This commit is contained in:
parent
37c744759c
commit
a0d076f01a
@ -287,11 +287,16 @@ struct _TestSetup
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const TestSetup test_setups[] = {
|
static const TestSetup test_setups[] = {
|
||||||
|
{
|
||||||
|
.name = "plain",
|
||||||
|
.create_test = NULL,
|
||||||
|
.create_reference = NULL,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = "colorflip",
|
.name = "colorflip",
|
||||||
.create_test = colorflip_create_test,
|
.create_test = colorflip_create_test,
|
||||||
.create_reference = colorflip_create_reference,
|
.create_reference = colorflip_create_reference,
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -304,14 +309,24 @@ run_single_test (const TestSetup *setup,
|
|||||||
GskRenderNode *test;
|
GskRenderNode *test;
|
||||||
GdkTexture *reference, *rendered, *diff;
|
GdkTexture *reference, *rendered, *diff;
|
||||||
|
|
||||||
|
if (setup->create_test)
|
||||||
|
{
|
||||||
test = setup->create_test (org_test);
|
test = setup->create_test (org_test);
|
||||||
save_node (test, file_name, setup->name, ".node");
|
save_node (test, file_name, setup->name, ".node");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
test = gsk_render_node_ref (org_test);
|
||||||
|
|
||||||
rendered = gsk_renderer_render_texture (renderer, test, NULL);
|
rendered = gsk_renderer_render_texture (renderer, test, NULL);
|
||||||
save_image (rendered, file_name, setup->name, ".out.png");
|
save_image (rendered, file_name, setup->name, ".out.png");
|
||||||
|
|
||||||
|
if (setup->create_reference)
|
||||||
|
{
|
||||||
reference = setup->create_reference (renderer, org_reference);
|
reference = setup->create_reference (renderer, org_reference);
|
||||||
save_image (reference, file_name, setup->name, ".ref.png");
|
save_image (reference, file_name, setup->name, ".ref.png");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
reference = g_object_ref (org_reference);
|
||||||
|
|
||||||
diff = reftest_compare_textures (reference, rendered);
|
diff = reftest_compare_textures (reference, rendered);
|
||||||
if (diff)
|
if (diff)
|
||||||
@ -384,24 +399,7 @@ run_node_test (gconstpointer data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (plain)
|
if (plain)
|
||||||
{
|
run_single_test (&test_setups[0], test->node_file, renderer, node, reference_texture);
|
||||||
/* Render the .node file and download to cairo surface */
|
|
||||||
rendered_texture = gsk_renderer_render_texture (renderer, node, NULL);
|
|
||||||
g_assert_nonnull (rendered_texture);
|
|
||||||
|
|
||||||
save_image (rendered_texture, test->node_file, NULL, ".out.png");
|
|
||||||
|
|
||||||
/* Now compare the two */
|
|
||||||
diff_texture = reftest_compare_textures (reference_texture, rendered_texture);
|
|
||||||
if (diff_texture)
|
|
||||||
{
|
|
||||||
save_image (diff_texture, test->node_file, NULL, ".diff.png");
|
|
||||||
g_test_fail ();
|
|
||||||
}
|
|
||||||
|
|
||||||
g_clear_object (&diff_texture);
|
|
||||||
g_clear_object (&rendered_texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (flip)
|
if (flip)
|
||||||
{
|
{
|
||||||
@ -738,7 +736,7 @@ run_node_test (gconstpointer data)
|
|||||||
skip_clip:
|
skip_clip:
|
||||||
|
|
||||||
if (colorflip)
|
if (colorflip)
|
||||||
run_single_test (&test_setups[0], test->node_file, renderer, node, reference_texture);
|
run_single_test (&test_setups[1], test->node_file, renderer, node, reference_texture);
|
||||||
|
|
||||||
g_object_unref (reference_texture);
|
g_object_unref (reference_texture);
|
||||||
gsk_render_node_unref (node);
|
gsk_render_node_unref (node);
|
||||||
|
Loading…
Reference in New Issue
Block a user