[epiphany] Fix test ephy-web-view



commit 255a3edf6c849d68a8135d6e94b07a0317134c9f
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Fri Dec 21 14:57:12 2018 +0100

    Fix test ephy-web-view
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/378

 embed/ephy-embed-shell.c   | 17 ++++-------------
 tests/ephy-web-view-test.c |  9 +++++++--
 tests/meson.build          | 19 +++++++++----------
 3 files changed, 20 insertions(+), 25 deletions(-)
---
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 29efccd38..191b11b62 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -837,8 +837,6 @@ ephy_embed_shell_startup (GApplication *application)
 
   G_APPLICATION_CLASS (ephy_embed_shell_parent_class)->startup (application);
 
-  ephy_embed_shell_create_web_context (shell);
-
   webkit_web_context_set_process_model (priv->web_context, 
WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES);
 
   webkit_web_context_set_sandbox_enabled (priv->web_context, TRUE);
@@ -854,7 +852,6 @@ ephy_embed_shell_startup (GApplication *application)
                            G_CALLBACK (initialize_web_process_extensions),
                            shell, 0);
 
-  priv->permissions_manager = ephy_permissions_manager_new ();
   g_signal_connect_object (priv->web_context, "initialize-notification-permissions",
                            G_CALLBACK (initialize_notification_permissions),
                            shell, 0);
@@ -909,8 +906,6 @@ ephy_embed_shell_startup (GApplication *application)
                                          EPHY_PREFS_WEB_COOKIES_POLICY);
   ephy_embed_prefs_set_cookie_accept_policy (cookie_manager, cookie_policy);
 
-  priv->filters_manager = ephy_filters_manager_new (NULL);
-
   g_signal_connect_object (priv->web_context, "download-started",
                            G_CALLBACK (download_started_cb), shell, 0);
 
@@ -966,21 +961,17 @@ ephy_embed_shell_constructed (GObject *object)
 {
   EphyEmbedShell *shell;
   EphyEmbedShellPrivate *priv;
-  EphyEmbedShellMode mode;
 
   G_OBJECT_CLASS (ephy_embed_shell_parent_class)->constructed (object);
 
   shell = EPHY_EMBED_SHELL (object);
   priv = ephy_embed_shell_get_instance_private (shell);
   priv->guid = g_dbus_generate_guid ();
-  mode = ephy_embed_shell_get_mode (shell);
 
-  /* These do not run the EmbedShell application instance, so make sure that
-   *  there is a web context and a user content manager for them. */
-  if (mode == EPHY_EMBED_SHELL_MODE_TEST ||
-      mode == EPHY_EMBED_SHELL_MODE_SEARCH_PROVIDER) {
-    ephy_embed_shell_create_web_context (shell);
-  }
+  ephy_embed_shell_create_web_context (shell);
+
+  priv->permissions_manager = ephy_permissions_manager_new ();
+  priv->filters_manager = ephy_filters_manager_new (NULL);
 }
 
 static void
diff --git a/tests/ephy-web-view-test.c b/tests/ephy-web-view-test.c
index 797715f45..22a473011 100644
--- a/tests/ephy-web-view-test.c
+++ b/tests/ephy-web-view-test.c
@@ -141,8 +141,10 @@ test_ephy_web_view_load_url (void)
     URLTest test;
     GMainLoop *loop;
     EphyWebView *view;
+    GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
 
     view = EPHY_WEB_VIEW (ephy_web_view_new ());
+    gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (view));
     test = test_load_url[i];
     loop = g_main_loop_new (NULL, FALSE);
 
@@ -316,11 +318,11 @@ test_ephy_web_view_normalize_or_autosearch (void)
                                             "http://www.google.com/?q=%s";,
                                             "");
 
-  g_assert_true (ephy_search_engine_manager_set_default_engine (manager, default_engine));
   verify_normalize_or_autosearch_urls (view, normalize_or_autosearch_test_google, G_N_ELEMENTS 
(normalize_or_autosearch_test_google));
 
   ephy_search_engine_manager_delete_engine (manager, "org.gnome.Epiphany.EphyWebViewTest");
 
+  g_assert_true (ephy_search_engine_manager_set_default_engine (manager, default_engine));
   g_free (default_engine);
   g_object_unref (g_object_ref_sink (view));
 }
@@ -392,7 +394,7 @@ test_ephy_web_view_provisional_load_failure_updates_back_forward_list (void)
   view = EPHY_WEB_VIEW (ephy_web_view_new ());
 
   loop = setup_ensure_back_forward_list_changes (view);
-  bad_url = "http://localhost:2984375932/";;
+  bad_url = "http://localhost:2984375930/";;
 
   ephy_web_view_load_url (view, bad_url);
 
@@ -412,6 +414,9 @@ visit_url_cb (EphyHistoryService *service,
               EphyHistoryURL     *url,
               gpointer            user_data)
 {
+  if (strcmp (url->url, "http://localhost:2984375932/";) != 0)
+    return;
+
   /* We are only loading an error page, this code should never be
    * reached. */
   g_assert_not_reached ();
diff --git a/tests/meson.build b/tests/meson.build
index a6572b721..d879d6aea 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -175,16 +175,15 @@ if get_option('unit_tests').enabled()
        env: envs
   )
 
-  # FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=780280
-  # web_view_test = executable('test-ephy-web-view',
-  #   'ephy-web-view-test.c',
-  #   dependencies: ephymain_dep,
-  #   c_args: test_cargs,
-  # )
-  # test('Web view test',
-  #      web_view_test,
-  #      env: envs
-  # )
+  web_view_test = executable('test-ephy-web-view',
+    'ephy-web-view-test.c',
+    resources,
+    dependencies: ephymain_dep
+  )
+  test('Web view test',
+       web_view_test,
+       env: envs
+  )
 
   if get_option('network_tests').enabled()
     gsb_service_test = executable('test-ephy-gsb-service',


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