[gimp/metadata-browser: 28/45] Replaced test for exporting on empty XMPModel.
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser: 28/45] Replaced test for exporting on empty XMPModel.
- Date: Tue, 19 Feb 2013 23:42:05 +0000 (UTC)
commit e1a6f31b5e5e1b3228d93a106606ae4d0c4930c4
Author: Roman Joost <roman bromeco de>
Date: Wed Sep 28 20:05:27 2011 +1000
Replaced test for exporting on empty XMPModel.
Replaced test, which assures that values set on an empty model are also
correctly serialized.
.../metadata/tests/test-xmp-model-functional.c | 91 +++++++-------------
1 files changed, 33 insertions(+), 58 deletions(-)
---
diff --git a/plug-ins/metadata/tests/test-xmp-model-functional.c
b/plug-ins/metadata/tests/test-xmp-model-functional.c
index 6a0746c..e24f862 100644
--- a/plug-ins/metadata/tests/test-xmp-model-functional.c
+++ b/plug-ins/metadata/tests/test-xmp-model-functional.c
@@ -74,18 +74,7 @@ static void
gimp_test_xmp_model_setup (GimpTestFixture *fixture,
gconstpointer data)
{
- gchar *uri = NULL;
- GError *error = NULL;
-
fixture->xmp_model = xmp_model_new ();
-
- uri = g_build_filename (g_getenv ("GIMP_TESTING_ABS_TOP_SRCDIR"),
- "plug-ins/metadata/tests/files/test.xmp",
- NULL);
-
- xmp_model_parse_file (fixture->xmp_model, uri, &error);
-
- g_free (uri);
}
@@ -116,6 +105,15 @@ test_xmp_model_import_export_structures (GimpTestFixture *fixture,
TestDataEntry *testdata;
const gchar *scalarvalue = "test";
GError **error = NULL;
+ gchar *uri = NULL;
+
+
+ uri = g_build_filename (g_getenv ("GIMP_TESTING_ABS_TOP_SRCDIR"),
+ "plug-ins/metadata/tests/files/test.xmp",
+ NULL);
+
+ xmp_model_parse_file (fixture->xmp_model, uri, error);
+ g_free (uri);
for (i = 0; import_exportdata[i].name != NULL; ++i)
{
@@ -170,70 +168,47 @@ test_xmp_model_import_export_structures (GimpTestFixture *fixture,
* @data:
*
* Functional test, which assures that changes in the string
- * representation is correctly merged on export.
+ * representation is correctly merged on export. This test starts of
+ * with inserting scalar values only.
**/
static void
test_xmp_model_import_export (GimpTestFixture *fixture,
gconstpointer data)
{
- 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);
+ gboolean result;
+ GString *buffer;
+ TestDataEntry *testdata;
+ const gchar **after_value;
+ const gchar *scalarvalue = "test";
+ GError **error = NULL;
- value = xmp_model_get_raw_property_value (fixture->xmp_model,
- "dc",
- "description");
- g_assert (value != NULL);
- g_assert (oldvalue == value);
+ /* dc:title */
+ testdata = &(import_exportdata[0]);
- scalar = xmp_model_get_scalar_property (fixture->xmp_model,
- "dc",
- "description");
- g_assert_cmpstr ("My good description", ==, scalar);
+ /* set a new scalar value */
+ result = xmp_model_set_scalar_property (fixture->xmp_model,
+ testdata->schema_name,
+ testdata->name,
+ scalarvalue);
+ g_assert (result == TRUE);
- /* 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
- */
+ /* export */
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 */
+ /* import */
xmp_model_parse_buffer (fixture->xmp_model,
buffer->str,
buffer->len,
TRUE,
error);
+ after_value = xmp_model_get_raw_property_value (fixture->xmp_model,
+ testdata->schema_name,
+ testdata->name);
- 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");
+ /* check that the scalar value is correctly exported */
+ g_assert (after_value != NULL);
+ g_assert_cmpstr (after_value[testdata->pos], ==, scalarvalue);
}
int main(int argc, char **argv)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]