[folks] tests: Manually iterate main context on tear_down in various tests
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] tests: Manually iterate main context on tear_down in various tests
- Date: Sun, 6 Apr 2014 08:59:48 +0000 (UTC)
commit b2bdc304d02fde725c5ad0919036ea23f3301b4d
Author: Philip Withnall <philip withnall collabora co uk>
Date: Thu Apr 3 14:40:56 2014 +0100
tests: Manually iterate main context on tear_down in various 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.
See https://bugzilla.gnome.org/show_bug.cgi?id=727700.
https://bugzilla.gnome.org/show_bug.cgi?id=726973
tests/lib/bluez/test-case.vala | 9 +++++++++
tests/lib/eds/test-case.vala | 9 +++++++++
tests/lib/key-file/test-case.vala | 15 +++++++++++++++
tests/lib/libsocialweb/test-case.vala | 9 +++++++++
tests/lib/telepathy/test-case.vala | 9 +++++++++
tests/lib/tracker/test-case.vala | 9 +++++++++
6 files changed, 60 insertions(+), 0 deletions(-)
---
diff --git a/tests/lib/bluez/test-case.vala b/tests/lib/bluez/test-case.vala
index accaf0b..fafee05 100644
--- a/tests/lib/bluez/test-case.vala
+++ b/tests/lib/bluez/test-case.vala
@@ -122,6 +122,15 @@ public class BluezTest.TestCase : Folks.TestCase
Environment.unset_variable ("FOLKS_PRIMARY_STORE");
+ /* Ensure that all pending BlueZ operations are complete.
+ *
+ * FIXME: This should be eliminated and unprepare() should guarantee there
+ * are no more pending Backend/PersonaStore events.
+ *
+ * https://bugzilla.gnome.org/show_bug.cgi?id=727700 */
+ var context = MainContext.default ();
+ while (context.iteration (false));
+
base.tear_down ();
}
}
diff --git a/tests/lib/eds/test-case.vala b/tests/lib/eds/test-case.vala
index 3db29f4..8979b64 100644
--- a/tests/lib/eds/test-case.vala
+++ b/tests/lib/eds/test-case.vala
@@ -214,6 +214,15 @@ public class EdsTest.TestCase : Folks.TestCase
Environment.unset_variable ("FOLKS_PRIMARY_STORE");
+ /* Ensure that all pending operations are complete.
+ *
+ * FIXME: This should be eliminated and unprepare() should guarantee there
+ * are no more pending Backend/PersonaStore events.
+ *
+ * https://bugzilla.gnome.org/show_bug.cgi?id=727700 */
+ var context = MainContext.default ();
+ while (context.iteration (false));
+
base.tear_down ();
}
}
diff --git a/tests/lib/key-file/test-case.vala b/tests/lib/key-file/test-case.vala
index 762508b..870ee3e 100644
--- a/tests/lib/key-file/test-case.vala
+++ b/tests/lib/key-file/test-case.vala
@@ -47,4 +47,19 @@ public class KfTest.TestCase : Folks.TestCase
Environment.set_variable ("FOLKS_BACKENDS_ALLOWED", "key-file", true);
Environment.set_variable ("FOLKS_PRIMARY_STORE", "key-file", true);
}
+
+ public override void tear_down ()
+ {
+ /* Ensure that all pending key file operations (e.g. saving the key file)
+ * are complete.
+ *
+ * FIXME: This should be eliminated and unprepare() should guarantee there
+ * are no more pending Backend/PersonaStore events.
+ *
+ * https://bugzilla.gnome.org/show_bug.cgi?id=727700 */
+ var context = MainContext.default ();
+ while (context.iteration (false));
+
+ base.tear_down ();
+ }
}
diff --git a/tests/lib/libsocialweb/test-case.vala b/tests/lib/libsocialweb/test-case.vala
index 2617588..d3dc031 100644
--- a/tests/lib/libsocialweb/test-case.vala
+++ b/tests/lib/libsocialweb/test-case.vala
@@ -86,6 +86,15 @@ public class LibsocialwebTest.TestCase : Folks.TestCase
this.lsw_backend = 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.
+ *
+ * https://bugzilla.gnome.org/show_bug.cgi?id=727700 */
+ var context = MainContext.default ();
+ while (context.iteration (false));
+
base.tear_down ();
}
}
diff --git a/tests/lib/telepathy/test-case.vala b/tests/lib/telepathy/test-case.vala
index 28ff908..2efb711 100644
--- a/tests/lib/telepathy/test-case.vala
+++ b/tests/lib/telepathy/test-case.vala
@@ -218,6 +218,15 @@ public class TpfTest.TestCase : Folks.TestCase
((!) this.kf_backend).tear_down ();
}
+ /* Ensure that all pending operations are complete.
+ *
+ * FIXME: This should be eliminated and unprepare() should guarantee there
+ * are no more pending Backend/PersonaStore events.
+ *
+ * https://bugzilla.gnome.org/show_bug.cgi?id=727700 */
+ var context = MainContext.default ();
+ while (context.iteration (false));
+
base.tear_down ();
}
}
diff --git a/tests/lib/tracker/test-case.vala b/tests/lib/tracker/test-case.vala
index fd0df80..664cc8a 100644
--- a/tests/lib/tracker/test-case.vala
+++ b/tests/lib/tracker/test-case.vala
@@ -111,6 +111,15 @@ public class TrackerTest.TestCase : Folks.TestCase
((!) this.tracker_backend).tear_down ();
}
+ /* Ensure that all pending BlueZ operations are complete.
+ *
+ * FIXME: This should be eliminated and unprepare() should guarantee there
+ * are no more pending Backend/PersonaStore events.
+ *
+ * https://bugzilla.gnome.org/show_bug.cgi?id=727700 */
+ 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]