Bug 691382 — Restore tests disabled by bug #668415 (which has been fixed)
authorTravis Reitter <travis.reitter@collabora.co.uk>
Mon, 7 Jan 2013 06:27:27 +0000 (22:27 -0800)
committerTravis Reitter <travis.reitter@collabora.co.uk>
Thu, 10 Jan 2013 01:16:15 +0000 (17:16 -0800)
This ports the store-removed test to the current EDS introspection bindings
and removes the change-primary-store test on the basis that we don't really
support clients changing the primary store.

In the future, we may want to add a test to ensure we cope with the primary
store disappearing, but that's a different case.

Closes: https://bugzilla.gnome.org/show_bug.cgi?id=691382

NEWS
tests/eds/Makefile.am
tests/eds/change-primary-store.vala [deleted file]
tests/eds/store-removed.vala
tests/lib/eds/backend.vala

diff --git a/NEWS b/NEWS
index 277a89a..6cf7faa 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,7 @@ Bugs fixed:
 • Bug 690876 — eds: fix various test failures
 • Bug 691167 — Build failure: key-file tests built before dependencies
 • Bug 686695 — support nickname in add_persona_from_details
+• Bug 691382 — Restore tests disabled by bug #668415 (which has been fixed)
 
 API changes:
 • Add Backend.enable_persona_store and disable_persona_store.
index 655aeca..b5a8723 100644 (file)
@@ -41,11 +41,6 @@ AM_VALAFLAGS = \
        -g \
        $(NULL)
 
-# FIXME: these tests have been removed temporarily due to bgo#668415
-#      store-removed \
-#      change-primary-store \
-#      $(NULL)
-
 # in order from least to most complex
 noinst_PROGRAMS = \
        persona-store-tests \
@@ -77,6 +72,7 @@ noinst_PROGRAMS = \
        set-roles \
        linkable-properties \
        link-personas-diff-stores \
+       store-removed \
        anti-linking \
        enable-disable-stores \
        create-remove-stores \
@@ -98,11 +94,6 @@ TESTS_ENVIRONMENT = \
 
 TESTS = $(noinst_PROGRAMS)
 
-# FIXME: temporarily removed due to bgo#668415
-#store_removed_SOURCES = \
-#      store-removed.vala \
-#      $(NULL)
-
 anti_linking_SOURCES = \
        anti-linking.vala \
        $(NULL)
@@ -219,11 +210,6 @@ set_roles_SOURCES = \
        set-roles.vala \
        $(NULL)
 
-# FIXME: temporarily removed due to bgo#668415
-#change_primary_store_SOURCES = \
-#      change-primary-store.vala \
-#      $(NULL)
-
 link_personas_diff_stores_SOURCES = \
        link-personas-diff-stores.vala \
        $(NULL)
@@ -240,17 +226,16 @@ set_is_favourite_SOURCES = \
        set-is-favourite.vala \
        $(NULL)
 
+store_removed_SOURCES = \
+       store-removed.vala \
+       $(NULL)
+
 CLEANFILES = \
         *.pid \
         *.address \
         $(TESTS) \
         $(NULL)
 
-# FIXME: temporarily removed due to bgo#668415
-#      store_removed_vala.stamp \
-#      change_primary_store_vala.stamp \
-#      $(NULL)
-
 MAINTAINERCLEANFILES = \
        $(addsuffix .c,$(noinst_PROGRAMS)) \
        $(addsuffix _vala.stamp,$(subst -,_,$(noinst_PROGRAMS))) \
diff --git a/tests/eds/change-primary-store.vala b/tests/eds/change-primary-store.vala
deleted file mode 100644 (file)
index 9d821aa..0000000
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * Copyright (C) 2011 Collabora Ltd.
- *
- * This library is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 2.1 of the License, or
- * (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this library.  If not, see <http://www.gnu.org/licenses/>.
- *
- * Authors: Raul Gutierrez Segales <raul.gutierrez.segales@collabora.co.uk>
- *
- */
-
-using Folks;
-using Gee;
-
-public class ChangePrimaryStoreTests : Folks.TestCase
-{
-  private GLib.MainLoop _main_loop;
-  private EdsTest.Backend _eds_backend;
-  private EdsTest.Backend _eds_backend_other;
-  private IndividualAggregator _aggregator;
-  private Folks.PersonaStore _pstore1;
-  private Folks.PersonaStore _pstore2;
-  private bool _new_primary_store_found;
-
-  public ChangePrimaryStoreTests ()
-    {
-      base ("ChangePrimaryStoreTests");
-
-      this._eds_backend = new EdsTest.Backend ();
-      this._eds_backend.address_book_uri = "system-address-book";
-      this._eds_backend_other = new EdsTest.Backend ();
-      this._eds_backend_other.address_book_uri = "other";
-
-      this.add_test ("test primary store changes in the IndividualAggregator",
-          this.test_change_primary_store);
-    }
-
-  public override void set_up ()
-    {
-      Environment.unset_variable ("FOLKS_PRIMARY_STORE");
-      this._eds_backend.set_up (true);
-      this._eds_backend_other.set_up ();
-    }
-
-  public override void tear_down ()
-    {
-      this._eds_backend.tear_down ();
-      this._eds_backend_other.tear_down ();
-    }
-
-  public void test_change_primary_store ()
-    {
-      this._main_loop = new GLib.MainLoop (null, false);
-      this._new_primary_store_found = false;
-
-      this._test_change_primary_store ();
-
-      var timer_id = Timeout.add_seconds (8, () =>
-        {
-          this._main_loop.quit ();
-          assert_not_reached ();
-        });
-
-      this._main_loop.run ();
-
-      assert (this._new_primary_store_found);
-
-      GLib.Source.remove (timer_id);
-      this._aggregator = null;
-      this._main_loop = null;
-    }
-
-  private async void _test_change_primary_store ()
-    {
-      var store = BackendStore.dup ();
-      yield store.prepare ();
-      this._aggregator = new IndividualAggregator ();
-      try
-        {
-          yield this._aggregator.prepare ();
-
-          this._pstore1 = this._get_persona_store (store,
-              this._eds_backend.address_book_uid);
-          this._pstore2 = this._get_persona_store (store,
-              this._eds_backend_other.address_book_uid);
-
-          assert (this._pstore1 != null);
-          assert (this._pstore2 != null);
-
-          assert (this._aggregator.primary_store == this._pstore1);
-
-          this._aggregator.notify["primary-store"].connect (
-              this._primary_store_cb);
-
-          this._eds_backend_other.set_as_default ();
-        }
-      catch (GLib.Error e)
-        {
-          GLib.warning ("Error when calling prepare: %s\n", e.message);
-        }
-    }
-
-  private PersonaStore? _get_persona_store (BackendStore store, string store_id)
-    {
-      PersonaStore? pstore = null;
-      foreach (var backend in store.enabled_backends.values)
-        {
-          pstore = backend.persona_stores.get (store_id);
-          if (pstore != null)
-            break;
-        }
-      return pstore;
-    }
-
-  private void _primary_store_cb (Object ia_obj, ParamSpec ps)
-    {
-      IndividualAggregator ia = (IndividualAggregator) ia_obj;
-
-      if (ia.primary_store == this._pstore2)
-        {
-          this._new_primary_store_found = true;
-          this._main_loop.quit ();
-        }
-    }
-}
-
-public int main (string[] args)
-{
-  Test.init (ref args);
-
-  TestSuite root = TestSuite.get_root ();
-  root.add_suite (new ChangePrimaryStoreTests ().get_suite ());
-
-  Test.run ();
-
-  return 0;
-}
index db3911a..b8c99a5 100644 (file)
@@ -19,6 +19,7 @@
  */
 
 using EdsTest;
+using E;
 using Folks;
 using Gee;
 
@@ -70,7 +71,7 @@ public class StoreRemovedTests : Folks.TestCase
       this._eds_backend.add_contact (c1);
 
       /* Schedule the test to start with the main loop. */
-      this._test_single_store_part1_async ();
+      this._test_single_store_part1_async.begin ();
 
       var timeout_id = Timeout.add_seconds (5, () =>
         {
@@ -83,10 +84,10 @@ public class StoreRemovedTests : Folks.TestCase
       /* We should have a single individual by now. */
       assert (this._aggregator.individuals.size == 1);
 
-      Source.remove (timeout_id);
+      GLib.Source.remove (timeout_id);
 
       /* Part 2, where we remove the address book. */
-      this._test_single_store_part2_async ();
+      this._test_single_store_part2_async.begin ();
 
       timeout_id = Timeout.add_seconds (5, () =>
         {
@@ -99,7 +100,7 @@ public class StoreRemovedTests : Folks.TestCase
       /* The individual should be gone. */
       assert (this._aggregator.individuals.size == 0);
 
-      Source.remove (timeout_id);
+      GLib.Source.remove (timeout_id);
     }
 
   private async void _test_single_store_part1_async ()
@@ -181,16 +182,7 @@ public class StoreRemovedTests : Folks.TestCase
 
       /* Tear down the backend. This should remove all individuals. We check
        * for this above. */
-      E.SourceList? source_list = null;
-      try
-        {
-          E.BookClient.get_sources (out source_list);
-          source_list.remove_source_by_uid (this._eds_backend.address_book_uid);
-        }
-      catch (GLib.Error e1)
-        {
-          critical ("Error getting source list: %s", e1.message);
-        }
+      this._eds_backend.tear_down ();
     }
 }
 
index 202c7dc..40a04f2 100644 (file)
@@ -327,7 +327,10 @@ public class EdsTest.Backend
 
       try
         {
-          this._source_file.delete ();
+          if (this._source_file != null)
+            {
+              this._source_file.delete ();
+            }
         }
       catch (GLib.Error e)
         {