[epiphany/overview-2: 2/9] Add basic tests for EphySnapshotService



commit 5e2c65bc4398b2ed064c3792159629a7c5ba69fa
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Tue Jan 24 16:07:39 2012 +0200

    Add basic tests for EphySnapshotService
    
    https://bugzilla.gnome.org/show_bug.cgi?id=668578

 tests/Makefile.am             |    6 +++-
 tests/ephy-snapshot-service.c |   78 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 83 insertions(+), 1 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 400b27c..4c6a13e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,7 +2,8 @@ noinst_PROGRAMS = \
 	test-ephy-download \
 	test-ephy-embed-single \
 	test-ephy-location-entry \
-	test-ephy-search-entry
+	test-ephy-search-entry \
+	test-ephy-snapshot-service
 
 # Mostly copied from Makefile.decl in glib
 GTESTER = gtester
@@ -114,3 +115,6 @@ test_ephy_location_entry_SOURCES = \
 
 test_ephy_search_entry_SOURCES = \
 	ephy-search-entry.c
+
+test_ephy_snapshot_service_SOURCES = \
+	ephy-snapshot-service.c
diff --git a/tests/ephy-snapshot-service.c b/tests/ephy-snapshot-service.c
new file mode 100644
index 0000000..4efb994
--- /dev/null
+++ b/tests/ephy-snapshot-service.c
@@ -0,0 +1,78 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ *  Copyright  2012 Igalia S.L.
+ *
+ *  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, 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, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ *  Author: Claudio Saavedra  <csaavedra igalia com>
+ */
+
+#include "config.h"
+#include "ephy-debug.h"
+#include "ephy-snapshot-service.h"
+
+static time_t mtime;
+
+static void
+on_snapshot_ready (GdkPixbuf *snapshot,
+                   gint data)
+{
+  g_assert_cmpint (data, ==, G_MAXINT);
+  g_assert (GDK_IS_PIXBUF (snapshot));
+
+  gtk_main_quit();
+}
+
+static void
+test_snapshot (void)
+{
+  EphySnapshotService *service = ephy_snapshot_service_get_default ();
+
+  ephy_snapshot_service_get_snapshot (service,
+                                      "http://www.gnome.org";,
+                                      mtime,
+                                      (EphySnapshotServiceCallback)on_snapshot_ready,
+                                      GINT_TO_POINTER (G_MAXINT));
+  gtk_main ();
+}
+
+static void
+test_cached_snapshot (void)
+{
+  EphySnapshotService *service = ephy_snapshot_service_get_default ();
+
+  ephy_snapshot_service_get_snapshot (service,
+                                      "http://www.gnome.org";,
+                                      mtime,
+                                      (EphySnapshotServiceCallback)on_snapshot_ready,
+                                      GINT_TO_POINTER (G_MAXINT));
+  gtk_main ();
+}
+
+int
+main (int argc, char *argv[])
+{
+  gtk_test_init (&argc, &argv);
+  ephy_debug_init ();
+
+  mtime = time(NULL);
+
+  g_test_add_func ("/lib/ephy-snapshot-service/test_snapshot",
+                   test_snapshot);
+  g_test_add_func ("/lib/ephy-snapshot-service/test_cached_snapshot",
+                   test_cached_snapshot);
+
+  return g_test_run ();
+}



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