[folks] tracker: Fix the match-im-addresses test



commit 31f33c548dd855a9230f27b0257fe201fa76d23a
Author: Philip Withnall <philip tecnocode co uk>
Date:   Wed Aug 31 19:30:10 2011 +0100

    tracker: Fix the match-im-addresses test
    
    Due to the Tracker tests now running with the tracker persona store as the
    writeable store, Tracker personas in the tests are now linked by their
    linkeable properties (as their persona store is now fully trusted due to
    being the writeable store).
    
    This caused the two personas in the match-im-addresses test to be linked
    together implicitly by the aggregator, when the test case assumed they
    weren't. This broke the test.
    
    This commit fixes the test permanently by changing the way we consider
    potential matches based on IM addresses. Previously, we only indicated a
    potential match if the two individuals under consideration shared a common
    IM address + protocol combination. This commit changes that so that two
    individuals are now considered to potentially match if they share a common
    IM address *only*. Protocols are no longer considered.
    
    This allows us to change the way the personas are set up in the
    match-im-addresses test so that they're no longer implicitly linked by the
    aggregator.

 folks/potential-match.vala            |   21 ++++++++++++---------
 tests/tracker/match-im-addresses.vala |    5 ++---
 2 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/folks/potential-match.vala b/folks/potential-match.vala
index 0bac511..8f4d528 100644
--- a/folks/potential-match.vala
+++ b/folks/potential-match.vala
@@ -223,22 +223,25 @@ public class Folks.PotentialMatch : Object
   /**
    * Number of equal IM addresses between two individuals.
    *
+   * This compares the addresses without comparing their associated protocols.
+   *
    * @since 0.5.0
    */
   public void _inspect_im_addresses ()
     {
-      foreach (var proto in this._individual_a.im_addresses.get_keys ())
+      var addrs = new HashSet<string> ();
+
+      foreach (var im_a in this._individual_a.im_addresses.get_values ())
         {
-          var addrs_a = this._individual_a.im_addresses.get (proto);
-          var addrs_b = this._individual_b.im_addresses.get (proto);
+          addrs.add (im_a.value);
+        }
 
-          foreach (var im_a in addrs_a)
+      foreach (var im_b in this._individual_b.im_addresses.get_values ())
+        {
+          if (addrs.contains (im_b.value) == true)
             {
-              if (addrs_b.contains (im_a))
-                {
-                  this._result = MatchResult.HIGH;
-                  return;
-                }
+              this._result = MatchResult.HIGH;
+              return;
             }
         }
     }
diff --git a/tests/tracker/match-im-addresses.vala b/tests/tracker/match-im-addresses.vala
index 79bba36..5f57276 100644
--- a/tests/tracker/match-im-addresses.vala
+++ b/tests/tracker/match-im-addresses.vala
@@ -126,8 +126,7 @@ public class MatchIMAddressesTests : Folks.TestCase
           this._try_potential_match ();
         }
 
-      /* We can't assert (removed.size == 0) because these Personas will get
-       * auto-linked (and thus one Individual will get removed */
+      assert (removed.size == 0);
     }
 
   private void _try_potential_match ()
@@ -193,7 +192,7 @@ public class MatchIMAddressesTests : Folks.TestCase
       im_addrs = new HashMultiMap<string, ImFieldDetails> (null, null,
           (GLib.HashFunc) ImFieldDetails.hash,
           (GLib.EqualFunc) ImFieldDetails.equal);
-      im_addrs.set ("jabber", new ImFieldDetails (this._im_addr_1));
+      im_addrs.set ("jabber", new ImFieldDetails (this._im_addr_2));
       val.set_object (im_addrs);
       details2.insert (
           Folks.PersonaStore.detail_key (PersonaDetail.IM_ADDRESSES),



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