[evolution-ews] Make OAB decode test a standalone program



commit f1e33ac07168e58941ed4d24f1835b0acd68a8ac
Author: David Woodhouse <David Woodhouse intel com>
Date:   Mon Jul 15 10:02:01 2013 +0100

    Make OAB decode test a standalone program

 src/addressbook/Makefile.am       |   19 ++++++++-
 src/addressbook/ews-oab-decoder.c |   75 --------------------------------
 src/addressbook/oab-decode-test.c |   86 +++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+), 76 deletions(-)
---
diff --git a/src/addressbook/Makefile.am b/src/addressbook/Makefile.am
index 67005cf..062ae16 100644
--- a/src/addressbook/Makefile.am
+++ b/src/addressbook/Makefile.am
@@ -57,7 +57,24 @@ libebookbackendews_la_LIBADD = \
 libebookbackendews_la_LDFLAGS = \
        -module -avoid-version $(NO_UNDEFINED)
 
-noinst_PROGRAMS = gal-lzx-decompress-test
+noinst_PROGRAMS = gal-lzx-decompress-test oab-decode-test
+
+oab_decode_test_CPPFLAGS = \
+       $(AM_CPPFLAGS) \
+       $(LIBEBOOK_CFLAGS) \
+       $(LIBEDATABOOK_CFLAGS)  \
+       $(GNOME_PLATFORM_CFLAGS) \
+       $(NULL)
+
+oab_decode_test_SOURCES = \
+       oab-decode-test.c
+
+oab_decode_test_LDADD = \
+       $(GNOME_PLATFORM_LIBS) \
+       $(LIBEBOOK_LIBS) \
+       $(LIBEDATABOOK_LIBS)  \
+       $(top_builddir)/src/addressbook/libebookbackendews.la
+       $(NULL)
 
 gal_lzx_decompress_test_CPPFLAGS = \
        $(AM_CPPFLAGS) \
diff --git a/src/addressbook/ews-oab-decoder.c b/src/addressbook/ews-oab-decoder.c
index a0c365d..47c7134 100644
--- a/src/addressbook/ews-oab-decoder.c
+++ b/src/addressbook/ews-oab-decoder.c
@@ -1154,78 +1154,3 @@ ews_oab_decoder_get_contact_from_offset (EwsOabDecoder *eod,
        return contact;
 }
 
-#ifdef TEST_BUILD
-
-struct _db_data {
-       GSList *contact_collector;
-       guint collected_length;
-       EBookBackendSqliteDB *summary;
-       const gchar *folderid;
-};
-
-static void
-ews_test_store_contact (EContact *contact,
-                        goffset offset,
-                        guint percent,
-                        gpointer user_data,
-                        GError **error)
-{
-       struct _db_data *data = (struct _db_data *) user_data;
-
-       data->contact_collector = g_slist_prepend (data->contact_collector, g_object_ref (contact));
-       data->collected_length += 1;
-
-       if (data->collected_length == 1000 || percent >= 100) {
-               data->contact_collector = g_slist_reverse (data->contact_collector);
-               e_book_backend_sqlitedb_add_contacts (data->summary, data->folderid, data->contact_collector, 
FALSE, error);
-               g_print ("percent complete %d \n", percent);
-
-               g_slist_foreach (data->contact_collector, (GFunc) g_object_unref, NULL);
-               g_slist_free (data->contact_collector);
-               data->contact_collector = NULL;
-               data->collected_length = 0;
-       }
-}
-
-gint
-main (gint argc,
-      gchar *argv[])
-{
-       EBookBackendSqliteDB *summary;
-       EwsOabDecoder *eod;
-       GError *err = NULL;
-       GTimer *timer;
-       struct _db_data data;
-
-       g_type_init ();
-
-       if (argc != 3) {
-               g_print ("Pass the oab filename  and cache dir as argument \n");
-               return -1;
-       }
-
-       summary = e_book_backend_sqlitedb_new (argv[2], "dum", "de", "dum", TRUE, NULL);
-       eod = ews_oab_decoder_new (argv[1], argv[2], &err);
-
-       data.contact_collector = NULL;
-       data.collected_length = 0;
-       data.summary = summary;
-       data.folderid = "de";
-
-       timer = g_timer_new ();
-       g_timer_start (timer);
-       if (!ews_oab_decoder_decode (eod, ews_test_store_contact, &data, NULL, &err)) {
-               g_print ("Unable to decode %s \n", err->message);
-       }
-       g_timer_stop (timer);
-       g_print ("Time elapsed %lf \n", g_timer_elapsed (timer, NULL));
-
-       if (err)
-               g_clear_error (&err);
-
-       g_object_unref (eod);
-       g_object_unref (summary);
-
-       return 0;
-}
-#endif /* TEST_BUILD */
diff --git a/src/addressbook/oab-decode-test.c b/src/addressbook/oab-decode-test.c
new file mode 100644
index 0000000..04b4cb9
--- /dev/null
+++ b/src/addressbook/oab-decode-test.c
@@ -0,0 +1,86 @@
+#undef EDS_DISABLE_DEPRECATED
+
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib/gstdio.h>
+
+#include <libebook/libebook.h>
+#include <libedata-book/libedata-book.h>
+
+#include "ews-oab-decoder.h"
+#include "ews-oab-props.h"
+
+struct _db_data {
+       GSList *contact_collector;
+       guint collected_length;
+       EBookBackendSqliteDB *summary;
+       const gchar *folderid;
+};
+
+static void
+ews_test_store_contact (EContact *contact,
+                        goffset offset,
+                        guint percent,
+                        gpointer user_data,
+                        GError **error)
+{
+       struct _db_data *data = (struct _db_data *) user_data;
+
+       data->contact_collector = g_slist_prepend (data->contact_collector, g_object_ref (contact));
+       data->collected_length += 1;
+
+       if (data->collected_length == 1000 || percent >= 100) {
+               data->contact_collector = g_slist_reverse (data->contact_collector);
+               e_book_backend_sqlitedb_add_contacts (data->summary, data->folderid, data->contact_collector, 
FALSE, error);
+               g_print ("percent complete %d \n", percent);
+
+               g_slist_foreach (data->contact_collector, (GFunc) g_object_unref, NULL);
+               g_slist_free (data->contact_collector);
+               data->contact_collector = NULL;
+               data->collected_length = 0;
+       }
+}
+
+gint
+main (gint argc,
+      gchar *argv[])
+{
+       EBookBackendSqliteDB *summary;
+       EwsOabDecoder *eod;
+       GError *err = NULL;
+       GTimer *timer;
+       struct _db_data data;
+
+       g_type_init ();
+
+       if (argc != 3) {
+               g_print ("Pass the oab filename  and cache dir as argument \n");
+               return -1;
+       }
+
+       summary = e_book_backend_sqlitedb_new (argv[2], "dum", "de", "dum", TRUE, NULL);
+       eod = ews_oab_decoder_new (argv[1], argv[2], &err);
+
+       data.contact_collector = NULL;
+       data.collected_length = 0;
+       data.summary = summary;
+       data.folderid = "de";
+
+       timer = g_timer_new ();
+       g_timer_start (timer);
+       if (!ews_oab_decoder_decode (eod, ews_test_store_contact, &data, NULL, &err)) {
+               g_print ("Unable to decode %s \n", err->message);
+       }
+       g_timer_stop (timer);
+       g_print ("Time elapsed %lf \n", g_timer_elapsed (timer, NULL));
+
+       if (err)
+               g_clear_error (&err);
+
+       g_object_unref (eod);
+       g_object_unref (summary);
+
+       return 0;
+}
+


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