[gnome-documents] pdf-loader: add a simple test for the PDF loader



commit 40b04a66f63f42b9278df5c128835ec5897655aa
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Aug 3 14:40:28 2011 +0200

    pdf-loader: add a simple test for the PDF loader

 src/Makefile-lib.am       |   14 ++++++++++++
 src/lib/test-pdf-loader.c |   50 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile-lib.am b/src/Makefile-lib.am
index 2cdc252..689ca52 100644
--- a/src/Makefile-lib.am
+++ b/src/Makefile-lib.am
@@ -35,6 +35,20 @@ libgdprivate_1_0_la_SOURCES = \
     $(gdprivate_source_h) \
     $(gdprivate_source_c)
 
+noinst_PROGRAMS = \
+    test-pdf-loader
+
+test_pdf_loader_SOURCES = \
+    lib/test-pdf-loader.c
+
+test_pdf_loader_CPPFLAGS = \
+    -I$(top_srcdir)/src \
+    $(DOCUMENTS_CFLAGS)
+
+test_pdf_loader_LDADD = \
+    $(top_builddir)/src/libgdprivate-1.0.la \
+    $(DOCUMENTS_LIBS)
+
 INTROSPECTION_GIRS += Gd-1.0.gir
 
 Gd-1.0.gir: libgdprivate-1.0.la Makefile
diff --git a/src/lib/test-pdf-loader.c b/src/lib/test-pdf-loader.c
new file mode 100644
index 0000000..4a6615f
--- /dev/null
+++ b/src/lib/test-pdf-loader.c
@@ -0,0 +1,50 @@
+#include "gd-pdf-loader.h"
+
+#include <glib.h>
+#include <evince-document.h>
+
+static GMainLoop *loop = NULL;
+
+static void
+load_ready_cb (GObject *source,
+               GAsyncResult *res,
+               gpointer _user_data)
+{
+  EvDocument *document = NULL;
+  GError *error = NULL;
+
+  document = gd_pdf_loader_load_uri_finish (GD_PDF_LOADER (source), res, &error);
+
+  if (error != NULL) {
+    g_printerr ("Failed loading the PDF document: %s\n", error->message);
+    g_error_free (error);
+  } else {
+    g_print ("Loading OK: %p\n", document);
+    g_object_unref (document);
+  }
+
+  g_main_loop_quit (loop);
+}
+
+int
+main (int argc,
+      char **argv)
+{
+  GdPdfLoader *loader;
+  GCancellable *cancellable;
+
+  g_type_init ();
+  ev_init ();
+  loop = g_main_loop_new (NULL, FALSE);
+
+  loader = gd_pdf_loader_new ("goa:documents:account_1311218785");
+  cancellable = g_cancellable_new ();
+  gd_pdf_loader_load_uri_async (loader, "https://docs.google.com/feeds/documents/private/full/document%3A1AwLAOHbqJdSMaj-LChH77t9liQwzHDBaPdfiY5zzFuk";,
+                                cancellable, load_ready_cb, NULL);
+  g_object_unref (cancellable);
+  g_main_loop_run (loop);
+
+  g_object_unref (loader);
+
+  return 0;
+}



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