[gimp/metadata-browser: 25/45] New functional test to make sure raw values are updated.



commit e1a39c4eff9a7d51d4337b00d91267a495fbe4e9
Author: Roman Joost <roman bromeco de>
Date:   Mon Sep 26 21:02:40 2011 +1000

    New functional test to make sure raw values are updated.

 plug-ins/metadata/tests/.gitignore                 |    1 +
 plug-ins/metadata/tests/Makefile.am                |    1 +
 plug-ins/metadata/tests/files/test.xmp             |    1 +
 .../metadata/tests/test-xmp-model-functional.c     |   59 +++++++++++++++++++-
 4 files changed, 61 insertions(+), 1 deletions(-)
---
diff --git a/plug-ins/metadata/tests/.gitignore b/plug-ins/metadata/tests/.gitignore
index 1c15490..8857c7e 100644
--- a/plug-ins/metadata/tests/.gitignore
+++ b/plug-ins/metadata/tests/.gitignore
@@ -3,3 +3,4 @@
 /.deps
 /.libs
 test-xmp-model
+test-xmp-model-functional
diff --git a/plug-ins/metadata/tests/Makefile.am b/plug-ins/metadata/tests/Makefile.am
index b1ec90b..27f1b48 100644
--- a/plug-ins/metadata/tests/Makefile.am
+++ b/plug-ins/metadata/tests/Makefile.am
@@ -22,6 +22,7 @@ LDADD = \
        ../base64.o             \
        ../xmp-parse.o          \
        ../xmp-schemas.o        \
+       ../xmp-encode.o         \
        ../xmp-model.o
 
 
diff --git a/plug-ins/metadata/tests/files/test.xmp b/plug-ins/metadata/tests/files/test.xmp
index 774e439..7ff6369 100644
--- a/plug-ins/metadata/tests/files/test.xmp
+++ b/plug-ins/metadata/tests/files/test.xmp
@@ -16,6 +16,7 @@
   <dc:description>
    <rdf:Alt>
     <rdf:li xml:lang='x-default'>bla</rdf:li>
+    <rdf:li xml:lang='de_DE'>Deutsche Beschreibung</rdf:li>
    </rdf:Alt>
   </dc:description>
  </rdf:Description>
diff --git a/plug-ins/metadata/tests/test-xmp-model-functional.c 
b/plug-ins/metadata/tests/test-xmp-model-functional.c
index eafdf89..6f6c66d 100644
--- a/plug-ins/metadata/tests/test-xmp-model-functional.c
+++ b/plug-ins/metadata/tests/test-xmp-model-functional.c
@@ -90,7 +90,64 @@ static void
 test_xmp_model_import_export (GimpTestFixture *fixture,
                               gconstpointer    data)
 {
-  g_assert (TRUE);
+  gboolean     result;
+  const gchar **oldvalue;
+  const gchar **value;
+  const gchar  *scalar;
+  GString      *buffer;
+  GError      **error = NULL;
+
+  /* The XMPModel is already loaded with imported XMP metadata */
+  g_assert (! xmp_model_is_empty (fixture->xmp_model));
+  oldvalue = xmp_model_get_raw_property_value (fixture->xmp_model,
+                                               "dc",
+                                               "description");
+  g_assert_cmpstr (oldvalue[0], ==, "x-default");
+  g_assert_cmpstr (oldvalue[2], ==, "de_DE");
+
+  /* We can now change the string representation of the raw values,
+   * which will not change the raw value itself. The current GtkEntry
+   * widgets of XMP_TYPE_LANG_ALT only change the x-default value, which
+   * may change in the future */
+  result = xmp_model_set_scalar_property (fixture->xmp_model,
+                                          "dc",
+                                          "description",
+                                          "My good description");
+  g_assert (result == TRUE);
+
+  value = xmp_model_get_raw_property_value (fixture->xmp_model,
+                                            "dc",
+                                            "description");
+  g_assert (value != NULL);
+  g_assert (oldvalue == value);
+
+  scalar = xmp_model_get_scalar_property (fixture->xmp_model,
+                                          "dc",
+                                          "description");
+  g_assert_cmpstr ("My good description", ==, scalar);
+
+  /* Once we write the XMPModel to a file, we take care of the changes
+   * in the string representation and merge it with the raw value
+   */
+  buffer = g_string_new ("GIMP_TEST");
+  xmp_generate_packet (fixture->xmp_model, buffer);
+
+  /* We reread the buffer into the XMPModel and expect it to have
+   * updated raw values */
+  xmp_model_parse_buffer (fixture->xmp_model,
+                          buffer->str,
+                          buffer->len,
+                          TRUE,
+                          error);
+
+  value = xmp_model_get_raw_property_value (fixture->xmp_model,
+                                            "dc",
+                                            "description");
+  g_assert (value != NULL);
+  g_assert_cmpstr (value[0], ==, "x-default");
+  g_assert_cmpstr (value[1], ==, "My good description");
+  g_assert_cmpstr (value[2], ==, "de_DE");
+  g_assert_cmpstr (value[3], ==, "Deutsche Beschreibung");
 }
 
 int main(int argc, char **argv)


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