[epiphany] tests: add the beginnings of ephy-session unit testing
- From: Xan Lopez <xan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] tests: add the beginnings of ephy-session unit testing
- Date: Thu, 14 Jun 2012 06:47:27 +0000 (UTC)
commit 979434a28ef2025f66655ceb83c7fbfd9fb48d7f
Author: Xan Lopez <xan igalia com>
Date: Thu Jun 14 07:33:35 2012 +0200
tests: add the beginnings of ephy-session unit testing
For now a simple test that verifies that loading a session works.
We need to link with the resource files, which is unfortunate, but I'm
not sure there's a way around it since this test will actually spawn a
full EphyWindow (ie, it's not only testing the session or shell code
but the entire browser as a side effect).
tests/Makefile.am | 6 +++
tests/ephy-session-test.c | 98 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 104 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3e3b00d..985f677 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -9,6 +9,7 @@ noinst_PROGRAMS = \
test-ephy-location-entry \
test-ephy-migration \
test-ephy-search-entry \
+ test-ephy-session \
test-ephy-sqlite \
test-ephy-web-view \
$(NULL)
@@ -141,6 +142,11 @@ test_ephy_migration_SOURCES = \
test_ephy_search_entry_SOURCES = \
ephy-search-entry-test.c
+test_ephy_session_SOURCES = \
+ ephy-session-test.c \
+ $(top_builddir)/src/epiphany-resources.c \
+ $(top_builddir)/src/epiphany-resources.h
+
test_ephy_sqlite_SOURCES = \
ephy-sqlite-test.c
diff --git a/tests/ephy-session-test.c b/tests/ephy-session-test.c
new file mode 100644
index 0000000..70d2e4b
--- /dev/null
+++ b/tests/ephy-session-test.c
@@ -0,0 +1,98 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * Copyright  2012 - Igalia S.L.
+ *
+ * Epiphany 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.
+ *
+ * Epiphany 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 Epiphany; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ */
+
+#include "config.h"
+#include "ephy-debug.h"
+#include "ephy-embed-container.h"
+#include "ephy-embed-prefs.h"
+#include "ephy-embed-private.h"
+#include "ephy-file-helpers.h"
+#include "ephy-private.h"
+#include "ephy-shell.h"
+#include "ephy-session.h"
+
+#include <glib.h>
+#include <glib/gstdio.h>
+#include <gtk/gtk.h>
+#include <string.h>
+
+const char *session_data =
+"<?xml version=\"1.0\"?>"
+"<session>"
+ "<window x=\"94\" y=\"48\" width=\"1132\" height=\"684\" active-tab=\"0\" role=\"epiphany-window-67c6e8a5\">"
+ "<embed url=\"about:memory\" title=\"Memory usage\"/>"
+ "</window>"
+"</session>";
+
+static void
+test_ephy_session_load ()
+{
+ EphySession *session;
+ gboolean ret;
+ GList *l;
+ EphyEmbed *embed;
+ EphyWebView *view;
+
+ session = EPHY_SESSION (ephy_shell_get_session (ephy_shell));
+ g_assert (session);
+
+ ret = ephy_session_load_from_string (session, session_data, -1, 0);
+ g_assert (ret);
+
+ l = ephy_session_get_windows (session);
+ g_assert (l);
+ g_assert_cmpint (g_list_length (l), ==, 1);
+
+ embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (l->data));
+ g_assert (embed);
+ view = ephy_embed_get_web_view (embed);
+ g_assert (view);
+ g_assert_cmpstr (ephy_web_view_get_address (view), ==, "ephy-about:memory");
+}
+
+int
+main (int argc, char *argv[])
+{
+ int ret;
+
+ gtk_test_init (&argc, &argv);
+
+ ephy_debug_init ();
+ ephy_embed_prefs_init ();
+
+ if (!ephy_file_helpers_init (NULL,
+ EPHY_FILE_HELPERS_PRIVATE_PROFILE | EPHY_FILE_HELPERS_ENSURE_EXISTS,
+ NULL)) {
+ g_debug ("Something wrong happened with ephy_file_helpers_init()");
+ return -1;
+ }
+
+ _ephy_shell_create_instance (EPHY_EMBED_SHELL_MODE_TEST);
+
+ g_test_add_func ("/src/ephy-session/load",
+ test_ephy_session_load);
+
+ ret = g_test_run ();
+
+ g_object_unref (ephy_shell);
+ ephy_file_helpers_shutdown ();
+
+ return ret;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]