[evolution-data-server/openismus-work-master] ECalClient test, test-client-get-free-busy: Create a valid user identity and account
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work-master] ECalClient test, test-client-get-free-busy: Create a valid user identity and account
- Date: Wed, 23 Jan 2013 07:59:49 +0000 (UTC)
commit cb74deac8ba490220b84b9a9b823e5cb1de980e2
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Wed Jan 23 16:49:19 2013 +0900
ECalClient test, test-client-get-free-busy: Create a valid user identity and account
Without this, the backend does not report any free-busy information,
with this commit the backend actually reports the free-busy data and
the test now additionally asserts that the free-busy data was reported.
tests/libecal/client/test-client-get-free-busy.c | 90 ++++++++++++++++++++--
1 files changed, 83 insertions(+), 7 deletions(-)
---
diff --git a/tests/libecal/client/test-client-get-free-busy.c b/tests/libecal/client/test-client-get-free-busy.c
index 8aac997..4b8a0b7 100644
--- a/tests/libecal/client/test-client-get-free-busy.c
+++ b/tests/libecal/client/test-client-get-free-busy.c
@@ -4,20 +4,89 @@
#include <libecal/libecal.h>
#include <libical/ical.h>
-#include "client-test-utils.h"
#include "e-test-server-utils.h"
+#define MAIL_ACCOUNT_UID "test-email-account"
+#define MAIL_IDENTITY_UID "test-email-identity"
+#define USER_EMAIL "user example com"
+
static ETestServerClosure cal_closure =
{ E_TEST_SERVER_CALENDAR, NULL, E_CAL_CLIENT_SOURCE_TYPE_EVENTS };
-#define USER_EMAIL "user example com"
+static gboolean received_free_busy_data = FALSE;
+
+
+static void
+setup_fixture (ETestServerFixture *fixture,
+ gconstpointer user_data)
+{
+ GError *error = NULL;
+ ESource *scratch;
+ ESourceMailAccount *mail_account;
+ ESourceMailIdentity *mail_identity;
+
+ e_test_server_utils_setup (fixture, user_data);
+
+ /* Create the mail identity */
+ scratch = e_source_new_with_uid (MAIL_IDENTITY_UID, NULL, &error);
+ if (!scratch)
+ g_error ("Failed to create scratch source for an email user: %s", error->message);
+
+ mail_identity = e_source_get_extension (scratch, E_SOURCE_EXTENSION_MAIL_IDENTITY);
+ e_source_mail_identity_set_address (mail_identity, USER_EMAIL);
+
+ if (!e_source_registry_commit_source_sync (fixture->registry, scratch, NULL, &error))
+ g_error ("Unable to add new addressbook source to the registry: %s", error->message);
+
+ g_object_unref (scratch);
+
+ /* Create the mail account */
+ scratch = e_source_new_with_uid (MAIL_ACCOUNT_UID, NULL, &error);
+ if (!scratch)
+ g_error ("Failed to create scratch source for an email user: %s", error->message);
+
+ mail_account = e_source_get_extension (scratch, E_SOURCE_EXTENSION_MAIL_ACCOUNT);
+ e_source_mail_account_set_identity_uid (mail_account, MAIL_IDENTITY_UID);
+
+ if (!e_source_registry_commit_source_sync (fixture->registry, scratch, NULL, &error))
+ g_error ("Unable to add new addressbook source to the registry: %s", error->message);
+
+ g_object_unref (scratch);
+}
+
+static void
+teardown_fixture (ETestServerFixture *fixture,
+ gconstpointer user_data)
+{
+ GError *error = NULL;
+ ESource *source;
+
+ /* Remove the account */
+ source = e_source_registry_ref_source (fixture->registry, MAIL_ACCOUNT_UID);
+ if (!source)
+ g_error ("Unable to fetch mail account");
+
+ if (!e_source_remove_sync (source, NULL, &error))
+ g_error ("Unable to remove mail account: %s", error->message);
+
+ /* Remove the identity */
+ source = e_source_registry_ref_source (fixture->registry, MAIL_IDENTITY_UID);
+ if (!source)
+ g_error ("Unable to fetch mail identity");
+
+ if (!e_source_remove_sync (source, NULL, &error))
+ g_error ("Unable to remove mail identity: %s", error->message);
+
+ e_test_server_utils_teardown (fixture, user_data);
+}
static void
free_busy_data_cb (ECalClient *client,
const GSList *free_busy,
const gchar *func_name)
{
- g_print (" Received %d Free/Busy components from %s\n", g_slist_length ((GSList *) free_busy), func_name);
+ if (g_slist_length ((GSList *) free_busy) > 0)
+ received_free_busy_data = TRUE;
}
static void
@@ -33,6 +102,9 @@ test_get_free_busy_sync (ETestServerFixture *fixture,
cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
+ /* This is set by the free-busy-data callback */
+ received_free_busy_data = FALSE;
+
utc = icaltimezone_get_utc_timezone ();
start = time_from_isodate ("20040212T000000Z");
end = time_add_day_with_zone (start, 2, utc);
@@ -46,6 +118,8 @@ test_get_free_busy_sync (ETestServerFixture *fixture,
g_signal_handler_disconnect (cal_client, sig_id);
g_slist_free (users);
+
+ g_assert (received_free_busy_data);
}
static void
@@ -62,8 +136,7 @@ async_get_free_busy_result_ready (GObject *source_object,
if (!e_cal_client_get_free_busy_finish (cal_client, result, &error))
g_error ("create object finish: %s", error->message);
- if (!e_client_remove_sync (E_CLIENT (cal_client), NULL, &error))
- g_error ("client remove sync: %s", error->message);
+ g_assert (received_free_busy_data);
g_main_loop_quit (loop);
}
@@ -79,6 +152,9 @@ test_get_free_busy_async (ETestServerFixture *fixture,
cal_client = E_TEST_SERVER_UTILS_SERVICE (fixture, ECalClient);
+ /* This is set by the free-busy-data callback */
+ received_free_busy_data = FALSE;
+
utc = icaltimezone_get_utc_timezone ();
start = time_from_isodate ("20040212T000000Z");
end = time_add_day_with_zone (start, 2, utc);
@@ -104,10 +180,10 @@ main (gint argc,
g_test_add (
"/ECalClient/GetFreeBusy/Sync", ETestServerFixture, &cal_closure,
- e_test_server_utils_setup, test_get_free_busy_sync, e_test_server_utils_teardown);
+ setup_fixture, test_get_free_busy_sync, teardown_fixture);
g_test_add (
"/ECalClient/GetFreeBusy/Async", ETestServerFixture, &cal_closure,
- e_test_server_utils_setup, test_get_free_busy_async, e_test_server_utils_teardown);
+ setup_fixture, test_get_free_busy_async, teardown_fixture);
return e_test_server_utils_run ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]