[Xfce4-commits] <midori:master> Use test soup server for tab unit tests

Christian Dywan noreply at xfce.org
Sun Nov 18 16:52:06 CET 2012


Updating branch refs/heads/master
         to 87890b7cbe355c5dfb182bf846e02f5f859e5512 (commit)
       from 99013c6901d45a46b1b079359ee64ae914ff5f8a (commit)

commit 87890b7cbe355c5dfb182bf846e02f5f859e5512
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sun Nov 18 16:44:54 2012 +0100

    Use test soup server for tab unit tests
    
    No live website should be required for passing tests.

 midori/midori.vapi |    4 +++-
 tests/tab.vala     |   15 +++++++++++++--
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/midori/midori.vapi b/midori/midori.vapi
index 7d1890d..ce37fa8 100644
--- a/midori/midori.vapi
+++ b/midori/midori.vapi
@@ -68,6 +68,7 @@ namespace Midori {
         public Gtk.Statusbar statusbar { owned get; }
         [NoAccessorMethod]
         public string statusbar_text { owned get; set; }
+        [NoAccessorMethod]
         public Midori.WebSettings settings { get; set; }
         [NoAccessorMethod]
         public Katze.Array? bookmarks { owned get; set; }
@@ -159,7 +160,8 @@ namespace Midori {
         public bool minimized { get; }
         public float zoom_level { get; }
         public Katze.Array news_feeds { get; }
-        public WebSettings settings { get; set; }
+        [NoAccessorMethod]
+        public WebSettings settings { owned get; set; }
         public GLib.Object net { get; }
 
         [HasEmitter]
diff --git a/tests/tab.vala b/tests/tab.vala
index 7566175..85cb54c 100644
--- a/tests/tab.vala
+++ b/tests/tab.vala
@@ -80,6 +80,8 @@ void tab_special () {
     browser.set ("speed-dial", dial, "settings", settings);
     */
     var tab = new Midori.View.with_title ();
+    tab.settings = new Midori.WebSettings ();
+    tab.settings.set ("enable-plugins", false);
     browser.add (tab);
     /* browser.add_tab (tab); */
     var loop = MainContext.default ();
@@ -120,8 +122,17 @@ void tab_special () {
     /* FIXME assert (tab.special); */
     /* FIXME assert (!tab.can_save ()); */
 
-    /* FIXME use an HTTP URI that's available even offline */
-    tab.set_uri ("http://example.com");
+    var test_address = new Soup.Address ("127.0.0.1", Soup.ADDRESS_ANY_PORT);
+    test_address.resolve_sync ();
+    var test_server = new Soup.Server ("interface", test_address, null);
+    string test_url = "http://%s:%u".printf (test_address.get_physical (), test_server.get_port ());
+    test_server.run_async ();
+    test_server.add_handler ("/", (server, msg, path, query, client)=>{
+        msg.set_status_full (200, "OK");
+        msg.response_body.append_take ("<body></body>".data);
+        });
+
+    tab.set_uri (test_url);
     do { loop.iteration (true); } while (tab.load_status != Midori.LoadStatus.FINISHED);
     assert (!tab.is_blank ());
     assert (tab.can_view_source ());


More information about the Xfce4-commits mailing list