this._test_add_persona_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
foreach (var k in this._properties_found.get_values ())
{
this._test_anti_linking_basic_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- stderr.printf ("Personas failed to be anti-linked\n");
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_before_update);
assert (this._found_after_update);
this._test_anti_linking_removal_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- stderr.printf ("Personas failed to be anti-linked\n");
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_before_update);
assert (this._found_after_update);
this._test_avatar_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- return false;
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (this._main_loop);
assert (this._avatars_are_equal);
}
this._test_creating_removing_stores_async.begin ();
- var timer_id = Timeout.add_seconds (20, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop, 20);
assert (this._store_removed.size > 0);
foreach (bool removed in this._store_removed.values)
{
assert (removed == true);
}
-
- GLib.Source.remove (timer_id);
+
this._aggregator = null;
this._main_loop = null;
}
this._test_email_details_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- return false;
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (this._main_loop, 5);
assert (this._email_count == 6);
assert (this._email_types.size == 1);
this._test_disabling_stores_async.begin ();
- var timer_id = Timeout.add_seconds (8, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._store_removed.size > 0);
foreach (bool removed in this._store_removed.values)
{
assert (removed == true);
}
-
- GLib.Source.remove (timer_id);
+
this._aggregator = null;
this._main_loop = null;
}
this._test_im_details_interface_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._num_addrs == 2);
assert (this._found_addr_1 == true);
this._test_singleton_individuals_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- return false;
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (this._main_loop, 5);
assert (this._found_individuals.size == 2);
}
this._test_linking_personas_async.begin ();
- var timer_id = Timeout.add_seconds (8, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop, 8);
assert (this._linked_individual_found == true);
- GLib.Source.remove (timer_id);
this._aggregator = null;
this._main_loop = null;
}
this._test_linking_personas_async.begin ();
- var timer_id = Timeout.add_seconds (8, () =>
- {
- // Let the main loop run out of events before we quit (yes, this is a HACK)
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- return false;
- });
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop, 8);
- GLib.Source.remove (timer_id);
this._aggregator = null;
this._main_loop = null;
}
if (this._linking_props.size == 0)
{
+ /* FIXME: if the timeout is reached, should this just fail? */
Timeout.add_seconds (5, () =>
{
this._main_loop.quit ();
this._test_linkable_properties_aggregate_after_change_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- stderr.printf ("Personas failed to be aggregated after being given " +
- "the same linkable properties\n");
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_before_update);
assert (this._found_after_update);
this._test_names_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- return false;
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (this._main_loop, 5);
assert (this._names_count == 2);
assert (this._c1.size == 0);
backend_store.load_backends.begin ();
- Timeout.add_seconds (3, () =>
- {
- main_loop.quit ();
- return false;
- });
-
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop);
assert (this._capabilities_received.contains ("can-add-personas"));
assert (this._capabilities_received.contains ("can-remove-personas"));
this._test_phone_numbers_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- return false;
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (this._main_loop, 5);
assert (this._phones_count == 6);
assert (this._phone_types.size == 3);
this._test_postal_address_details_interface_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_postal_address == true);
}
this._test_remove_persona_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._persona_removed == true);
assert (this._individual_removed == true);
this._test_removal_async.begin ();
- Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- return false;
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (this._main_loop, 5);
assert (this._added == true);
assert (this._removed == true);
this._test_set_avatar_async.begin ();
- var timeout_id = Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_before_update);
assert (this._found_after_update);
- Source.remove (timeout_id);
this._aggregator = null;
this._main_loop = null;
}
this._test_set_individual_avatar_async.begin ();
- var timeout_id = Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_before_update);
assert (this._found_after_update);
- Source.remove (timeout_id);
this._aggregator = null;
this._main_loop = null;
}
this._test_set_birthday_async.begin ();
- Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_before_update);
assert (this._found_after_update);
this._test_set_emails_async.begin ();
- Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_before_update);
assert (this._found_after_update);
this._test_set_gender_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._gender_before_update);
assert (this._gender_after_update);
this._test_set_im_addresses_async.begin ();
- Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_before_update);
assert (this._found_after_update);
this._test_set_is_favourite_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (!this._is_favourite_before_update);
assert (this._is_favourite_after_update);
this._test_set_names_async.begin ();
- Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._full_name_found_before_update);
assert (this._full_name_found_after_update);
this._test_set_full_name_async.begin ();
- Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_before_update);
assert (this._found_after_update);
this._test_set_phones_async.begin ();
- Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_before_update);
assert (this._found_after_update);
this._test_set_postal_addresses_async.begin ();
- Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_before_update);
assert (this._found_after_update);
this._test_set_postal_addresses_async.begin ();
- Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_before_update);
assert (this._found_after_update);
this._test_set_roles_async.begin ();
- Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop, 5);
assert (this._found_before_update);
assert (this._found_after_update);
this._test_set_structured_name_async.begin ();
- Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop, 5);
assert (this._found_before_update);
assert (this._found_after_update);
this._test_set_urls_async.begin ();
- Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop, 5);
assert (this._found_before_update);
assert (this._found_url_extra_1);
/* Schedule the test to start with the main loop. */
this._test_single_store_part1_async.begin ();
- var timeout_id = Timeout.add_seconds (5, () =>
- {
- critical ("Timeout reached.");
- return false;
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop, 5);
/* We should have a single individual by now. */
assert (this._aggregator.individuals.size == 1);
- GLib.Source.remove (timeout_id);
-
/* Part 2, where we remove the address book. */
this._test_single_store_part2_async.begin ();
- timeout_id = Timeout.add_seconds (5, () =>
- {
- critical ("Timeout reached.");
- return false;
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop, 5);
/* The individual should be gone. */
assert (this._aggregator.individuals.size == 0);
-
- GLib.Source.remove (timeout_id);
}
private async void _test_single_store_part1_async ()
this._test_updates_async.begin ();
- Timeout.add_seconds (5, () => {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop, 5);
assert (this._found_before_update);
assert (this._found_after_update);
public class AggregationTests : TpfTest.MixedTestCase
{
private HashSet<string> _default_personas;
- private int _test_timeout = 3;
public AggregationTests ()
{
this.test_ensure_individual_property_writeable_add_persona);
this.add_test ("ensure individual property writeable:failure",
this.test_ensure_individual_property_writeable_failure);
-
- if (Environment.get_variable ("FOLKS_TEST_VALGRIND") != null)
- this._test_timeout = 10;
}
public override void set_up_tp ()
/* Kill the main loop after a few seconds. If there are still individuals
* in the set of expected individuals, the aggregator has either failed or
* been too slow (which we can consider to be failure). */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
/* We should have enumerated exactly the individuals in the set */
assert (expected_individuals.size == 0);
/* Kill the main loop after a few seconds. If there are still individuals
* in the set of expected individuals, the aggregator has either failed or
* been too slow (which we can consider to be failure). */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
/* Verify the two individuals we should have */
assert (individual1 != null);
/* Kill the main loop after a few seconds. If there are still individuals
* in the set of expected individuals, the aggregator has either failed or
* been too slow (which we can consider to be failure). */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
/* Verify the two individuals we should have */
assert (individual1 != null);
/* Kill the main loop after a few seconds. If there are still individuals
* in the set of expected individuals, the aggregator has either failed or
* been too slow (which we can consider to be failure). */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
/* The user exported by the aggregator should be the same as the one
* we've kept track of */
/* Kill the main loop after a few seconds. If there are still individuals
* in the set of expected individuals, the aggregator has either failed or
* been too slow (which we can consider to be failure). */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
aggregator.disconnect (individuals_changed_id);
aggregator.disconnect (individuals_changed_detailed_id);
/* Kill the main loop after a few seconds. We can assume that we've
* reached a quiescent state by this point. */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
/* Check that all Individuals are either ADDED or FINALISED. There should
* be no Individuals which are REMOVED (but not yet finalised). */
/* Kill the main loop after a few seconds. We can assume that we've
* reached another quiescent state by this point. */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
/* Now that the backends have been finalised, all the Individuals should
* have been finalised too. */
});
/* Kill the main loop after a few seconds. */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
/* Check we've got the individual we want */
assert (individual != null);
Persona? writeable_persona = null;
/* Kill the main loop after a few seconds. */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
assert (writeable_persona != null);
assert (writeable_persona == persona);
});
/* Kill the main loop after a few seconds. */
- var timeout_id = Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
/* Check we've got the individual we want */
assert (individual != null);
/* Remove the signal handler */
aggregator.disconnect (individuals_changed_id);
- Source.remove (timeout_id);
aggregator.individuals_changed_detailed.connect ((changes) =>
{
var added = changes.get_values ();
});
/* Kill the main loop after a few seconds. */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
assert (writeable_persona != null);
assert (writeable_persona != persona);
});
/* Kill the main loop after a few seconds. */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
/* Check we've got the individual we want */
assert (individual != null);
Persona? writeable_persona = null;
/* Kill the main loop after a few seconds. */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
assert (writeable_persona == null);
public class InitTests : TpfTest.MixedTestCase
{
- private int _test_timeout = 5;
-
public InitTests ()
{
base ("Init");
aggregator = null;
}
- /* Kill the main loop after a few seconds. */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
-
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 5);
/* Clean up for the next test */
tp_backend.remove_account (account2_handle);
public class IndividualRetrievalTests : KfTest.TestCase
{
- private int _test_timeout = 3;
-
public IndividualRetrievalTests ()
{
base ("IndividualRetrieval");
this.add_test ("singleton individuals", this.test_singleton_individuals);
this.add_test ("aliases", this.test_aliases);
-
- if (Environment.get_variable ("FOLKS_TEST_VALGRIND") != null)
- this._test_timeout = 10;
}
public void test_singleton_individuals ()
/* Kill the main loop after a few seconds. If there are still individuals
* in the set of expected individuals, the aggregator has either failed
* or been too slow (which we can consider to be failure). */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
-
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
/* We should have enumerated exactly the individuals in the set */
assert (expected_individuals.size == 0);
/* Kill the main loop after a few seconds. If there are still individuals
* in the set of expected individuals, the aggregator has either failed
* or been too slow (which we can consider to be failure). */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
-
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
/* We should have enumerated exactly one individual */
assert (individuals_changed_count == 1);
{
main_loop.quit ();
});
- uint timer_id = Timeout.add_seconds (5, () =>
- {
- assert_not_reached ();
- });
lsw_backend.set_up ();
- main_loop.run ();
- Source.remove (timer_id);
+ Folks.TestUtils.loop_run_with_timeout (main_loop, 5);
}
public override void tear_down ()
public extern static bool remove_directory_recursively (string path);
/**
+ * Apply an arbitrary fudge factor to the timeout, which might be
+ * appropriate for any debuggers or other slow wrappers we're using.
+ *
+ * @param timeout A timeout in any units
+ * @return A revised timeout in the same units
+ */
+ public static int multiply_timeout (int timeout)
+ {
+ int result = timeout;
+
+ if (Environment.get_variable ("FOLKS_TEST_VALGRIND") != null)
+ {
+ result *= 10;
+ }
+
+ if (Environment.get_variable ("FOLKS_TEST_CALLGRIND") != null)
+ {
+ result *= 10;
+ }
+
+ return result;
+ }
+
+ /**
+ * Run //loop// with a timeout. Something should call ``loop.quit()``
+ * before the timeout is reached. If not, a fatal error occurs.
+ *
+ * @param loop A main loop.
+ * @param timeout A timeout, initially in seconds, defaulting to long
+ * enough to do something "reasonably fast". It will be adjusted with
+ * multiply_timeout() before use.
+ */
+ public static void loop_run_with_timeout (MainLoop loop, int timeout = 5)
+ {
+ var source = new TimeoutSource.seconds (
+ TestUtils.multiply_timeout (timeout));
+ source.set_callback (() => { error ("Timed out"); });
+ source.attach (loop.get_context ());
+
+ loop.run ();
+
+ source.destroy ();
+ }
+
+ /**
+ * Run //loop// with a timeout. Something should call ``loop.quit()``
+ * before the timeout is reached. If not, the timeout callback will do so.
+ *
+ * This function is a bad idea: we don't want things to run for an arbitrary
+ * time. Use loop_run_with_timeout() instead.
+ *
+ * FIXME: Remove this when it has no more callers.
+ *
+ * @param loop A main loop.
+ * @param timeout A timeout, initially in seconds, defaulting to long
+ * enough to do something "reasonably fast". It will be adjusted with
+ * multiply_timeout() before use.
+ */
+ [Deprecated (replacement = "loop_run_with_timeout")]
+ public static void loop_run_with_non_fatal_timeout (MainLoop loop,
+ int timeout = 3)
+ {
+ var source = new TimeoutSource.seconds (
+ TestUtils.multiply_timeout (timeout));
+ source.set_callback (() =>
+ {
+ loop.quit ();
+ return false;
+ });
+ source.attach (loop.get_context ());
+
+ loop.run ();
+
+ source.destroy ();
+ }
+
+ /**
* Compare the content of two {@link LoadableIcon}s for equality.
*
* This is in contrast to {@link Icon.equal}, which returns ``false`` for
});
aggregator.prepare.begin ();
- uint timer_id = Timeout.add_seconds (5, () =>
- {
- assert_not_reached ();
- });
- main_loop.run ();
- Source.remove (timer_id);
+ TestUtils.loop_run_with_timeout (main_loop, 5);
aggregator.disconnect (handler_id);
/* Check the aggregator got the correct data */
return false;
});
- timer_id = Timeout.add_seconds (5, () =>
- {
- assert_not_reached ();
- });
- main_loop.run ();
- Source.remove (timer_id);
+ TestUtils.loop_run_with_timeout (main_loop, 5);
}
}
assert_not_reached ();
}
- uint timer_id = Timeout.add_seconds (5, () =>
- {
- assert_not_reached ();
- });
- main_loop.run ();
- Source.remove (timer_id);
+ TestUtils.loop_run_with_timeout (main_loop, 5);
/* Test adding two contacts */
});
aggregator.prepare.begin ();
- timer_id = Timeout.add_seconds (5, () =>
- {
- assert_not_reached ();
- });
- main_loop.run ();
- Source.remove (timer_id);
+ TestUtils.loop_run_with_timeout (main_loop, 5);
aggregator.disconnect (handler_id);
assert (i1 != null);
assert (i2 != null);
main_loop.quit ();
});
- timer_id = Timeout.add_seconds (5, () =>
- {
- assert_not_reached ();
- });
- main_loop.run ();
- Source.remove (timer_id);
+ TestUtils.loop_run_with_timeout (main_loop, 5);
i1.disconnect (handler_id);
/* Test deleting two contacts */
main_loop.quit ();
});
- timer_id = Timeout.add_seconds (5, () =>
- {
- assert_not_reached ();
- });
- main_loop.run ();
- Source.remove (timer_id);
+ TestUtils.loop_run_with_timeout (main_loop, 5);
aggregator.disconnect (handler_id);
}
}
public class IndividualPropertiesTests : TpfTest.TestCase
{
- private int _test_timeout = 3;
private HashSet<string>? _changes_pending = null;
public IndividualPropertiesTests ()
this.test_individual_properties_change_alias_through_test_cm);
this.add_test ("individual properties:change contact info",
this.test_individual_properties_change_contact_info);
-
- if (Environment.get_variable ("FOLKS_TEST_VALGRIND") != null)
- this._test_timeout = 10;
}
public override void set_up ()
/* Kill the main loop after a few seconds. If there are still individuals
* in the set of expected individuals, the aggregator has either failed
* or been too slow (which we can consider to be failure). */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
-
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop);
/* necessary to reset the aggregator for the next test */
aggregator = null;
/* Kill the main loop after a few seconds. If the alias hasn't been
* notified, something along the way failed or been too slow (which we can
* consider to be failure). */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
-
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop);
assert (alias_notified);
/* Kill the main loop after a few seconds. If the alias hasn't been
* notified, something along the way failed or been too slow (which we can
* consider to be failure). */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
-
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop);
assert (alias_notified);
/* Kill the main loop after a few seconds. If the alias hasn't been
* notified, something along the way failed or been too slow (which we can
* consider to be failure). */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
-
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop);
assert (this._changes_pending.size == 0);
public class IndividualRetrievalTests : TpfTest.TestCase
{
private HashSet<string> default_individuals;
- private int _test_timeout = 3;
public IndividualRetrievalTests ()
{
this.add_test ("aggregator", this.test_aggregator);
this.add_test ("aggregator:add", this.test_aggregator_add);
-
- if (Environment.get_variable ("FOLKS_TEST_VALGRIND") != null)
- this._test_timeout = 10;
}
public void test_aggregator ()
/* Kill the main loop after a few seconds. If there are still individuals
* in the set of expected individuals, the aggregator has either failed or
* been too slow (which we can consider to be failure). */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop);
/* We should have enumerated exactly the individuals in the set */
assert (expected_individuals.size == 0);
/* Kill the main loop after a few seconds. If there are still individuals
* in the set of expected individuals, the aggregator has either failed or
* been too slow (which we can consider to be failure). */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
Idle.add (() =>
{
return false;
});
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop);
/* We should have received (and removed) the individuals in the set */
assert (added_individuals.size == 0);
public class InitTests : TpfTest.TestCase
{
- private int _test_timeout = 5;
-
public InitTests ()
{
base ("Init");
});
/* Add a timeout for failure. */
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
-
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (this._main_loop, 5);
/* Check results. */
assert (aggregator.is_quiescent == true);
public class PersonaStoreCapabilitiesTests : TpfTest.TestCase
{
private HashSet<string>? _capabilities_received = null;
- private int _test_timeout = 3;
public PersonaStoreCapabilitiesTests ()
{
this.add_test ("persona store capabilities",
this.test_persona_store_capabilities);
-
- if (Environment.get_variable ("FOLKS_TEST_VALGRIND") != null)
- this._test_timeout = 10;
}
public override void set_up ()
backend_store.load_backends.begin ();
- Timeout.add_seconds (this._test_timeout, () =>
- {
- main_loop.quit ();
- return false;
- });
-
- main_loop.run ();
+ TestUtils.loop_run_with_non_fatal_timeout (main_loop);
assert (this._capabilities_received.contains ("can-add-personas"));
assert (this._capabilities_received.contains ("can-remove-personas"));
this._test_add_contact_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._contact_added == true);
}
this._test_add_persona_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
foreach (var k in this._properties_found.get_values ())
{
var store = BackendStore.dup ();
_test_additional_names_updates_async.begin (store);
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_additional_names_found == true);
assert (this._updated_additional_names_found == true);
test_avatar_details_interface_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._avatars_are_equal);
}
test_avatar_updates_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_avatar_found == true);
assert (this._updated_avatar_found == true);
this._test_birthay_details_interface.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_birthday == true);
}
test_birthday_updates_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_birthday_found == true);
assert (this._updated_birthday_found == true);
_test_default_contact_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_default_user == true);
assert (this._found_not_user == true);
this._test_duplicated_emails_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._individual_id_1 != "");
assert (this._individual_id_2 != "");
}
this._test_duplicated_phones_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._individual_id_1 != "");
assert (this._individual_id_2 != "");
}
this._test_email_details_interface_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._num_emails == 2);
assert (this._found_email_1 == true);
this._test_emails_updates_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_email_found == true);
this._test_family_name_updates_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_family_name_found == true);
assert (this._updated_family_name_found == true);
this._test_favourite_details_interface_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- return false;
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_p1 == true);
assert (this._found_p2 == true);
// this timer is slightly higher than usual because sleep
// to ensure a (usually delayed) INSERT event has happened
- Timeout.add_seconds (7, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop, 7);
assert (this._is_favourite_1 == true);
assert (this._is_favourite_2 == false);
this._test_fullname_updates_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_name_found == true);
assert (this._updated_name_found == true);
this._test_gender_details_interface_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- return false;
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_gender == true);
}
this._test_given_name_updates_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_given_name_found == true);
assert (this._updated_given_name_found == true);
this._test_im_details_interface_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._num_addrs == 2);
assert (this._found_addr_1 == true);
this._test_imaddresses_updates_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_imaddress_found == true);
assert (this._updated_imaddr_found == true);
this._test_singleton_individuals_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._c1.size == 0);
assert (this._c2.size == 0);
/* Kill the main loop after 8 seconds: if the linked individual hasn't
* show up at this point then we've either seen an error or we've been
* too slow (which we can consider to be failure). */
- Timeout.add_seconds (8, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop, 8);
/* Check we get the new individual (containing the linked
* personas) and that the previous ones were removed. */
/* Kill the main loop after 5 seconds: if the linked individual hasn't
* show up at this point then we've either seen an error or we've been
* too slow (which we can consider to be failure). */
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
/* Check we get the new individual (containing the linked
* personas) and that the previous ones were removed. */
this._test_match_all_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
/* Expected outcome:
*
this._test_match_email_addresses_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._match >= Folks.MatchResult.HIGH);
}
this._test_match_im_addresses_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._match >= Folks.MatchResult.HIGH);
}
this._test_match_email_addresses_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
/* Some e-mail addresses (namely admin, webmaster, etc.)
* are considered common alias so they shouldn't
this._test_match_name_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
}
public void test_match_name_1 ()
this._test_match_phone_number_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
/* Phone number match is very decisive */
assert (this._match == Folks.MatchResult.HIGH);
this._test_name_details_interface_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._c1.size == 0);
assert (this._c2.size == 0);
this._test_nickname_updates_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._updated_nickname_found == true);
}
this._test_note_details_interface_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_note == true);
}
this._test_phone_details_interface_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._num_phones == 2);
assert (this._found_phone_1 == true);
this._test_phones_updates_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_phone_found == true);
assert (this._initial_phone_found_again == false);
this._test_postal_address_details_interface_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_postal_address == true);
}
this._test_prefix_name_updates_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_prefix_name_found == true);
assert (this._updated_prefix_name_found == true);
this._test_remove_contact_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._contact_added == true);
assert (this._contact_removed == true);
this._test_remove_persona_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._persona_removed == true);
assert (this._individual_removed == true);
this._test_role_details_interface_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_role == true);
}
this._test_set_avatar_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._avatar_found);
}
this._test_set_bday_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._bday_found);
}
this._email_found = false;
this._test_set_duplicate_email_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
/* we should see the e-mail address twice:
* 1) when we create the Persona
* 2) when we re-set the address */
this._test_set_emails_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._email_1_found);
assert (this._email_2_found);
this._test_set_alias_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
/* Note:
* the is-favourite property is notified as a
this._test_set_full_name_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_changed_full_name);
}
this._test_set_gender_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._gender_found);
}
this._test_set_im_addresses_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_individual_found);
assert (this._addresses.length () == 0);
this._test_set_nickname_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_nickname_found == true);
assert (this._modified_nickname_found == true);
this._test_set_notes_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._note_found);
}
this._test_set_null_avatar_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._null_avatar_set);
}
this._test_set_phones_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._phone_1_found);
assert (this._phone_2_found);
this._test_set_postal_addresses_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._postal_address_found);
}
this._test_set_roles_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._role_found);
}
this._test_set_structured_name_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._sname_found);
}
this._test_set_urls_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._urls.size == 0);
}
this._test_suffix_name_updates_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_suffix_name_found == true);
assert (this._updated_suffix_name_found == true);
this._test_url_details_interface_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._found_blog == true);
assert (this._found_website == true);
this._test_website_updates_async.begin ();
- Timeout.add_seconds (5, () =>
- {
- this._main_loop.quit ();
- assert_not_reached ();
- });
-
- this._main_loop.run ();
+ TestUtils.loop_run_with_timeout (this._main_loop);
assert (this._initial_website_found == true);
assert (this._updated_website_found == true);