[gimp/metadata-browser: 10/45] Bootstrapping unittests to test the XMPModel.



commit 744beb479f783d3d0d959e240464953e549403a0
Author: Roman Joost <roman bromeco de>
Date:   Sun Sep 11 16:49:18 2011 +1000

    Bootstrapping unittests to test the XMPModel.

 configure.ac                                |    2 +
 plug-ins/metadata/Makefile.am               |    3 +
 plug-ins/metadata/tests/.gitignore          |    5 ++
 plug-ins/metadata/tests/Makefile.am         |   48 ++++++++++++
 plug-ins/metadata/tests/files/Makefile.am   |    2 +
 plug-ins/metadata/tests/files/photoshop.xmp |   89 +++++++++++++++++++++++
 plug-ins/metadata/tests/files/test.xmp      |   25 +++++++
 plug-ins/metadata/tests/test-xmp-model.c    |  103 +++++++++++++++++++++++++++
 8 files changed, 277 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index dd82502..9ea6fa4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2240,6 +2240,8 @@ plug-ins/lighting/images/Makefile
 plug-ins/map-object/Makefile
 plug-ins/maze/Makefile
 plug-ins/metadata/Makefile
+plug-ins/metadata/tests/Makefile
+plug-ins/metadata/tests/files/Makefile
 plug-ins/pagecurl/Makefile
 plug-ins/print/Makefile
 plug-ins/pygimp/Makefile
diff --git a/plug-ins/metadata/Makefile.am b/plug-ins/metadata/Makefile.am
index 8babc5f..6bca0f4 100644
--- a/plug-ins/metadata/Makefile.am
+++ b/plug-ins/metadata/Makefile.am
@@ -1,4 +1,7 @@
 ## Process this file with automake to produce Makefile.in
+SUBDIRS = \
+       tests
+
 
 libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la
 libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la
diff --git a/plug-ins/metadata/tests/.gitignore b/plug-ins/metadata/tests/.gitignore
new file mode 100644
index 0000000..1c15490
--- /dev/null
+++ b/plug-ins/metadata/tests/.gitignore
@@ -0,0 +1,5 @@
+/Makefile
+/Makefile.in
+/.deps
+/.libs
+test-xmp-model
diff --git a/plug-ins/metadata/tests/Makefile.am b/plug-ins/metadata/tests/Makefile.am
new file mode 100644
index 0000000..067092f
--- /dev/null
+++ b/plug-ins/metadata/tests/Makefile.am
@@ -0,0 +1,48 @@
+SUBDIRS = \
+       files
+
+libgimpui = $(top_builddir)/libgimp/libgimpui-$(GIMP_API_VERSION).la
+libgimpwidgets = $(top_builddir)/libgimpwidgets/libgimpwidgets-$(GIMP_API_VERSION).la
+libgimp = $(top_builddir)/libgimp/libgimp-$(GIMP_API_VERSION).la
+libgimpconfig = $(top_builddir)/libgimpconfig/libgimpconfig-$(GIMP_API_VERSION).la
+libgimpcolor = $(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
+libgimpbase = $(top_builddir)/libgimpbase/libgimpbase-$(GIMP_API_VERSION).la
+libgimpmath = $(top_builddir)/libgimpmath/libgimpmath-$(GIMP_API_VERSION).la
+
+
+LDADD = \
+       $(libgimpui)            \
+       $(libgimpwidgets)       \
+       $(libgimp)              \
+       $(libgimpmath)          \
+       $(libgimpconfig)        \
+       $(libgimpcolor)         \
+       $(libgimpbase)          \
+       $(GLIB_LIBS)
+
+
+INCLUDES = \
+       -I$(top_srcdir) \
+       $(GTK_CFLAGS)   \
+       $(EXIF_CFLAGS)  \
+       -I$(includedir) \
+       -I ../
+
+
+TESTS = test-xmp-model$(EXEEXT)
+
+EXTRA_PROGRAMS = $(TESTS)
+
+test_xmp_model_SOURCES = \
+       test-xmp-model.c        \
+       ../base64.c             \
+       ../base64.h             \
+       ../xmp-parse.c          \
+       ../xmp-parse.h          \
+       ../xmp-schemas.c        \
+       ../xmp-schemas.h        \
+       ../xmp-model.c          \
+       ../xmp-model.h
+
+CLEANFILES = $(EXTRA_PROGRAMS)
+
diff --git a/plug-ins/metadata/tests/files/Makefile.am b/plug-ins/metadata/tests/files/Makefile.am
new file mode 100644
index 0000000..d115213
--- /dev/null
+++ b/plug-ins/metadata/tests/files/Makefile.am
@@ -0,0 +1,2 @@
+EXTRA_DIST = \
+           test.xmp
diff --git a/plug-ins/metadata/tests/files/photoshop.xmp b/plug-ins/metadata/tests/files/photoshop.xmp
new file mode 100644
index 0000000..443e6f9
--- /dev/null
+++ b/plug-ins/metadata/tests/files/photoshop.xmp
@@ -0,0 +1,89 @@
+<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
+<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.1-c036 46.276720, Mon Feb 19 2007 22:40:08     
   ">
+   <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";>
+      <rdf:Description rdf:about=""
+            xmlns:dc="http://purl.org/dc/elements/1.1/";>
+         <dc:format>application/vnd.adobe.photoshop</dc:format>
+         <dc:title>
+            <rdf:Alt>
+               <rdf:li xml:lang="x-default">Document Title</rdf:li>
+            </rdf:Alt>
+         </dc:title>
+         <dc:creator>
+            <rdf:Seq>
+               <rdf:li>Roman Joost</rdf:li>
+            </rdf:Seq>
+         </dc:creator>
+         <dc:description>
+            <rdf:Alt>
+               <rdf:li xml:lang="x-default">This is an example export from Photoshop</rdf:li>
+            </rdf:Alt>
+         </dc:description>
+         <dc:subject>
+            <rdf:Bag>
+               <rdf:li>Test</rdf:li>
+               <rdf:li>Image</rdf:li>
+               <rdf:li>Photoshop</rdf:li>
+            </rdf:Bag>
+         </dc:subject>
+         <dc:rights>
+            <rdf:Alt>
+               <rdf:li xml:lang="x-default">Don't copy!</rdf:li>
+            </rdf:Alt>
+         </dc:rights>
+      </rdf:Description>
+      <rdf:Description rdf:about=""
+            xmlns:xap="http://ns.adobe.com/xap/1.0/";>
+         <xap:CreatorTool>Adobe Photoshop CS3 Windows</xap:CreatorTool>
+         <xap:CreateDate>2011-09-09T11:34:36+10:00</xap:CreateDate>
+         <xap:ModifyDate>2011-09-09T11:34:36+10:00</xap:ModifyDate>
+         <xap:MetadataDate>2011-09-09T11:34:36+10:00</xap:MetadataDate>
+      </rdf:Description>
+      <rdf:Description rdf:about=""
+            xmlns:xapMM="http://ns.adobe.com/xap/1.0/mm/";>
+         <xapMM:DocumentID>uuid:E50AF9014DB3E0118751F8D311BA6F96</xapMM:DocumentID>
+         <xapMM:InstanceID>uuid:E50AF9014DB3E0118751F8D311BA6F96</xapMM:InstanceID>
+      </rdf:Description>
+      <rdf:Description rdf:about=""
+            xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/";>
+         <photoshop:ColorMode>0</photoshop:ColorMode>
+         <photoshop:AuthorsPosition>Mr</photoshop:AuthorsPosition>
+         <photoshop:DateCreated>2011-09-09</photoshop:DateCreated>
+         <photoshop:City>Brisbane</photoshop:City>
+         <photoshop:State>QLD</photoshop:State>
+         <photoshop:Country>Australia</photoshop:Country>
+      </rdf:Description>
+      <rdf:Description rdf:about=""
+            xmlns:xapRights="http://ns.adobe.com/xap/1.0/rights/";>
+         <xapRights:Marked>True</xapRights:Marked>
+         <xapRights:WebStatement>http://www.gimp.org</xapRights:WebStatement>
+      </rdf:Description>
+      <rdf:Description rdf:about=""
+            xmlns:illustrator="http://ns.adobe.com/illustrator/1.0/";>
+         <illustrator:StartupProfile>Print</illustrator:StartupProfile>
+      </rdf:Description>
+   </rdf:RDF>
+</x:xmpmeta>
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                                                                                                    
+                           
+<?xpacket end="w"?>
+
diff --git a/plug-ins/metadata/tests/files/test.xmp b/plug-ins/metadata/tests/files/test.xmp
new file mode 100644
index 0000000..774e439
--- /dev/null
+++ b/plug-ins/metadata/tests/files/test.xmp
@@ -0,0 +1,25 @@
+<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
+<x:xmpmeta xmlns:x='adobe:ns:meta/'>
+<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
+
+ <rdf:Description xmlns:dc='http://purl.org/dc/elements/1.1/'>
+  <dc:title>
+   <rdf:Alt>
+    <rdf:li xml:lang='x-default'>image title</rdf:li>
+   </rdf:Alt>
+  </dc:title>
+  <dc:creator>
+   <rdf:Seq>
+    <rdf:li>roman</rdf:li>
+   </rdf:Seq>
+  </dc:creator>
+  <dc:description>
+   <rdf:Alt>
+    <rdf:li xml:lang='x-default'>bla</rdf:li>
+   </rdf:Alt>
+  </dc:description>
+ </rdf:Description>
+
+</rdf:RDF>
+</x:xmpmeta>
+<?xpacket end='r'?>
diff --git a/plug-ins/metadata/tests/test-xmp-model.c b/plug-ins/metadata/tests/test-xmp-model.c
new file mode 100644
index 0000000..98bf81c
--- /dev/null
+++ b/plug-ins/metadata/tests/test-xmp-model.c
@@ -0,0 +1,103 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 2011 Róman Joost <romanofski gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <string.h>
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+#include "xmp-parse.h"
+#include "xmp-encode.h"
+#include "xmp-model.h"
+
+
+#define ADD_TEST(function) \
+  g_test_add ("/metadata-xmp-model/" #function, \
+              GimpTestFixture, \
+              NULL, \
+              gimp_test_xmp_model_setup, \
+              function, \
+              gimp_test_xmp_model_teardown);
+
+
+typedef struct
+{
+  XMPModel *xmpmodel;
+} GimpTestFixture;
+
+
+static void gimp_test_xmp_model_setup       (GimpTestFixture *fixture,
+                                             gconstpointer    data);
+static void gimp_test_xmp_model_teardown    (GimpTestFixture *fixture,
+                                             gconstpointer    data);
+
+
+/**
+ * gimp_test_xmp_model_setup:
+ * @fixture: GimpTestFixture fixture
+ * @data:
+ *
+ * Test fixture to setup an XMPModel.
+ **/
+static void
+gimp_test_xmp_model_setup (GimpTestFixture *fixture,
+                           gconstpointer    data)
+{
+  fixture->xmpmodel = xmp_model_new ();
+}
+
+
+static void
+gimp_test_xmp_model_teardown (GimpTestFixture *fixture,
+                              gconstpointer    data)
+{
+  g_object_unref (fixture->xmpmodel);
+}
+
+
+/**
+ * test_xmp_model_is_empty:
+ * @fixture:
+ * @data:
+ *
+ * Test to assert that newly created models are empty
+ **/
+static void
+test_xmp_model_is_empty (GimpTestFixture *fixture,
+                         gconstpointer    data)
+{
+  XMPModel *xmpmodel;
+
+  xmpmodel = xmp_model_new ();
+
+  g_assert (xmp_model_is_empty (xmpmodel));
+}
+
+
+int main(int argc, char **argv)
+{
+  gint result = -1;
+
+  g_type_init();
+  g_test_init (&argc, &argv, NULL);
+
+  ADD_TEST (test_xmp_model_is_empty);
+
+  result = g_test_run ();
+
+  return result;
+}


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