[evolution-kolab] test-kolab-mail-access: Add a dummy EBackend.
- From: Matthew Barnes <mbarnes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-kolab] test-kolab-mail-access: Add a dummy EBackend.
- Date: Tue, 4 Sep 2012 13:36:18 +0000 (UTC)
commit d17227cc40c0fe624188dce0fd3004f8cffe3576
Author: Matthew Barnes <mbarnes redhat com>
Date: Tue Sep 4 08:51:36 2012 -0400
test-kolab-mail-access: Add a dummy EBackend.
Test is still not working, but closer. Needs to have a GMainLoop
running for D-Bus communication to work, and preferably not fork.
.../integration/libekolab/test-kolab-mail-access.c | 129 +++++++++++++++++++-
1 files changed, 126 insertions(+), 3 deletions(-)
---
diff --git a/src/tests/integration/libekolab/test-kolab-mail-access.c b/src/tests/integration/libekolab/test-kolab-mail-access.c
index d7b1dd6..def2ac3 100644
--- a/src/tests/integration/libekolab/test-kolab-mail-access.c
+++ b/src/tests/integration/libekolab/test-kolab-mail-access.c
@@ -56,6 +56,116 @@
/*----------------------------------------------------------------------------*/
+/* XXX This is a dummy EBackend which simply routes authentication requests
+ * from CamelKolabSession to an ESourceRegistry. A DummyBackend is fed
+ * to kolab_mail_access_configure(). */
+
+typedef struct _DummyBackend DummyBackend;
+typedef struct _DummyBackendClass DummyBackendClass;
+
+struct _DummyBackend {
+ EBackend parent;
+ ESourceRegistry *registry;
+};
+
+struct _DummyBackendClass {
+ EBackendClass parent_class;
+};
+
+/* Forward Declarations */
+GType dummy_backend_get_type (void) G_GNUC_CONST;
+EBackend * dummy_backend_new (ESource *source,
+ GCancellable *cancellable,
+ GError **error);
+static void dummy_backend_initable_interface_init
+ (GInitableIface *interface);
+
+G_DEFINE_TYPE_WITH_CODE (
+ DummyBackend,
+ dummy_backend,
+ E_TYPE_BACKEND,
+ G_IMPLEMENT_INTERFACE (
+ G_TYPE_INITABLE,
+ dummy_backend_initable_interface_init))
+
+static void
+dummy_backend_dispose (GObject *object)
+{
+ DummyBackend *dummy_backend = (DummyBackend *) object;
+
+ if (dummy_backend->registry != NULL) {
+ g_object_unref (dummy_backend->registry);
+ dummy_backend->registry = NULL;
+ }
+
+ /* Chain up to parent's dispose() method. */
+ G_OBJECT_CLASS (dummy_backend_parent_class)->dispose (object);
+}
+
+static gboolean
+dummy_backend_authenticate_sync (EBackend *backend,
+ ESourceAuthenticator *auth,
+ GCancellable *cancellable,
+ GError **error)
+{
+ DummyBackend *dummy_backend = (DummyBackend *) backend;
+
+ return e_source_registry_authenticate_sync (
+ dummy_backend->registry,
+ e_backend_get_source (backend),
+ auth, cancellable, error);
+}
+
+static gboolean
+dummy_backend_initable_init (GInitable *initable,
+ GCancellable *cancellable,
+ GError **error)
+{
+ DummyBackend *dummy_backend = (DummyBackend *) initable;
+
+ dummy_backend->registry =
+ e_source_registry_new_sync (cancellable, error);
+
+ return (dummy_backend->registry != NULL);
+}
+
+static void
+dummy_backend_class_init (DummyBackendClass *class)
+{
+ GObjectClass *object_class;
+ EBackendClass *backend_class;
+
+ object_class = G_OBJECT_CLASS (class);
+ object_class->dispose = dummy_backend_dispose;
+
+ backend_class = E_BACKEND_CLASS (class);
+ backend_class->authenticate_sync = dummy_backend_authenticate_sync;
+}
+
+static void
+dummy_backend_initable_interface_init (GInitableIface *interface)
+{
+ interface->init = dummy_backend_initable_init;
+}
+
+static void
+dummy_backend_init (DummyBackend *dummy_backend)
+{
+}
+
+EBackend *
+dummy_backend_new (ESource *source,
+ GCancellable *cancellable,
+ GError **error)
+{
+ return g_initable_new (
+ dummy_backend_get_type (),
+ cancellable, error,
+ "source", source, NULL);
+}
+
+/*----------------------------------------------------------------------------*/
+
static gboolean
kolab_itest_koma_ksettings_envset (KolabSettingsHandler *ksettings,
GError **err)
@@ -331,6 +441,8 @@ test_kolab_mail_access (KolabFolderContextID context)
KolabMailAccess *kmailaccess = NULL;
KolabSettingsHandler *ksettings = NULL;
CamelKolabIMAPXSettings *camel_settings;
+ EBackend *backend;
+ ESource *source;
gboolean ok = FALSE;
gboolean rval = TRUE;
GError *tmp_err = NULL;
@@ -340,6 +452,14 @@ test_kolab_mail_access (KolabFolderContextID context)
if (! ok)
goto test_part_cleanup;
+ source = e_source_new (NULL, NULL, NULL);
+ /* XXX Any ESource configuration necessary? */
+ backend = dummy_backend_new (source, NULL, &tmp_err);
+ g_object_unref (source);
+
+ if (backend == NULL)
+ goto test_part_cleanup;
+
/* create settings handler object with
* a dummy CamelKolabIMAPXSettings */
camel_settings = g_object_new (CAMEL_TYPE_KOLAB_IMAPX_SETTINGS, NULL);
@@ -365,9 +485,10 @@ test_kolab_mail_access (KolabFolderContextID context)
kmailaccess = KOLAB_MAIL_ACCESS (g_object_new (KOLAB_TYPE_MAIL_ACCESS, NULL));
/* configure mail access subsystem */
- /* FIXME Need to pass an EBackend here.
- * As currently written, this call will abort. */
- ok = kolab_mail_access_configure (kmailaccess, NULL, ksettings, &tmp_err);
+ ok = kolab_mail_access_configure (kmailaccess,
+ backend,
+ ksettings,
+ &tmp_err);
if (! ok)
goto test_part_cleanup;
@@ -442,6 +563,8 @@ test_kolab_mail_access (KolabFolderContextID context)
test_part_cleanup:
+ if (backend != NULL)
+ g_object_unref (backend);
if (kmailaccess != NULL)
g_object_unref (kmailaccess);
if (ksettings != NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]