[folks] Add initial BackendStore test.
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Add initial BackendStore test.
- Date: Thu, 4 Nov 2010 00:41:04 +0000 (UTC)
commit d65fc45442d2ed3fe714291ffa43393e60ed47da
Author: Travis Reitter <travis reitter collabora co uk>
Date: Fri Oct 29 16:49:14 2010 -0700
Add initial BackendStore test.
Helps bgo#629081.
configure.ac | 1 +
tests/Makefile.am | 1 +
tests/folks/Makefile.am | 47 ++++++++++++++++++++++
tests/folks/backend-loading.vala | 79 ++++++++++++++++++++++++++++++++++++++
4 files changed, 128 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 65f8e26..30e60fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -219,6 +219,7 @@ AC_CONFIG_FILES([
folks/Makefile
docs/Makefile
tests/Makefile
+ tests/folks/Makefile
tests/telepathy/Makefile
tests/lib/Makefile
tests/lib/folks-test-uninstalled.pc
diff --git a/tests/Makefile.am b/tests/Makefile.am
index bc8aad4..a53fa52 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,6 +1,7 @@
SUBDIRS = \
lib \
tools \
+ folks \
telepathy \
$(NULL)
diff --git a/tests/folks/Makefile.am b/tests/folks/Makefile.am
new file mode 100644
index 0000000..60e7ab3
--- /dev/null
+++ b/tests/folks/Makefile.am
@@ -0,0 +1,47 @@
+AM_CPPFLAGS = \
+ $(GLIB_CFLAGS) \
+ $(GEE_CFLAGS) \
+ -I$(top_srcdir)/folks \
+ -I$(top_srcdir)/tests/lib \
+ -include $(CONFIG_HEADER) \
+ $(NULL)
+
+LDADD = \
+ $(top_builddir)/tests/lib/libfolks-test.la \
+ $(top_builddir)/folks/libfolks.la \
+ $(GLIB_LIBS) \
+ $(GEE_LIBS) \
+ $(NULL)
+
+AM_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-1.0 \
+ --pkg folks \
+ --pkg folks-test \
+ $(NULL)
+
+# in order from least to most complex
+noinst_PROGRAMS = \
+ backend-loading \
+ $(NULL)
+
+TESTS = $(noinst_PROGRAMS)
+
+backend_loading_SOURCES = \
+ backend-loading.vala \
+ $(NULL)
+
+CLEANFILES = \
+ $(addsuffix .c,$(noinst_PROGRAMS)) \
+ backend_loading_vala.stamp \
+ *.pid \
+ *.address \
+ $(TESTS) \
+ $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/tests/folks/backend-loading.vala b/tests/folks/backend-loading.vala
new file mode 100644
index 0000000..10bed97
--- /dev/null
+++ b/tests/folks/backend-loading.vala
@@ -0,0 +1,79 @@
+using Gee;
+using Folks;
+
+public class BackendLoadingTests : Folks.TestCase
+{
+ public BackendLoadingTests ()
+ {
+ base ("BackendLoading");
+
+ /* Ignore the error caused by not running the logger */
+ Test.log_set_fatal_handler ((d, l, m) =>
+ {
+ return !m.has_suffix ("couldn't get list of favourite contacts: " +
+ "The name org.freedesktop.Telepathy.Logger was not provided by " +
+ "any .service files");
+ });
+
+ this.add_test ("load and prep", this.test_load_and_prep);
+ }
+
+ public override void set_up ()
+ {
+ }
+
+ public override void tear_down ()
+ {
+ }
+
+ public void test_load_and_prep ()
+ {
+ var main_loop = new GLib.MainLoop (null, false);
+ var backends_expected = new HashSet<string> (str_hash, str_equal);
+
+ backends_expected.add ("key-file");
+ backends_expected.add ("telepathy");
+
+ var store = BackendStore.dup ();
+ store.prepare.begin ((o, r) =>
+ {
+ store.prepare.end (r);
+ });
+
+ store.load_backends.begin ((o, r) =>
+ {
+ try
+ {
+ store.load_backends.end (r);
+
+ store.enabled_backends.foreach ((i) =>
+ {
+ var backend = (Backend) i;
+ assert (backends_expected.contains (backend.name));
+ backends_expected.remove (backend.name);
+ });
+
+ assert (backends_expected.size == 0);
+ main_loop.quit ();
+ }
+ catch (GLib.Error e)
+ {
+ GLib.error ("Failed to load backends: %s", e.message);
+ }
+ });
+
+ main_loop.run ();
+ }
+}
+
+public int main (string[] args)
+{
+ Test.init (ref args);
+
+ TestSuite root = TestSuite.get_root ();
+ root.add_suite (new BackendLoadingTests ().get_suite ());
+
+ Test.run ();
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]