diff options
author | Claudio Saavedra <csaavedra@igalia.com> | 2012-01-24 16:07:39 +0200 |
---|---|---|
committer | Claudio Saavedra <csaavedra@igalia.com> | 2012-01-27 13:00:18 +0200 |
commit | 93af9fc58a0aa207fb9326396f81f8b30390a7e3 (patch) | |
tree | ba46918349bb5c01f2bb6af2012b0e88eb5f5cb6 | |
parent | 1677dc338d9ef1547b631984dd52e4dd591f5551 (diff) | |
download | epiphany-snapshot-service.tar.gz |
Add basic tests for EphySnapshotServicesnapshot-service
https://bugzilla.gnome.org/show_bug.cgi?id=668578
-rw-r--r-- | tests/Makefile.am | 6 | ||||
-rw-r--r-- | tests/ephy-snapshot-service.c | 78 |
2 files changed, 83 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 400b27cc1..4c6a13e63 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 000000000..4efb9940c --- /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 (); +} |