[folks] LibsocialwebTest.TestCase: defer creation of lsw_backend until set_up()



commit fb2abc0ab8a72b346d30679df39dd217d092b676
Author: Simon McVittie <simon mcvittie collabora co uk>
Date:   Thu Mar 14 15:50:06 2013 +0000

    LibsocialwebTest.TestCase: defer creation of lsw_backend until set_up()
    
    Also destroy it in tear_down(), for symmetry. Since there are only two
    LSW test cases and neither of them has more than one test, we don't
    need to worry much about compatibility - it's easy to check.
    
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=695381
    Signed-off-by: Simon McVittie <simon mcvittie collabora co uk>
    Reviewed-by: Philip Withnall <philip tecnocode co uk>

 tests/lib/libsocialweb/test-case.vala |   34 +++++++++++++++-----------------
 1 files changed, 16 insertions(+), 18 deletions(-)
---
diff --git a/tests/lib/libsocialweb/test-case.vala b/tests/lib/libsocialweb/test-case.vala
index 18dffc2..f9a05d1 100644
--- a/tests/lib/libsocialweb/test-case.vala
+++ b/tests/lib/libsocialweb/test-case.vala
@@ -30,8 +30,6 @@ public class LibsocialwebTest.TestCase : Folks.TestCase
     {
       base (name);
 
-      this.lsw_backend = new LibsocialwebTest.Backend ();
-
       Environment.set_variable ("FOLKS_BACKENDS_ALLOWED", "libsocialweb", true);
       Environment.set_variable ("FOLKS_PRIMARY_STORE", "", true);
     }
@@ -40,25 +38,24 @@ public class LibsocialwebTest.TestCase : Folks.TestCase
     {
       base.set_up ();
 
-      if (this.lsw_backend != null)
-        {
-          var lsw_backend = (!) this.lsw_backend;
+      this.lsw_backend = new LibsocialwebTest.Backend ();
 
-          var main_loop = new GLib.MainLoop (null, false);
+      var lsw_backend = (!) this.lsw_backend;
 
-          this.lsw_backend.ready.connect (() =>
-            {
-              main_loop.quit ();
-            });
-          uint timer_id = Timeout.add_seconds (5, () =>
-            {
-              assert_not_reached ();
-            });
+      var main_loop = new GLib.MainLoop (null, false);
 
-          lsw_backend.set_up ();
-          main_loop.run ();
-          Source.remove (timer_id);
-        }
+      this.lsw_backend.ready.connect (() =>
+        {
+          main_loop.quit ();
+        });
+      uint timer_id = Timeout.add_seconds (5, () =>
+        {
+          assert_not_reached ();
+        });
+
+      lsw_backend.set_up ();
+      main_loop.run ();
+      Source.remove (timer_id);
     }
 
   public override void tear_down ()
@@ -66,6 +63,7 @@ public class LibsocialwebTest.TestCase : Folks.TestCase
       if (this.lsw_backend != null)
         {
           ((!) this.lsw_backend).tear_down ();
+          this.lsw_backend = null;
         }
 
       base.tear_down ();


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