[gimp/metadata-browser] Simple parser test to read from a file with XMP metadata.



commit 6476a47d340b70fc40d2a09b7b57498a7dd04693
Author: Roman Joost <roman bromeco de>
Date:   Sat Sep 17 13:50:25 2011 +1000

    Simple parser test to read from a file with XMP metadata.
    
    This test should be a base to test parsing property types into the
    XMPModel.

 plug-ins/metadata/tests/Makefile.am      |    6 ++++-
 plug-ins/metadata/tests/test-xmp-model.c |   39 ++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletions(-)
---
diff --git a/plug-ins/metadata/tests/Makefile.am b/plug-ins/metadata/tests/Makefile.am
index 067092f..9c6b260 100644
--- a/plug-ins/metadata/tests/Makefile.am
+++ b/plug-ins/metadata/tests/Makefile.am
@@ -29,7 +29,11 @@ INCLUDES = \
 	-I ../
 
 
-TESTS = test-xmp-model$(EXEEXT)
+TESTS_ENVIRONMENT = \
+	GIMP_TESTING_ABS_TOP_SRCDIR= abs_top_srcdir@
+
+TESTS = \
+	test-xmp-model
 
 EXTRA_PROGRAMS = $(TESTS)
 
diff --git a/plug-ins/metadata/tests/test-xmp-model.c b/plug-ins/metadata/tests/test-xmp-model.c
index 520ea3f..64b8593 100644
--- a/plug-ins/metadata/tests/test-xmp-model.c
+++ b/plug-ins/metadata/tests/test-xmp-model.c
@@ -161,6 +161,44 @@ test_xmp_model_get_raw_property_value (GimpTestFixture *fixture,
   g_assert_cmpstr (result[1], ==, expected[1]);
 }
 
+/**
+ * test_xmp_model_parse_file:
+ * @fixture:
+ * @data:
+ *
+ * A very simple test parsing a file with XMP DC metadata.
+ **/
+static void
+test_xmp_model_parse_file (GimpTestFixture *fixture,
+                           gconstpointer    data)
+{
+  gchar   *uri = NULL;
+  const gchar   *value = NULL;
+  GError  *error = NULL;
+
+  uri = g_build_filename (g_getenv ("GIMP_TESTING_ABS_TOP_SRCDIR"),
+                          "plug-ins/metadata/tests/files/test.xmp",
+                          NULL);
+  g_assert (uri != NULL);
+
+  xmp_model_parse_file (fixture->xmpmodel, uri, &error);
+  g_assert (! xmp_model_is_empty (fixture->xmpmodel));
+
+  // title
+  value = xmp_model_get_scalar_property (fixture->xmpmodel, "dc", "title");
+  g_assert_cmpstr (value, == , "image title");
+
+  // creator
+  value = xmp_model_get_scalar_property (fixture->xmpmodel, "dc", "creator");
+  g_assert_cmpstr (value, == , "roman");
+
+  // description
+  value = xmp_model_get_scalar_property (fixture->xmpmodel, "dc", "description");
+  g_assert_cmpstr (value, == , "bla");
+
+  g_free (uri);
+}
+
 int main(int argc, char **argv)
 {
   gint result = -1;
@@ -171,6 +209,7 @@ int main(int argc, char **argv)
   ADD_TEST (test_xmp_model_is_empty);
   ADD_TEST (test_xmp_model_set_get_scalar_property);
   ADD_TEST (test_xmp_model_get_raw_property_value);
+  ADD_TEST (test_xmp_model_parse_file);
 
   result = g_test_run ();
 



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