[folks] React to alias changes coming from Telepathy. Fixes bgo#630431.
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] React to alias changes coming from Telepathy. Fixes bgo#630431.
- Date: Wed, 6 Oct 2010 18:13:00 +0000 (UTC)
commit f449e826a86b23fc9dd9aa50e71a5d2c66f7c8c1
Author: Travis Reitter <travis reitter collabora co uk>
Date: Tue Oct 5 17:27:48 2010 -0700
React to alias changes coming from Telepathy. Fixes bgo#630431.
Add a test for Tpf.Persona properties (changed through the test CM itself).
This simulates a change coming through Telepathy, vs. one we're triggering
ourselves (as in the last test).
backends/telepathy/lib/tpf-persona.vala | 9 ++++
tests/telepathy/contact-properties.vala | 74 +++++++++++++++++++++++++++++++
2 files changed, 83 insertions(+), 0 deletions(-)
---
diff --git a/backends/telepathy/lib/tpf-persona.vala b/backends/telepathy/lib/tpf-persona.vala
index 994af54..f681f74 100644
--- a/backends/telepathy/lib/tpf-persona.vala
+++ b/backends/telepathy/lib/tpf-persona.vala
@@ -230,6 +230,15 @@ public class Tpf.Persona : Folks.Persona,
linkable_properties: linkable_properties,
is_user: contact.handle == connection.self_handle);
+ contact.notify["alias"].connect ((s, p) =>
+ {
+ if (this._alias != contact.alias)
+ {
+ this._alias = contact.alias;
+ this.notify_property ("alias");
+ }
+ });
+
debug ("Creating new Tpf.Persona '%s' for service-specific UID '%s': %p",
uid, id, this);
this.is_constructed = true;
diff --git a/tests/telepathy/contact-properties.vala b/tests/telepathy/contact-properties.vala
index 0eee786..4286eae 100644
--- a/tests/telepathy/contact-properties.vala
+++ b/tests/telepathy/contact-properties.vala
@@ -24,6 +24,8 @@ public class ContactPropertiesTests : Folks.TestCase
this.test_individual_properties);
this.add_test ("individual properties:change alias through tp backend",
this.test_individual_properties_change_alias_through_tp_backend);
+ this.add_test ("individual properties:change alias through test cm",
+ this.test_individual_properties_change_alias_through_test_cm);
}
public override void set_up ()
@@ -254,6 +256,78 @@ public class ContactPropertiesTests : Folks.TestCase
/* necessary to reset the aggregator for the next test */
aggregator = null;
}
+
+ public void test_individual_properties_change_alias_through_test_cm ()
+ {
+ var main_loop = new GLib.MainLoop (null, false);
+ var alias_notified = false;
+
+ /* Ignore the error caused by not running the logger */
+ Test.log_set_fatal_handler ((d, l, m) =>
+ {
+ return !m.has_suffix ("couldn't get list of favourite contacts: " +
+ "The name org.freedesktop.Telepathy.Logger was not provided by " +
+ "any .service files");
+ });
+
+ /* Set up the aggregator */
+ var aggregator = new IndividualAggregator ();
+ aggregator.individuals_changed.connect ((added, removed, m, a, r) =>
+ {
+ var new_alias = "New Alias";
+
+ foreach (Individual i in added)
+ {
+ /* We only check one */
+ if (i.id != (this.individual_id_prefix + "olivier example com"))
+ {
+ continue;
+ }
+
+ /* Check properties */
+ assert (i.alias != new_alias);
+
+ i.notify["alias"].connect ((s, p) =>
+ {
+ /* we can't re-use i here due to Vala's implementation */
+ var ind = (Individual) s;
+
+ if (ind.alias == new_alias)
+ alias_notified = true;
+ });
+
+ /* the contact list this aggregator is based upon has exactly 1
+ * Tpf.Persona per Individual */
+ var persona = i.personas.data;
+ assert (persona is Tpf.Persona);
+
+ /* set the alias through Telepathy and wait for it to hit our
+ * alias notification callback above */
+
+ var handle = (Handle) ((Tpf.Persona) persona).contact.handle;
+ this.conn.manager.set_alias (handle, new_alias);
+ }
+
+ assert (removed == null);
+ });
+ aggregator.prepare ();
+
+ /* 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 (3, () =>
+ {
+ main_loop.quit ();
+ return false;
+ });
+
+ main_loop.run ();
+
+ assert (alias_notified);
+
+ /* necessary to reset the aggregator for the next test */
+ aggregator = null;
+ }
}
public int main (string[] args)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]