[folks/648811-dummy-backend-rebase1: 3/5] Fix dummy compilation.
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks/648811-dummy-backend-rebase1: 3/5] Fix dummy compilation.
- Date: Fri, 1 Nov 2013 16:39:35 +0000 (UTC)
commit 6cf54b6e304570d8d853131f019b1b2fa095e663
Author: Renato Araujo Oliveira Filho <renato filho canonical com>
Date: Sun Oct 27 19:17:00 2013 -0300
Fix dummy compilation.
backends/Makefile.am | 1 +
backends/dummy/Makefile.am | 5 +-
backends/dummy/lib/Makefile.am | 4 +-
backends/dummy/lib/dummy-fat-persona.vala | 12 ++--
backends/dummy/lib/folks-dummy.deps | 2 +-
configure.ac | 5 +-
tests/dummy/Makefile.am | 66 ++++++++++++++++++++++
tests/dummy/individual-retrieval.vala | 57 +++++++++++++++++++
tests/folks/aggregation.vala | 38 +++++++-----
tests/lib/Makefile.am | 1 -
tests/lib/dummy/Makefile.am | 59 +++++++++++++++++++
tests/lib/dummy/test-case.vala | 87 +++++++++++++++++++++++++++++
tests/lib/test-case.vala | 60 +-------------------
13 files changed, 309 insertions(+), 88 deletions(-)
---
diff --git a/backends/Makefile.am b/backends/Makefile.am
index 1a3d1c4..0aa043f 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -30,6 +30,7 @@ DIST_SUBDIRS = \
ofono \
telepathy \
tracker \
+ dummy \
$(NULL)
-include $(top_srcdir)/git.mk
diff --git a/backends/dummy/Makefile.am b/backends/dummy/Makefile.am
index c5a4dcd..01534eb 100644
--- a/backends/dummy/Makefile.am
+++ b/backends/dummy/Makefile.am
@@ -2,8 +2,7 @@ SUBDIRS = lib
BACKEND_NAME = "dummy"
-VALAFLAGS += \
- $(AM_VALAFLAGS) \
+AM_VALAFLAGS += \
$(ERROR_VALAFLAGS) \
--vapidir=. \
--vapidir=$(top_builddir)/backends/dummy/lib \
@@ -22,7 +21,7 @@ dummy_deps = \
folks \
folks-internal \
folks-dummy \
- gee-1.0 \
+ gee-0.8 \
gio-2.0 \
gobject-2.0 \
$(NULL)
diff --git a/backends/dummy/lib/Makefile.am b/backends/dummy/lib/Makefile.am
index be80ed6..0255bbb 100644
--- a/backends/dummy/lib/Makefile.am
+++ b/backends/dummy/lib/Makefile.am
@@ -1,8 +1,10 @@
BACKEND_NAME = "dummy"
AM_CPPFLAGS = \
+ -I$(top_srcdir) \
-I$(top_srcdir)/folks \
-include $(CONFIG_HEADER) \
+ -include folks/redeclare-internal-api.h \
-DPACKAGE_DATADIR=\"$(pkgdatadir)\" \
-DBACKEND_NAME=\"$(BACKEND_NAME)\" \
-DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \
@@ -44,7 +46,7 @@ libfolks_dummy_la_VALAFLAGS = \
--vapidir=$(top_srcdir)/folks \
--pkg folks \
--pkg folks-internal \
- --pkg gee-1.0 \
+ --pkg gee-0.8 \
--pkg gio-2.0 \
--pkg gobject-2.0 \
--includedir folks \
diff --git a/backends/dummy/lib/dummy-fat-persona.vala b/backends/dummy/lib/dummy-fat-persona.vala
index c157734..7cac9ea 100644
--- a/backends/dummy/lib/dummy-fat-persona.vala
+++ b/backends/dummy/lib/dummy-fat-persona.vala
@@ -87,8 +87,8 @@ public class Dummyf.FatPersona : Dummyf.Persona,
private HashMultiMap<string, WebServiceFieldDetails> _web_service_addresses =
new HashMultiMap<string, WebServiceFieldDetails> (
null, null,
- (GLib.HashFunc) WebServiceFieldDetails.hash,
- (GLib.EqualFunc) WebServiceFieldDetails.equal);
+ AbstractFieldDetails<string>.hash_static,
+ AbstractFieldDetails<string>.equal_static);
/**
* { inheritDoc}
@@ -215,8 +215,8 @@ public class Dummyf.FatPersona : Dummyf.Persona,
private HashSet<EmailFieldDetails>? _email_addresses =
new HashSet<EmailFieldDetails> (
- (GLib.HashFunc) EmailFieldDetails.hash,
- (GLib.EqualFunc) EmailFieldDetails.equal);
+ AbstractFieldDetails<string>.hash_static,
+ AbstractFieldDetails<string>.equal_static);
private Set<EmailFieldDetails> _email_addresses_ro;
/**
@@ -439,8 +439,8 @@ public class Dummyf.FatPersona : Dummyf.Persona,
private HashMultiMap<string, ImFieldDetails> _im_addresses =
new HashMultiMap<string, ImFieldDetails> (null, null,
- (GLib.HashFunc) ImFieldDetails.hash,
- (GLib.EqualFunc) ImFieldDetails.equal);
+ AbstractFieldDetails<string>.hash_static,
+ AbstractFieldDetails<string>.equal_static);
/**
* { inheritDoc}
diff --git a/backends/dummy/lib/folks-dummy.deps b/backends/dummy/lib/folks-dummy.deps
index 13b117b..45c26b8 100644
--- a/backends/dummy/lib/folks-dummy.deps
+++ b/backends/dummy/lib/folks-dummy.deps
@@ -1,4 +1,4 @@
glib-2.0
gobject-2.0
folks
-gee-1.0
+gee-0.8
diff --git a/configure.ac b/configure.ac
index 69fc20e..08aa703 100644
--- a/configure.ac
+++ b/configure.ac
@@ -291,6 +291,8 @@ AS_IF([test \
! -e ${sd}tests/folks/backend_loading_vala.stamp -o \
! -e ${sd}tests/key-file/individual_retrieval_vala.stamp -o \
! -e ${sd}tests/lib/folks-test.vapi -o \
+ ! -e ${sd}tests/lib/dummy/dummy-test.vapi -o \
+ ! -e ${sd}tests/lib/dummy/libdummy_test_la_vala.stamp -o \
! -e ${sd}tests/lib/key-file/kf-test.vapi -o \
! -e ${sd}tests/lib/key-file/libkf_test_la_vala.stamp -o \
! -e ${sd}tests/lib/telepathy/contactlist/tp-test-contactlist.gir -o \
@@ -300,6 +302,7 @@ AS_IF([test \
! -e ${sd}tests/telepathy/individual_retrieval_vala.stamp -o \
! -e ${sd}tests/telepathy/individual_properties_vala.stamp -o \
! -e ${sd}tests/folks/backend_loading_vala.stamp -o \
+ ! -e ${sd}backends/dummy/dummy_la_vala.stamp -o \
! -e ${sd}backends/key-file/key_file_la_vala.stamp -o \
! -e ${sd}backends/telepathy/telepathy_la_vala.stamp \
-o \
@@ -672,8 +675,8 @@ AC_CONFIG_FILES([
tests/tracker/Makefile
tests/lib/Makefile
tests/lib/folks-test-uninstalled.pc
- tests/lib/dummy/Makefile
tests/lib/eds/Makefile
+ tests/lib/dummy/Makefile
tests/lib/key-file/Makefile
tests/lib/libsocialweb/Makefile
tests/lib/telepathy/Makefile
diff --git a/tests/dummy/Makefile.am b/tests/dummy/Makefile.am
new file mode 100644
index 0000000..5f562c5
--- /dev/null
+++ b/tests/dummy/Makefile.am
@@ -0,0 +1,66 @@
+AM_CFLAGS = \
+ $(ERROR_CFLAGS) \
+ $(NULL)
+
+AM_CPPFLAGS = \
+ $(GLIB_CFLAGS) \
+ $(GEE_CFLAGS) \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/folks \
+ -I$(top_srcdir)/tests/lib \
+ -I$(top_srcdir)/tests/lib/key-file \
+ -include $(CONFIG_HEADER) \
+ $(NULL)
+
+LDADD = \
+ $(top_builddir)/tests/lib/key-file/libkf-test.la \
+ $(top_builddir)/tests/lib/libfolks-test.la \
+ $(top_builddir)/folks/libfolks.la \
+ $(GLIB_LIBS) \
+ $(GEE_LIBS) \
+ $(NULL)
+
+AM_VALAFLAGS += \
+ $(ERROR_VALAFLAGS) \
+ --vapidir=. \
+ --vapidir=$(top_srcdir)/folks \
+ --vapidir=$(top_srcdir)/tests/lib \
+ --vapidir=$(top_srcdir)/tests/lib/key-file \
+ --pkg gobject-2.0 \
+ --pkg gio-2.0 \
+ --pkg gee-0.8 \
+ --pkg folks \
+ --pkg folks-test \
+ --pkg kf-test \
+ -g \
+ $(NULL)
+
+# in order from least to most complex
+noinst_PROGRAMS = \
+ individual-retrieval \
+ $(NULL)
+
+TESTS = $(noinst_PROGRAMS)
+
+individual_retrieval_SOURCES = \
+ individual-retrieval.vala \
+ $(NULL)
+
+CLEANFILES = \
+ *.pid \
+ *.address \
+ $(TESTS) \
+ $(NULL)
+
+MAINTAINERCLEANFILES = \
+ $(addsuffix .c,$(noinst_PROGRAMS)) \
+ individual_retrieval_vala.stamp \
+ $(NULL)
+
+EXTRA_DIST = \
+ $(MAINTAINERCLEANFILES) \
+ $(NULL)
+
+-include $(top_srcdir)/git.mk
+-include $(top_srcdir)/valgrind.mk
+-include $(top_srcdir)/check.mk
diff --git a/tests/dummy/individual-retrieval.vala b/tests/dummy/individual-retrieval.vala
new file mode 100644
index 0000000..de78d78
--- /dev/null
+++ b/tests/dummy/individual-retrieval.vala
@@ -0,0 +1,57 @@
+/*
+ * 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: Renato Araujo Oliveira Filho <renato canonical com>
+ */
+
+using Gee;
+using Folks;
+using DummyTest;
+
+public class IndividualRetrievalTests : DummyTest.TestCase
+{
+ public IndividualRetrievalTests ()
+ {
+ base ("IndividualRetrieval");
+
+ this.add_test ("singleton individuals", this.test_singleton_individuals);
+ this.add_test ("aliases", this.test_aliases);
+ }
+
+ public void test_singleton_individuals ()
+ {
+ var main_loop = new GLib.MainLoop (null, false);
+
+ Dummy.PersonaStore dummy_persona_store = new Dummy.PersonaStore();
+ dummy_persona_store.add_persona_from_details(details);
+ }
+
+ public void test_aliases ()
+ {
+ }
+}
+
+public int main (string[] args)
+{
+ Test.init (ref args);
+
+ var tests = new IndividualRetrievalTests ();
+ tests.register ();
+ Test.run ();
+ tests.final_tear_down ();
+
+ return 0;
+}
diff --git a/tests/folks/aggregation.vala b/tests/folks/aggregation.vala
index 4699fcb..4f42b0c 100644
--- a/tests/folks/aggregation.vala
+++ b/tests/folks/aggregation.vala
@@ -1,6 +1,5 @@
/*
* Copyright (C) 2011 Collabora Ltd.
- * Copyright (C) 2013 Philip Withnall
*
* 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
@@ -16,7 +15,6 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*
* Authors: Travis Reitter <travis reitter collabora co uk>
- * Philip Withnall <philip tecnocode co uk>
*/
using Gee;
@@ -27,6 +25,11 @@ public class AggregationTests : TpfTest.MixedTestCase
{
private HashSet<string> _default_personas;
+ private static string iid_prefix =
+ "telepathy:/org/freedesktop/Telepathy/Account/cm/protocol/account:";
+ private string olivier_sha1 = Checksum.compute_for_string (ChecksumType.SHA1,
+ iid_prefix + "olivier example com");
+
public AggregationTests ()
{
base ("Aggregation");
@@ -152,10 +155,18 @@ public class AggregationTests : TpfTest.MixedTestCase
Idle.add (() =>
{
- this.test_iid_async.begin ((s, r) =>
+ aggregator.prepare.begin ((s,r) =>
{
- this.test_iid_async.end (r);
- main_loop.quit ();
+ try
+ {
+ aggregator.prepare.end (r);
+ }
+ catch (GLib.Error e1)
+ {
+ GLib.critical ("Failed to prepare aggregator: %s",
+ e1.message);
+ assert_not_reached ();
+ }
});
return false;
@@ -163,14 +174,9 @@ public class AggregationTests : TpfTest.MixedTestCase
TestUtils.loop_run_with_non_fatal_timeout (main_loop, 3);
- /* Prepare the aggregator. */
- var individuals = yield this.individual_aggregator_prepare ();
-
- /* Check the individuals. */
- TestUtils.individuals_map_equals (individuals,
- {
- "store1:iid1,store2:iid1"
- });
+ /* We should have enumerated exactly the individuals in the set */
+ assert (expected_individuals.size == 0);
+ assert (expected_individuals_detailed.size == 0);
/* Clean up for the next test */
tp_backend.remove_account (account2_handle);
@@ -1105,8 +1111,7 @@ public class AggregationTests : TpfTest.MixedTestCase
{
assert (i != null);
- /* olivier example com */
- if (i.id == "0e46c5e74f61908f49550d241f2a1651892a1695")
+ if (i.id == olivier_sha1)
{
assert (individual == null);
individual = i;
@@ -1195,7 +1200,7 @@ public class AggregationTests : TpfTest.MixedTestCase
* we have to check for the personas themselves. */
foreach (var p in i.personas)
{
- if (p.uid == "telepathy:/org/freedesktop/Telepathy/Account/cm/protocol/account:olivier
example com")
+ if (p.uid == iid_prefix + "olivier example com")
{
got_tpf = true;
}
@@ -1377,3 +1382,4 @@ public int main (string[] args)
return 0;
}
+
diff --git a/tests/lib/Makefile.am b/tests/lib/Makefile.am
index d2721b9..aa005ac 100644
--- a/tests/lib/Makefile.am
+++ b/tests/lib/Makefile.am
@@ -40,7 +40,6 @@ noinst_LTLIBRARIES = libfolks-test.la
libfolks_test_la_SOURCES = \
haze-remove-directory.c \
- normal-test-case.vala \
test-case.vala \
test-case-helper.c \
test-utils.vala \
diff --git a/tests/lib/dummy/Makefile.am b/tests/lib/dummy/Makefile.am
new file mode 100644
index 0000000..a90d068
--- /dev/null
+++ b/tests/lib/dummy/Makefile.am
@@ -0,0 +1,59 @@
+AM_VALAFLAGS += \
+ $(ERROR_VALAFLAGS) \
+ --library=dummy-test \
+ --header=dummy-test.h \
+ --vapidir=$(top_srcdir)/folks \
+ --vapidir=$(top_srcdir)/backends/dummy/lib \
+ --vapidir=$(top_srcdir)/backends/dummy/vapi \
+ --vapidir=$(abs_top_srcdir)/tests/lib \
+ --vapidir=$(abs_top_builddir)/tests/lib \
+ --vapidir=. \
+ --pkg gee-0.8 \
+ --pkg folks-dummy \
+ --pkg folks-test \
+ -g \
+ $(NULL)
+
+noinst_LTLIBRARIES = libdummy-test.la
+
+libdummy_test_la_SOURCES = \
+ test-case.vala \
+ $(NULL)
+
+libdummy_test_la_CFLAGS = \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/folks \
+ -I$(top_srcdir)/tests/lib \
+ -I$(top_srcdir)/backends/dummy/lib \
+ -I$(top_srcdir)/backends/dummy/lib/folks \
+ $(AM_CFLAGS) \
+ $(ERROR_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(GEE_CFLAGS) \
+ $(NULL)
+
+libdummy_test_la_LIBADD = \
+ $(top_builddir)/folks/libfolks.la \
+ $(top_builddir)/tests/lib/libfolks-test.la \
+ $(top_builddir)/backends/dummy/lib/libfolks-dummy.la \
+ $(GLIB_LIBS) \
+ $(GEE_LIBS) \
+ $(NULL)
+
+MAINTAINERCLEANFILES = \
+ dummy-test.vapi \
+ dummy-test.h \
+ $(NULL)
+
+EXTRA_DIST = \
+ dummy-test.deps \
+ dummy-test.vapi \
+ dummy-test.h \
+ $(NULL)
+
+GITIGNOREFILES = \
+ $(patsubst %.vala,%.c,$(filter %.vala,$(libdummy_test_la_SOURCES))) \
+ libdummy_test_la_vala.stamp \
+ $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/tests/lib/dummy/test-case.vala b/tests/lib/dummy/test-case.vala
new file mode 100644
index 0000000..28498a5
--- /dev/null
+++ b/tests/lib/dummy/test-case.vala
@@ -0,0 +1,87 @@
+/* test-case.vala
+ *
+ *
+ * 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Author:
+ * Renato Araujo Oliveira Filho <renato canonical com>
+ */
+
+using Folks;
+using Gee;
+
+/**
+ * A test case for the dummy backend, which is configured as the
+ * primary store and as the only backend allowed.
+ */
+public class Dummy.TestCase : Folks.TestCase
+{
+ /**
+ * The dummy test backend.
+ */
+ public Dummyf.Backend dummy_backend;
+
+ /**
+ * The default persona store
+ */
+ public Dummyf.PersonaStore dummy_persona_store;
+
+ public TestCase (string name)
+ {
+ base (name);
+
+ Environment.set_variable ("FOLKS_BACKENDS_ALLOWED", "dummy", true);
+ }
+
+ public override void set_up ()
+ {
+ base.set_up ();
+
+ this.dummy_backend = new Dummyf.Backend ();
+ this.dummy_backend.prepare.begin((obj, res) => {
+ try {
+ this.dummy_backend.prepare.end(res);
+ } catch (GLib.Error error) {
+ }
+ });
+ this.configure_primary_store ();
+ }
+
+ public virtual void configure_primary_store ()
+ {
+ var persona_stores = new HashSet<PersonaStore>();
+ string[] writable_properties = {"birthday", "email-addresses", "full-name"};
+ this.dummy_persona_store = new Dummyf.PersonaStore("dummy", "Dummy personas", writable_properties);
+
+ persona_stores.add(this.dummy_persona_store);
+ this.dummy_backend.register_persona_stores(persona_stores);
+ }
+
+ public override void tear_down ()
+ {
+ if (this.dummy_backend != null)
+ {
+ this.dummy_backend.unprepare.begin((obj, res) => {
+ try {
+ this.dummy_backend.unprepare.end(res);
+ } catch (GLib.Error error) {
+ }
+ });
+ this.dummy_backend = null;
+ }
+
+ base.tear_down ();
+ }
+}
diff --git a/tests/lib/test-case.vala b/tests/lib/test-case.vala
index 0180a79..838f69c 100644
--- a/tests/lib/test-case.vala
+++ b/tests/lib/test-case.vala
@@ -59,7 +59,7 @@ public abstract class Folks.TestCase : Object
if (Environment.get_variable ("FOLKS_TESTS_INSTALLED") == null)
{
- string[] locations = {
+ string[] locations = {
Folks.BuildConf.ABS_TOP_BUILDDIR + "/backends/key-file/.libs/key-file.so",
};
@@ -240,7 +240,6 @@ public abstract class Folks.TestCase : Object
this._suite.add (add_test_helper (name, test));
}
-<<<<<<< HEAD
/* implemented in test-case-helper.c */
internal extern GLib.TestCase add_test_helper (string name, TestMethod test);
@@ -263,13 +262,6 @@ public abstract class Folks.TestCase : Object
* as the last thing in their implementation.
*/
public virtual void tear_down ()
-=======
- public virtual async void set_up ()
- {
- }
-
- public virtual async void tear_down ()
->>>>>>> dummy: UNFINISHED work to document backend and port tests to it
{
}
@@ -304,11 +296,7 @@ public abstract class Folks.TestCase : Object
}
}
-<<<<<<< HEAD
~TestCase ()
-=======
- private class Adaptor
->>>>>>> dummy: UNFINISHED work to document backend and port tests to it
{
this.final_tear_down ();
}
@@ -321,28 +309,8 @@ public abstract class Folks.TestCase : Object
public static void set_up ()
{
-<<<<<<< HEAD
GLib.set_printerr_handler (LogAdaptor._printerr_func_stack_trace);
Log.set_default_handler (LogAdaptor._log_func_stack_trace);
-=======
- GLib.set_printerr_handler (Adaptor._printerr_func_stack_trace);
- Log.set_default_handler (this._log_func_stack_trace);
-
- var main_loop = new MainLoop ();
-
- Idle.add (() =>
- {
- this._test_case.set_up.begin ((s, r) =>
- {
- this._test_case.set_up.end (r);
- main_loop.quit ();
- });
-
- return false;
- });
-
- main_loop.run ();
->>>>>>> dummy: UNFINISHED work to document backend and port tests to it
}
private static void _printerr_func_stack_trace (string? text)
@@ -372,31 +340,5 @@ public abstract class Folks.TestCase : Object
GLib.on_error_stack_trace ("libtool --mode=execute gdb");
}
}
-<<<<<<< HEAD
-=======
-
- public void run (void* fixture)
- {
- this._test ();
- }
-
- public void tear_down (void* fixture)
- {
- var main_loop = new MainLoop ();
-
- Idle.add (() =>
- {
- this._test_case.tear_down.begin ((s, r) =>
- {
- this._test_case.tear_down.end (r);
- main_loop.quit ();
- });
-
- return false;
- });
-
- main_loop.run ();
- }
->>>>>>> dummy: UNFINISHED work to document backend and port tests to it
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]