use IndividualAggregator.dup () in tests and tools
[platform/upstream/folks.git] / tests / tracker / url-details-interface.vala
index 0d17caf..3cba442 100644 (file)
@@ -23,11 +23,10 @@ using TrackerTest;
 using Folks;
 using Gee;
 
-public class UrlDetailsInterfaceTests : Folks.TestCase
+public class UrlDetailsInterfaceTests : TrackerTest.TestCase
 {
   private GLib.MainLoop _main_loop;
   private IndividualAggregator _aggregator;
-  private TrackerTest.Backend _tracker_backend;
   private string _blog_url;
   private string _website_url;
   private string _urls;
@@ -38,21 +37,12 @@ public class UrlDetailsInterfaceTests : Folks.TestCase
     {
       base ("UrlDetailsInterfaceTests");
 
-      this._tracker_backend = new TrackerTest.Backend ();
-      this._tracker_backend.debug = false;
+      ((!) this.tracker_backend).debug = false;
 
       this.add_test ("test url details interface",
           this.test_url_details_interface);
     }
 
-  public override void set_up ()
-    {
-    }
-
-  public override void tear_down ()
-    {
-    }
-
   public void test_url_details_interface ()
     {
       this._main_loop = new GLib.MainLoop (null, false);
@@ -63,35 +53,27 @@ public class UrlDetailsInterfaceTests : Folks.TestCase
 
       c1.set (Trf.OntologyDefs.NCO_FULLNAME, "persona #1");
       c1.set (TrackerTest.Backend.URLS, this._urls);
-      this._tracker_backend.add_contact (c1);
+      ((!) this.tracker_backend).add_contact (c1);
 
-      this._tracker_backend.set_up ();
+      ((!) this.tracker_backend).set_up ();
 
       this._found_blog = false;
       this._found_website = false;
 
-      this._test_url_details_interface_async ();
-
-      Timeout.add_seconds (5, () =>
-        {
-          this._main_loop.quit ();
-          assert_not_reached ();
-        });
+      this._test_url_details_interface_async.begin ();
 
-      this._main_loop.run ();
+      TestUtils.loop_run_with_timeout (this._main_loop);
 
       assert (this._found_blog == true);
       assert (this._found_website == true);
-
-      this._tracker_backend.tear_down ();
     }
 
   private async void _test_url_details_interface_async ()
     {
       var store = BackendStore.dup ();
       yield store.prepare ();
-      this._aggregator = new IndividualAggregator ();
-      this._aggregator.individuals_changed.connect
+      this._aggregator = IndividualAggregator.dup ();
+      this._aggregator.individuals_changed_detailed.connect
           (this._individuals_changed_cb);
       try
         {
@@ -103,15 +85,16 @@ public class UrlDetailsInterfaceTests : Folks.TestCase
         }
     }
 
-  private void _individuals_changed_cb
-      (GLib.List<Individual>? added,
-       GLib.List<Individual>? removed,
-       string? message,
-       Persona? actor,
-       GroupDetails.ChangeReason reason)
+  private void _individuals_changed_cb (
+       MultiMap<Individual?, Individual?> changes)
     {
-      foreach (Individual i in added)
+      var added = changes.get_values ();
+      var removed = changes.get_keys ();
+
+      foreach (var i in added)
         {
+          assert (i != null);
+
           string full_name = i.full_name;
           if (full_name != null)
             {
@@ -129,11 +112,16 @@ public class UrlDetailsInterfaceTests : Folks.TestCase
             }
         }
 
-      assert (removed == null);
-
       if (this._found_blog &&
           this._found_website)
         this._main_loop.quit ();
+
+      assert (removed.size == 1);
+
+      foreach (var i in removed)
+        {
+          assert (i == null);
+        }
     }
 }
 
@@ -141,10 +129,10 @@ public int main (string[] args)
 {
   Test.init (ref args);
 
-  TestSuite root = TestSuite.get_root ();
-  root.add_suite (new UrlDetailsInterfaceTests ().get_suite ());
-
+  var tests = new UrlDetailsInterfaceTests ();
+  tests.register ();
   Test.run ();
+  tests.final_tear_down ();
 
   return 0;
 }