[folks] Test: disconnect individuals_changed signal to avoid race



commit 470410c9f7d78a31632f6d1e98459efec16d1030
Author: Xavier Claessens <xavier claessens collabora co uk>
Date:   Fri Mar 30 10:19:32 2012 +0200

    Test: disconnect individuals_changed signal to avoid race
    
    Otherwise, deleting the 2nd account runs the mainloop and could make
    the aggregator realize the 1st account got removed and start removing
    its individuals.

 tests/folks/aggregation.vala |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)
---
diff --git a/tests/folks/aggregation.vala b/tests/folks/aggregation.vala
index f9b7236..e555998 100644
--- a/tests/folks/aggregation.vala
+++ b/tests/folks/aggregation.vala
@@ -640,7 +640,8 @@ public class AggregationTests : Folks.TestCase
 
       /* Set up the aggregator */
       var aggregator = new IndividualAggregator ();
-      aggregator.individuals_changed_detailed.connect ((changes) =>
+      var individuals_changed_detailed_id =
+          aggregator.individuals_changed_detailed.connect ((changes) =>
         {
           var removed = changes.get_keys ();
           var added = changes.get_values ();
@@ -648,7 +649,8 @@ public class AggregationTests : Folks.TestCase
           this._test_user_individuals_changed (true, added, removed,
               ref user_individual_detailed);
         });
-      aggregator.individuals_changed.connect ((added, removed, m, a, r) =>
+      var individuals_changed_id =
+          aggregator.individuals_changed.connect ((added, removed, m, a, r) =>
         {
           this._test_user_individuals_changed (false, added, removed,
               ref user_individual);
@@ -711,6 +713,9 @@ public class AggregationTests : Folks.TestCase
       assert (display_ids_detailed.contains ("me example com") &&
           display_ids_detailed.contains ("me2 example com"));
 
+      aggregator.disconnect (individuals_changed_id);
+      aggregator.disconnect (individuals_changed_detailed_id);
+
       /* Clean up for the next test */
       this._tp_backend.remove_account (account2_handle);
       this._tp_backend.remove_account (account1_handle);
@@ -770,14 +775,16 @@ public class AggregationTests : Folks.TestCase
 
       /* Set up the aggregator */
       var aggregator = new IndividualAggregator ();
-      aggregator.individuals_changed_detailed.connect ((changes) =>
+      var individuals_changed_detailed_id =
+          aggregator.individuals_changed_detailed.connect ((changes) =>
         {
           var removed = changes.get_keys ();
           var added = changes.get_values ();
 
           this._test_untrusted_store_individuals_changed (true, added, removed);
         });
-      aggregator.individuals_changed.connect ((added, removed, m, a, r) =>
+      var individuals_changed_id =
+          aggregator.individuals_changed.connect ((added, removed, m, a, r) =>
         {
           this._test_untrusted_store_individuals_changed (false, added,
               removed);
@@ -813,6 +820,9 @@ public class AggregationTests : Folks.TestCase
 
       main_loop.run ();
 
+      aggregator.disconnect (individuals_changed_id);
+      aggregator.disconnect (individuals_changed_detailed_id);
+
       /* Clean up for the next test */
       this._tp_backend.remove_account (account2_handle);
       this._tp_backend.remove_account (account1_handle);



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