[gtk/wip/baedert/nodeeditor: 10/16] testsuite: Add tests for the new node parser



commit 5584e1409a2bf1396742de9f380fc8b6be72b0d6
Author: Benjamin Otte <otte redhat com>
Date:   Tue Mar 19 05:29:20 2019 +0100

    testsuite: Add tests for the new node parser
    
    These are just a few crashes I encountered while developing it.

 testsuite/gsk/meson.build            | 28 ++++++++++++++++++++++++++++
 testsuite/gsk/node-parser.c          | 30 ++++++++++++++++++++++++++++++
 testsuite/gsk/nodeparser/crash1.node |  2 ++
 testsuite/gsk/nodeparser/crash2.node |  3 +++
 testsuite/gsk/nodeparser/crash3.node | 18 ++++++++++++++++++
 5 files changed, 81 insertions(+)
---
diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build
index f2568a6710..fcfc1d05f8 100644
--- a/testsuite/gsk/meson.build
+++ b/testsuite/gsk/meson.build
@@ -18,6 +18,14 @@ compare_render = executable(
   install_dir: testexecdir
 )
 
+node_parser = executable(
+  'node-parser',
+  ['node-parser.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',
@@ -70,6 +78,26 @@ foreach gl_test : gl_tests
        suite: 'gsk')
 endforeach
 
+node_parser_tests = [
+  'crash1',
+  'crash2',
+  'crash3',
+]
+
+foreach test : node_parser_tests
+  test('parser ' + test, node_parser,
+       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' ],
diff --git a/testsuite/gsk/node-parser.c b/testsuite/gsk/node-parser.c
new file mode 100644
index 0000000000..397b13f69f
--- /dev/null
+++ b/testsuite/gsk/node-parser.c
@@ -0,0 +1,30 @@
+#include <gtk/gtk.h>
+
+int
+main (int argc, char **argv)
+{
+  GError *error = NULL;
+  GskRenderNode *node;
+  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);
+  if (error)
+    g_test_message ("Error: %s\n", error->message);
+
+  g_clear_error (&error);
+  g_clear_pointer (&node, gsk_render_node_unref);
+  g_bytes_unref (bytes);
+  g_object_unref (file);
+
+  return 0;
+}
diff --git a/testsuite/gsk/nodeparser/crash1.node b/testsuite/gsk/nodeparser/crash1.node
new file mode 100644
index 0000000000..bba912ef7b
--- /dev/null
+++ b/testsuite/gsk/nodeparser/crash1.node
@@ -0,0 +1,2 @@
+opacity {
+  child = color {
diff --git a/testsuite/gsk/nodeparser/crash2.node b/testsuite/gsk/nodeparser/crash2.node
new file mode 100644
index 0000000000..677e9f2ea3
--- /dev/null
+++ b/testsuite/gsk/nodeparser/crash2.node
@@ -0,0 +1,3 @@
+cross-fade {
+  from: color {
+    co
diff --git a/testsuite/gsk/nodeparser/crash3.node b/testsuite/gsk/nodeparser/crash3.node
new file mode 100644
index 0000000000..3d89f88386
--- /dev/null
+++ b/testsuite/gsk/nodeparser/crash3.node
@@ -0,0 +1,18 @@
+cross-fade {
+  start: container {
+    color {
+      color: red;
+      bounds: 0 0 10 10;
+    }
+    color {
+      color: green;
+      bounds: 10 10 10 10;
+    }
+  }
+  end: color {
+    color: blue;
+    bounds: 5 5 10 10;
+  }
+  progress: 0.2;
+}
+


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