[tracker] Added a few fields to the XMP writeback support



commit 21256f5e86b6ada22fcf3133868183f5c28ff50e
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Dec 15 15:00:39 2009 +0100

    Added a few fields to the XMP writeback support

 configure.ac                                       |    1 +
 data/ontologies/30-nie.ontology                    |    3 +-
 data/ontologies/32-nco.ontology                    |    3 +-
 data/ontologies/38-nmm.ontology                    |   24 ++-
 src/tracker-writeback/Makefile.am                  |   12 +-
 src/tracker-writeback/tracker-writeback-consumer.c |    5 +-
 src/tracker-writeback/tracker-writeback-xmp.c      |  203 +++++++++++++++-----
 tests/Makefile.am                                  |    3 +-
 tests/tracker-writeback/01-writeback.py            |  103 ++++++++++
 tests/tracker-writeback/Makefile.am                |   11 +
 tests/tracker-writeback/data/test01.jpg            |  Bin 0 -> 306 bytes
 tests/tracker-writeback/tests.xml                  |   28 +++
 12 files changed, 333 insertions(+), 63 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e037308..e6b9bbf 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1709,6 +1709,7 @@ AC_CONFIG_FILES([
 	tests/tracker-miner-fs/Makefile
 	tests/tracker-extract/Makefile
 	tests/tracker-store/Makefile
+	tests/tracker-writeback/Makefile
 	utils/Makefile
 	utils/gtk-sparql/Makefile
 	utils/lyrics/Makefile
diff --git a/data/ontologies/30-nie.ontology b/data/ontologies/30-nie.ontology
index 5571fec..d6e0e61 100644
--- a/data/ontologies/30-nie.ontology
+++ b/data/ontologies/30-nie.ontology
@@ -137,7 +137,8 @@ nie:copyright a rdf:Property ;
 	rdfs:subPropertyOf dc:rights , nie:legal ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nie:InformationElement ;
-	rdfs:range xsd:string .
+	rdfs:range xsd:string ;
+	tracker:writeback true .
 
 nie:comment a rdf:Property ;
 	nrl:maxCardinality 1 ;
diff --git a/data/ontologies/32-nco.ontology b/data/ontologies/32-nco.ontology
index f79d2e0..1f622bb 100644
--- a/data/ontologies/32-nco.ontology
+++ b/data/ontologies/32-nco.ontology
@@ -208,7 +208,8 @@ nco:contributor a rdf:Property ;
 	rdfs:comment "An entity responsible for making contributions to the content of the InformationElement." ;
 	rdfs:subPropertyOf dc:contributor ;
 	rdfs:domain nie:InformationElement ;
-	rdfs:range nco:Contact .
+	rdfs:range nco:Contact ;
+	tracker:writeback true .
 
 nco:creator a rdf:Property ;
 	rdfs:label "creator" ;
diff --git a/data/ontologies/38-nmm.ontology b/data/ontologies/38-nmm.ontology
index c38fdcb..cf42877 100644
--- a/data/ontologies/38-nmm.ontology
+++ b/data/ontologies/38-nmm.ontology
@@ -323,14 +323,16 @@ nmm:camera a rdf:Property ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
 	rdfs:range xsd:string ;
-	tracker:weight 3 .
+	tracker:weight 3 ;
+	tracker:writeback true .
 
 nmm:exposureTime a rdf:Property ;
 	rdfs:label "Exposure time" ;
 	rdfs:comment "Exposure time of the photo" ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range xsd:double .
+	rdfs:range xsd:double ;
+	tracker:writeback true .
 
 nmm:Flash a rdfs:Class ;
 	rdfs:label "Flash values" ;
@@ -344,28 +346,32 @@ nmm:flash a rdf:Property ;
 	rdfs:comment "Specifies whether flash was used" ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range nmm:Flash .
+	rdfs:range nmm:Flash ;
+	tracker:writeback true .
 
 nmm:fnumber a rdf:Property ;
 	rdfs:label "F number" ;
 	rdfs:comment "The diameter of the entrance pupil in terms of the focal length of the lens" ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range xsd:double .
+	rdfs:range xsd:double ;
+	tracker:writeback true .
 
 nmm:focalLength a rdf:Property ;
 	rdfs:label "Focal length" ;
 	rdfs:comment "A measure of how strongly the lens converges light" ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range xsd:double .
+	rdfs:range xsd:double ;
+	tracker:writeback true .
 
 nmm:isoSpeed a rdf:Property ;
 	rdfs:label "ISO speed" ;
 	rdfs:comment "Measure of a photographic film's sensitivity to light as ISO value" ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range xsd:double .
+	rdfs:range xsd:double ;
+	tracker:writeback true .
 
 nmm:MeteringMode a rdfs:Class ;
 	rdfs:label "Metering mode values" ;
@@ -383,7 +389,8 @@ nmm:meteringMode a rdf:Property ;
 	rdfs:comment "Metering mode refers to the way in which a camera determines the exposure." ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range nmm:MeteringMode .
+	rdfs:range nmm:MeteringMode ;
+	tracker:writeback true .
 
 nmm:WhiteBalance a rdfs:Class ;
 	rdfs:label "White balance" ;
@@ -395,7 +402,8 @@ nmm:white-balance-manual a nmm:WhiteBalance .
 nmm:whiteBalance a rdf:Property ;
 	nrl:maxCardinality 1 ;
 	rdfs:domain nmm:Photo ;
-	rdfs:range nmm:WhiteBalance .
+	rdfs:range nmm:WhiteBalance ;
+	tracker:writeback true .
 
 nmm:isCropped a rdf:Property ;
 	nrl:maxCardinality 1 ;
diff --git a/src/tracker-writeback/Makefile.am b/src/tracker-writeback/Makefile.am
index 4655653..ea895d3 100644
--- a/src/tracker-writeback/Makefile.am
+++ b/src/tracker-writeback/Makefile.am
@@ -39,12 +39,12 @@ libwriteback_xmp_la_LIBADD = $(GLIB2_LIBS) $(GCOV_LIBS) $(EXEMPI_LIBS)
 endif
 
 # Playlists
-if HAVE_TOTEM_PL_PARSER
-modules_LTLIBRARIES += libwriteback-playlist.la
-libwriteback_playlist_la_SOURCES = tracker-writeback-playlist.c
-libwriteback_playlist_la_LDFLAGS = $(module_flags)
-libwriteback_playlist_la_LIBADD = $(GLIB2_LIBS) $(GCOV_LIBS) $(TOTEM_PL_PARSER_LIBS)
-endif
+#if HAVE_TOTEM_PL_PARSER
+#modules_LTLIBRARIES += libwriteback-playlist.la
+#libwriteback_playlist_la_SOURCES = tracker-writeback-playlist.c
+#libwriteback_playlist_la_LDFLAGS = $(module_flags)
+#libwriteback_playlist_la_LIBADD = $(GLIB2_LIBS) $(GCOV_LIBS) $(TOTEM_PL_PARSER_LIBS)
+#endif
 
 #
 # Binaries
diff --git a/src/tracker-writeback/tracker-writeback-consumer.c b/src/tracker-writeback/tracker-writeback-consumer.c
index a1e0098..d7b9cab 100644
--- a/src/tracker-writeback/tracker-writeback-consumer.c
+++ b/src/tracker-writeback/tracker-writeback-consumer.c
@@ -123,7 +123,10 @@ tracker_writeback_consumer_constructed (GObject *object)
 		path = modules->data;
 		module = tracker_writeback_module_get (path);
 
-		g_hash_table_insert (priv->modules, g_strdup (path), module);
+		if (module) {
+			g_hash_table_insert (priv->modules, g_strdup (path), module);
+		}
+
 		modules = modules->next;
 	}
 }
diff --git a/src/tracker-writeback/tracker-writeback-xmp.c b/src/tracker-writeback/tracker-writeback-xmp.c
index 8135bb9..b396ded 100644
--- a/src/tracker-writeback/tracker-writeback-xmp.c
+++ b/src/tracker-writeback/tracker-writeback-xmp.c
@@ -128,8 +128,7 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
 	xmp = xmp_files_get_new_xmp (xmp_files);
 
 	if (!xmp) {
-		g_free (path);
-		return FALSE;
+		xmp = xmp_new_empty ();
 	}
 
 #ifdef DEBUG_XMP
@@ -185,11 +184,56 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
 			}
 		}
 
+		if (g_strcmp0 (row[1], TRACKER_NCO_PREFIX "contributor") == 0) {
+			GPtrArray *name_array;
+			GError *error = NULL;
+			gchar *query;
+
+			query = g_strdup_printf ("SELECT ?fullname { "
+			                         "  <%s> nco:fullname ?fullname "
+			                         "}", row[2]);
+
+			name_array = tracker_resources_sparql_query (client, query, &error);
+
+			g_free (query);
+
+			if (!error) {
+				if (name_array && name_array->len > 0) {
+					GStrv name_row;
+
+					name_row = g_ptr_array_index (name_array, 0);
+
+					if (name_row[0]) {
+						xmp_delete_property (xmp, NS_DC, "contributor");
+						xmp_set_property (xmp, NS_DC, "contributor", name_row[0], 0);
+					}
+				}
+
+				if (name_array) {
+					g_ptr_array_foreach (name_array, (GFunc) g_strfreev, NULL);
+					g_ptr_array_free (name_array, TRUE);
+				}
+
+			} else {
+				g_clear_error (&error);
+			}
+		}
+
 		if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "description") == 0) {
 			xmp_delete_property (xmp, NS_DC, "description");
 			xmp_set_property (xmp, NS_DC, "description", row[2], 0);
 		}
 
+		if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "copyright") == 0) {
+			xmp_delete_property (xmp, NS_EXIF, "Copyright");
+			xmp_set_property (xmp, NS_EXIF, "Copyright", row[2], 0);
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "comment") == 0) {
+			xmp_delete_property (xmp, NS_EXIF, "UserComment");
+			xmp_set_property (xmp, NS_EXIF, "UserComment", row[2], 0);
+		}
+
 		if (g_strcmp0 (row[1], TRACKER_NIE_PREFIX "keyword") == 0) {
 			if (!keywords) {
 				keywords = g_string_new (row[2]);
@@ -204,55 +248,124 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
 		}
 
 		if (g_strcmp0 (row[1], TRACKER_NFO_PREFIX "orientation") == 0) {
-			guint i;
-
-			static const gchar *ostr[8] = {
-				/* 0 */ TRACKER_NFO_PREFIX "orientation-top",
-				/* 1 */ TRACKER_NFO_PREFIX "orientation-top-mirror",
-				/* 2 */ TRACKER_NFO_PREFIX "orientation-bottom",
-				/* 3 */ TRACKER_NFO_PREFIX "orientation-bottom-mirror",
-				/* 4 */ TRACKER_NFO_PREFIX "orientation-left-mirror",
-				/* 5 */ TRACKER_NFO_PREFIX "orientation-right",
-				/* 6 */ TRACKER_NFO_PREFIX "orientation-right-mirror",
-				/* 7 */ TRACKER_NFO_PREFIX "orientation-left"
-			};
 
 			xmp_delete_property (xmp, NS_EXIF, "Orientation");
 
-			for (i=0; i < 8; i++) {
-				if (g_strcmp0 (row[2], ostr[i]) == 0) {
-					switch (i) {
-					case 0:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "top - left", 0);
-						break;
-					case 1:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "top - right", 0);
-						break;
-					case 2:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "bottom - right", 0);
-						break;
-					case 3:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "bottom - left", 0);
-						break;
-					case 4:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "left - top", 0);
-						break;
-					case 5:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "right - top", 0);
-						break;
-					case 6:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "right - bottom", 0);
-						break;
-					case 7:
-						xmp_set_property (xmp, NS_EXIF, "Orientation", "left - bottom", 0);
-						break;
-					default:
-						break;
-					}
-				}
+			if        (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-top") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "top - left", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-top-mirror") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "top - right", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-bottom") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "bottom - right", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-bottom-mirror") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "bottom - left", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-left-mirror") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "left - top", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-right") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "right - top", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-right-mirror") == 0) {
+					xmp_set_property (xmp, NS_EXIF, "Orientation", "right - bottom", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NFO_PREFIX "orientation-left") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "Orientation", "left - bottom", 0);
+			}
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "meteringMode") == 0) {
+
+			xmp_delete_property (xmp, NS_EXIF, "MeteringMode");
+
+			/* 0 = Unknown
+			   1 = Average
+			   2 = CenterWeightedAverage
+			   3 = Spot
+			   4 = MultiSpot
+			   5 = Pattern
+			   6 = Partial
+			   255 = other  */
+
+			if        (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "meteringMode-center-weighted-average") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "0", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "meteringMode-average") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "1", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "meteringMode-spot") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "3", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "meteringMode-multispot") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "4", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "meteringMode-pattern") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "5", 0);
+			} else if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "meteringMode-partial") == 0) {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "6", 0);
+			} else {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "255", 0);
+			}
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "whiteBalance") == 0) {
+
+			xmp_delete_property (xmp, NS_EXIF, "WhiteBalance");
+
+			if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "whiteBalance-auto") == 0) {
+				/* 0 = Auto white balance
+				 * 1 = Manual white balance */
+				xmp_set_property (xmp, NS_EXIF, "WhiteBalance", "0", 0);
+			} else {
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "1", 0);
 			}
 		}
 
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "flash") == 0) {
+
+			xmp_delete_property (xmp, NS_EXIF, "Flash");
+
+			if (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "flash-on") == 0) {
+				/* 0 = Flash did not fire
+				   1 = Flash fired */
+				xmp_set_property (xmp, NS_EXIF, "Flash", "0", 0);
+			} else {
+				xmp_set_property (xmp, NS_EXIF, "Flash", "1", 0);
+			}
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "focalLength") == 0) {
+			xmp_delete_property (xmp, NS_EXIF, "FocalLength");
+			xmp_set_property (xmp, NS_EXIF, "FocalLength", row[2], 0);
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "exposureTime") == 0) {
+			xmp_delete_property (xmp, NS_EXIF, "ExposureTime");
+			xmp_set_property (xmp, NS_EXIF, "ExposureTime", row[2], 0);
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "isoSpeed") == 0) {
+			xmp_delete_property (xmp, NS_EXIF, "ISOSpeedRatings");
+			xmp_set_property (xmp, NS_EXIF, "ISOSpeedRatings", row[2], 0);
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "fnumber") == 0) {
+			xmp_delete_property (xmp, NS_EXIF, "FNumber");
+			xmp_set_property (xmp, NS_EXIF, "FNumber", row[2], 0);
+		}
+
+		if (g_strcmp0 (row[1], TRACKER_NMM_PREFIX "camera") == 0) {
+			gchar *work_on = g_strdup (row[2]);
+			gchar *ptr = strchr (work_on, ' ');
+
+			if (ptr) {
+
+				*ptr = '\0';
+				ptr++;
+
+				xmp_delete_property (xmp, NS_EXIF, "Make");
+				xmp_set_property (xmp, NS_EXIF, "Make", work_on, 0);
+				xmp_delete_property (xmp, NS_EXIF, "Model");
+				xmp_set_property (xmp, NS_EXIF, "Model", ptr, 0);
+			} else {
+				xmp_delete_property (xmp, NS_EXIF, "Model");
+				xmp_set_property (xmp, NS_EXIF, "Model", work_on, 0);
+			}
+
+			g_free (work_on);
+		}
 
 		/*
 		  if (g_strcmp0 (row[1], PHOTO_HAS "contact") == 0) {
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8549d7f..df9a5e9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,4 +9,5 @@ SUBDIRS = 			\
 	tracker-miner-fs	\
 	tracker-extract		\
 	tracker-store		\
-	functional-tests
+	functional-tests	\
+	tracker-writeback
diff --git a/tests/tracker-writeback/01-writeback.py b/tests/tracker-writeback/01-writeback.py
new file mode 100755
index 0000000..a4dcb04
--- /dev/null
+++ b/tests/tracker-writeback/01-writeback.py
@@ -0,0 +1,103 @@
+#!/usr/bin/env python2.5
+
+# Copyright (C) 2008, Nokia (urho konttori nokia com)
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA  02110-1301, USA.
+#
+
+
+import dbus
+import unittest
+import random
+import os
+import shutil
+import re
+import time
+import commands
+
+TRACKER = 'org.freedesktop.Tracker1'
+TRACKER_OBJ = '/org/freedesktop/Tracker1/Resources'
+RESOURCES_IFACE = "org.freedesktop.Tracker1.Resources"
+
+class TestInsertion (unittest.TestCase):
+
+    def setUp (self):
+        bus = dbus.SessionBus ()
+        tracker = bus.get_object (TRACKER, TRACKER_OBJ)
+        self.resources = dbus.Interface (tracker,
+                                         dbus_interface=RESOURCES_IFACE);
+
+    def test_simple_insertion (self):
+	try:        
+	        os.mkdir (os.getcwd() + "/tmp")
+	except:
+		print ""
+
+        shutil.copy2 (os.getcwd() + "/data/test01.jpg",
+                      os.getcwd() + "/tmp/test01.jpg")
+
+        uri = "file://" + os.getcwd() + "/tmp/test01.jpg"
+        
+        insert = """INSERT { <%s> a nfo:Image, nmm:Photo, nfo:FileDataObject;
+                      nie:isStoredAs <%s> ;
+                      nie:url '%s' ;
+                      nie:title 'test_title_1' ;
+                      nco:creator [ a nco:Contact ;
+                                    nco:fullname 'test_fullname_1' ] ;
+                      nie:description 'test_description_1' ;
+                      nie:keyword 'test_keyword_1' ;
+                      nie:keyword 'test_keyword_2' ;
+                      nie:keyword 'test_keyword_3' ;
+                      nie:contentCreated '2001-10-26T21:32:52' ;
+                      nfo:orientation nfo:orientation-top-mirror ;
+                      nmm:meteringMode nmm:meteringMode-average ;
+                      nmm:whiteBalance nmm:whiteBalance-auto ;
+                      nmm:flash nmm:flash-on ;
+                      nmm:focalLength '1' ;
+                      nmm:exposureTime '1' ;
+                      nmm:isoSpeed '1' ;
+                      nmm:fnumber '1' ;
+                      nmm:camera 'Some Test Model' ;
+                      nco:contributor [ a nco:Contact ;
+                                        nco:fullname 'test_fullname_2' ] ;
+                      nie:copyright 'test_copyright_1'
+               }""" % (uri, uri, uri)
+
+
+        self.resources.SparqlUpdate (insert)
+
+	time.sleep (3)
+
+	ret = os.system ("exiftool " + os.getcwd() + "/tmp/test01.jpg | grep test_title_1")
+        self.assertEqual (ret, 0)
+
+	ret = os.system ("exiftool " + os.getcwd() + "/tmp/test01.jpg | grep test_fullname_1")
+        self.assertEqual (ret, 0)
+
+	ret = os.system ("exiftool " + os.getcwd() + "/tmp/test01.jpg | grep test_description_1")
+        self.assertEqual (ret, 0)
+
+	ret = os.system ("exiftool " + os.getcwd() + "/tmp/test01.jpg | grep test_keyword_1")
+        self.assertEqual (ret, 0)
+
+	ret = os.system ("exiftool " + os.getcwd() + "/tmp/test01.jpg | grep test_keyword_2")
+        self.assertEqual (ret, 0)
+
+	ret = os.system ("exiftool " + os.getcwd() + "/tmp/test01.jpg | grep test_keyword_3")
+        self.assertEqual (ret, 0)
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/tests/tracker-writeback/Makefile.am b/tests/tracker-writeback/Makefile.am
new file mode 100644
index 0000000..6eae4f1
--- /dev/null
+++ b/tests/tracker-writeback/Makefile.am
@@ -0,0 +1,11 @@
+include $(top_srcdir)/Makefile.decl
+
+if DIST_FUNCTIONAL_TESTS
+configdir = $(datadir)/tracker-tests
+
+config_DATA =			\
+	tests.xml		\
+	01-writeback.py		
+
+EXTRA_DIST = $(config_DATA)
+endif
diff --git a/tests/tracker-writeback/data/test01.jpg b/tests/tracker-writeback/data/test01.jpg
new file mode 100644
index 0000000..a62b7d4
Binary files /dev/null and b/tests/tracker-writeback/data/test01.jpg differ
diff --git a/tests/tracker-writeback/tests.xml b/tests/tracker-writeback/tests.xml
new file mode 100644
index 0000000..37b3a8b
--- /dev/null
+++ b/tests/tracker-writeback/tests.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<testdefinition version="0.1">
+  <suite name="tracker-tests" domain="tracker-store">
+    <!-- At least one set per suite, name and description mandatory -->
+    <set name="testset1" description="Basic sparql tests" feature="sparql-insert">
+      <pre_steps>
+        <!-- This doesn't seem to work -->
+        <step>. /tmp/session_bus_address.user</step>
+        <step>tracker-writeback &</step>
+      </pre_steps>
+
+      <!-- At least one case per set, name mandatory, description mandatory, other optional -->
+      <case name="test_simple_insertion" type="Functional" level="Feature"
+            description="Insert and check results" requirement="01" subfeature="">
+        <!-- dbus env variables defined here. This works. -->
+        <step expected_result="0">. /tmp/session_bus_address.user; python2.5 /usr/share/tracker-tests/01-writeback.py</step>
+      </case>
+
+
+      <!-- Environments optional - tells where the tests are run -->
+      <environments>
+        <scratchbox>true</scratchbox>
+        <hardware>true</hardware>
+      </environments>
+
+    </set>
+  </suite>
+</testdefinition>



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