[folks] tests: Manually iterate main context on tear_down in Dummy tests



commit 45e1af8c28747154278ee5058a3b144899050abb
Author: Travis Reitter <travis reitter collabora co uk>
Date:   Mon Apr 7 09:12:02 2014 -0700

    tests: Manually iterate main context on tear_down in Dummy tests
    
    The code under test in these cases doesn’t (yet) correctly ensure there
    are no pending events before returning. To avoid assertion failure,
    manually iterate the global default main context until all pending
    events have been handled, then continue to tear_down.
    
    In future, it would be better to fix the tests and backends themselves
    to not leak main context events after unprepare() has been called.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=726973

 tests/lib/dummy/test-case.vala |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/tests/lib/dummy/test-case.vala b/tests/lib/dummy/test-case.vala
index c5e7ebe..4379677 100644
--- a/tests/lib/dummy/test-case.vala
+++ b/tests/lib/dummy/test-case.vala
@@ -140,6 +140,14 @@ public class DummyTest.TestCase : Folks.TestCase
       this.dummy_persona_store = null;
       this.dummy_backend = null;
       this._backend_store = null;
+
+      /* Ensure that all pending operations are complete.
+       *
+       * FIXME: This should be eliminated and unprepare() should guarantee there
+       * are no more pending Backend/PersonaStore events. */
+      var context = MainContext.default ();
+      while (context.iteration (false));
+
       base.tear_down ();
     }
 }


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