[gnome-photos/wip/rishi/test-magic-filter] test-pipeline: Test the deserialization of the Instagram filters
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/test-magic-filter] test-pipeline: Test the deserialization of the Instagram filters
- Date: Mon, 25 May 2020 20:57:37 +0000 (UTC)
commit 14b3058a888ddb768f2dc790f2b35ee990d1258e
Author: Debarshi Ray <debarshir gnome org>
Date: Mon May 25 22:34:30 2020 +0200
test-pipeline: Test the deserialization of the Instagram filters
The Instagram filters make clever use of the "name" and "compat-name"
properties of GeglOperation and the PhotosOperationInstaPreset
enumerated type to prevent the Instagram filter names from appearing in
the XML, while still using them internally throughout the codebase.
Enumerated types can be vulnerable to backwards compatibility breakages
whenever a new name is added to the list, and it's necessary that older
XMLs continue to work with newer versions of the code.
Therefore, it's worth testing this.
tests/unit/meson.build | 6 +
...otos-test-pipeline-edited-magic-filter-1947.xml | 8 ++
...otos-test-pipeline-edited-magic-filter-caap.xml | 8 ++
...test-pipeline-edited-magic-filter-calistoga.xml | 8 ++
...-test-pipeline-edited-magic-filter-hometown.xml | 8 ++
...test-pipeline-edited-magic-filter-mogadishu.xml | 8 ++
...otos-test-pipeline-edited-magic-filter-none.xml | 8 ++
tests/unit/photos-test-pipeline.c | 133 ++++++++++++++++++++-
8 files changed, 186 insertions(+), 1 deletion(-)
---
diff --git a/tests/unit/meson.build b/tests/unit/meson.build
index 6acbf22b..445241a5 100644
--- a/tests/unit/meson.build
+++ b/tests/unit/meson.build
@@ -22,6 +22,12 @@ tests = {
test_data = [
'photos-test-pipeline-edited-00.xml',
+ 'photos-test-pipeline-edited-magic-filter-none.xml',
+ 'photos-test-pipeline-edited-magic-filter-1947.xml',
+ 'photos-test-pipeline-edited-magic-filter-calistoga.xml',
+ 'photos-test-pipeline-edited-magic-filter-caap.xml',
+ 'photos-test-pipeline-edited-magic-filter-mogadishu.xml',
+ 'photos-test-pipeline-edited-magic-filter-hometown.xml',
'photos-test-pipeline-not-edited-00.xml',
]
diff --git a/tests/unit/photos-test-pipeline-edited-magic-filter-1947.xml
b/tests/unit/photos-test-pipeline-edited-magic-filter-1947.xml
new file mode 100644
index 00000000..46730e65
--- /dev/null
+++ b/tests/unit/photos-test-pipeline-edited-magic-filter-1947.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<gegl>
+ <node operation='photos:magic-filter'>
+ <params>
+ <param name='preset'>1947</param>
+ </params>
+ </node>
+</gegl>
diff --git a/tests/unit/photos-test-pipeline-edited-magic-filter-caap.xml
b/tests/unit/photos-test-pipeline-edited-magic-filter-caap.xml
new file mode 100644
index 00000000..945a1974
--- /dev/null
+++ b/tests/unit/photos-test-pipeline-edited-magic-filter-caap.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<gegl>
+ <node operation='photos:magic-filter'>
+ <params>
+ <param name='preset'>caap</param>
+ </params>
+ </node>
+</gegl>
diff --git a/tests/unit/photos-test-pipeline-edited-magic-filter-calistoga.xml
b/tests/unit/photos-test-pipeline-edited-magic-filter-calistoga.xml
new file mode 100644
index 00000000..c306b251
--- /dev/null
+++ b/tests/unit/photos-test-pipeline-edited-magic-filter-calistoga.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<gegl>
+ <node operation='photos:magic-filter'>
+ <params>
+ <param name='preset'>calistoga</param>
+ </params>
+ </node>
+</gegl>
diff --git a/tests/unit/photos-test-pipeline-edited-magic-filter-hometown.xml
b/tests/unit/photos-test-pipeline-edited-magic-filter-hometown.xml
new file mode 100644
index 00000000..dbf3af3b
--- /dev/null
+++ b/tests/unit/photos-test-pipeline-edited-magic-filter-hometown.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<gegl>
+ <node operation='photos:magic-filter'>
+ <params>
+ <param name='preset'>hometown</param>
+ </params>
+ </node>
+</gegl>
diff --git a/tests/unit/photos-test-pipeline-edited-magic-filter-mogadishu.xml
b/tests/unit/photos-test-pipeline-edited-magic-filter-mogadishu.xml
new file mode 100644
index 00000000..7f20e77f
--- /dev/null
+++ b/tests/unit/photos-test-pipeline-edited-magic-filter-mogadishu.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<gegl>
+ <node operation='photos:magic-filter'>
+ <params>
+ <param name='preset'>mogadishu</param>
+ </params>
+ </node>
+</gegl>
diff --git a/tests/unit/photos-test-pipeline-edited-magic-filter-none.xml
b/tests/unit/photos-test-pipeline-edited-magic-filter-none.xml
new file mode 100644
index 00000000..2f8e858e
--- /dev/null
+++ b/tests/unit/photos-test-pipeline-edited-magic-filter-none.xml
@@ -0,0 +1,8 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<gegl>
+ <node operation='photos:magic-filter'>
+ <params>
+ <param name='preset'>none</param>
+ </params>
+ </node>
+</gegl>
diff --git a/tests/unit/photos-test-pipeline.c b/tests/unit/photos-test-pipeline.c
index 6dddb034..61d9617c 100644
--- a/tests/unit/photos-test-pipeline.c
+++ b/tests/unit/photos-test-pipeline.c
@@ -1,6 +1,6 @@
/*
* Photos - access, organize and share your photos on GNOME
- * Copyright © 2018 – 2019 Red Hat, Inc.
+ * Copyright © 2018 – 2020 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
@@ -27,6 +27,7 @@
#include "photos-debug.h"
#include "photos-gegl.h"
+#include "photos-operation-insta-common.h"
#include "photos-pipeline.h"
@@ -215,6 +216,49 @@ photos_test_pipeline_check_full (PhotosPipeline *pipeline, GeglNode *parent_expe
}
+static void
+photos_test_pipeline_check_magic_filter (PhotosPipeline *pipeline,
+ PhotosOperationInstaPreset preset_expected,
+ PhotosOperationInstaPreset preset_compat_expected)
+{
+ g_autoptr (GSList) children = NULL;
+ GeglNode *graph;
+ GeglNode *input;
+ GeglNode *output;
+ GeglNode *previous;
+ const gchar *operation;
+ g_autofree gchar *previous_pad_name = NULL;
+ gint preset;
+ 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, ==, 3);
+
+ 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, ==, "photos:magic-filter");
+
+ gegl_node_get (previous, "preset", &preset, NULL);
+ g_assert_cmpint (preset, ==, preset_expected);
+ g_assert_cmpint (preset, ==, preset_compat_expected);
+
+ previous = gegl_node_get_producer (previous, "input", &previous_pad_name);
+ g_assert_true (previous == input);
+ g_assert_cmpstr (previous_pad_name, ==, "output");
+}
+
+
static void
photos_test_pipeline_pipeline_new_async (GeglNode *parent,
const gchar *const *filenames,
@@ -242,6 +286,72 @@ photos_test_pipeline_pipeline_new_async (GeglNode *parent,
}
+static void
+photos_test_pipeline_magic_filter_none (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+ g_autoptr (PhotosPipeline) pipeline = NULL;
+ const gchar *const filenames[] = { "photos-test-pipeline-edited-magic-filter-none.xml", NULL };
+
+ photos_test_pipeline_pipeline_new_async (NULL, filenames, NULL, photos_test_pipeline_async, fixture);
+ g_main_loop_run (fixture->loop);
+
+ {
+ g_autoptr (GError) error = NULL;
+
+ pipeline = photos_pipeline_new_finish (fixture->res, &error);
+ g_assert_no_error (error);
+ }
+
+ photos_test_pipeline_check_magic_filter (pipeline,
+ PHOTOS_OPERATION_INSTA_PRESET_NONE,
+ PHOTOS_OPERATION_INSTA_PRESET_NONE);
+}
+
+
+static void
+photos_test_pipeline_magic_filter_1947 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+ g_autoptr (PhotosPipeline) pipeline = NULL;
+ const gchar *const filenames[] = { "photos-test-pipeline-edited-magic-filter-1947.xml", NULL };
+
+ photos_test_pipeline_pipeline_new_async (NULL, filenames, NULL, photos_test_pipeline_async, fixture);
+ g_main_loop_run (fixture->loop);
+
+ {
+ g_autoptr (GError) error = NULL;
+
+ pipeline = photos_pipeline_new_finish (fixture->res, &error);
+ g_assert_no_error (error);
+ }
+
+ photos_test_pipeline_check_magic_filter (pipeline,
+ PHOTOS_OPERATION_INSTA_PRESET_1947,
+ PHOTOS_OPERATION_INSTA_PRESET_1977);
+}
+
+
+static void
+photos_test_pipeline_magic_filter_calistoga (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
+{
+ g_autoptr (PhotosPipeline) pipeline = NULL;
+ const gchar *const filenames[] = { "photos-test-pipeline-edited-magic-filter-calistoga.xml", NULL };
+
+ photos_test_pipeline_pipeline_new_async (NULL, filenames, NULL, photos_test_pipeline_async, fixture);
+ g_main_loop_run (fixture->loop);
+
+ {
+ g_autoptr (GError) error = NULL;
+
+ pipeline = photos_pipeline_new_finish (fixture->res, &error);
+ g_assert_no_error (error);
+ }
+
+ photos_test_pipeline_check_magic_filter (pipeline,
+ PHOTOS_OPERATION_INSTA_PRESET_CALISTOGA,
+ PHOTOS_OPERATION_INSTA_PRESET_BRANNAN);
+}
+
+
static void
photos_test_pipeline_no_parent_blank_uris_0 (PhotosTestPipelineFixture *fixture, gconstpointer user_data)
{
@@ -1488,6 +1598,27 @@ main (gint argc, gchar *argv[])
photos_gegl_init ();
photos_gegl_ensure_builtins ();
+ g_test_add ("/pipeline/new/magic-filter-none",
+ PhotosTestPipelineFixture,
+ NULL,
+ photos_test_pipeline_setup,
+ photos_test_pipeline_magic_filter_none,
+ photos_test_pipeline_teardown);
+
+ g_test_add ("/pipeline/new/magic-filter-1947",
+ PhotosTestPipelineFixture,
+ NULL,
+ photos_test_pipeline_setup,
+ photos_test_pipeline_magic_filter_1947,
+ photos_test_pipeline_teardown);
+
+ g_test_add ("/pipeline/new/magic-filter-calistoga",
+ PhotosTestPipelineFixture,
+ NULL,
+ photos_test_pipeline_setup,
+ photos_test_pipeline_magic_filter_calistoga,
+ photos_test_pipeline_teardown);
+
g_test_add ("/pipeline/new/no-parent-blank-uris-0",
PhotosTestPipelineFixture,
NULL,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]