]> saetta.ns0.it Git - reptool/libreptool/commitdiff
Putted more order to tests (refs #178).
authorAndrea Zagli <azagli@libero.it>
Wed, 2 Nov 2011 17:09:04 +0000 (18:09 +0100)
committerAndrea Zagli <azagli@libero.it>
Wed, 2 Nov 2011 17:09:04 +0000 (18:09 +0100)
20 files changed:
.gitignore
tests/Makefile.am
tests/creation.c [new file with mode: 0644]
tests/db.rpt [new file with mode: 0644]
tests/gtktreeview.c [new file with mode: 0644]
tests/liststore.c [new file with mode: 0644]
tests/mm.rptr [new file with mode: 0644]
tests/newline.rpt [new file with mode: 0644]
tests/report.rpt [new file with mode: 0644]
tests/rptprint.c [new file with mode: 0644]
tests/rptreport.c [new file with mode: 0644]
tests/rptreport_gtktreeview.c [deleted file]
tests/test_report.rpt [deleted file]
tests/test_report_db.rpt [deleted file]
tests/test_report_newline.rpt [deleted file]
tests/test_rptprint.c [deleted file]
tests/test_rptprint_mm.rptr [deleted file]
tests/test_rptreport.c [deleted file]
tests/test_rptreport_creation.c [deleted file]
tests/test_rptreport_liststore.c [deleted file]

index 237bf03360f94078b9902b8d0dcabb98d190cadc..cdc3c5078c14d751bdf51e1a90ee15a0da16ddcc 100644 (file)
@@ -46,12 +46,13 @@ stamp-h1
 src/parser.tab.[ch]
 tests/test*.png
 tests/*.pdf
-tests/rptreport_gtktreeview
+tests/gtktreeview
+tests/test_report.rpt
 tests/test_report.rptr
-tests/test_rptprint
-tests/test_rptreport
-tests/test_rptreport_creation
-tests/test_rptreport_liststore
+tests/rptprint
+tests/rptreport
+tests/creation
+tests/liststore
 tests/test_report_created*
 POTFILES
 mkinstalldirs
index 1dc29519972992479e09b2b209dd82844d38c986..9ec6cf4456fe0c3547e93e2b322d667caee6f6b4 100644 (file)
@@ -6,16 +6,18 @@ AM_CPPFLAGS = $(REPTOOL_CFLAGS) \
 libreptool = $(top_builddir)/src/libreptool.la
 
 noinst_PROGRAMS = \
-                  test_rptreport \
-                  test_rptprint \
-                  test_rptreport_creation \
-                  test_rptreport_liststore \
-                  rptreport_gtktreeview
+                  rptreport \
+                  rptprint \
+                  creation \
+                  liststore \
+                  gtktreeview
 
 LDADD = $(libreptool)
 
 EXTRA_DIST = \
-             test_report.rpt \
-             test_report_db.rpt \
-             test_rptprint.rptr \
-             db_test.db
+             report.rpt \
+             db.rpt \
+             mm.rptr \
+             newline.rpt \
+             db_test.db \
+             gnome-globe.png
diff --git a/tests/creation.c b/tests/creation.c
new file mode 100644 (file)
index 0000000..7f05ab1
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2007-2011 Andrea Zagli <azagli@inwind.it>
+ *
+ * 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 2 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 Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#include <rptreport.h>
+#include <rptprint.h>
+#include <rptobject.h>
+#include <rptobjectellipse.h>
+#include <rptobjectimage.h>
+#include <rptobjectline.h>
+#include <rptobjectrect.h>
+#include <rptobjecttext.h>
+
+int
+main (int argc, char **argv)
+{
+       RptReport *rptr;
+       RptPrint *rptp;
+       RptObject *obj;
+       RptPoint point;
+       RptSize size;
+       RptStroke stroke;
+       RptColor *color;
+
+       g_type_init ();
+
+       rptr = rpt_report_new ();
+
+       if (rptr != NULL)
+               {
+                       g_object_set (G_OBJECT (rptr), "unit-length", 3, NULL);
+
+                       size.width = 210;
+                       size.height = 297;
+                       rpt_report_set_page_size (rptr, size);
+
+                       point.x = 10;
+                       point.y = 10;
+                       obj = rpt_obj_text_new ("text1", point);
+                       size.width = 210;
+                       size.height = 50;
+                       g_object_set (obj,
+                                     "source", "\"The first object inserted.\"",
+                                     "size", &size,
+                                     NULL);
+                       rpt_report_add_object_to_section (rptr, obj, RPTREPORT_SECTION_BODY);
+
+                       point.x = 10;
+                       point.y = 60;
+                       obj = rpt_obj_line_new ("line1", point);
+                       size.width = 210;
+                       size.height = 0;
+                       stroke.color = rpt_common_parse_color ("#FF0000");
+                       stroke.style = NULL;
+                       g_object_set (obj,
+                                     "size", &size,
+                                     "stroke", &stroke,
+                                     NULL);
+                       rpt_report_add_object_to_section (rptr, obj, RPTREPORT_SECTION_BODY);
+
+                       point.x = 0;
+                       point.y = 0;
+                       obj = rpt_obj_line_new ("line2", point);
+                       size.width = 210;
+                       size.height = 297;
+                       stroke.color = rpt_common_parse_color ("#000000AA");
+                       stroke.style = NULL;
+                       g_object_set (obj,
+                                     "size", &size,
+                                     "stroke", &stroke,
+                                     NULL);
+                       rpt_report_add_object_to_section (rptr, obj, RPTREPORT_SECTION_BODY);
+
+                       point.x = 210;
+                       point.y = 0;
+                       obj = rpt_obj_line_new ("line3", point);
+                       size.width = -210;
+                       size.height = 297;
+                       stroke.color = rpt_common_parse_color ("#000000AA");
+                       g_object_set (obj,
+                                     "size", &size,
+                                     "stroke", &stroke,
+                                     NULL);
+                       rpt_report_add_object_to_section (rptr, obj, RPTREPORT_SECTION_BODY);
+
+                       point.x = 105;
+                       point.y = 148.5;
+                       obj = rpt_obj_ellipse_new ("circle1", point);
+                       size.width = 50;
+                       size.height = 50;
+                       color = rpt_common_parse_color ("#00FF0099");
+                       stroke.color = rpt_common_parse_color ("#00FF00AA");
+                       stroke.style = NULL;
+                       g_object_set (obj,
+                                     "size", &size,
+                                     "stroke", &stroke,
+                                     "fill-color", color,
+                                     NULL);
+                       rpt_report_add_object_to_section (rptr, obj, RPTREPORT_SECTION_BODY);
+
+                       point.x = 50;
+                       point.y = 200;
+                       obj = rpt_obj_image_new ("image1", point);
+                       size.width = 100;
+                       size.height = 100;
+                       g_object_set (obj,
+                                     "size", &size,
+                                     "source", "gnome-globe.png",
+                                     NULL);
+                       rpt_report_add_object_to_section (rptr, obj, RPTREPORT_SECTION_BODY);
+
+                       xmlDoc *report = rpt_report_get_xml (rptr);
+                       xmlSaveFormatFileEnc ("test_report_created.rpt", report, "UTF-8", 2);
+
+                       xmlDoc *rptprint = rpt_report_get_xml_rptprint (rptr);
+                       xmlSaveFormatFileEnc ("test_report_created.rptr", rptprint, "UTF-8", 2);
+               
+                       rptp = rpt_print_new_from_xml (rptprint);
+                       if (rptp != NULL)
+                               {
+                                       rpt_print_set_output_type (rptp, RPT_OUTPUT_PDF);
+                                       rpt_print_set_output_filename (rptp, "test_report_created.pdf");
+                                       rpt_print_print (rptp, NULL);
+                               }
+               }
+
+       return 0;
+}
diff --git a/tests/db.rpt b/tests/db.rpt
new file mode 100644 (file)
index 0000000..8852066
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" ?>
+<reptool>
+       <page width="595" height="842" />
+
+       <database>
+               <provider>SQLite</provider>
+               <!-- connection-string must be changed to your libretool source directory because SQLite wants an absolute path -->
+               <connection-string>DB_DIR=.;DB_NAME=db_test.db</connection-string>
+               <sql>SELECT * FROM articles ORDER BY name</sql>
+       </database>
+
+       <report>
+               <report-header height="80">
+                       <text name="rephead" x="10" y="10" width="300" height="70" visible="y" font-name="Verdana" font-size="16" font-bold="y" font-underline="y" font-color="#0000FF" source="&quot;the report's header&quot;" />
+               </report-header>
+               <page-header height="80" first-page="y">
+                       <text name="title" x="10" y="10" width="300" height="50" visible="y" font-name="Courier New" font-size="10" font-bold="y" source="&quot;the page's title&quot; &amp; &quot; - &quot; &amp; @Page" />
+                       <line name="line1" x="10" y="65" width="500" height="0" visible="y" stroke-width="1.0" />
+               </page-header>
+               <body height="200">
+                       <text name="txt_id" x="50" y="50" width="100" height="50" visible="y" border-top-width="1.0" border-top-color="#FF0000" source="[id]" fill-with="." />
+                       <text name="txt_name" x="200" y="50" width="100" height="50" visible="y" source="[name]" />
+                       <text name="txt_req" x="50" y="100" width="100" height="50" visible="y" source="[nonexistent]" />
+                       <rect name="rect1" x="400" y="10" width="20" height="20" visible="y" fill-color="#00FF00" />
+                       <image name="img1" x="450" y="10" width="60" height="60" visible="y" border-bottom-width="1.0" border-bottom-color="#FF0000" border-bottom-style="10;10" source="tests/gnome-globe.png" />
+               </body>
+               <report-footer height="50">
+                       <line name="line3" x="10" y="10" width="500" height="0" visible="y" stroke-color="#FFFF00" stroke-style="50;10" />
+                       <text name="txt_report_footer" x="10" y="20" width="500" height="30" visible="y" horizontal-align="center" source="&quot;the report's footer&quot;" />
+                       <line name="line4" x="10" y="50" width="500" height="0" visible="y" stroke-color="#FFFF00" stroke-style="1;5" />
+               </report-footer>
+               <page-footer height="80" first-page="y" last-page="y">
+                       <line name="line2" x="10" y="10" width="500" height="0" visible="y" />
+                       <text name="footer" x="10" y="20" width="300" height="50" visible="y" source="&quot;the page's footer&quot;" />
+                       <ellipse name="ellipse1" x="400" y="50" width="20" height="10" visible="y" stroke-color="#FF0000" fill-color="#00FF00" />
+                       <text name="page_n" x="500" y="20" width="50" height="50" visible="y" source="@Page &amp; &quot;/&quot; &amp; @Pages" />
+               </page-footer>
+       </report>
+</reptool>
diff --git a/tests/gtktreeview.c b/tests/gtktreeview.c
new file mode 100644 (file)
index 0000000..76dc3b6
--- /dev/null
@@ -0,0 +1,140 @@
+/*
+ * Copyright (C) 2011 Andrea Zagli <azagli@libero.it>
+ *
+ * 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 2 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 Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#include <rptreport.h>
+#include <rptprint.h>
+
+enum
+{
+       TITLE_COLUMN,
+       AUTHOR_COLUMN,
+       CHECKED_COLUMN,
+       N_COLUMNS
+};
+
+GtkWidget *w;
+GtkWidget *tree;
+
+gboolean
+on_w_delete_event (GtkWidget *widget,
+                   GdkEvent *event,
+                   gpointer user_data)
+{
+       return FALSE;
+}
+
+void
+on_btn_stampa_clicked (GtkButton *button, gpointer user_data)
+{
+       RptReport *rptr;
+       RptPrint *rptp;
+
+       rptr = rpt_report_new_from_gtktreeview (GTK_TREE_VIEW (tree), "\"Report's Title\"");
+
+       if (rptr != NULL)
+               {
+                       xmlDoc *report = rpt_report_get_xml (rptr);
+                       rpt_report_set_output_type (rptr, RPT_OUTPUT_GTK);
+                       xmlSaveFormatFile ("test_report.rpt", report, 2);
+
+                       xmlDoc *rptprint = rpt_report_get_xml_rptprint (rptr);
+                       xmlSaveFormatFile ("test_report.rptr", rptprint, 2);
+
+                       rptp = rpt_print_new_from_xml (rptprint);
+                       if (rptp != NULL)
+                               {
+                                       g_object_set (G_OBJECT (rptp), "path-relatives-to", "..", NULL);
+                                       rpt_print_set_output_type (rptp, RPT_OUTPUT_GTK);
+                                       rpt_print_print (rptp, GTK_WINDOW (w));
+                               }
+               }
+}
+
+int
+main (int argc, char **argv)
+{
+       gtk_init (&argc, &argv);
+
+       GtkListStore *store = gtk_list_store_new (N_COLUMNS,       /* Total number of columns */
+                                                 G_TYPE_STRING,   /* Book title              */
+                                                 G_TYPE_STRING,   /* Author                  */
+                                                 G_TYPE_BOOLEAN); /* Is checked out?         */
+
+       GtkTreeIter   iter;
+
+       gtk_list_store_append (store, &iter);  /* Acquire an iterator */
+
+       gtk_list_store_set (store, &iter,
+                           TITLE_COLUMN, "The Principle of Reason",
+                           AUTHOR_COLUMN, "Martin Heidegger",
+                           CHECKED_COLUMN, FALSE,
+                           -1);
+
+       gtk_list_store_append (store, &iter);
+       gtk_list_store_set (store, &iter,
+                           TITLE_COLUMN, "The Art of Computer Programming",
+                           AUTHOR_COLUMN, "Donald E. Knuth",
+                           CHECKED_COLUMN, FALSE,
+                           -1);
+
+       tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
+
+       GtkCellRenderer *renderer;
+       GtkTreeViewColumn *column;
+
+       renderer = gtk_cell_renderer_text_new ();
+       column = gtk_tree_view_column_new_with_attributes ("Book's title",
+                                                          renderer,
+                                                          "text", TITLE_COLUMN,
+                                                          NULL);
+       gtk_tree_view_column_set_resizable (column, TRUE);
+       gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+
+       renderer = gtk_cell_renderer_text_new ();
+       column = gtk_tree_view_column_new_with_attributes ("Author",
+                                                          renderer,
+                                                          "text", AUTHOR_COLUMN,
+                                                          NULL);
+       gtk_tree_view_column_set_resizable (column, TRUE);
+       gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
+
+       w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+       gtk_window_set_default_size (GTK_WINDOW (w), 500, 400);
+
+       g_signal_connect (w, "delete-event", G_CALLBACK (on_w_delete_event), NULL);
+       g_signal_connect (w, "destroy", gtk_main_quit, NULL);
+
+       GtkWidget *box = gtk_vbox_new (FALSE, 5);
+
+       gtk_container_add (GTK_CONTAINER (w), box);
+
+       gtk_box_pack_start (GTK_BOX (box), tree, TRUE, TRUE, 0);
+
+       GtkWidget *btn_stampa = gtk_button_new_from_stock ("gtk-print");
+
+       gtk_box_pack_start (GTK_BOX (box), btn_stampa, FALSE, FALSE, 0);
+
+       g_signal_connect (G_OBJECT (btn_stampa), "clicked",
+                         G_CALLBACK (on_btn_stampa_clicked), NULL);
+
+       gtk_widget_show_all (w);
+
+       gtk_main ();
+
+       return 0;
+}
diff --git a/tests/liststore.c b/tests/liststore.c
new file mode 100644 (file)
index 0000000..27458dc
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2011 Andrea Zagli <azagli@libero.it>
+ *
+ * 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 2 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 Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#include <rptreport.h>
+#include <rptprint.h>
+
+gchar
+*field_request (RptReport *rpt_report,
+                gchar *field_name,
+                GdaDataModel *data_model,
+                gint row,
+                GtkTreeModel *treemodel,
+                GtkTreeIter *iter,
+                gpointer user_data)
+{
+       gchar *ret = NULL;
+
+       if (g_strcmp0 (field_name, "nonexistent") == 0 &&
+           treemodel != NULL &&
+           iter != NULL)
+               {
+                       gint id;
+                       gchar *name;
+
+                       gtk_tree_model_get (treemodel, iter,
+                                           0, &id,
+                                           1, &name,
+                                           -1);
+
+                       ret = g_strdup_printf ("%d - %s", id, name);
+               }
+
+       return ret;
+}
+
+int
+main (int argc, char **argv)
+{
+       RptReport *rptr;
+       RptPrint *rptp;
+
+       GtkListStore *model;
+       GtkTreeIter iter;
+       GHashTable *columns_names;
+
+       g_type_init ();
+
+       rptr = rpt_report_new_from_file (argv[1]);
+
+       model = gtk_list_store_new (2,
+                                   G_TYPE_INT,
+                                   G_TYPE_STRING);
+
+       gtk_list_store_append (model, &iter);
+       gtk_list_store_set (model, &iter,
+                           0, 1,
+                           1, "Mary Jane Red",
+                           -1);
+
+       gtk_list_store_append (model, &iter);
+       gtk_list_store_set (model, &iter,
+                           0, 2,
+                           1, "John Doe",
+                           -1);
+
+       gtk_list_store_append (model, &iter);
+       gtk_list_store_set (model, &iter,
+                           0, 3,
+                           1, "Elene McArty",
+                           -1);
+
+       gtk_list_store_append (model, &iter);
+       gtk_list_store_set (model, &iter,
+                           0, 4,
+                           1, "Raul Bread",
+                           -1);
+
+       columns_names = g_hash_table_new (g_str_hash, g_str_equal);
+       g_hash_table_insert (columns_names, "id", "0");
+       g_hash_table_insert (columns_names, "name", "1");
+
+       rpt_report_set_database_as_gtktreemodel (rptr, GTK_TREE_MODEL (model), columns_names);
+
+       g_signal_connect (rptr, "field-request", G_CALLBACK (field_request), NULL);
+
+       if (rptr != NULL)
+               {
+                       rpt_report_set_output_type (rptr, RPT_OUTPUT_PNG);
+                       rpt_report_set_output_filename (rptr, "test.png");
+
+                       xmlDoc *report = rpt_report_get_xml (rptr);
+                       xmlSaveFormatFile ("test_report.rpt", report, 2);
+
+                       xmlDoc *rptprint = rpt_report_get_xml_rptprint (rptr);
+                       xmlSaveFormatFile ("test_report.rptr", rptprint, 2);
+               
+                       rptp = rpt_print_new_from_xml (rptprint);
+                       if (rptp != NULL)
+                               {
+                                       g_object_set (G_OBJECT (rptp), "path-relatives-to", "..", NULL);
+
+                                       rpt_print_print (rptp, NULL);
+                               }
+               }
+
+       return 0;
+}
diff --git a/tests/mm.rptr b/tests/mm.rptr
new file mode 100644 (file)
index 0000000..cdf540d
--- /dev/null
@@ -0,0 +1,25 @@
+<?xml version="1.0" ?>
+<reptool_report>
+       <properties>
+               <unit-length>mm</unit-length>
+       </properties>
+       <page width="210" height="297">
+               <text x="10" y="20" width="210" height="100" visible="y" border-top-width="2.83" border-bottom-width="2.83" font-size="12" font-color="#0F0" border-top="2.83" border-bottom="2.83">Text sample</text>
+               <!--<line x="10" y="300" width="100" height="0" visible="y" stroke-color="#F00" />
+               <image x="250" y="180" width="300" height="200" visible="y" border-top-width="1.0" border-right-width="1.0" border-bottom-width="1.0" border-left-width="1.0" source="tests/city.png" />
+               <rect x="10" y="500" width="400" height="10" visible="y" fill-color="#00F" />
+               <text x="10" y="400" width="100" height="50" visible="y" border-top-width="1.0" border-right-width="1.0" border-bottom-width="1.0" border-left-width="1.0" border-top-color="#FF0000" border-right-color="#FF0000" border-bottom-color="#FF0000" border-left-color="#FF0000" background-color="#000000" font-color="#FFFFFF">White on black</text>
+       </page>
+
+       <page width="595" height="842">
+               <text x="10" y="300" width="300" height="800" visible="y" font-size="30" font-color="#FF0">Text sample on second page</text>
+               <line x="10" y="300" width="100" height="0" visible="y" stroke-color="#0F0" />
+               <ellipse x="200" y="700" width="100" height="30" visible="y" stroke-color="#FF0000" fill-color="#0000FF" />
+               <text x="350" y="20" width="200" height="100" visible="y" font-underline="single">Underline single</text>
+               <text x="350" y="120" width="200" height="100" visible="y" font-underline="double">Underline double</text>
+               <text x="350" y="220" width="200" height="100" visible="y" font-underline="low">Underline low</text>
+               <text x="350" y="320" width="200" height="100" visible="y" font-underline="error">Underline error</text>
+               <text x="350" y="420" width="200" height="100" visible="y" font-bold="y" font-color="#FF0000" font-strike="y">Text striked and bold</text>
+               <text x="350" y="520" width="200" height="100" visible="y" font-italic="y">Text italic</text>-->
+       </page>
+</reptool_report>
diff --git a/tests/newline.rpt b/tests/newline.rpt
new file mode 100644 (file)
index 0000000..639bf14
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<reptool>
+  <properties>
+    <name>Newline test</name>
+    <description>A report to test if the newline character (#10) works</description>
+  </properties>
+  <page width="595.000000" height="842.000000" margin-left="100.000000" margin-top="200.000000"/>
+  <report>
+    <body>
+      <text name="txt_id" visible="y" x="50.000000" y="50.000000" width="100.000000" height="50.000000" border-top-width="1.000000" border-top-color="#FF0000FF" font-name="Sans" font-size="12.000000" source="&quot;text with&#10;new line&quot;"/>
+      <text name="txt_invisible" visible="y" x="50.000000" y="250.000000" width="100.000000" height="50.000000" border-top-width="1.000000" border-top-color="#FF0000FF" font-name="Sans" font-size="12.000000" source="&quot;text with&#10;new line&quot;" letter-spacing="20"/>
+      <text name="txt_long" visible="y" x="50.000000" y="350.000000" width="300.000000" height="50.000000" border-top-width="1.000000" border-top-color="#FF0000FF" border-right-width="1" border-right-color="#000" font-name="Sans" font-size="12.000000" source="&quot;text with new line&quot;" fill-with="."/>
+      <text name="txt_dot" visible="y" x="50.000000" y="400.000000" width="300.000000" height="50.000000" border-top-width="1.000000" border-top-color="#FF0000FF" font-name="Sans" font-size="12.000000" source="&quot;.&quot;"/>
+      <text name="txt_long_with_spacing" visible="y" x="0.000000" y="450.000000" width="400.000000" height="50.000000" border-top-width="1.000000" border-top-color="#FF0000FF" font-name="Sans" font-size="12.000000" source="&quot;text with&#10;new line&quot;" letter-spacing="10"/>
+      <text name="txt_date" visible="y" x="0.000000" y="500.000000" width="400.000000" height="50.000000" font-name="Sans" font-size="12.000000" source="@Date{%d/%m/%Y} &amp; &quot; &quot; &amp; @Time{%H.%M.%S}" letter-spacing="10"/>
+    </body>
+  </report>
+</reptool>
diff --git a/tests/report.rpt b/tests/report.rpt
new file mode 100644 (file)
index 0000000..708e4f2
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" ?>
+<reptool>
+       <page width="595" height="842" margin-top="50" margin-left="100" margin-right="10" />
+
+       <report>
+               <body height="800">
+                       <text name="text4" x="-50" y="10" width="500" height="150" visible="y" source="&quot;text outside from left&quot;" />
+                       <text name="text1" x="100" y="50" width="500" height="150" visible="y" source="&quot;the text's content&quot;" />
+                       <text name="date" x="100" y="150" width="500" height="150" visible="y" source="@Date" />
+                       <text name="time" x="100" y="250" width="500" height="150" visible="y" source="@Time" />
+                       <text name="text2" x="100" y="350" width="200" height="100" visible="y" 
+                               border-top-width="1.0" border-right-width="1.0" border-bottom-width="1.0" border-left-width="1.0"
+                               padding-top="20" padding-right="20" padding-bottom="20" padding-left="10"
+                               source="&quot;text very very long to try padding and border&quot;" />
+                       <text name="text3" x="400" y="350" width="200" height="50" visible="y" source="&quot;another long text to test page margins&quot;" />
+                       <text name="text5" x="50" y="460" width="200" height="50" visible="y" source="[field_to_request]" />
+                       <text name="text6" x="50" y="600" width="200" height="50" visible="y" 
+                               border-top-width="1.0" border-right-width="1.0" border-bottom-width="1.0" border-left-width="1.0"
+                               border-bottom-style="10"
+                               rotation="45" source="&quot;Rotated text&quot;" />
+                       <line name="line1" x="350" y="50" width="200" height="0" visible="y" rotation="-45" />
+                       <rect name="rect1" x="350" y="250" width="200" height="50" visible="y" fill-color="#FFFF00" rotation="45" stroke-style="10" />
+                       <image name="image1" x="200" y="460" width="200" height="150" visible="y" 
+                               border-top-width="1.0" border-right-width="1.0" border-bottom-width="1.0" border-left-width="1.0"
+                               border-top-color="#FF0000" border-right-color="#FF0000" border-bottom-color="#FF0000" border-left-color="#FF0000"
+                               rotation="135" source="tests/city.png" />
+               </body>
+       </report>
+</reptool>
diff --git a/tests/rptprint.c b/tests/rptprint.c
new file mode 100644 (file)
index 0000000..8b56093
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2006-2011 Andrea Zagli <azagli@libero.it>
+ *
+ * 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 2 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 Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#include <rptprint.h>
+
+static gchar *rptr_file_name = NULL;
+static gchar *output_type = NULL;
+static gchar *output_file_name = NULL;
+
+static GOptionEntry entries[] =
+{
+       { "rptr-file-name", 'r', 0, G_OPTION_ARG_STRING, &rptr_file_name, "RptPrint definition file name", "RPTR_FILE_NAME" },
+       { "output-type", 'o', 0, G_OPTION_ARG_STRING, &output_type, "Output type (png | pdf | ps | svg | gtk | gtk-default)", "OUTPUT-TYPE" },
+       { "output-file-name", 'f', 0, G_OPTION_ARG_FILENAME, &output_file_name, "Output file name", "FILE-NAME" },
+       { NULL }
+};
+
+int
+main (int argc, char **argv)
+{
+       GError *error;
+       GOptionContext *context;
+
+       RptPrint *rptp;
+
+       g_type_init ();
+
+       context = g_option_context_new ("- test rptprint");
+       g_option_context_add_main_entries (context, entries, NULL);
+
+       error = NULL;
+       if (!g_option_context_parse (context, &argc, &argv, &error)
+           || error != NULL)
+               {
+                       g_error ("Option parsing failed: %s.", error != NULL && error->message != NULL ? error->message : "no details");
+                       return 0;
+               }
+
+       rptp = rpt_print_new_from_file (rptr_file_name);
+
+       if (rptp != NULL)
+               {
+                       rpt_print_set_output_type (rptp, rpt_common_stroutputtype_to_enum (output_type));
+                       if (g_strcmp0 (output_type, "png") == 0
+                           || g_strcmp0 (output_type, "pdf") == 0
+                           || g_strcmp0 (output_type, "ps") == 0
+                           || g_strcmp0 (output_type, "svg") == 0)
+                               {
+                                       rpt_print_set_output_filename (rptp, output_file_name == NULL ? g_strdup_printf ("test.%s", output_type) : output_file_name);
+                               }
+                       rpt_print_print (rptp, NULL);
+               }
+       else
+               {
+                       g_error ("Error on creating RptPrint object.");
+                       return 0;
+               }
+
+       return 0;
+}
diff --git a/tests/rptreport.c b/tests/rptreport.c
new file mode 100644 (file)
index 0000000..bc0dfde
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+ * Copyright (C) 2007-2011 Andrea Zagli <azagli@libero.it>
+ *
+ * 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 2 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 Library General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
+ */
+
+#include <rptreport.h>
+#include <rptprint.h>
+
+static gchar *rpt_file_name = NULL;
+static gchar *xml_rpt_file_name = NULL;
+static gchar *xml_rptr_file_name = NULL;
+static gchar *path_relatives_to  = NULL;
+static gchar *output_type = NULL;
+static gchar *output_file_name = NULL;
+
+static GOptionEntry entries[] =
+{
+       { "rpt-file-name", 'r', 0, G_OPTION_ARG_STRING, &rpt_file_name, "RptReport definition file name", "RPT_FILE_NAME" },
+       { "xml-report-file-name", 'x', 0, G_OPTION_ARG_FILENAME, &xml_rpt_file_name, "RptReport xml output file name", "FILE-NAME" },
+       { "xml-print-file-name", 'p', 0, G_OPTION_ARG_FILENAME, &xml_rptr_file_name, "RptPrint xml output file name", "FILE-NAME" },
+       { "path-relatives-to", 't', 0, G_OPTION_ARG_FILENAME, &path_relatives_to, "Path relatives to", "FILE-NAME" },
+       { "output-type", 'o', 0, G_OPTION_ARG_STRING, &output_type, "Output type (png | pdf | ps | svg | gtk | gtk-default)", "OUTPUT-TYPE" },
+       { "output-file-name", 'f', 0, G_OPTION_ARG_FILENAME, &output_file_name, "Output file name", "FILE-NAME" },
+       { NULL }
+};
+
+gchar
+*field_request (RptReport *rpt_report,
+                gchar *field_name,
+                GdaDataModel *data_model,
+                gint row,
+                GtkTreeModel *treemodel,
+                GtkTreeIter *iter,
+                gpointer user_data)
+{
+       gchar *ret = NULL;
+
+       if (g_strcmp0 (field_name, "field_to_request") == 0)
+               {
+                       ret = g_strdup ("the field requested");
+               }
+       else if (g_strcmp0 (field_name, "nonexistent") == 0 &&
+                data_model != NULL &&
+                row > -1)
+               {
+                       ret = g_strdup_printf ("%s - %s",
+                                              gda_value_stringify (gda_data_model_get_value_at (data_model, 0, row, NULL)),
+                                              gda_value_stringify (gda_data_model_get_value_at (data_model, 1, row, NULL)));
+               }
+
+       return ret;
+}
+
+int
+main (int argc, char **argv)
+{
+       GError *error;
+       GOptionContext *context;
+
+       RptReport *rptr;
+       RptPrint *rptp;
+
+       g_type_init ();
+
+       context = g_option_context_new ("- test rptprint");
+       g_option_context_add_main_entries (context, entries, NULL);
+
+       error = NULL;
+       if (!g_option_context_parse (context, &argc, &argv, &error)
+           || error != NULL)
+               {
+                       g_error ("Option parsing failed: %s.", error != NULL && error->message != NULL ? error->message : "no details");
+                       return 0;
+               }
+
+       rptr = rpt_report_new_from_file (rpt_file_name);
+       if (rptr == NULL)
+               {
+                       g_error ("Error on creating RptReport object.");
+                       return 0;
+               }
+
+       g_signal_connect (rptr, "field-request", G_CALLBACK (field_request), NULL);
+
+       if (rptr != NULL)
+               {
+                       xmlDoc *report = rpt_report_get_xml (rptr);
+                       if (xml_rpt_file_name != NULL)
+                               {
+                                       xmlSaveFormatFileEnc (xml_rpt_file_name, report, "UTF-8", 2);
+                               }
+
+                       xmlDoc *rptprint = rpt_report_get_xml_rptprint (rptr);
+                       if (xml_rptr_file_name != NULL)
+                               {
+                                       xmlSaveFormatFileEnc (xml_rptr_file_name, rptprint, "UTF-8", 2);
+                               }
+
+                       rptp = rpt_print_new_from_xml (rptprint);
+                       if (rptp != NULL)
+                               {
+                                       if (path_relatives_to != NULL)
+                                               {
+                                                       g_object_set (G_OBJECT (rptp), "path-relatives-to", path_relatives_to, NULL);
+                                               }
+
+                                       rpt_print_set_output_type (rptp, rpt_common_stroutputtype_to_enum (output_type));
+                                       if (g_strcmp0 (output_type, "png") == 0
+                                           || g_strcmp0 (output_type, "pdf") == 0
+                                           || g_strcmp0 (output_type, "ps") == 0
+                                           || g_strcmp0 (output_type, "svg") == 0)
+                                               {
+                                                       rpt_print_set_output_filename (rptp, output_file_name == NULL ? g_strdup_printf ("test.%s", output_type) : output_file_name);
+                                               }
+                                       rpt_print_print (rptp, NULL);
+                               }
+                       else
+                               {
+                                       g_error ("Error on creating RptPrint object.");
+                                       return 0;
+                               }
+               }
+
+       return 0;
+}
diff --git a/tests/rptreport_gtktreeview.c b/tests/rptreport_gtktreeview.c
deleted file mode 100644 (file)
index 76dc3b6..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2011 Andrea Zagli <azagli@libero.it>
- *
- * 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 2 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 Library General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
- */
-
-#include <rptreport.h>
-#include <rptprint.h>
-
-enum
-{
-       TITLE_COLUMN,
-       AUTHOR_COLUMN,
-       CHECKED_COLUMN,
-       N_COLUMNS
-};
-
-GtkWidget *w;
-GtkWidget *tree;
-
-gboolean
-on_w_delete_event (GtkWidget *widget,
-                   GdkEvent *event,
-                   gpointer user_data)
-{
-       return FALSE;
-}
-
-void
-on_btn_stampa_clicked (GtkButton *button, gpointer user_data)
-{
-       RptReport *rptr;
-       RptPrint *rptp;
-
-       rptr = rpt_report_new_from_gtktreeview (GTK_TREE_VIEW (tree), "\"Report's Title\"");
-
-       if (rptr != NULL)
-               {
-                       xmlDoc *report = rpt_report_get_xml (rptr);
-                       rpt_report_set_output_type (rptr, RPT_OUTPUT_GTK);
-                       xmlSaveFormatFile ("test_report.rpt", report, 2);
-
-                       xmlDoc *rptprint = rpt_report_get_xml_rptprint (rptr);
-                       xmlSaveFormatFile ("test_report.rptr", rptprint, 2);
-
-                       rptp = rpt_print_new_from_xml (rptprint);
-                       if (rptp != NULL)
-                               {
-                                       g_object_set (G_OBJECT (rptp), "path-relatives-to", "..", NULL);
-                                       rpt_print_set_output_type (rptp, RPT_OUTPUT_GTK);
-                                       rpt_print_print (rptp, GTK_WINDOW (w));
-                               }
-               }
-}
-
-int
-main (int argc, char **argv)
-{
-       gtk_init (&argc, &argv);
-
-       GtkListStore *store = gtk_list_store_new (N_COLUMNS,       /* Total number of columns */
-                                                 G_TYPE_STRING,   /* Book title              */
-                                                 G_TYPE_STRING,   /* Author                  */
-                                                 G_TYPE_BOOLEAN); /* Is checked out?         */
-
-       GtkTreeIter   iter;
-
-       gtk_list_store_append (store, &iter);  /* Acquire an iterator */
-
-       gtk_list_store_set (store, &iter,
-                           TITLE_COLUMN, "The Principle of Reason",
-                           AUTHOR_COLUMN, "Martin Heidegger",
-                           CHECKED_COLUMN, FALSE,
-                           -1);
-
-       gtk_list_store_append (store, &iter);
-       gtk_list_store_set (store, &iter,
-                           TITLE_COLUMN, "The Art of Computer Programming",
-                           AUTHOR_COLUMN, "Donald E. Knuth",
-                           CHECKED_COLUMN, FALSE,
-                           -1);
-
-       tree = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
-
-       GtkCellRenderer *renderer;
-       GtkTreeViewColumn *column;
-
-       renderer = gtk_cell_renderer_text_new ();
-       column = gtk_tree_view_column_new_with_attributes ("Book's title",
-                                                          renderer,
-                                                          "text", TITLE_COLUMN,
-                                                          NULL);
-       gtk_tree_view_column_set_resizable (column, TRUE);
-       gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
-
-       renderer = gtk_cell_renderer_text_new ();
-       column = gtk_tree_view_column_new_with_attributes ("Author",
-                                                          renderer,
-                                                          "text", AUTHOR_COLUMN,
-                                                          NULL);
-       gtk_tree_view_column_set_resizable (column, TRUE);
-       gtk_tree_view_append_column (GTK_TREE_VIEW (tree), column);
-
-       w = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-       gtk_window_set_default_size (GTK_WINDOW (w), 500, 400);
-
-       g_signal_connect (w, "delete-event", G_CALLBACK (on_w_delete_event), NULL);
-       g_signal_connect (w, "destroy", gtk_main_quit, NULL);
-
-       GtkWidget *box = gtk_vbox_new (FALSE, 5);
-
-       gtk_container_add (GTK_CONTAINER (w), box);
-
-       gtk_box_pack_start (GTK_BOX (box), tree, TRUE, TRUE, 0);
-
-       GtkWidget *btn_stampa = gtk_button_new_from_stock ("gtk-print");
-
-       gtk_box_pack_start (GTK_BOX (box), btn_stampa, FALSE, FALSE, 0);
-
-       g_signal_connect (G_OBJECT (btn_stampa), "clicked",
-                         G_CALLBACK (on_btn_stampa_clicked), NULL);
-
-       gtk_widget_show_all (w);
-
-       gtk_main ();
-
-       return 0;
-}
diff --git a/tests/test_report.rpt b/tests/test_report.rpt
deleted file mode 100644 (file)
index 10c269d..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0"?>
-<reptool>
-  <properties>
-    <unit-length>mm</unit-length>
-    <output-type>pdf</output-type>
-    <output-filename>rptreport.pdf</output-filename>
-    <copies>1</copies>
-  </properties>
-  <database>
-    <provider/>
-    <connection-string/>
-    <sql/>
-  </database>
-  <page width="297,000000" height="210,000000" margin-top="10,000000" margin-right="10,000000" margin-bottom="10,000000" margin-left="10,000000"/>
-  <report>
-    <page-header first-page="y" last-page="y" height="27,000000">
-      <text name="title" x="0,000000" y="0,000000" width="277,000000" height="10,000000" visible="y" font-name="Droid Sans" font-size="11,000000" font-bold="y" font-color="#000000FF" source="&quot;Report's Title&quot;"/>
-      <text name="title_0" x="0,000000" y="15,000000" width="50,000000" height="10,000000" visible="y" font-name="Droid Sans" font-size="9,000000" font-bold="y" font-color="#000000FF" source="&quot;Book's title&quot;"/>
-      <text name="title_1" x="55,000000" y="15,000000" width="76,000000" height="10,000000" visible="y" font-name="Droid Sans" font-size="9,000000" font-bold="y" font-color="#000000FF" source="&quot;Author&quot;"/>
-      <line name="line1" x="0,000000" y="25,000000" width="277,000000" height="0,000000" visible="y"/>
-    </page-header>
-    <body height="15,000000">
-      <text name="field_0" x="0,000000" y="0,000000" width="50,000000" height="10,000000" visible="y" font-name="Droid Sans" font-size="9,000000" font-color="#000000FF" source="[field_0]"/>
-      <text name="field_1" x="55,000000" y="0,000000" width="76,000000" height="10,000000" visible="y" font-name="Droid Sans" font-size="9,000000" font-color="#000000FF" source="[field_1]"/>
-    </body>
-    <page-footer first-page="y" last-page="y" height="12,000000">
-      <line name="line2" x="0,000000" y="0,000000" width="277,000000" height="0,000000" visible="y"/>
-      <text name="pages" x="0,000000" y="2,000000" width="277,000000" height="10,000000" visible="y" font-name="Droid Sans" font-size="8,000000" font-color="#000000FF" horizontal-align="right" source="&quot;Page &quot; &amp; @Page &amp; &quot; of &quot; &amp; @Pages"/>
-    </page-footer>
-  </report>
-</reptool>
diff --git a/tests/test_report_db.rpt b/tests/test_report_db.rpt
deleted file mode 100644 (file)
index 8852066..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" ?>
-<reptool>
-       <page width="595" height="842" />
-
-       <database>
-               <provider>SQLite</provider>
-               <!-- connection-string must be changed to your libretool source directory because SQLite wants an absolute path -->
-               <connection-string>DB_DIR=.;DB_NAME=db_test.db</connection-string>
-               <sql>SELECT * FROM articles ORDER BY name</sql>
-       </database>
-
-       <report>
-               <report-header height="80">
-                       <text name="rephead" x="10" y="10" width="300" height="70" visible="y" font-name="Verdana" font-size="16" font-bold="y" font-underline="y" font-color="#0000FF" source="&quot;the report's header&quot;" />
-               </report-header>
-               <page-header height="80" first-page="y">
-                       <text name="title" x="10" y="10" width="300" height="50" visible="y" font-name="Courier New" font-size="10" font-bold="y" source="&quot;the page's title&quot; &amp; &quot; - &quot; &amp; @Page" />
-                       <line name="line1" x="10" y="65" width="500" height="0" visible="y" stroke-width="1.0" />
-               </page-header>
-               <body height="200">
-                       <text name="txt_id" x="50" y="50" width="100" height="50" visible="y" border-top-width="1.0" border-top-color="#FF0000" source="[id]" fill-with="." />
-                       <text name="txt_name" x="200" y="50" width="100" height="50" visible="y" source="[name]" />
-                       <text name="txt_req" x="50" y="100" width="100" height="50" visible="y" source="[nonexistent]" />
-                       <rect name="rect1" x="400" y="10" width="20" height="20" visible="y" fill-color="#00FF00" />
-                       <image name="img1" x="450" y="10" width="60" height="60" visible="y" border-bottom-width="1.0" border-bottom-color="#FF0000" border-bottom-style="10;10" source="tests/gnome-globe.png" />
-               </body>
-               <report-footer height="50">
-                       <line name="line3" x="10" y="10" width="500" height="0" visible="y" stroke-color="#FFFF00" stroke-style="50;10" />
-                       <text name="txt_report_footer" x="10" y="20" width="500" height="30" visible="y" horizontal-align="center" source="&quot;the report's footer&quot;" />
-                       <line name="line4" x="10" y="50" width="500" height="0" visible="y" stroke-color="#FFFF00" stroke-style="1;5" />
-               </report-footer>
-               <page-footer height="80" first-page="y" last-page="y">
-                       <line name="line2" x="10" y="10" width="500" height="0" visible="y" />
-                       <text name="footer" x="10" y="20" width="300" height="50" visible="y" source="&quot;the page's footer&quot;" />
-                       <ellipse name="ellipse1" x="400" y="50" width="20" height="10" visible="y" stroke-color="#FF0000" fill-color="#00FF00" />
-                       <text name="page_n" x="500" y="20" width="50" height="50" visible="y" source="@Page &amp; &quot;/&quot; &amp; @Pages" />
-               </page-footer>
-       </report>
-</reptool>
diff --git a/tests/test_report_newline.rpt b/tests/test_report_newline.rpt
deleted file mode 100644 (file)
index 639bf14..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<reptool>
-  <properties>
-    <name>Newline test</name>
-    <description>A report to test if the newline character (#10) works</description>
-  </properties>
-  <page width="595.000000" height="842.000000" margin-left="100.000000" margin-top="200.000000"/>
-  <report>
-    <body>
-      <text name="txt_id" visible="y" x="50.000000" y="50.000000" width="100.000000" height="50.000000" border-top-width="1.000000" border-top-color="#FF0000FF" font-name="Sans" font-size="12.000000" source="&quot;text with&#10;new line&quot;"/>
-      <text name="txt_invisible" visible="y" x="50.000000" y="250.000000" width="100.000000" height="50.000000" border-top-width="1.000000" border-top-color="#FF0000FF" font-name="Sans" font-size="12.000000" source="&quot;text with&#10;new line&quot;" letter-spacing="20"/>
-      <text name="txt_long" visible="y" x="50.000000" y="350.000000" width="300.000000" height="50.000000" border-top-width="1.000000" border-top-color="#FF0000FF" border-right-width="1" border-right-color="#000" font-name="Sans" font-size="12.000000" source="&quot;text with new line&quot;" fill-with="."/>
-      <text name="txt_dot" visible="y" x="50.000000" y="400.000000" width="300.000000" height="50.000000" border-top-width="1.000000" border-top-color="#FF0000FF" font-name="Sans" font-size="12.000000" source="&quot;.&quot;"/>
-      <text name="txt_long_with_spacing" visible="y" x="0.000000" y="450.000000" width="400.000000" height="50.000000" border-top-width="1.000000" border-top-color="#FF0000FF" font-name="Sans" font-size="12.000000" source="&quot;text with&#10;new line&quot;" letter-spacing="10"/>
-      <text name="txt_date" visible="y" x="0.000000" y="500.000000" width="400.000000" height="50.000000" font-name="Sans" font-size="12.000000" source="@Date{%d/%m/%Y} &amp; &quot; &quot; &amp; @Time{%H.%M.%S}" letter-spacing="10"/>
-    </body>
-  </report>
-</reptool>
diff --git a/tests/test_rptprint.c b/tests/test_rptprint.c
deleted file mode 100644 (file)
index 8b56093..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2006-2011 Andrea Zagli <azagli@libero.it>
- *
- * 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 2 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 Library General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
- */
-
-#include <rptprint.h>
-
-static gchar *rptr_file_name = NULL;
-static gchar *output_type = NULL;
-static gchar *output_file_name = NULL;
-
-static GOptionEntry entries[] =
-{
-       { "rptr-file-name", 'r', 0, G_OPTION_ARG_STRING, &rptr_file_name, "RptPrint definition file name", "RPTR_FILE_NAME" },
-       { "output-type", 'o', 0, G_OPTION_ARG_STRING, &output_type, "Output type (png | pdf | ps | svg | gtk | gtk-default)", "OUTPUT-TYPE" },
-       { "output-file-name", 'f', 0, G_OPTION_ARG_FILENAME, &output_file_name, "Output file name", "FILE-NAME" },
-       { NULL }
-};
-
-int
-main (int argc, char **argv)
-{
-       GError *error;
-       GOptionContext *context;
-
-       RptPrint *rptp;
-
-       g_type_init ();
-
-       context = g_option_context_new ("- test rptprint");
-       g_option_context_add_main_entries (context, entries, NULL);
-
-       error = NULL;
-       if (!g_option_context_parse (context, &argc, &argv, &error)
-           || error != NULL)
-               {
-                       g_error ("Option parsing failed: %s.", error != NULL && error->message != NULL ? error->message : "no details");
-                       return 0;
-               }
-
-       rptp = rpt_print_new_from_file (rptr_file_name);
-
-       if (rptp != NULL)
-               {
-                       rpt_print_set_output_type (rptp, rpt_common_stroutputtype_to_enum (output_type));
-                       if (g_strcmp0 (output_type, "png") == 0
-                           || g_strcmp0 (output_type, "pdf") == 0
-                           || g_strcmp0 (output_type, "ps") == 0
-                           || g_strcmp0 (output_type, "svg") == 0)
-                               {
-                                       rpt_print_set_output_filename (rptp, output_file_name == NULL ? g_strdup_printf ("test.%s", output_type) : output_file_name);
-                               }
-                       rpt_print_print (rptp, NULL);
-               }
-       else
-               {
-                       g_error ("Error on creating RptPrint object.");
-                       return 0;
-               }
-
-       return 0;
-}
diff --git a/tests/test_rptprint_mm.rptr b/tests/test_rptprint_mm.rptr
deleted file mode 100644 (file)
index cdf540d..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" ?>
-<reptool_report>
-       <properties>
-               <unit-length>mm</unit-length>
-       </properties>
-       <page width="210" height="297">
-               <text x="10" y="20" width="210" height="100" visible="y" border-top-width="2.83" border-bottom-width="2.83" font-size="12" font-color="#0F0" border-top="2.83" border-bottom="2.83">Text sample</text>
-               <!--<line x="10" y="300" width="100" height="0" visible="y" stroke-color="#F00" />
-               <image x="250" y="180" width="300" height="200" visible="y" border-top-width="1.0" border-right-width="1.0" border-bottom-width="1.0" border-left-width="1.0" source="tests/city.png" />
-               <rect x="10" y="500" width="400" height="10" visible="y" fill-color="#00F" />
-               <text x="10" y="400" width="100" height="50" visible="y" border-top-width="1.0" border-right-width="1.0" border-bottom-width="1.0" border-left-width="1.0" border-top-color="#FF0000" border-right-color="#FF0000" border-bottom-color="#FF0000" border-left-color="#FF0000" background-color="#000000" font-color="#FFFFFF">White on black</text>
-       </page>
-
-       <page width="595" height="842">
-               <text x="10" y="300" width="300" height="800" visible="y" font-size="30" font-color="#FF0">Text sample on second page</text>
-               <line x="10" y="300" width="100" height="0" visible="y" stroke-color="#0F0" />
-               <ellipse x="200" y="700" width="100" height="30" visible="y" stroke-color="#FF0000" fill-color="#0000FF" />
-               <text x="350" y="20" width="200" height="100" visible="y" font-underline="single">Underline single</text>
-               <text x="350" y="120" width="200" height="100" visible="y" font-underline="double">Underline double</text>
-               <text x="350" y="220" width="200" height="100" visible="y" font-underline="low">Underline low</text>
-               <text x="350" y="320" width="200" height="100" visible="y" font-underline="error">Underline error</text>
-               <text x="350" y="420" width="200" height="100" visible="y" font-bold="y" font-color="#FF0000" font-strike="y">Text striked and bold</text>
-               <text x="350" y="520" width="200" height="100" visible="y" font-italic="y">Text italic</text>-->
-       </page>
-</reptool_report>
diff --git a/tests/test_rptreport.c b/tests/test_rptreport.c
deleted file mode 100644 (file)
index 2cb7c79..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2007-2011 Andrea Zagli <azagli@libero.it>
- *
- * 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 2 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 Library General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
- */
-
-#include <rptreport.h>
-#include <rptprint.h>
-
-static gchar *rpt_file_name = NULL;
-static gchar *xml_rpt_file_name = NULL;
-static gchar *xml_rptr_file_name = NULL;
-static gchar *path_relatives_to  = NULL;
-static gchar *output_type = NULL;
-static gchar *output_file_name = NULL;
-
-static GOptionEntry entries[] =
-{
-       { "rpt-file-name", 'r', 0, G_OPTION_ARG_STRING, &rpt_file_name, "RptReport definition file name", "RPT_FILE_NAME" },
-       { "xml-report-file-name", 'x', 0, G_OPTION_ARG_FILENAME, &xml_rpt_file_name, "RptReport xml output file name", "FILE-NAME" },
-       { "xml-print-file-name", 'p', 0, G_OPTION_ARG_FILENAME, &xml_rptr_file_name, "RptPrint xml output file name", "FILE-NAME" },
-       { "path-relatives-to", 't', 0, G_OPTION_ARG_FILENAME, &path_relatives_to, "Path relatives to", "FILE-NAME" },
-       { "output-type", 'o', 0, G_OPTION_ARG_STRING, &output_type, "Output type (png | pdf | ps | svg | gtk | gtk-default)", "OUTPUT-TYPE" },
-       { "output-file-name", 'f', 0, G_OPTION_ARG_FILENAME, &output_file_name, "Output file name", "FILE-NAME" },
-       { NULL }
-};
-
-gchar
-*field_request (RptReport *rpt_report,
-                gchar *field_name,
-                GdaDataModel *data_model,
-                gint row,
-                GtkTreeModel *treemodel,
-                GtkTreeIter *iter,
-                gpointer user_data)
-{
-       gchar *ret = NULL;
-
-       if (g_strcmp0 (field_name, "field_to_request") == 0)
-               {
-                       ret = g_strdup ("the field requested");
-               }
-       else if (g_strcmp0 (field_name, "nonexistent") == 0 &&
-                data_model != NULL &&
-                row > -1)
-               {
-                       ret = g_strdup_printf ("%s - %s",
-                                              gda_value_stringify (gda_data_model_get_value_at (data_model, 0, row, NULL)),
-                                              gda_value_stringify (gda_data_model_get_value_at (data_model, 1, row, NULL)));
-               }
-
-       return ret;
-}
-
-int
-main (int argc, char **argv)
-{
-       GError *error;
-       GOptionContext *context;
-
-       RptReport *rptr;
-       RptPrint *rptp;
-
-       g_type_init ();
-
-       context = g_option_context_new ("- test rptprint");
-       g_option_context_add_main_entries (context, entries, NULL);
-
-       error = NULL;
-       if (!g_option_context_parse (context, &argc, &argv, &error)
-           || error != NULL)
-               {
-                       g_error ("Option parsing failed: %s.", error != NULL && error->message != NULL ? error->message : "no details");
-                       return 0;
-               }
-
-       rptr = rpt_report_new_from_file (rpt_file_name);
-       if (rptr == NULL)
-               {
-                       g_error ("Error on creating RptReport object.");
-                       return 0;
-               }
-
-       g_signal_connect (rptr, "field-request", G_CALLBACK (field_request), NULL);
-
-       if (rptr != NULL)
-               {
-                       xmlDoc *report = rpt_report_get_xml (rptr);
-                       if (xml_rpt_file_name != NULL)
-                               {
-                                       xmlSaveFormatFileEnc (xml_rpt_file_name, report, "UTF-8", 2);
-                               }
-
-                       xmlDoc *rptprint = rpt_report_get_xml_rptprint (rptr);
-                       if (xml_rptr_file_name)
-                               {
-                                       xmlSaveFormatFileEnc (xml_rptr_file_name, rptprint, "UTF-8", 2);
-                               }
-
-                       rptp = rpt_print_new_from_xml (rptprint);
-                       if (rptp != NULL)
-                               {
-                                       if (path_relatives_to != NULL)
-                                               {
-                                                       g_object_set (G_OBJECT (rptp), "path-relatives-to", path_relatives_to, NULL);
-                                               }
-
-                                       rpt_print_set_output_type (rptp, rpt_common_stroutputtype_to_enum (output_type));
-                                       if (g_strcmp0 (output_type, "png") == 0
-                                           || g_strcmp0 (output_type, "pdf") == 0
-                                           || g_strcmp0 (output_type, "ps") == 0
-                                           || g_strcmp0 (output_type, "svg") == 0)
-                                               {
-                                                       rpt_print_set_output_filename (rptp, output_file_name == NULL ? g_strdup_printf ("test.%s", output_type) : output_file_name);
-                                               }
-                                       rpt_print_print (rptp, NULL);
-                               }
-                       else
-                               {
-                                       g_error ("Error on creating RptPrint object.");
-                                       return 0;
-                               }
-               }
-
-       return 0;
-}
diff --git a/tests/test_rptreport_creation.c b/tests/test_rptreport_creation.c
deleted file mode 100644 (file)
index 7f05ab1..0000000
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2007-2011 Andrea Zagli <azagli@inwind.it>
- *
- * 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 2 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 Library General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
- */
-
-#include <rptreport.h>
-#include <rptprint.h>
-#include <rptobject.h>
-#include <rptobjectellipse.h>
-#include <rptobjectimage.h>
-#include <rptobjectline.h>
-#include <rptobjectrect.h>
-#include <rptobjecttext.h>
-
-int
-main (int argc, char **argv)
-{
-       RptReport *rptr;
-       RptPrint *rptp;
-       RptObject *obj;
-       RptPoint point;
-       RptSize size;
-       RptStroke stroke;
-       RptColor *color;
-
-       g_type_init ();
-
-       rptr = rpt_report_new ();
-
-       if (rptr != NULL)
-               {
-                       g_object_set (G_OBJECT (rptr), "unit-length", 3, NULL);
-
-                       size.width = 210;
-                       size.height = 297;
-                       rpt_report_set_page_size (rptr, size);
-
-                       point.x = 10;
-                       point.y = 10;
-                       obj = rpt_obj_text_new ("text1", point);
-                       size.width = 210;
-                       size.height = 50;
-                       g_object_set (obj,
-                                     "source", "\"The first object inserted.\"",
-                                     "size", &size,
-                                     NULL);
-                       rpt_report_add_object_to_section (rptr, obj, RPTREPORT_SECTION_BODY);
-
-                       point.x = 10;
-                       point.y = 60;
-                       obj = rpt_obj_line_new ("line1", point);
-                       size.width = 210;
-                       size.height = 0;
-                       stroke.color = rpt_common_parse_color ("#FF0000");
-                       stroke.style = NULL;
-                       g_object_set (obj,
-                                     "size", &size,
-                                     "stroke", &stroke,
-                                     NULL);
-                       rpt_report_add_object_to_section (rptr, obj, RPTREPORT_SECTION_BODY);
-
-                       point.x = 0;
-                       point.y = 0;
-                       obj = rpt_obj_line_new ("line2", point);
-                       size.width = 210;
-                       size.height = 297;
-                       stroke.color = rpt_common_parse_color ("#000000AA");
-                       stroke.style = NULL;
-                       g_object_set (obj,
-                                     "size", &size,
-                                     "stroke", &stroke,
-                                     NULL);
-                       rpt_report_add_object_to_section (rptr, obj, RPTREPORT_SECTION_BODY);
-
-                       point.x = 210;
-                       point.y = 0;
-                       obj = rpt_obj_line_new ("line3", point);
-                       size.width = -210;
-                       size.height = 297;
-                       stroke.color = rpt_common_parse_color ("#000000AA");
-                       g_object_set (obj,
-                                     "size", &size,
-                                     "stroke", &stroke,
-                                     NULL);
-                       rpt_report_add_object_to_section (rptr, obj, RPTREPORT_SECTION_BODY);
-
-                       point.x = 105;
-                       point.y = 148.5;
-                       obj = rpt_obj_ellipse_new ("circle1", point);
-                       size.width = 50;
-                       size.height = 50;
-                       color = rpt_common_parse_color ("#00FF0099");
-                       stroke.color = rpt_common_parse_color ("#00FF00AA");
-                       stroke.style = NULL;
-                       g_object_set (obj,
-                                     "size", &size,
-                                     "stroke", &stroke,
-                                     "fill-color", color,
-                                     NULL);
-                       rpt_report_add_object_to_section (rptr, obj, RPTREPORT_SECTION_BODY);
-
-                       point.x = 50;
-                       point.y = 200;
-                       obj = rpt_obj_image_new ("image1", point);
-                       size.width = 100;
-                       size.height = 100;
-                       g_object_set (obj,
-                                     "size", &size,
-                                     "source", "gnome-globe.png",
-                                     NULL);
-                       rpt_report_add_object_to_section (rptr, obj, RPTREPORT_SECTION_BODY);
-
-                       xmlDoc *report = rpt_report_get_xml (rptr);
-                       xmlSaveFormatFileEnc ("test_report_created.rpt", report, "UTF-8", 2);
-
-                       xmlDoc *rptprint = rpt_report_get_xml_rptprint (rptr);
-                       xmlSaveFormatFileEnc ("test_report_created.rptr", rptprint, "UTF-8", 2);
-               
-                       rptp = rpt_print_new_from_xml (rptprint);
-                       if (rptp != NULL)
-                               {
-                                       rpt_print_set_output_type (rptp, RPT_OUTPUT_PDF);
-                                       rpt_print_set_output_filename (rptp, "test_report_created.pdf");
-                                       rpt_print_print (rptp, NULL);
-                               }
-               }
-
-       return 0;
-}
diff --git a/tests/test_rptreport_liststore.c b/tests/test_rptreport_liststore.c
deleted file mode 100644 (file)
index 27458dc..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2011 Andrea Zagli <azagli@libero.it>
- *
- * 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 2 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 Library General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
- */
-
-#include <rptreport.h>
-#include <rptprint.h>
-
-gchar
-*field_request (RptReport *rpt_report,
-                gchar *field_name,
-                GdaDataModel *data_model,
-                gint row,
-                GtkTreeModel *treemodel,
-                GtkTreeIter *iter,
-                gpointer user_data)
-{
-       gchar *ret = NULL;
-
-       if (g_strcmp0 (field_name, "nonexistent") == 0 &&
-           treemodel != NULL &&
-           iter != NULL)
-               {
-                       gint id;
-                       gchar *name;
-
-                       gtk_tree_model_get (treemodel, iter,
-                                           0, &id,
-                                           1, &name,
-                                           -1);
-
-                       ret = g_strdup_printf ("%d - %s", id, name);
-               }
-
-       return ret;
-}
-
-int
-main (int argc, char **argv)
-{
-       RptReport *rptr;
-       RptPrint *rptp;
-
-       GtkListStore *model;
-       GtkTreeIter iter;
-       GHashTable *columns_names;
-
-       g_type_init ();
-
-       rptr = rpt_report_new_from_file (argv[1]);
-
-       model = gtk_list_store_new (2,
-                                   G_TYPE_INT,
-                                   G_TYPE_STRING);
-
-       gtk_list_store_append (model, &iter);
-       gtk_list_store_set (model, &iter,
-                           0, 1,
-                           1, "Mary Jane Red",
-                           -1);
-
-       gtk_list_store_append (model, &iter);
-       gtk_list_store_set (model, &iter,
-                           0, 2,
-                           1, "John Doe",
-                           -1);
-
-       gtk_list_store_append (model, &iter);
-       gtk_list_store_set (model, &iter,
-                           0, 3,
-                           1, "Elene McArty",
-                           -1);
-
-       gtk_list_store_append (model, &iter);
-       gtk_list_store_set (model, &iter,
-                           0, 4,
-                           1, "Raul Bread",
-                           -1);
-
-       columns_names = g_hash_table_new (g_str_hash, g_str_equal);
-       g_hash_table_insert (columns_names, "id", "0");
-       g_hash_table_insert (columns_names, "name", "1");
-
-       rpt_report_set_database_as_gtktreemodel (rptr, GTK_TREE_MODEL (model), columns_names);
-
-       g_signal_connect (rptr, "field-request", G_CALLBACK (field_request), NULL);
-
-       if (rptr != NULL)
-               {
-                       rpt_report_set_output_type (rptr, RPT_OUTPUT_PNG);
-                       rpt_report_set_output_filename (rptr, "test.png");
-
-                       xmlDoc *report = rpt_report_get_xml (rptr);
-                       xmlSaveFormatFile ("test_report.rpt", report, 2);
-
-                       xmlDoc *rptprint = rpt_report_get_xml_rptprint (rptr);
-                       xmlSaveFormatFile ("test_report.rptr", rptprint, 2);
-               
-                       rptp = rpt_print_new_from_xml (rptprint);
-                       if (rptp != NULL)
-                               {
-                                       g_object_set (G_OBJECT (rptp), "path-relatives-to", "..", NULL);
-
-                                       rpt_print_print (rptp, NULL);
-                               }
-               }
-
-       return 0;
-}