aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Rego Casasnovas <rego@igalia.com>2013-03-13 21:54:11 +0800
committerXan Lopez <xan@igalia.com>2013-03-13 22:45:40 +0800
commit20bee459a4fdbffae3688c25abacfec28895e8b3 (patch)
tree820215e76084760833400836eb638461bf44ead3
parentb9006782f55d4472eecdfa4f4f46c7f6c7b67e60 (diff)
downloadgsoc2013-epiphany-20bee459a4fdbffae3688c25abacfec28895e8b3.tar
gsoc2013-epiphany-20bee459a4fdbffae3688c25abacfec28895e8b3.tar.gz
gsoc2013-epiphany-20bee459a4fdbffae3688c25abacfec28895e8b3.tar.bz2
gsoc2013-epiphany-20bee459a4fdbffae3688c25abacfec28895e8b3.tar.lz
gsoc2013-epiphany-20bee459a4fdbffae3688c25abacfec28895e8b3.tar.xz
gsoc2013-epiphany-20bee459a4fdbffae3688c25abacfec28895e8b3.tar.zst
gsoc2013-epiphany-20bee459a4fdbffae3688c25abacfec28895e8b3.zip
Fix provisional_load_failure_updates_back_forward_list test in WK2
The EphyWebView test provisional_load_failure_updates_back_forward_list was failing in WK2 for a similar issue than other tests. We were not waiting for the "changed" signal in WebKitBackForwardList, so the list was not ready when checking it. https://bugzilla.gnome.org/show_bug.cgi?id=695649
-rw-r--r--tests/ephy-web-view-test.c61
1 files changed, 53 insertions, 8 deletions
diff --git a/tests/ephy-web-view-test.c b/tests/ephy-web-view-test.c
index 49ccf54dc..c1d5531fd 100644
--- a/tests/ephy-web-view-test.c
+++ b/tests/ephy-web-view-test.c
@@ -344,7 +344,53 @@ quit_main_loop_when_load_finished (WebKitWebView *view, GParamSpec *spec, GMainL
}
#endif
-#ifndef HAVE_WEBKIT2
+#ifdef HAVE_WEBKIT2
+static guint back_forward_list_counter = 0;
+
+static void
+back_forward_list_changed (WebKitBackForwardList *list,
+ WebKitBackForwardListItem *added_item,
+ GList *removed_items,
+ GMainLoop *loop)
+{
+ back_forward_list_counter--;
+
+ if (back_forward_list_counter == 0)
+ g_main_loop_quit (loop);
+}
+
+static void
+wait_until_back_forward_list_changes (WebKitWebView *view,
+ GMainLoop *loop)
+{
+ WebKitBackForwardList *back_forward_list = webkit_web_view_get_back_forward_list (view);
+ g_signal_connect (back_forward_list, "changed", G_CALLBACK (back_forward_list_changed), loop);
+}
+
+static GMainLoop*
+setup_ensure_back_forward_list_changes (EphyWebView *view)
+{
+ GMainLoop *loop;
+
+ back_forward_list_counter = 1;
+
+ loop = g_main_loop_new (NULL, FALSE);
+ wait_until_back_forward_list_changes (WEBKIT_WEB_VIEW (view), loop);
+
+ return loop;
+}
+
+static void
+ensure_back_forward_list_changes (GMainLoop *loop)
+{
+ if (back_forward_list_counter != 0)
+ g_main_loop_run (loop);
+
+ g_assert_cmpint (back_forward_list_counter, ==, 0);
+ g_main_loop_unref (loop);
+}
+#endif
+
static void
test_ephy_web_view_provisional_load_failure_updates_back_forward_list (void)
{
@@ -353,21 +399,24 @@ test_ephy_web_view_provisional_load_failure_updates_back_forward_list (void)
const char *bad_url;
view = EPHY_WEB_VIEW (ephy_web_view_new ());
+#ifdef HAVE_WEBKIT2
+ loop = setup_ensure_back_forward_list_changes (view);
+#else
loop = g_main_loop_new (NULL, FALSE);
+#endif
bad_url = "http://localhost:2984375932/";
ephy_web_view_load_url (view, bad_url);
#ifdef HAVE_WEBKIT2
- g_signal_connect (view, "load-changed",
- G_CALLBACK (quit_main_loop_when_load_finished), loop);
+ ensure_back_forward_list_changes (loop);
#else
g_signal_connect (view, "notify::load-status",
G_CALLBACK (quit_main_loop_when_load_finished), loop);
-#endif
g_main_loop_run (loop);
g_main_loop_unref (loop);
+#endif
#ifdef HAVE_WEBKIT2
g_assert (webkit_back_forward_list_get_current_item (
@@ -387,7 +436,6 @@ test_ephy_web_view_provisional_load_failure_updates_back_forward_list (void)
g_object_unref (g_object_ref_sink (view));
}
-#endif
static gboolean
visit_url_cb (EphyHistoryService *service,
@@ -468,11 +516,8 @@ main (int argc, char *argv[])
g_test_add_func ("/embed/ephy-web-view/load_url",
test_ephy_web_view_load_url);
-#ifndef HAVE_WEBKIT2
- /* FIXME: see https://bugzilla.gnome.org/show_bug.cgi?id=695649 */
g_test_add_func ("/embed/ephy-web-view/provisional_load_failure_updates_back_forward_list",
test_ephy_web_view_provisional_load_failure_updates_back_forward_list);
-#endif
g_test_add_func ("/embed/ephy-web-view/error-pages-not-stored-in-history",
test_ephy_web_view_error_pages_not_stored_in_history);