LibsocialwebTest.TestCase: defer creation of lsw_backend until set_up()
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Thu, 14 Mar 2013 15:50:06 +0000 (15:50 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Mon, 18 Mar 2013 19:08:30 +0000 (19:08 +0000)
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

index 18dffc2..f9a05d1 100644 (file)
@@ -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 ();