use IndividualAggregator.dup () in tests and tools
[platform/upstream/folks.git] / tests / tracker / set-emails.vala
index c7e5720..b7e1dad 100644 (file)
@@ -23,10 +23,9 @@ using TrackerTest;
 using Folks;
 using Gee;
 
-public class SetEmailsTests : Folks.TestCase
+public class SetEmailsTests : TrackerTest.TestCase
 {
   private GLib.MainLoop _main_loop;
-  private TrackerTest.Backend _tracker_backend;
   private IndividualAggregator _aggregator;
   private string _persona_fullname;
   private string _email_1;
@@ -38,19 +37,9 @@ public class SetEmailsTests : Folks.TestCase
     {
       base ("SetEmailsTests");
 
-      this._tracker_backend = new TrackerTest.Backend ();
-
       this.add_test ("test setting emails ", this.test_set_emails);
     }
 
-  public override void set_up ()
-    {
-    }
-
-  public override void tear_down ()
-    {
-    }
-
   public void test_set_emails ()
     {
       this._main_loop = new GLib.MainLoop (null, false);
@@ -60,34 +49,26 @@ public class SetEmailsTests : Folks.TestCase
       this._email_2 = "email-2@example.org";
 
       c1.set (Trf.OntologyDefs.NCO_FULLNAME, this._persona_fullname);
-      this._tracker_backend.add_contact (c1);
+      ((!) this.tracker_backend).add_contact (c1);
 
-      this._tracker_backend.set_up ();
+      ((!) this.tracker_backend).set_up ();
 
       this._email_1_found = false;
       this._email_2_found = false;
 
-      this._test_set_emails_async ();
-
-      Timeout.add_seconds (5, () =>
-        {
-          this._main_loop.quit ();
-          assert_not_reached ();
-        });
+      this._test_set_emails_async.begin ();
 
-      this._main_loop.run ();
+      TestUtils.loop_run_with_timeout (this._main_loop);
 
       assert (this._email_1_found);
       assert (this._email_2_found);
-
-     this._tracker_backend.tear_down ();
     }
 
   private async void _test_set_emails_async ()
     {
       var store = BackendStore.dup ();
       yield store.prepare ();
-      this._aggregator = new IndividualAggregator ();
+      this._aggregator = IndividualAggregator.dup ();
       this._aggregator.individuals_changed_detailed.connect
           (this._individuals_changed_cb);
       try
@@ -115,8 +96,8 @@ public class SetEmailsTests : Folks.TestCase
               i.notify["email-addresses"].connect (this._notify_emails_cb);
 
               var emails = new HashSet<EmailFieldDetails> (
-                  (GLib.HashFunc) EmailFieldDetails.hash,
-                  (GLib.EqualFunc) EmailFieldDetails.equal);
+                  AbstractFieldDetails<string>.hash_static,
+                  AbstractFieldDetails<string>.equal_static);
               var p1 = new EmailFieldDetails (this._email_1);
               emails.add (p1);
               var p2 = new EmailFieldDetails (this._email_2);
@@ -162,10 +143,10 @@ public int main (string[] args)
 {
   Test.init (ref args);
 
-  TestSuite root = TestSuite.get_root ();
-  root.add_suite (new SetEmailsTests ().get_suite ());
-
+  var tests = new SetEmailsTests ();
+  tests.register ();
   Test.run ();
+  tests.final_tear_down ();
 
   return 0;
 }