[tracker/regions-of-interest] tests/libtracker-extract: test for XMP with custom namespaces prefixes



commit d8d065e895d8b1940ce7a84a8d6537e759e4e910
Author: Ivan Frade <ivan frade gmail com>
Date:   Mon Aug 1 16:00:06 2011 +0300

    tests/libtracker-extract: test for XMP with custom namespaces prefixes

 tests/libtracker-extract/Makefile.am        |    2 +-
 tests/libtracker-extract/areas-ns.xmp       |   32 +++++++++++++++
 tests/libtracker-extract/tracker-test-xmp.c |   57 +++++++++++++++++++++++----
 3 files changed, 82 insertions(+), 9 deletions(-)
---
diff --git a/tests/libtracker-extract/Makefile.am b/tests/libtracker-extract/Makefile.am
index 7986025..7024ca2 100644
--- a/tests/libtracker-extract/Makefile.am
+++ b/tests/libtracker-extract/Makefile.am
@@ -30,4 +30,4 @@ tracker_test_utils_SOURCES = tracker-test-utils.c
 
 tracker_test_xmp_SOURCES = tracker-test-xmp.c
 
-EXTRA_DIST = encoding-detect.bin areas.xmp areas-with-contacts.xmp
+EXTRA_DIST = encoding-detect.bin areas.xmp areas-with-contacts.xmp areas-ns.xmp
diff --git a/tests/libtracker-extract/areas-ns.xmp b/tests/libtracker-extract/areas-ns.xmp
new file mode 100644
index 0000000..9ee43d9
--- /dev/null
+++ b/tests/libtracker-extract/areas-ns.xmp
@@ -0,0 +1,32 @@
+<!-- Same XMP with areas but using a different namespace prefix -->
+<x:xmpmeta
+      xmlns:x="adobe:ns:meta/"
+      xmlns:exif="http://ns.adobe.com/exif/1.0/";
+      xmlns:my-dym="http://ns.adobe.com/xap/1.0/sType/Dimensions#";
+      xmlns:my-area="http://ns.adobe.com/xap/1.0/sType/Area#";
+      xmlns:my-ns="http://www.metadataworkinggroup.com/schemas/regions/";>
+     <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
+       <rdf:Description rdf:about="">
+       <my-ns:Regions rdf:parseType="Resource">
+         <my-ns:AppliedToDimensions my-dym:w="4288" my-dym:h="2848" my-dym:unit="pixel"/>
+         <my-ns:RegionList>
+             <rdf:Bag>
+                  <rdf:li rdf:parseType="Resource">
+                      <my-ns:Area my-area:x="0.5" my-area:y="0.5" my-area:w="0.06"
+                                   my-area:h="0.09" my-area:unit="normalized"/>
+                      <my-ns:Type>Face</my-ns:Type>
+                      <my-ns:Name>Average Joe</my-ns:Name>
+                  </rdf:li>
+                  <rdf:li rdf:parseType="Resource">
+                      <my-ns:Area my-area:x="0.51" my-area:y="0.51" my-area:w="0.01"
+                                   my-area:h="0.09" my-area:unit="normalized"/>
+                      <my-ns:Type>Pet</my-ns:Type>
+                      <my-ns:Name>Fidoz</my-ns:Name>
+                      <my-ns:Description>Fido looks happy!</my-ns:Description>
+                  </rdf:li>
+              </rdf:Bag>
+          </my-ns:RegionList>
+        </my-ns:Regions>
+        </rdf:Description>
+     </rdf:RDF>
+</x:xmpmeta>
diff --git a/tests/libtracker-extract/tracker-test-xmp.c b/tests/libtracker-extract/tracker-test-xmp.c
index 1d2aa36..4a83d5f 100644
--- a/tests/libtracker-extract/tracker-test-xmp.c
+++ b/tests/libtracker-extract/tracker-test-xmp.c
@@ -347,7 +347,7 @@ debug_print_sparql (TrackerXmpData *data)
         /* To print the sparql */
         TrackerSparqlBuilder *metadata, *preupdate;
         GString              *where;
-        /* Print the sparql */
+
 	metadata = tracker_sparql_builder_new_update ();
 	preupdate = tracker_sparql_builder_new_update ();
 	where = g_string_new ("");
@@ -355,9 +355,6 @@ debug_print_sparql (TrackerXmpData *data)
 	tracker_sparql_builder_insert_open (metadata, NULL);
         tracker_sparql_builder_subject_iri (metadata, "urn:uuid:test");
 
-        /* To add few more metadata */
-        //data->title = g_strdup ("test");
-
         tracker_xmp_apply (preupdate, metadata, where, "urn:uuid:test", data);
 
 	tracker_sparql_builder_insert_close (metadata);
@@ -406,7 +403,7 @@ test_xmp_regions (void)
         g_assert_cmpstr (region->type, ==, "Face");
         g_assert_cmpstr (region->title, ==, "John Doe");
 
-        debug_print_sparql (data);
+        //debug_print_sparql (data);
         
         tracker_xmp_free (data);
 }
@@ -449,8 +446,49 @@ test_xmp_regions_quill (void)
         g_assert_cmpstr (region->link_class, ==, "nco:PersonContact");
         g_assert_cmpstr (region->link_uri, ==, "urn:uuid:1");
 
-        debug_print_sparql (data);
+        //debug_print_sparql (data);
+
+        tracker_xmp_free (data);
+}
+
+static void
+test_xmp_regions_ns_prefix (void)
+{
+        TrackerXmpData       *data;
+        TrackerXmpRegion     *region;
+
+        GFile            *f;
+        gchar            *contents;
+        gsize             size;
+
+        f = g_file_new_for_path ("./areas-ns.xmp");
+        g_assert(g_file_load_contents (f, NULL, &contents, &size, NULL, NULL));
+        g_object_unref (f);
+
+        data = tracker_xmp_new (contents, size, "test://file");
+
+        g_assert_cmpint (2, ==, g_list_length (data->regions));
+        
+        /* Regions are stacked while parsing.*/
+        region = g_list_nth_data (data->regions, 0);
+        g_assert_cmpstr (region->x, ==, "0.51");
+        g_assert_cmpstr (region->y, ==, "0.51");
+        g_assert_cmpstr (region->width, ==, "0.01");
+        g_assert_cmpstr (region->height, ==, "0.09");
+        g_assert_cmpstr (region->type, ==, "Pet");
+        g_assert_cmpstr (region->title, ==, "Fidoz");
+        g_assert_cmpstr (region->description, ==, "Fido looks happy!");
+
+        region = g_list_nth_data (data->regions, 1);
+        g_assert_cmpstr (region->x, ==, "0.5");
+        g_assert_cmpstr (region->y, ==, "0.5");
+        g_assert_cmpstr (region->width, ==, "0.06");
+        g_assert_cmpstr (region->height, ==, "0.09");
+        g_assert_cmpstr (region->type, ==, "Face");
+        g_assert_cmpstr (region->title, ==, "Average Joe");
 
+        //debug_print_sparql (data);
+        
         tracker_xmp_free (data);
 }
 
@@ -470,7 +508,7 @@ main (int    argc,
 
 	g_test_add_func ("/libtracker-extract/tracker-xmp/parsing_xmp",
 	                 test_parsing_xmp);
-/*
+
 	g_test_add_func ("/libtracker-extract/tracker-xmp/metering-mode",
 	                 test_xmp_metering_mode);
 
@@ -479,12 +517,15 @@ main (int    argc,
 
 	g_test_add_func ("/libtracker-extract/tracker-xmp/sparql_translation",
 	                 test_xmp_apply);
-*/
+
         g_test_add_func ("/libtracker-extract/tracker-xmp/xmp_regions",
                          test_xmp_regions);
 
         g_test_add_func ("/libtracker-extract/tracker-xmp/xmp_regions_2",
                          test_xmp_regions_quill);
+
+        g_test_add_func ("/libtracker-extract/tracker-xmp/xmp_regions_ns_prefix",
+                         test_xmp_regions_ns_prefix);
 #endif
 	g_test_add_func ("/libtracker-extract/tracker-xmp/sparql_translation_location",
 	                 test_xmp_apply_location);



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