[folks] Add a test of an individual's properties



commit 5353632439278dbe41511fc3cd7647715fee23e8
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Thu Jul 8 18:55:34 2010 +0100

    Add a test of an individual's properties

 tests/telepathy/contact-retrieval.vala |   54 ++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/tests/telepathy/contact-retrieval.vala b/tests/telepathy/contact-retrieval.vala
index 61d68bf..ccf6402 100644
--- a/tests/telepathy/contact-retrieval.vala
+++ b/tests/telepathy/contact-retrieval.vala
@@ -20,6 +20,8 @@ public class ContactRetrievalTests : Folks.TestCase
       base ("ContactRetrieval");
 
       this.add_test ("aggregator", this.test_aggregator);
+      this.add_test ("individual properties",
+          this.test_individual_properties);
     }
 
   public override void set_up ()
@@ -176,6 +178,58 @@ public class ContactRetrievalTests : Folks.TestCase
       /* We should have enumerated exactly the individuals in the set */
       assert (expected_individuals.size == 0);
     }
+
+  public void test_individual_properties ()
+    {
+      var main_loop = new GLib.MainLoop (null, 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) =>
+        {
+          foreach (Individual i in added)
+            {
+              /* We only check one */
+              if (i.id != "telepathy:protocol:olivier example com")
+                {
+                  continue;
+                }
+
+              /* Check properties */
+              assert (i.alias == "Olivier");
+              assert (i.presence_message == "");
+              assert (i.presence_type == PresenceType.AWAY);
+              assert (i.is_online () == true);
+
+              /* Check groups */
+              assert (i.groups.size () == 2);
+              assert (i.groups.lookup ("Montreal") == true);
+              assert (i.groups.lookup ("Francophones") == true);
+            }
+
+          assert (removed == null);
+        });
+      aggregator.prepare ();
+
+      /* 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 (3, () =>
+        {
+          main_loop.quit ();
+          return false;
+        });
+
+      main_loop.run ();
+    }
 }
 
 public int main (string[] args)



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