[tracker/writeback: 4/7] Added a unit test for tracker-writeback



commit a51964035b21688ca1dcfcd810c842809f4e78c0
Author: Philip Van Hoof <philip codeminded be>
Date:   Tue Dec 15 16:59:12 2009 +0100

    Added a unit test for tracker-writeback
    
    Made the tracker-writeback unit test actually test something

 configure.ac                                       |    1 +
 src/tracker-writeback/tracker-writeback-consumer.c |    5 +++-
 src/tracker-writeback/tracker-writeback-xmp.c      |   25 ++++++++---------
 tests/Makefile.am                                  |    3 +-
 tests/tracker-writeback/01-writeback.py            |    1 -
 tests/tracker-writeback/Makefile.am                |   11 ++++++++
 tests/tracker-writeback/data/test01.jpg            |  Bin 0 -> 306 bytes
 tests/tracker-writeback/tests.xml                  |   28 ++++++++++++++++++++
 8 files changed, 58 insertions(+), 16 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index eb2cfca..d7c199f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1708,6 +1708,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/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 fd92ca0..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
@@ -285,19 +284,19 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
 			   255 = other  */
 
 			if        (g_strcmp0 (row[2], TRACKER_NMM_PREFIX "meteringMode-center-weighted-average") == 0) {
-				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "center", 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", "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", "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", "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", "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", "partial", 0);
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "6", 0);
 			} else {
-				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "other", 0);
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "255", 0);
 			}
 		}
 
@@ -308,9 +307,9 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
 			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", "auto", 0);
+				xmp_set_property (xmp, NS_EXIF, "WhiteBalance", "0", 0);
 			} else {
-				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "manual", 0);
+				xmp_set_property (xmp, NS_EXIF, "MeteringMode", "1", 0);
 			}
 		}
 
@@ -321,9 +320,9 @@ writeback_xmp_update_file_metadata (TrackerWritebackFile *wbf,
 			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", "on", 0);
+				xmp_set_property (xmp, NS_EXIF, "Flash", "0", 0);
 			} else {
-				xmp_set_property (xmp, NS_EXIF, "Flash", "off", 0);
+				xmp_set_property (xmp, NS_EXIF, "Flash", "1", 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
index aa23596..a4dcb04 100755
--- a/tests/tracker-writeback/01-writeback.py
+++ b/tests/tracker-writeback/01-writeback.py
@@ -99,6 +99,5 @@ class TestInsertion (unittest.TestCase):
 	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]