[gtk/label-sizing: 1/5] reftest: On failure, save the node files, too




commit cad979b734d15b58d08456dd206f1ff02d9a05d7
Author: Benjamin Otte <otte redhat com>
Date:   Tue Oct 19 01:01:36 2021 +0200

    reftest: On failure, save the node files, too
    
    Doesn't hurt to have them available, so it's easy to figure out if a
    failure is due to the renderer or if we're generating wrong node files.

 testsuite/reftests/gtk-reftest.c      | 32 ++++++++++++++++++++++++++++++++
 testsuite/reftests/reftest-snapshot.c |  5 ++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
---
diff --git a/testsuite/reftests/gtk-reftest.c b/testsuite/reftests/gtk-reftest.c
index f247ac4ef1..2bf3fcc5f8 100644
--- a/testsuite/reftests/gtk-reftest.c
+++ b/testsuite/reftests/gtk-reftest.c
@@ -292,6 +292,36 @@ save_image (GdkTexture *texture,
   g_free (filename);
 }
 
+static void
+save_node (GskRenderNode *node,
+           const char    *test_name,
+           const char    *extension)
+{
+  GError *error = NULL;
+  char *filename;
+  gboolean ret;
+  GBytes *bytes;
+  
+  filename = get_output_file (test_name, extension, &error);
+  if (filename == NULL)
+    {
+      g_test_message ("Not storing test result node: %s", error->message);
+      g_error_free (error);
+      return;
+    }
+
+  g_test_message ("Storing test result node at %s", filename);
+  bytes = gsk_render_node_serialize (node);
+  ret = g_file_set_contents (filename,
+                             g_bytes_get_data (bytes, NULL),
+                             g_bytes_get_size (bytes),
+                             NULL);
+  g_assert_true (ret);
+
+  g_bytes_unref (bytes);
+  g_free (filename);
+}
+
 static void
 test_ui_file (GFile *file)
 {
@@ -335,6 +365,8 @@ test_ui_file (GFile *file)
   save_image (reference_image, ui_file, ".ref.png");
   if (diff_image)
     {
+      save_node (g_object_get_data (G_OBJECT (ui_image), "source-render-node"), ui_file, ".out.node");
+      save_node (g_object_get_data (G_OBJECT (reference_image), "source-render-node"), ui_file, ".ref.node");
       save_image (diff_image, ui_file, ".diff.png");
       g_object_unref (diff_image);
       g_test_fail ();
diff --git a/testsuite/reftests/reftest-snapshot.c b/testsuite/reftests/reftest-snapshot.c
index 1787c73ab8..167311630e 100644
--- a/testsuite/reftests/reftest-snapshot.c
+++ b/testsuite/reftests/reftest-snapshot.c
@@ -248,7 +248,10 @@ draw_paintable (GdkPaintable *paintable,
                                            gdk_paintable_get_intrinsic_width (paintable),
                                            gdk_paintable_get_intrinsic_height (paintable)
                                          ));
-  gsk_render_node_unref (node);
+  g_object_set_data_full (G_OBJECT (texture),
+                          "source-render-node",
+                          node,
+                          (GDestroyNotify) gsk_render_node_unref);
 
   g_signal_handlers_disconnect_by_func (paintable, draw_paintable, out_texture);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]