[gnome-photos/wip/rishi/unit-tests: 2/2] tests: Test the Pipeline



commit 18125562253f01fc0535251184e2206a176be21f
Author: Debarshi Ray <debarshir gnome org>
Date:   Fri Nov 2 14:19:46 2018 +0100

    tests: Test the Pipeline

 tests/unit/Makefile.am                            |  17 +
 tests/unit/meson.build                            |   4 +
 tests/unit/photos-test-pipeline-edited-00.xml     |  57 ++
 tests/unit/photos-test-pipeline-not-edited-00.xml |   3 +
 tests/unit/photos-test-pipeline.c                 | 859 ++++++++++++++++++++++
 5 files changed, 940 insertions(+)
---
diff --git a/tests/unit/Makefile.am b/tests/unit/Makefile.am
index 690c96f6..7a39e69e 100644
--- a/tests/unit/Makefile.am
+++ b/tests/unit/Makefile.am
@@ -5,6 +5,23 @@ AM_TESTS_ENVIRONMENT += \
        $(NULL)
 
 test_programs = \
+       photos-test-pipeline
+       $(NULL)
+
+photos_test_pipeline_CPPFLAGS = \
+       -DPACKAGE_TEST_DIR=\""${abs_srcdir}"\" \
+       $(GDK_PIXBUF_CFLAGS) \
+       $(GEGL_CFLAGS) \
+       $(GLIB_CFLAGS) \
+       -I$(top_builddir)/src \
+       -I$(top_srcdir)/src \
+       $(NULL)
+
+photos_test_pipeline_LDADD = \
+       $(GDK_PIXBUF_LIBS) \
+       $(GEGL_LIBS) \
+       $(GLIB_LIBS) \
+       $(top_builddir)/src/libgnome-photos.la \
        $(NULL)
 
 AM_CFLAGS = \
diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index 97b2d1e5..14e52caf 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -12,6 +12,10 @@ test_env.set('MALLOC_CHECK_', '2')
 test_env.set('MALLOC_PERTURB_', '@0@'.format(random_number % 256))
 
 tests = {
+  'photos-test-pipeline': {
+    'c_args': ['-DPACKAGE_TEST_DIR="@0@"'.format(meson.current_source_dir())],
+    'dependencies': [gdk_pixbuf_dep, gegl_dep, glib_dep, libgnome_photos_dep]
+  },
 }
 
 foreach test_name, extra_args: tests
diff --git a/tests/unit/photos-test-pipeline-edited-00.xml b/tests/unit/photos-test-pipeline-edited-00.xml
new file mode 100644
index 00000000..0dba944e
--- /dev/null
+++ b/tests/unit/photos-test-pipeline-edited-00.xml
@@ -0,0 +1,57 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<gegl>
+  <node operation='gegl:brightness-contrast'>
+      <params>
+        <param name='contrast'>2</param>
+        <param name='brightness'>0</param>
+      </params>
+  </node>
+  <node operation='gegl:exposure'>
+      <params>
+        <param name='black-level'>0.1</param>
+        <param name='exposure'>3</param>
+      </params>
+  </node>
+  <node operation='gegl:unsharp-mask'>
+      <params>
+        <param name='std-dev'>3</param>
+        <param name='scale'>10</param>
+        <param name='threshold'>0</param>
+      </params>
+  </node>
+  <node operation='photos:magic-filter'>
+      <params>
+        <param name='preset'>1947</param>
+      </params>
+  </node>
+  <node operation='photos:saturation'>
+      <params>
+        <param name='scale'>2</param>
+      </params>
+  </node>
+  <node operation='gegl:shadows-highlights'>
+      <params>
+        <param name='shadows'>100</param>
+        <param name='highlights'>-100</param>
+        <param name='whitepoint'>0</param>
+        <param name='radius'>100</param>
+        <param name='compress'>50</param>
+        <param name='shadows-ccorrect'>100</param>
+        <param name='highlights-ccorrect'>50</param>
+      </params>
+  </node>
+  <node operation='gegl:noise-reduction'>
+      <params>
+        <param name='iterations'>16</param>
+      </params>
+  </node>
+  <node operation='gegl:crop'>
+      <params>
+        <param name='x'>120.52800000000001</param>
+        <param name='y'>185.77600000000004</param>
+        <param name='width'>199.584</param>
+        <param name='height'>308.44799999999998</param>
+        <param name='reset-origin'>false</param>
+      </params>
+  </node>
+</gegl>
diff --git a/tests/unit/photos-test-pipeline-not-edited-00.xml 
b/tests/unit/photos-test-pipeline-not-edited-00.xml
new file mode 100644
index 00000000..3e0d17e2
--- /dev/null
+++ b/tests/unit/photos-test-pipeline-not-edited-00.xml
@@ -0,0 +1,3 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<gegl>
+</gegl>
diff --git a/tests/unit/photos-test-pipeline.c b/tests/unit/photos-test-pipeline.c
new file mode 100644
index 00000000..7a6429de
--- /dev/null
+++ b/tests/unit/photos-test-pipeline.c
@@ -0,0 +1,859 @@
+/*
+ * Photos - access, organize and share your photos on GNOME
+ * Copyright © 2018 Red Hat, Inc.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include "config.h"
+
+#include <locale.h>
+
+#include <glib.h>
+#include <gegl.h>
+
+#include "photos-debug.h"
+#include "photos-gegl.h"
+#include "photos-pipeline.h"
+
+
+typedef struct _PhotosTestPipelineFixture PhotosTestPipelineFixture;
+
+struct _PhotosTestPipelineFixture
+{
+  GMainContext *context;
+  GMainLoop *loop;
+};
+
+
+static void
+photos_test_pipeline_setup (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  fixture->context = g_main_context_new ();
+  g_main_context_push_thread_default (fixture->context);
+  fixture->loop = g_main_loop_new (fixture->context, FALSE);
+}
+
+
+static void
+photos_test_pipeline_teardown (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  g_main_context_pop_thread_default (fixture->context);
+  g_clear_pointer (&fixture->context, g_main_context_unref);
+  g_clear_pointer (&fixture->loop, g_main_loop_unref);
+}
+
+
+static void
+photos_test_pipeline_check_empty (PhotosPipeline *pipeline)
+{
+  g_autoptr (GSList) children = NULL;
+  GeglNode *graph;
+  GeglNode *input;
+  GeglNode *output;
+  GeglNode *previous;
+  gboolean is_edited;
+  const gchar *operation;
+  g_autofree gchar *previous_pad_name = NULL;
+  guint length;
+
+  g_assert_true (PHOTOS_IS_PIPELINE (pipeline));
+
+  graph = photos_pipeline_get_graph (pipeline);
+
+  input = gegl_node_get_input_proxy (graph, "input");
+  output = gegl_node_get_output_proxy (graph, "output");
+  previous = gegl_node_get_producer (output, "input", &previous_pad_name);
+  g_assert_true (previous == input);
+  g_assert_cmpstr (previous_pad_name, ==, "output");
+
+  children = gegl_node_get_children (graph);
+  length = g_slist_length (children);
+  g_assert_cmpuint (length, ==, 2);
+  operation = gegl_node_get_operation (GEGL_NODE (children->data));
+  g_assert_cmpstr (operation, ==, "gegl:nop");
+  operation = gegl_node_get_operation (GEGL_NODE (children->next->data));
+  g_assert_cmpstr (operation, ==, "gegl:nop");
+
+  is_edited = photos_pipeline_is_edited (pipeline);
+  g_assert_false (is_edited);
+}
+
+
+static void
+photos_test_pipeline_check_full (PhotosPipeline *pipeline)
+{
+  g_autoptr (GSList) children = NULL;
+  GeglNode *graph;
+  GeglNode *input;
+  GeglNode *output;
+  GeglNode *previous;
+  gboolean is_edited;
+  const gchar *operation;
+  g_autofree gchar *previous_pad_name = NULL;
+  guint length;
+
+  g_assert_true (PHOTOS_IS_PIPELINE (pipeline));
+
+  graph = photos_pipeline_get_graph (pipeline);
+
+  children = gegl_node_get_children (graph);
+  length = g_slist_length (children);
+  g_assert_cmpuint (length, ==, 10);
+
+  input = gegl_node_get_input_proxy (graph, "input");
+  output = gegl_node_get_output_proxy (graph, "output");
+
+  previous = gegl_node_get_producer (output, "input", &previous_pad_name);
+  g_assert_true (previous != input);
+  g_assert_cmpstr (previous_pad_name, ==, "output");
+
+  operation = gegl_node_get_operation (GEGL_NODE (previous));
+  g_assert_cmpstr (operation, ==, "gegl:brightness-contrast");
+
+  previous = gegl_node_get_producer (previous, "input", &previous_pad_name);
+  g_assert_true (previous != input);
+  g_assert_cmpstr (previous_pad_name, ==, "output");
+
+  operation = gegl_node_get_operation (GEGL_NODE (previous));
+  g_assert_cmpstr (operation, ==, "gegl:exposure");
+
+  previous = gegl_node_get_producer (previous, "input", &previous_pad_name);
+  g_assert_true (previous != input);
+  g_assert_cmpstr (previous_pad_name, ==, "output");
+
+  operation = gegl_node_get_operation (GEGL_NODE (previous));
+  g_assert_cmpstr (operation, ==, "gegl:unsharp-mask");
+
+  previous = gegl_node_get_producer (previous, "input", &previous_pad_name);
+  g_assert_true (previous != input);
+  g_assert_cmpstr (previous_pad_name, ==, "output");
+
+  operation = gegl_node_get_operation (GEGL_NODE (previous));
+  g_assert_cmpstr (operation, ==, "photos:magic-filter");
+
+  previous = gegl_node_get_producer (previous, "input", &previous_pad_name);
+  g_assert_true (previous != input);
+  g_assert_cmpstr (previous_pad_name, ==, "output");
+
+  operation = gegl_node_get_operation (GEGL_NODE (previous));
+  g_assert_cmpstr (operation, ==, "photos:saturation");
+
+  previous = gegl_node_get_producer (previous, "input", &previous_pad_name);
+  g_assert_true (previous != input);
+  g_assert_cmpstr (previous_pad_name, ==, "output");
+
+  operation = gegl_node_get_operation (GEGL_NODE (previous));
+  g_assert_cmpstr (operation, ==, "gegl:shadows-highlights");
+
+  previous = gegl_node_get_producer (previous, "input", &previous_pad_name);
+  g_assert_true (previous != input);
+  g_assert_cmpstr (previous_pad_name, ==, "output");
+
+  operation = gegl_node_get_operation (GEGL_NODE (previous));
+  g_assert_cmpstr (operation, ==, "gegl:noise-reduction");
+
+  previous = gegl_node_get_producer (previous, "input", &previous_pad_name);
+  g_assert_true (previous != input);
+  g_assert_cmpstr (previous_pad_name, ==, "output");
+
+  operation = gegl_node_get_operation (GEGL_NODE (previous));
+  g_assert_cmpstr (operation, ==, "gegl:crop");
+
+  previous = gegl_node_get_producer (previous, "input", &previous_pad_name);
+  g_assert_true (previous == input);
+  g_assert_cmpstr (previous_pad_name, ==, "output");
+
+  is_edited = photos_pipeline_is_edited (pipeline);
+  g_assert_true (is_edited);
+}
+
+
+static void
+photos_test_pipeline_no_parent_blank_uris_0_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_blank_uris_0 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  const gchar *const uris[] = { NULL };
+
+  photos_pipeline_new_async (NULL, uris, NULL, photos_test_pipeline_no_parent_blank_uris_0_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_blank_uris_1_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_blank_uris_1 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  const gchar *const uris[] = { NULL, "this-should-not-be-used", NULL };
+
+  photos_pipeline_new_async (NULL, uris, NULL, photos_test_pipeline_no_parent_blank_uris_1_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_blank_uris_2_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_blank_uris_2 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  const gchar *const uris[] = { "", NULL };
+
+  photos_pipeline_new_async (NULL, uris, NULL, photos_test_pipeline_no_parent_blank_uris_2_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_blank_uris_3_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_blank_uris_3 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  const gchar *const uris[] = { "", "this-should-not-be-used", NULL };
+
+  photos_pipeline_new_async (NULL, uris, NULL, photos_test_pipeline_no_parent_blank_uris_3_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_null_uris_new (GObject *source_object, GAsyncResult *res, gpointer user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_null_uris (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  photos_pipeline_new_async (NULL, NULL, NULL, photos_test_pipeline_no_parent_null_uris_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_0_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_0 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  const gchar *const uris[] = { "file://" PACKAGE_TEST_DIR "/photos-test-pipeline-not-edited-00.xml", NULL };
+
+  photos_pipeline_new_async (NULL, uris, NULL, photos_test_pipeline_no_parent_with_uris_0_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_1_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_1 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  const gchar *const uris[] =
+    { "file://" PACKAGE_TEST_DIR "/photos-test-pipeline-not-edited-00.xml",
+      "file://" PACKAGE_TEST_DIR "/photos-test-pipeline-edited-00.xml",
+      NULL
+    };
+
+  photos_pipeline_new_async (NULL, uris, NULL, photos_test_pipeline_no_parent_with_uris_1_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_2_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_2 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  const gchar *const uris[] =
+    { "file://" PACKAGE_TEST_DIR "/photos-test-pipeline-not-edited-00.xml",
+      "file://this-does-not-exist",
+      NULL
+    };
+
+  photos_pipeline_new_async (NULL, uris, NULL, photos_test_pipeline_no_parent_with_uris_2_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_3_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_3 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  const gchar *const uris[] =
+    { "file://" PACKAGE_TEST_DIR "/photos-test-pipeline-not-edited-00.xml",
+      "this-should-not-be-used",
+      NULL
+    };
+
+  photos_pipeline_new_async (NULL, uris, NULL, photos_test_pipeline_no_parent_with_uris_3_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_4_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_full (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_4 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  const gchar *const uris[] = { "file://" PACKAGE_TEST_DIR "/photos-test-pipeline-edited-00.xml", NULL };
+
+  photos_pipeline_new_async (NULL, uris, NULL, photos_test_pipeline_no_parent_with_uris_4_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_5_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_full (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_5 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  const gchar *const uris[] =
+    { "file://" PACKAGE_TEST_DIR "/photos-test-pipeline-edited-00.xml",
+      "file://" PACKAGE_TEST_DIR "/photos-test-pipeline-not-edited-00.xml",
+      NULL
+    };
+
+  photos_pipeline_new_async (NULL, uris, NULL, photos_test_pipeline_no_parent_with_uris_5_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_6_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_full (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_6 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  const gchar *const uris[] =
+    { "file://" PACKAGE_TEST_DIR "/photos-test-pipeline-edited-00.xml",
+      "file://this-does-not-exist",
+      NULL
+    };
+
+  photos_pipeline_new_async (NULL, uris, NULL, photos_test_pipeline_no_parent_with_uris_6_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_7_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_full (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_no_parent_with_uris_7 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  const gchar *const uris[] =
+    { "file://" PACKAGE_TEST_DIR "/photos-test-pipeline-edited-00.xml",
+      "this-should-not-be-used",
+      NULL
+    };
+
+  photos_pipeline_new_async (NULL, uris, NULL, photos_test_pipeline_no_parent_with_uris_7_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_with_parent_blank_uris_0_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_with_parent_blank_uris_0 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  g_autoptr (GeglNode) parent = NULL;
+  const gchar *const uris[] = { NULL };
+
+  parent = gegl_node_new ();
+  photos_pipeline_new_async (parent, uris, NULL, photos_test_pipeline_with_parent_blank_uris_0_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_with_parent_blank_uris_1_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_with_parent_blank_uris_1 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  g_autoptr (GeglNode) parent = NULL;
+  const gchar *const uris[] = { NULL, "this-should-not-be-used", NULL };
+
+  parent = gegl_node_new ();
+  photos_pipeline_new_async (parent, uris, NULL, photos_test_pipeline_with_parent_blank_uris_1_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_with_parent_blank_uris_2_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_with_parent_blank_uris_2 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  g_autoptr (GeglNode) parent = NULL;
+  const gchar *const uris[] = { "", NULL };
+
+  photos_pipeline_new_async (NULL, uris, NULL, photos_test_pipeline_with_parent_blank_uris_2_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_with_parent_blank_uris_3_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_with_parent_blank_uris_3 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  g_autoptr (GeglNode) parent = NULL;
+  const gchar *const uris[] = { "", "this-should-not-be-used", NULL };
+
+  parent = gegl_node_new ();
+  photos_pipeline_new_async (parent, uris, NULL, photos_test_pipeline_with_parent_blank_uris_3_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_with_parent_null_uris_new (GObject *source_object, GAsyncResult *res, gpointer 
user_data)
+{
+  g_autoptr (PhotosPipeline) pipeline = NULL;
+  PhotosTestPipelineFixture *fixture = (PhotosTestPipelineFixture *) user_data;
+
+  {
+    g_autoptr (GError) error = NULL;
+
+    pipeline = photos_pipeline_new_finish (res, &error);
+    g_assert_no_error (error);
+  }
+
+  photos_test_pipeline_check_empty (pipeline);
+  g_main_loop_quit (fixture->loop);
+}
+
+
+static void
+photos_test_pipeline_with_parent_null_uris (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+  g_autoptr (GeglNode) parent = NULL;
+
+  parent = gegl_node_new ();
+  photos_pipeline_new_async (parent, NULL, NULL, photos_test_pipeline_with_parent_null_uris_new, fixture);
+  g_main_loop_run (fixture->loop);
+}
+
+
+gint
+main (gint argc, gchar *argv[])
+{
+  gint exit_status;
+
+  setlocale (LC_ALL, "");
+  g_test_init (&argc, &argv, NULL);
+  photos_debug_init ();
+  photos_gegl_init ();
+  photos_gegl_ensure_builtins ();
+
+  g_test_add ("/pipeline/new/no-parent-blank-uris-0",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_no_parent_blank_uris_0,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/no-parent-blank-uris-1",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_no_parent_blank_uris_1,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/no-parent-blank-uris-2",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_no_parent_blank_uris_2,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/no-parent-blank-uris-3",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_no_parent_blank_uris_3,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/no-parent-null-uris",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_no_parent_null_uris,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/no-parent-with-uris-0",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_no_parent_with_uris_0,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/no-parent-with-uris-1",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_no_parent_with_uris_1,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/no-parent-with-uris-2",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_no_parent_with_uris_2,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/no-parent-with-uris-3",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_no_parent_with_uris_3,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/no-parent-with-uris-4",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_no_parent_with_uris_4,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/no-parent-with-uris-5",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_no_parent_with_uris_5,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/no-parent-with-uris-6",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_no_parent_with_uris_6,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/no-parent-with-uris-7",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_no_parent_with_uris_7,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/with-parent-blank-uris-0",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_with_parent_blank_uris_0,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/with-parent-blank-uris-1",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_with_parent_blank_uris_1,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/with-parent-blank-uris-2",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_with_parent_blank_uris_2,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/with-parent-blank-uris-3",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_with_parent_blank_uris_3,
+              photos_test_pipeline_teardown);
+
+  g_test_add ("/pipeline/new/with-parent-null-uris",
+              PhotosTestPipelineFixture,
+              NULL,
+              photos_test_pipeline_setup,
+              photos_test_pipeline_with_parent_null_uris,
+              photos_test_pipeline_teardown);
+
+  exit_status = g_test_run ();
+
+  gegl_exit ();
+  return exit_status;
+}


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