[gtk/wip/otte/nodeeditor2: 37/59] testsuite: Add serialize-deserialize tests



commit 7d079d60bbaf888cdcf064c8007c7312c621d618
Author: Timm Bäder <mail baedert org>
Date:   Tue Apr 23 18:08:06 2019 +0200

    testsuite: Add serialize-deserialize tests
    
    Check that we can successfully deserialize a node, then serialize it
    again and deserialize that result once more.

 testsuite/gsk/meson.build                          |  29 ++
 testsuite/gsk/serialize-deserialize.c              |  43 +++
 testsuite/gsk/serializedeserialize/border.node     |   5 +
 testsuite/gsk/serializedeserialize/color.node      |   4 +
 testsuite/gsk/serializedeserialize/testswitch.node | 389 +++++++++++++++++++++
 5 files changed, 470 insertions(+)
---
diff --git a/testsuite/gsk/meson.build b/testsuite/gsk/meson.build
index df863a8fad..b2e6533bb3 100644
--- a/testsuite/gsk/meson.build
+++ b/testsuite/gsk/meson.build
@@ -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',
@@ -121,6 +129,27 @@ foreach test : node_parser_tests
        suite: 'gsk')
 endforeach
 
+serialize_deserialize_tests = [
+  'color',
+  'border',
+  'testswitch',
+]
+
+foreach test : serialize_deserialize_tests
+  test('serialize-deserialize ' + test, serialize_deserialize,
+       args: [join_paths(meson.current_source_dir(), 'serializedeserialize', 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/serialize-deserialize.c b/testsuite/gsk/serialize-deserialize.c
new file mode 100644
index 0000000000..45d4472a70
--- /dev/null
+++ b/testsuite/gsk/serialize-deserialize.c
@@ -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;
+}
diff --git a/testsuite/gsk/serializedeserialize/border.node b/testsuite/gsk/serializedeserialize/border.node
new file mode 100644
index 0000000000..89b490329f
--- /dev/null
+++ b/testsuite/gsk/serializedeserialize/border.node
@@ -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);
+}
diff --git a/testsuite/gsk/serializedeserialize/color.node b/testsuite/gsk/serializedeserialize/color.node
new file mode 100644
index 0000000000..acbc79288d
--- /dev/null
+++ b/testsuite/gsk/serializedeserialize/color.node
@@ -0,0 +1,4 @@
+color {
+  bounds: 100 100 200 300;
+  color: red;
+}
diff --git a/testsuite/gsk/serializedeserialize/testswitch.node 
b/testsuite/gsk/serializedeserialize/testswitch.node
new file mode 100644
index 0000000000..940d821e00
--- /dev/null
+++ b/testsuite/gsk/serializedeserialize/testswitch.node
@@ -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);
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+}


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