[gimp/metadata-browser] metadata: Bootstrapping integration test for various property types.



commit fc17f9cf4297d5d5b17cd2272c47423b9094d081
Author: Roman Joost <roman bromeco de>
Date:   Tue Mar 5 13:33:29 2013 +1000

    metadata: Bootstrapping integration test for various property types.

 plug-ins/metadata/tests/files/test_xmp.conf        |   14 +++++
 plug-ins/metadata/tests/files/test_xmp.jpg         |  Bin 0 -> 3129 bytes
 .../metadata/tests/test-xmp-model-functional.c     |   60 ++++++++++++++++++-
 3 files changed, 70 insertions(+), 4 deletions(-)
---
diff --git a/plug-ins/metadata/tests/files/test_xmp.conf b/plug-ins/metadata/tests/files/test_xmp.conf
new file mode 100644
index 0000000..c33dee7
--- /dev/null
+++ b/plug-ins/metadata/tests/files/test_xmp.conf
@@ -0,0 +1,14 @@
+# Exiv2 command file
+# Run with exiv2 -m test_xmp.conf test_xmp.jpg
+
+del     Xmp.dc.creator
+set     Xmp.dc.creator  XmpSeq  "1) Wilber"
+set     Xmp.dc.creator          "2) Wilma"
+
+del     Xmp.dc.contributor
+set     Xmp.dc.contributor      "Róman Joost"
+set     Xmp.dc.contributor      "Maiko Joost"
+
+set     Xmp.dc.title    LangAlt     lang=de-DE  Hallo, Welt
+set     Xmp.dc.title    LangAlt     Hello, World
+set     Xmp.dc.title    LangAlt     lang=ja     こんにちは世界
diff --git a/plug-ins/metadata/tests/files/test_xmp.jpg b/plug-ins/metadata/tests/files/test_xmp.jpg
new file mode 100644
index 0000000..00ff9e9
Binary files /dev/null and b/plug-ins/metadata/tests/files/test_xmp.jpg differ
diff --git a/plug-ins/metadata/tests/test-xmp-model-functional.c 
b/plug-ins/metadata/tests/test-xmp-model-functional.c
index b6de1c4..0d09f1f 100644
--- a/plug-ins/metadata/tests/test-xmp-model-functional.c
+++ b/plug-ins/metadata/tests/test-xmp-model-functional.c
@@ -45,18 +45,32 @@ typedef struct
   const gchar *schema_name;
   const gchar *name;
   int          pos;
+  const gchar *expected_value;
 } TestDataEntry;
 
 static TestDataEntry propertiestotest[] =
 {
-   { XMP_PREFIX_DUBLIN_CORE,  "title",          1 },
-   { XMP_PREFIX_DUBLIN_CORE,  "creator",        0 },
-   { XMP_PREFIX_DUBLIN_CORE,  "description",    1 },
-   { XMP_PREFIX_DUBLIN_CORE,  "subject",        0 },
+   { XMP_PREFIX_DUBLIN_CORE,  "title",          1, NULL },
+   { XMP_PREFIX_DUBLIN_CORE,  "creator",        0, NULL },
+   { XMP_PREFIX_DUBLIN_CORE,  "description",    1, NULL },
+   { XMP_PREFIX_DUBLIN_CORE,  "subject",        0, NULL },
    { NULL,  NULL,          0 }
 };
 TestDataEntry * const import_exportdata = propertiestotest;
 
+/**
+ * This testdata tests different types in the #XMPModel and what they
+ * return for the editor.
+ * Note: The pos attribute is ignored.
+ */
+static TestDataEntry _xmp_property_values_view[] =
+{
+   { XMP_PREFIX_DUBLIN_CORE,  "title",          0, "Hello, World," },  // lang alt
+   { XMP_PREFIX_DUBLIN_CORE,  "creator",        0, "1) Wilber, 2) Wilma" },  // seq
+   { NULL,  NULL,          0 }
+};
+TestDataEntry * const xmp_property_values_view = _xmp_property_values_view;
+
 
 static void gimp_test_xmp_model_setup       (GimpTestFixture *fixture,
                                              gconstpointer    data);
@@ -86,6 +100,43 @@ gimp_test_xmp_model_teardown (GimpTestFixture *fixture,
   g_object_unref (fixture->xmp_model);
 }
 
+
+/**
+ * test_xmp_model_value_types
+ * @fixture:
+ * @data:
+ *
+ * Test if different value types are correctly set. The string
+ * representation of the value should be correct.
+ **/
+static void
+test_xmp_model_value_types (GimpTestFixture *fixture,
+                            gconstpointer    data)
+{
+  int             i;
+  const gchar    *value;
+  TestDataEntry  *testdata;
+  GError        **error       = NULL;
+  gchar          *uri         = NULL;
+
+  uri = g_build_filename (g_getenv ("GIMP_TESTING_ABS_TOP_SRCDIR"),
+                          "plug-ins/metadata/tests/files/test_xmp.jpg",
+                          NULL);
+
+  xmp_model_parse_file (fixture->xmp_model, uri, error);
+  g_free (uri);
+
+  for (i = 0; xmp_property_values_view[i].name != NULL; ++i)
+   {
+    testdata = &(xmp_property_values_view[i]);
+
+    value = xmp_model_get_scalar_property (fixture->xmp_model,
+                                           testdata->schema_name,
+                                           testdata->name);
+    g_assert_cmpstr (value, ==, testdata->expected_value);
+   }
+}
+
 /**
  * test_xmp_model_import_export_structures:
  * @fixture:
@@ -215,6 +266,7 @@ int main(int argc, char **argv)
 
   ADD_TEST (test_xmp_model_import_export);
   ADD_TEST (test_xmp_model_import_export_structures);
+  ADD_TEST (test_xmp_model_value_types);
 
   result = g_test_run ();
 


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