aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorXan Lopez <xan@igalia.com>2012-12-12 00:29:19 +0800
committerXan Lopez <xan@igalia.com>2012-12-12 19:22:33 +0800
commit6ede0c3ebcbc129ea1112ee9f43427231ab50e07 (patch)
treea7914732e5ce2b86eeaf7d44956371c610d341e4 /tests
parent7f6211d2901f70d571f18106bf97ff636712a712 (diff)
downloadgsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.tar
gsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.tar.gz
gsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.tar.bz2
gsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.tar.lz
gsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.tar.xz
gsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.tar.zst
gsoc2013-epiphany-6ede0c3ebcbc129ea1112ee9f43427231ab50e07.zip
Handle a bit more gracefully the self-launch detection
Check whether the app that will launch a given download is actually the browser itself, and do nothing *before* going ahead. Seems better than actually launching and then aborting on startup through UUID hacks.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am12
-rw-r--r--tests/applications/defaults.list5
-rw-r--r--tests/applications/epiphany.desktop8
-rw-r--r--tests/data/test.html1
-rw-r--r--tests/ephy-embed-shell-test.c91
5 files changed, 116 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 992547eb7..aaaf6c149 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,6 +4,7 @@ noinst_PROGRAMS = \
test-ephy-bookmarks \
test-ephy-completion-model \
test-ephy-download \
+ test-ephy-embed-shell \
test-ephy-embed-single \
test-ephy-embed-utils \
test-ephy-encodings \
@@ -100,7 +101,8 @@ INCLUDES = \
-I$(top_srcdir)/src/bookmarks
CFLAGS = \
- $(DEPENDENCIES_CFLAGS) \
+ -DTEST_DIR=\"$(srcdir)\"\
+ $(DEPENDENCIES_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
$(AM_CFLAGS)
@@ -125,6 +127,9 @@ test_ephy_completion_model_SOURCES = \
test_ephy_download_SOURCES = \
ephy-download-test.c
+test_ephy_embed_shell_SOURCES = \
+ ephy-embed-shell-test.c
+
test_ephy_embed_single_SOURCES = \
ephy-embed-single-test.c
@@ -173,3 +178,8 @@ test_ephy_web_app_utils_SOURCES = \
test_ephy_web_view_SOURCES = \
ephy-web-view-test.c
+
+EXTRA_DIST = \
+ data/test.html \
+ applications/epiphany.desktop \
+ applications/defaults.list
diff --git a/tests/applications/defaults.list b/tests/applications/defaults.list
new file mode 100644
index 000000000..894702586
--- /dev/null
+++ b/tests/applications/defaults.list
@@ -0,0 +1,5 @@
+
+[Default Applications]
+text/html=epiphany.desktop
+
+
diff --git a/tests/applications/epiphany.desktop b/tests/applications/epiphany.desktop
new file mode 100644
index 000000000..8e5390cf8
--- /dev/null
+++ b/tests/applications/epiphany.desktop
@@ -0,0 +1,8 @@
+[Desktop Entry]
+Exec=epiphany %U
+StartupNotify=true
+Terminal=false
+Type=Application
+Icon=web-browser
+Categories=Network;GNOME;GTK;WebBrowser;
+MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;
diff --git a/tests/data/test.html b/tests/data/test.html
new file mode 100644
index 000000000..f806b922d
--- /dev/null
+++ b/tests/data/test.html
@@ -0,0 +1 @@
+<html>THIS IS A TEST!</html>
diff --git a/tests/ephy-embed-shell-test.c b/tests/ephy-embed-shell-test.c
new file mode 100644
index 000000000..27c1b9c46
--- /dev/null
+++ b/tests/ephy-embed-shell-test.c
@@ -0,0 +1,91 @@
+/* vim: set sw=2 ts=2 sts=2 et: */
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/*
+ * ephy-embed-shell-test.c
+ * This file is part of Epiphany
+ *
+ * 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.h"
+#include "ephy-embed-prefs.h"
+#include "ephy-embed-private.h"
+#include "ephy-embed-shell.h"
+#include "ephy-embed-utils.h"
+#include "ephy-file-helpers.h"
+#include "ephy-private.h"
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+static void
+test_ephy_embed_shell_launch_handler (void)
+{
+ EphyEmbedShell *embed_shell;
+ gboolean ret;
+ GFile *file;
+
+ embed_shell = ephy_embed_shell_get_default ();
+
+ ret = ephy_embed_shell_launch_handler (embed_shell, NULL, "text/html", 0);
+ g_assert (ret == FALSE);
+
+ file = g_file_new_for_path (TEST_DIR"/data/test.html");
+ g_assert (file);
+
+ ret = ephy_embed_shell_launch_handler (embed_shell, file, NULL, 0);
+ g_assert (ret == FALSE);
+
+ ret = ephy_embed_shell_launch_handler (embed_shell, file, "text/html", 0);
+ g_assert (ret == FALSE);
+
+ g_object_unref (file);
+}
+
+int
+main (int argc, char *argv[])
+{
+ int ret;
+
+ g_setenv ("XDG_DATA_DIRS", TEST_DIR, TRUE);
+ g_setenv ("XDG_DATA_HOME", TEST_DIR, TRUE);
+
+ gtk_test_init (&argc, &argv);
+
+ ephy_debug_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_application_register (G_APPLICATION (ephy_embed_shell_get_default ()), NULL, NULL);
+
+ g_test_add_func ("/embed/ephy-embed-shell/launch_handler",
+ test_ephy_embed_shell_launch_handler);
+
+ ret = g_test_run ();
+
+ g_object_unref (ephy_embed_shell_get_default ());
+ ephy_file_helpers_shutdown ();
+
+ return ret;
+}