[Xfce4-commits] <midori:master> Fix unit tests building with WebKit2

Christian Dywan noreply at xfce.org
Mon Apr 1 17:36:02 CEST 2013


Updating branch refs/heads/master
         to 3b6cfde8306aece485f37e36698eb9153163ef45 (commit)
       from 0bd1a896073715ff235ae433581b936f7420ae67 (commit)

commit 3b6cfde8306aece485f37e36698eb9153163ef45
Author: Christian Dywan <christian at twotoasts.de>
Date:   Mon Apr 1 17:33:45 2013 +0200

    Fix unit tests building with WebKit2

 tests/browser.c     |    2 ++
 tests/download.vala |   12 +++++++++++-
 tests/extensions.c  |    2 ++
 tests/properties.c  |    2 ++
 tests/tab.vala      |   19 +++++++++++++++++++
 5 files changed, 36 insertions(+), 1 deletions(-)

diff --git a/tests/browser.c b/tests/browser.c
index e20dfc5..8e5ab9b 100644
--- a/tests/browser.c
+++ b/tests/browser.c
@@ -165,8 +165,10 @@ main (int    argc,
     midori_app_setup (&argc, &argv, NULL);
     midori_paths_init (MIDORI_RUNTIME_MODE_NORMAL, NULL);
 
+    #ifndef HAVE_WEBKIT2
     g_object_set_data (G_OBJECT (webkit_get_default_session ()),
                        "midori-session-initialized", (void*)1);
+    #endif
 
     g_test_add_func ("/browser/create", browser_create);
     g_test_add_func ("/browser/tooltips", browser_tooltips);
diff --git a/tests/download.vala b/tests/download.vala
index f7ebe35..8ef8899 100644
--- a/tests/download.vala
+++ b/tests/download.vala
@@ -69,7 +69,11 @@ static void download_unique () {
 }
 
 void download_properties () {
+#if HAVE_WEBKIT2
+    var download = WebKit.WebContext.get_default ().download_uri ("file:///klaatu/barada/nikto.ogg");
+#else
     var download = new WebKit.Download (new WebKit.NetworkRequest ("file:///klaatu/barada/nikto.ogg"));
+#endif
     assert (Midori.Download.get_type (download) == 0);
     Midori.Download.set_type (download, Midori.DownloadType.OPEN);
     assert (Midori.Download.get_type (download) == Midori.DownloadType.OPEN);
@@ -78,16 +82,22 @@ void download_properties () {
     try {
         string filename;
         FileUtils.close (FileUtils.open_tmp ("XXXXXX", out filename));
+#if HAVE_WEBKIT2
+        download.set_destination (Filename.to_uri (filename, null));
+#else
         download.destination_uri = Filename.to_uri (filename, null);
-        string tee = Midori.Download.get_tooltip (download);
         download.start ();
+#endif
+        string tee = Midori.Download.get_tooltip (download);
         assert (Midori.Download.get_progress (download) == 0.0);
         var loop = MainContext.default ();
         do { loop.iteration (true); } while (loop.pending ());
         string tee2 = Midori.Download.get_tooltip (download);
         assert (tee2.contains (tee));
         do { loop.iteration (true); } while (!Midori.Download.is_finished (download));
+#if !HAVE_WEBKIT2
         assert (download.status == WebKit.DownloadStatus.ERROR);
+#endif
     }
     catch (Error error) {
         GLib.error (error.message);
diff --git a/tests/extensions.c b/tests/extensions.c
index 01a15f2..34fadb7 100644
--- a/tests/extensions.c
+++ b/tests/extensions.c
@@ -218,8 +218,10 @@ main (int    argc,
     g_test_init (&argc, &argv, NULL);
     midori_app_setup (&argc, &argv, NULL);
     midori_paths_init (MIDORI_RUNTIME_MODE_NORMAL, NULL);
+    #ifndef HAVE_WEBKIT2
     soup_session_add_feature_by_type (webkit_get_default_session (),
         SOUP_TYPE_COOKIE_JAR);
+    #endif
 
     g_test_add_func ("/extensions/create", extension_create);
     g_test_add_func ("/extensions/settings", extension_settings);
diff --git a/tests/properties.c b/tests/properties.c
index 5434d1d..e0cc87b 100644
--- a/tests/properties.c
+++ b/tests/properties.c
@@ -87,8 +87,10 @@ main (int    argc,
     midori_app_setup (&argc, &argv, NULL);
     midori_paths_init (MIDORI_RUNTIME_MODE_PRIVATE, NULL);
 
+    #ifndef HAVE_WEBKIT2
     g_object_set_data (G_OBJECT (webkit_get_default_session ()),
                        "midori-session-initialized", (void*)1);
+    #endif
 
     g_test_add_data_func ("/properties/app",
         (gconstpointer)MIDORI_TYPE_APP, properties_type_test);
diff --git a/tests/tab.vala b/tests/tab.vala
index 02efc1c..6e9da64 100644
--- a/tests/tab.vala
+++ b/tests/tab.vala
@@ -134,31 +134,39 @@ void tab_alias () {
     tab.set_uri ("about:new");
     do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
     assert (tab.uri == tab.settings.tabhome);
+#if !HAVE_WEBKIT2
     // Check that this is the real page, not white page with a URL
     assert (!tab.web_view.search_text ("about:", true, false, false));
+#endif
 
     tab.settings.tabhome = "about:blank";
     tab.set_uri ("about:new");
     do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
     assert (tab.uri == tab.settings.tabhome);
+#if !HAVE_WEBKIT2
     // Check that this is the real page, not white page with a URL
     assert (!tab.web_view.search_text ("about:", true, false, false));
+#endif
 
     tab.settings.tabhome = "about:search";
     tab.settings.location_entry_search = "http://.invalid/";
     tab.set_uri ("about:new");
     do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
     assert (tab.uri == tab.settings.location_entry_search);
+#if !HAVE_WEBKIT2
     // Check that this is the real page, not white page with a URL
     assert (!tab.web_view.search_text ("about:", true, false, false));
+#endif
 
     tab.settings.tabhome = "about:home";
     tab.settings.homepage = "http://.invalid/";
     tab.set_uri ("about:new");
     do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
     assert (tab.uri == tab.settings.homepage);
+#if !HAVE_WEBKIT2
     // Check that this is the real page, not white page with a URL
     assert (!tab.web_view.search_text ("about:", true, false, false));
+#endif
 }
 
 void tab_http () {
@@ -201,14 +209,20 @@ void tab_http () {
 
     var source = new Midori.View.with_title (null, tab.settings);
     browser.add_tab (source);
+#if HAVE_WEBKIT2
+#else
     source.web_view.set_view_source_mode (true);
+#endif
     source.web_view.load_uri (test_url);
     do { loop.iteration (true); } while (source.load_status != Midori.LoadStatus.FINISHED);
     assert (!source.is_blank ());
     assert (!source.can_view_source ());
     assert (!source.special);
     /* FIXME assert (source.can_save ()); */
+#if HAVE_WEBKIT2
+#else
     assert (source.web_view.get_view_source_mode ());
+#endif
 
     source.set_uri ("http://.invalid");
     do { loop.iteration (true); } while (source.load_status != Midori.LoadStatus.FINISHED);
@@ -216,7 +230,10 @@ void tab_http () {
     assert (!source.can_view_source ());
     assert (source.special);
     assert (!source.can_save ());
+#if HAVE_WEBKIT2
+#else
     assert (!source.web_view.get_view_source_mode ());
+#endif
 
     Midori.Test.release_max_timeout ();
 }
@@ -262,7 +279,9 @@ void main (string[] args) {
     Test.init (ref args);
     Midori.App.setup (ref args, null);
     Midori.Paths.init (Midori.RuntimeMode.NORMAL, null);
+#if !HAVE_WEBKIT2
     WebKit.get_default_session ().set_data<bool> ("midori-session-initialized", true);
+#endif
     Test.add_func ("/tab/load-title", tab_load_title);
     Test.add_func ("/tab/display-title", tab_display_title);
     Test.add_func ("/tab/ellipsize", tab_display_ellipsize);


More information about the Xfce4-commits mailing list