-noinst_LTLIBRARIES = libclient-test-utils.la
-libclient_test_utils_la_SOURCES = client-test-utils.c client-test-utils.h
-
-libclient_test_utils_la_CPPFLAGS = \
+TEST_CPPFLAGS= \
$(AM_CPPFLAGS) \
-I$(top_srcdir) \
-I$(top_builddir) \
$(CAMEL_CFLAGS) \
$(NULL)
-libclient_test_utils_la_LIBADD = \
+TEST_LIBS = \
$(top_builddir)/calendar/libecal/libecal-1.2.la \
$(top_builddir)/tests/test-server-utils/libetestserverutils.la \
$(EVOLUTION_CALENDAR_LIBS) \
# The test program
noinst_PROGRAMS = $(TESTS) $(BROKEN_TESTS) \
- test-client-open \
- test-client-examine \
- test-client-stress-views \
- test-client-stress-factory--serial \
- test-client-stress-factory--fifo \
- test-client-stress-factory--single-cal \
- $(NULL)
-
-TEST_CPPFLAGS= \
- $(libclient_test_utils_la_CPPFLAGS) \
- $(NULL)
-
-TEST_LIBS = \
- $(libclient_test_utils_la_LIBADD) \
- libclient-test-utils.la \
$(NULL)
# ordered alphanumerically
test_client_add_timezone_CPPFLAGS=$(TEST_CPPFLAGS)
test_client_create_object_LDADD=$(TEST_LIBS)
test_client_create_object_CPPFLAGS=$(TEST_CPPFLAGS)
-test_client_examine_LDADD=$(TEST_LIBS)
-test_client_examine_CPPFLAGS=$(TEST_CPPFLAGS)
test_client_get_attachment_uris_LDADD=$(TEST_LIBS)
test_client_get_attachment_uris_CPPFLAGS=$(TEST_CPPFLAGS)
test_client_get_free_busy_LDADD=$(TEST_LIBS)
test_client_modify_object_CPPFLAGS=$(TEST_CPPFLAGS)
test_client_get_revision_LDADD=$(TEST_LIBS)
test_client_get_revision_CPPFLAGS=$(TEST_CPPFLAGS)
-test_client_open_LDADD=$(TEST_LIBS)
-test_client_open_CPPFLAGS=$(TEST_CPPFLAGS)
test_client_receive_objects_LDADD=$(TEST_LIBS)
test_client_receive_objects_CPPFLAGS=$(TEST_CPPFLAGS)
test_client_bulk_methods_LDADD=$(TEST_LIBS)
test_client_remove_object_CPPFLAGS=$(TEST_CPPFLAGS)
test_client_send_objects_LDADD=$(TEST_LIBS)
test_client_send_objects_CPPFLAGS=$(TEST_CPPFLAGS)
-test_client_stress_factory__fifo_LDADD=$(TEST_LIBS)
-test_client_stress_factory__fifo_CPPFLAGS=$(TEST_CPPFLAGS)
-test_client_stress_factory__serial_LDADD=$(TEST_LIBS)
-test_client_stress_factory__serial_CPPFLAGS=$(TEST_CPPFLAGS)
-test_client_stress_factory__single_cal_LDADD=$(TEST_LIBS)
-test_client_stress_factory__single_cal_CPPFLAGS=$(TEST_CPPFLAGS)
-test_client_stress_views_LDADD=$(TEST_LIBS)
-test_client_stress_views_CPPFLAGS=$(TEST_CPPFLAGS)
-include $(top_srcdir)/git.mk
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdio.h>
-#include <libedataserver/libedataserver.h>
-
-#include "client-test-utils.h"
-
-void
-print_ecomp (ECalComponent *ecalcomp)
-{
- const gchar *uid = NULL;
- ECalComponentText summary = { 0 };
-
- g_return_if_fail (ecalcomp != NULL);
-
- e_cal_component_get_uid (ecalcomp, &uid);
- e_cal_component_get_summary (ecalcomp, &summary);
-
- g_print (" Component: %s\n", uid ? uid : "no-uid");
- g_print (" Summary: %s\n", summary.value ? summary.value : "NULL");
- g_print ("\n");
-}
-
-void
-print_icomp (icalcomponent *icalcomp)
-{
- ECalComponent *ecomp;
-
- g_return_if_fail (icalcomp != NULL);
-
- ecomp = e_cal_component_new ();
- icalcomp = icalcomponent_new_clone (icalcomp);
-
- if (!e_cal_component_set_icalcomponent (ecomp, icalcomp)) {
- icalcomponent_free (icalcomp);
- g_object_unref (ecomp);
- g_printerr ("%s: Failed to assing icalcomp to ECalComponent\n", G_STRFUNC);
- g_print ("\n");
- return;
- }
-
- print_ecomp (ecomp);
-
- g_object_unref (ecomp);
-}
-
-void
-report_error (const gchar *operation,
- GError **error)
-{
- g_return_if_fail (operation != NULL);
-
- g_printerr ("Failed to %s: %s\n", operation, (error && *error) ? (*error)->message : "Unknown error");
-
- g_clear_error (error);
-}
-
-void
-main_initialize (void)
-{
- static gboolean initialized = FALSE;
-
- if (initialized)
- return;
-
- g_type_init ();
- e_gdbus_templates_init_main_thread ();
-
- initialized = TRUE;
-}
-
-struct IdleData {
- GThreadFunc func;
- gpointer data;
- gboolean run_in_thread; /* FALSE to run in idle callback */
-};
-
-static gboolean
-idle_cb (gpointer data)
-{
- struct IdleData *idle = data;
-
- g_return_val_if_fail (idle != NULL, FALSE);
- g_return_val_if_fail (idle->func != NULL, FALSE);
-
- if (idle->run_in_thread) {
- GThread *thread;
-
- thread = g_thread_new (NULL, idle->func, idle->data);
- g_thread_unref (thread);
- } else {
- idle->func (idle->data);
- }
-
- g_free (idle);
-
- return FALSE;
-}
-
-static GMainLoop *loop = NULL;
-static gint main_stop_result = 0;
-
-static void
-do_start (GThreadFunc func,
- gpointer data)
-{
- main_initialize ();
-
- g_return_if_fail (loop == NULL);
-
- loop = g_main_loop_new (NULL, FALSE);
-
- if (func)
- func (data);
-
- g_main_loop_run (loop);
-
- g_main_loop_unref (loop);
- loop = NULL;
-}
-
-/* Starts new main-loop, but just before that calls 'func'.
- * Main-loop is kept running, and this function blocks,
- * until call of stop_main_loop (). */
-void
-start_main_loop (GThreadFunc func,
- gpointer data)
-{
- g_return_if_fail (loop == NULL);
-
- do_start (func, data);
-}
-
-/* Starts new main-loop and then invokes func in a new thread.
- * Main-loop is kept running, and this function blocks,
- * until call of stop_main_loop (). */
-void
-start_in_thread_with_main_loop (GThreadFunc func,
- gpointer data)
-{
- struct IdleData *idle;
-
- g_return_if_fail (func != NULL);
- g_return_if_fail (loop == NULL);
-
- main_initialize ();
-
- idle = g_new0 (struct IdleData, 1);
- idle->func = func;
- idle->data = data;
- idle->run_in_thread = TRUE;
-
- g_idle_add (idle_cb, idle);
-
- do_start (NULL, NULL);
-}
-
-/* Starts new main-loop and then invokes func in an idle callback.
- * Main-loop is kept running, and this function blocks,
- * until call of stop_main_loop (). */
-void
-start_in_idle_with_main_loop (GThreadFunc func,
- gpointer data)
-{
- struct IdleData *idle;
-
- g_return_if_fail (func != NULL);
- g_return_if_fail (loop == NULL);
-
- main_initialize ();
-
- idle = g_new0 (struct IdleData, 1);
- idle->func = func;
- idle->data = data;
- idle->run_in_thread = FALSE;
-
- g_idle_add (idle_cb, idle);
-
- do_start (NULL, NULL);
-}
-
-/* Stops main-loop previously run by start_main_loop,
- * start_in_thread_with_main_loop or start_in_idle_with_main_loop.
-*/
-void
-stop_main_loop (gint stop_result)
-{
- g_return_if_fail (loop != NULL);
-
- main_stop_result = stop_result;
- g_main_loop_quit (loop);
-}
-
-/* returns value used in stop_main_loop() */
-gint
-get_main_loop_stop_result (void)
-{
- return main_stop_result;
-}
-
-void
-foreach_configured_source (ESourceRegistry *registry,
- ECalClientSourceType source_type,
- void (*func) (ESource *source,
- ECalClientSourceType source_type))
-{
- gpointer foreach_async_data;
- ESource *source = NULL;
-
- g_return_if_fail (func != NULL);
-
- main_initialize ();
-
- foreach_async_data = foreach_configured_source_async_start (registry, source_type, &source);
- if (!foreach_async_data)
- return;
-
- do {
- func (source, source_type);
- } while (foreach_configured_source_async_next (&foreach_async_data, &source));
-}
-
-struct ForeachConfiguredData {
- ECalClientSourceType source_type;
- GList *list;
-};
-
-gpointer
-foreach_configured_source_async_start (ESourceRegistry *registry,
- ECalClientSourceType source_type,
- ESource **source)
-{
- struct ForeachConfiguredData *async_data;
- const gchar *extension_name;
- GList *list;
-
- g_return_val_if_fail (source != NULL, NULL);
-
- main_initialize ();
-
- switch (source_type) {
- case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
- extension_name = E_SOURCE_EXTENSION_CALENDAR;
- break;
- case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
- extension_name = E_SOURCE_EXTENSION_TASK_LIST;
- break;
- case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
- extension_name = E_SOURCE_EXTENSION_MEMO_LIST;
- break;
- default:
- g_assert_not_reached ();
- }
-
- list = e_source_registry_list_sources (registry, extension_name);
-
- async_data = g_new0 (struct ForeachConfiguredData, 1);
- async_data->source_type = source_type;
- async_data->list = list;
-
- *source = async_data->list->data;
-
- return async_data;
-}
-
-gboolean
-foreach_configured_source_async_next (gpointer *foreach_async_data,
- ESource **source)
-{
- struct ForeachConfiguredData *async_data;
-
- g_return_val_if_fail (foreach_async_data != NULL, FALSE);
- g_return_val_if_fail (source != NULL, FALSE);
-
- async_data = *foreach_async_data;
- g_return_val_if_fail (async_data != NULL, FALSE);
-
- if (async_data->list) {
- g_object_unref (async_data->list->data);
- async_data->list = async_data->list->next;
- }
- if (async_data->list) {
- *source = async_data->list->data;
- return TRUE;
- }
-
- g_free (async_data);
-
- *foreach_async_data = NULL;
-
- return FALSE;
-}
-
-ECalClientSourceType
-foreach_configured_source_async_get_source_type (gpointer foreach_async_data)
-{
- struct ForeachConfiguredData *async_data = foreach_async_data;
-
- g_return_val_if_fail (foreach_async_data != NULL, E_CAL_CLIENT_SOURCE_TYPE_LAST);
-
- return async_data->source_type;
-}
-
-ECalClient *
-new_temp_client (ECalClientSourceType source_type,
- gchar **uri)
-{
-#if 0 /* ACCOUNT_MGMT */
- ECalClient *cal_client;
- ESource *source;
- gchar *abs_uri, *filename;
- GError *error = NULL;
-
- filename = g_build_filename (g_get_tmp_dir (), "e-cal-client-test-XXXXXX/", NULL);
- abs_uri = g_strconcat ("local:", filename, NULL);
- g_free (filename);
-
- source = e_source_new_with_absolute_uri ("Test cal", abs_uri);
- if (uri)
- *uri = abs_uri;
- else
- g_free (abs_uri);
-
- g_return_val_if_fail (source != NULL, NULL);
-
- cal_client = e_cal_client_new (source, source_type, &error);
- g_object_unref (source);
-
- if (error)
- report_error ("new temp client", &error);
-
- return cal_client;
-#endif /* ACCOUNT_MGMT */
-
- return NULL;
-}
+++ /dev/null
-#ifndef CLIENT_TEST_UTILS_H
-#define CLIENT_TEST_UTILS_H
-
-#include <libecal/libecal.h>
-
-void print_ecomp (ECalComponent *ecalcomp);
-void print_icomp (icalcomponent *icalcomp);
-void report_error (const gchar *operation, GError **error);
-
-void main_initialize (void);
-void start_main_loop (GThreadFunc func, gpointer data);
-void start_in_thread_with_main_loop (GThreadFunc func, gpointer data);
-void start_in_idle_with_main_loop (GThreadFunc func, gpointer data);
-void stop_main_loop (gint stop_result);
-gint get_main_loop_stop_result (void);
-
-void foreach_configured_source (ESourceRegistry *registry, ECalClientSourceType source_type, void (*func) (ESource *source, ECalClientSourceType source_type));
-gpointer foreach_configured_source_async_start (ESourceRegistry *registry, ECalClientSourceType source_type, ESource **source);
-gboolean foreach_configured_source_async_next (gpointer *foreach_async_data, ESource **source);
-ECalClientSourceType foreach_configured_source_async_get_source_type (gpointer foreach_async_data);
-
-ECalClient *new_temp_client (ECalClientSourceType source_type, gchar **uri);
-
-#endif /* CLIENT_TEST_UTILS_H */
#include <libecal/libecal.h>
#include <libical/ical.h>
-#include "client-test-utils.h"
#include "e-test-server-utils.h"
#define TZID_NEW "XYZ"
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdlib.h>
-#include <string.h>
-#include <libecal/libecal.h>
-
-#include "client-test-utils.h"
-
-static gint running_async = 0;
-
-static GSList *
-get_known_prop_names (void)
-{
- GSList *prop_names = NULL;
-
- prop_names = g_slist_append (prop_names, (gpointer) CLIENT_BACKEND_PROPERTY_READONLY);
- prop_names = g_slist_append (prop_names, (gpointer) CLIENT_BACKEND_PROPERTY_ONLINE);
- prop_names = g_slist_append (prop_names, (gpointer) CLIENT_BACKEND_PROPERTY_OPENED);
- prop_names = g_slist_append (prop_names, (gpointer) CLIENT_BACKEND_PROPERTY_OPENING);
- prop_names = g_slist_append (prop_names, (gpointer) CLIENT_BACKEND_PROPERTY_CACHE_DIR);
- prop_names = g_slist_append (prop_names, (gpointer) CLIENT_BACKEND_PROPERTY_CAPABILITIES);
- prop_names = g_slist_append (prop_names, (gpointer) CAL_BACKEND_PROPERTY_CAL_EMAIL_ADDRESS);
- prop_names = g_slist_append (prop_names, (gpointer) CAL_BACKEND_PROPERTY_ALARM_EMAIL_ADDRESS);
- prop_names = g_slist_append (prop_names, (gpointer) CAL_BACKEND_PROPERTY_DEFAULT_OBJECT);
-
- return prop_names;
-}
-
-typedef struct _ExtraValues {
- gpointer async_data;
-
- GSList *todo_prop_names;
- GHashTable *retrieved_props;
- const gchar *cache_dir;
- icalcomponent *default_object;
-} ExtraValues;
-
-static void
-extra_values_free (ExtraValues *evals)
-{
- if (!evals)
- return;
-
- if (evals->default_object)
- icalcomponent_free (evals->default_object);
- g_slist_free (evals->todo_prop_names);
- g_hash_table_destroy (evals->retrieved_props);
- g_free (evals);
-}
-
-static void
-print_with_prefix (const gchar *str,
- const gchar *prefix)
-{
- const gchar *p = str, *n;
- while (n = strchr (p, '\n'), p) {
- if (!n) {
- g_print ("%s%s\n", prefix, p);
- break;
- } else {
- g_print ("%s%.*s\n", prefix, (gint) (n - p), p);
- n++;
- }
-
- p = n;
- }
-}
-
-static void
-print_each_property (gpointer prop_name,
- gpointer prop_value,
- gpointer user_data)
-{
- g_return_if_fail (prop_name != NULL);
-
- if (prop_value == NULL) {
- g_print ("\t %s: NULL\n", (const gchar *) prop_name);
- return;
- }
-
- g_print ("\t %s: ", (const gchar *) prop_name);
-
- if (g_str_equal (prop_name, CLIENT_BACKEND_PROPERTY_CAPABILITIES)) {
- GSList *values = e_client_util_parse_comma_strings (prop_value), *v;
-
- for (v = values; v; v = v->next) {
- if (v != values)
- g_print (", ");
-
- g_print ("'%s'", (const gchar *) v->data);
- }
-
- e_client_util_free_string_slist (values);
- } else if (g_str_equal (prop_name, CAL_BACKEND_PROPERTY_DEFAULT_OBJECT)) {
- g_print ("\n");
- print_with_prefix (prop_value, "\t\t");
- } else {
- g_print ("'%s'", (const gchar *) prop_value);
- }
-
- g_print ("\n");
-}
-
-static void
-print_values (const ExtraValues *evals,
- EClient *client)
-{
- const GSList *values;
-
- g_return_if_fail (evals != NULL);
-
- g_print ("\treadonly:%s\n", e_client_is_readonly (client) ? "yes" : "no");
- g_print ("\tonline:%s\n", e_client_is_online (client) ? "yes" : "no");
- g_print ("\tcache dir: %s%s%s\n", evals->cache_dir ? "'" : "", evals->cache_dir ? evals->cache_dir : "none", evals->cache_dir ? "'" : "");
- g_print ("\tcapabilities: ");
- values = e_client_get_capabilities (client);
- if (!values) {
- g_print ("NULL");
- } else {
- while (values) {
- const gchar *cap = values->data;
-
- g_print ("'%s'", cap);
- if (!e_client_check_capability (client, cap))
- g_print (" (not found in EClient)");
-
- values = values->next;
-
- if (values)
- g_print (", ");
- }
- }
- g_print ("\n");
-
- g_print ("\tdefault object: %s\n", evals->default_object ? "" : "none");
- if (evals->default_object) {
- gchar *comp_str = icalcomponent_as_ical_string_r (evals->default_object);
- print_with_prefix (comp_str, "\t ");
- g_free (comp_str);
- }
-
- g_print ("\tbackend properties:\n");
- g_hash_table_foreach (evals->retrieved_props, print_each_property, NULL);
-}
-
-static void
-identify_source (ESource *source,
- ECalClientSourceType source_type)
-{
- const gchar *name, *type, *uid;
-
- g_return_if_fail (source != NULL);
-
- switch (source_type) {
- case E_CAL_CLIENT_SOURCE_TYPE_EVENTS:
- type = "events";
- break;
- case E_CAL_CLIENT_SOURCE_TYPE_TASKS:
- type = "tasks";
- break;
- case E_CAL_CLIENT_SOURCE_TYPE_MEMOS:
- type = "memos";
- break;
- default:
- type = "unknown-type";
- break;
- }
-
- uid = e_source_get_uid (source);
- name = e_source_get_display_name (source);
-
- g_print ("\n Checking %s source '%s' (%s)\n", type, name, uid);
-}
-
-static void
-identify_client (ECalClient *cal_client)
-{
- g_return_if_fail (cal_client != NULL);
- g_return_if_fail (E_IS_CAL_CLIENT (cal_client));
-
- identify_source (e_client_get_source (E_CLIENT (cal_client)), e_cal_client_get_source_type (cal_client));
-}
-
-static void client_opened_async (GObject *source_object, GAsyncResult *result, gpointer async_data);
-
-static void
-continue_next_source (gpointer async_data)
-{
- ESource *source = NULL;
- ECalClient *cal_client;
- GError *error = NULL;
-
- g_return_if_fail (async_data != NULL);
-
- while (async_data && foreach_configured_source_async_next (&async_data, &source)) {
- ECalClientSourceType source_type = foreach_configured_source_async_get_source_type (async_data);
-
- cal_client = e_cal_client_new (source, source_type, &error);
- if (!cal_client) {
- identify_source (source, source_type);
- report_error ("cal client new", &error);
- continue;
- }
-
- e_client_open (E_CLIENT (cal_client), TRUE, NULL, client_opened_async, async_data);
- break;
- }
-
- if (!async_data) {
- running_async--;
- if (!running_async)
- stop_main_loop (0);
- }
-}
-
-static void
-client_got_backend_property_async (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
-{
- ExtraValues *evals = user_data;
- gchar *prop_value = NULL;
- GError *error = NULL;
- ECalClient *cal_client;
-
- g_return_if_fail (source_object != NULL);
- g_return_if_fail (E_IS_CAL_CLIENT (source_object));
- g_return_if_fail (evals != NULL);
-
- cal_client = E_CAL_CLIENT (source_object);
-
- if (!e_client_get_backend_property_finish (E_CLIENT (cal_client), result, &prop_value, &error)) {
- identify_client (cal_client);
- report_error ("get backend property finish", &error);
- }
-
- g_hash_table_insert (evals->retrieved_props, evals->todo_prop_names->data, prop_value);
- evals->todo_prop_names = g_slist_remove (evals->todo_prop_names, evals->todo_prop_names->data);
-
- if (!evals->todo_prop_names) {
- evals->cache_dir = e_cal_client_get_local_attachment_store (cal_client);
-
- /* to cache them, as it can be fetched with idle as well */
- e_client_get_capabilities (E_CLIENT (source_object));
-
- identify_client (cal_client);
- print_values (evals, E_CLIENT (source_object));
-
- g_object_unref (source_object);
-
- continue_next_source (evals->async_data);
- extra_values_free (evals);
- } else {
- e_client_get_backend_property (E_CLIENT (cal_client), evals->todo_prop_names->data, NULL, client_got_backend_property_async, evals);
- }
-}
-
-static void
-client_set_backend_property_async (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
-{
- ExtraValues *evals = user_data;
- GError *error = NULL;
- ECalClient *cal_client;
-
- g_return_if_fail (source_object != NULL);
- g_return_if_fail (E_IS_CAL_CLIENT (source_object));
- g_return_if_fail (evals != NULL);
-
- cal_client = E_CAL_CLIENT (source_object);
-
- if (!e_client_set_backend_property_finish (E_CLIENT (cal_client), result, &error)) {
- /* it may fail on the set_backend_property */
- g_clear_error (&error);
- } else {
- identify_client (cal_client);
- g_printerr (" Might fail on set_backend_property, but reported success\n");
- }
-
- e_client_get_backend_property (E_CLIENT (cal_client), evals->todo_prop_names->data, NULL, client_got_backend_property_async, evals);
-}
-
-static void
-client_got_default_object_async (GObject *source_object,
- GAsyncResult *result,
- gpointer evals_data)
-{
- ExtraValues *evals = evals_data;
- ECalClient *cal_client;
- GError *error = NULL;
-
- g_return_if_fail (source_object != NULL);
- g_return_if_fail (E_IS_CAL_CLIENT (source_object));
- g_return_if_fail (evals != NULL);
-
- cal_client = E_CAL_CLIENT (source_object);
-
- if (!e_cal_client_get_default_object_finish (cal_client, result, &evals->default_object, &error)) {
- identify_client (cal_client);
- report_error ("get default object finish", &error);
- }
-
- e_client_set_backend_property (E_CLIENT (cal_client), "*unknown*property*", "*value*", NULL, client_set_backend_property_async, evals);
-}
-
-static void
-client_opened_async (GObject *source_object,
- GAsyncResult *result,
- gpointer async_data)
-{
- ExtraValues *evals;
- GError *error = NULL;
- ECalClient *cal_client;
-
- g_return_if_fail (source_object != NULL);
- g_return_if_fail (E_IS_CAL_CLIENT (source_object));
- g_return_if_fail (async_data != NULL);
-
- cal_client = E_CAL_CLIENT (source_object);
-
- if (!e_client_open_finish (E_CLIENT (source_object), result, &error)) {
- identify_client (cal_client);
- report_error ("client open finish", &error);
- g_object_unref (source_object);
- continue_next_source (async_data);
- return;
- }
-
- evals = g_new0 (ExtraValues, 1);
- evals->async_data = async_data;
- evals->todo_prop_names = get_known_prop_names ();
- evals->retrieved_props = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
-
- e_cal_client_get_default_object (cal_client, NULL, client_got_default_object_async, evals);
-}
-
-static void
-check_source_sync (ESource *source,
- ECalClientSourceType source_type)
-{
- ECalClient *cal_client;
- GError *error = NULL;
- GSList *properties, *p;
- ExtraValues evals = { 0 };
-
- g_return_if_fail (source != NULL);
-
- identify_source (source, source_type);
-
- cal_client = e_cal_client_new (source, source_type, &error);
- if (!cal_client) {
- report_error ("cal client new", &error);
- return;
- }
-
- if (!e_client_open_sync (E_CLIENT (cal_client), TRUE, NULL, &error)) {
- report_error ("client open sync", &error);
- g_object_unref (cal_client);
- return;
- }
-
- if (!e_cal_client_get_default_object_sync (cal_client, &evals.default_object, NULL, &error)) {
- report_error ("get default object sync", &error);
- }
-
- if (!e_client_set_backend_property_sync (E_CLIENT (cal_client), "*unknown*property*", "*value*", NULL, &error)) {
- g_clear_error (&error);
- } else {
- identify_client (cal_client);
- g_printerr (" Might fail on set_backend_property, but reported success\n");
- }
-
- evals.retrieved_props = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free);
-
- properties = get_known_prop_names ();
- for (p = properties; p != NULL; p = p->next) {
- gchar *prop_value = NULL;
-
- if (!e_client_get_backend_property_sync (E_CLIENT (cal_client), p->data, &prop_value, NULL, &error)) {
- identify_client (cal_client);
- report_error ("get backend property sync", &error);
- } else {
- g_hash_table_insert (evals.retrieved_props, p->data, prop_value);
- }
- }
- g_slist_free (properties);
-
- evals.cache_dir = e_cal_client_get_local_attachment_store (cal_client);
-
- print_values (&evals, E_CLIENT (cal_client));
-
- g_hash_table_destroy (evals.retrieved_props);
- icalcomponent_free (evals.default_object);
- g_object_unref (cal_client);
-}
-
-static gboolean
-foreach_async (ESourceRegistry *registry,
- ECalClientSourceType source_type)
-{
- gpointer async_data;
- ESource *source = NULL;
- ECalClient *cal_client;
- GError *error = NULL;
-
- async_data = foreach_configured_source_async_start (registry, source_type, &source);
- if (!async_data) {
- stop_main_loop (1);
- return FALSE;
- }
-
- running_async++;
-
- while (cal_client = e_cal_client_new (source, source_type, &error), !cal_client) {
- identify_source (source, source_type);
- report_error ("cal client new", &error);
-
- if (!foreach_configured_source_async_next (&async_data, &source)) {
- running_async--;
- if (!running_async)
- stop_main_loop (0);
- return FALSE;
- }
-
- identify_source (source, source_type);
- }
-
- e_client_open (E_CLIENT (cal_client), TRUE, NULL, client_opened_async, async_data);
-
- return TRUE;
-}
-
-static gboolean
-in_main_thread_idle_cb (ESourceRegistry *registry)
-{
- g_print ("* run in main thread with mainloop running\n");
- foreach_configured_source (registry, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, check_source_sync);
- foreach_configured_source (registry, E_CAL_CLIENT_SOURCE_TYPE_TASKS, check_source_sync);
- foreach_configured_source (registry, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, check_source_sync);
- g_print ("---------------------------------------------------------\n\n");
-
- g_print ("* run in main thread async\n");
-
- if (!foreach_async (registry, E_CAL_CLIENT_SOURCE_TYPE_EVENTS))
- return FALSE;
-
- if (!foreach_async (registry, E_CAL_CLIENT_SOURCE_TYPE_TASKS))
- return FALSE;
-
- if (!foreach_async (registry, E_CAL_CLIENT_SOURCE_TYPE_MEMOS))
- return FALSE;
-
- return FALSE;
-}
-
-static gpointer
-worker_thread (ESourceRegistry *registry)
-{
- g_print ("* run in dedicated thread with mainloop running\n");
- foreach_configured_source (registry, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, check_source_sync);
- foreach_configured_source (registry, E_CAL_CLIENT_SOURCE_TYPE_TASKS, check_source_sync);
- foreach_configured_source (registry, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, check_source_sync);
- g_print ("---------------------------------------------------------\n\n");
-
- g_idle_add ((GSourceFunc) in_main_thread_idle_cb, registry);
-
- return NULL;
-}
-
-gint
-main (gint argc,
- gchar **argv)
-{
- ESourceRegistry *registry;
- GError *error = NULL;
-
- main_initialize ();
-
- registry = e_source_registry_new_sync (NULL, &error);
- if (error != NULL)
- g_error ("%s", error->message);
-
- g_print ("* run in main thread without mainloop\n");
- foreach_configured_source (registry, E_CAL_CLIENT_SOURCE_TYPE_EVENTS, check_source_sync);
- foreach_configured_source (registry, E_CAL_CLIENT_SOURCE_TYPE_TASKS, check_source_sync);
- foreach_configured_source (registry, E_CAL_CLIENT_SOURCE_TYPE_MEMOS, check_source_sync);
- g_print ("---------------------------------------------------------\n\n");
-
- start_in_thread_with_main_loop ((GThreadFunc) worker_thread, registry);
-
- return get_main_loop_stop_result ();
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdlib.h>
-#include <libecal/libecal.h>
-#include <libical/ical.h>
-
-#include "client-test-utils.h"
-
-static gboolean
-test_sync (void)
-{
- ECalClient *cal_client;
- GError *error = NULL;
-
- cal_client = new_temp_client (E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL);
- g_return_val_if_fail (cal_client != NULL, FALSE);
-
- if (!e_client_open_sync (E_CLIENT (cal_client), FALSE, NULL, &error)) {
- report_error ("client open sync", &error);
- g_object_unref (cal_client);
- return FALSE;
- }
-
- if (!e_client_remove_sync (E_CLIENT (cal_client), NULL, &error)) {
- report_error ("client remove sync", &error);
- g_object_unref (cal_client);
- return FALSE;
- }
-
- g_object_unref (cal_client);
-
- return TRUE;
-}
-
-/* asynchronous remove callback with a main-loop running */
-static void
-async_remove_ready (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
-{
- ECalClient *cal_client;
- GError *error = NULL;
-
- cal_client = E_CAL_CLIENT (source_object);
-
- if (!e_client_remove_finish (E_CLIENT (cal_client), result, &error)) {
- report_error ("remove finish", &error);
- g_object_unref (cal_client);
- stop_main_loop (1);
- return;
- }
-
- g_object_unref (cal_client);
-
- stop_main_loop (0);
-}
-
-/* asynchronous open callback with a main-loop running */
-static void
-async_open_ready (GObject *source_object,
- GAsyncResult *result,
- gpointer user_data)
-{
- ECalClient *cal_client;
- GError *error = NULL;
-
- cal_client = E_CAL_CLIENT (source_object);
-
- if (!e_client_open_finish (E_CLIENT (cal_client), result, &error)) {
- report_error ("open finish", &error);
- g_object_unref (cal_client);
- stop_main_loop (1);
- return;
- }
-
- e_client_remove (E_CLIENT (cal_client), NULL, async_remove_ready, NULL);
-}
-
-/* synchronously in idle with main-loop running */
-static gboolean
-test_sync_in_idle (gpointer user_data)
-{
- ECalClient *cal_client;
-
- if (!test_sync ()) {
- stop_main_loop (1);
- return FALSE;
- }
-
- cal_client = new_temp_client (E_CAL_CLIENT_SOURCE_TYPE_EVENTS, NULL);
- g_return_val_if_fail (cal_client != NULL, FALSE);
-
- e_client_open (E_CLIENT (cal_client), FALSE, NULL, async_open_ready, NULL);
-
- return FALSE;
-}
-
-/* synchronously in a dedicated thread with main-loop running */
-static gpointer
-test_sync_in_thread (gpointer user_data)
-{
- if (!test_sync ()) {
- stop_main_loop (1);
- return NULL;
- }
-
- g_idle_add (test_sync_in_idle, NULL);
-
- return NULL;
-}
-
-gint
-main (gint argc,
- gchar **argv)
-{
- main_initialize ();
-
- /* synchronously without main-loop */
- if (!test_sync ()) {
- return 1;
- }
-
- start_in_thread_with_main_loop (test_sync_in_thread, NULL);
-
- if (get_main_loop_stop_result () == 0)
- g_print ("Test finished successfully.\n");
-
- return get_main_loop_stop_result ();
-}
#include <libical/ical.h>
#include "e-test-server-utils.h"
-#include "client-test-utils.h" /* For print_icomp() */
static ETestServerClosure cal_closure =
{ E_TEST_SERVER_CALENDAR, NULL, E_CAL_CLIENT_SOURCE_TYPE_EVENTS };
+static void
+print_ecomp (ECalComponent *ecalcomp)
+{
+ const gchar *uid = NULL;
+ ECalComponentText summary = { 0 };
+
+ g_return_if_fail (ecalcomp != NULL);
+
+ e_cal_component_get_uid (ecalcomp, &uid);
+ e_cal_component_get_summary (ecalcomp, &summary);
+
+ g_print (" Component: %s\n", uid ? uid : "no-uid");
+ g_print (" Summary: %s\n", summary.value ? summary.value : "NULL");
+ g_print ("\n");
+}
+
+static void
+print_icomp (icalcomponent *icalcomp)
+{
+ ECalComponent *ecomp;
+
+ g_return_if_fail (icalcomp != NULL);
+
+ ecomp = e_cal_component_new ();
+ icalcomp = icalcomponent_new_clone (icalcomp);
+
+ if (!e_cal_component_set_icalcomponent (ecomp, icalcomp)) {
+ icalcomponent_free (icalcomp);
+ g_object_unref (ecomp);
+ g_printerr ("%s: Failed to assing icalcomp to ECalComponent\n", G_STRFUNC);
+ g_print ("\n");
+ return;
+ }
+
+ print_ecomp (ecomp);
+
+ g_object_unref (ecomp);
+}
+
static icalcomponent *
create_object (void)
{
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdlib.h>
-#include <libecal/libecal.h>
-
-#include "client-test-utils.h"
-
-#define NUM_CLIENTS 200
-
-gint
-main (gint argc,
- gchar **argv)
-{
- ECalClientSourceType source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
- ECalClient *cal_clients[NUM_CLIENTS];
- GError *error = NULL;
- gint ii;
-
- main_initialize ();
-
- /* Create and open many cals; then remove each of them */
-
- for (ii = 0; ii < NUM_CLIENTS; ii++) {
- cal_clients[ii] = new_temp_client (source_type, NULL);
- g_return_val_if_fail (cal_clients[ii] != NULL, 1);
-
- if (!e_client_open_sync (E_CLIENT (cal_clients[ii]), FALSE, NULL, &error)) {
- report_error ("client open sync", &error);
- while (ii >= 0) {
- g_object_unref (cal_clients[ii]);
- ii--;
- }
-
- return 1;
- }
- }
-
- for (ii = 0; ii < NUM_CLIENTS; ii++) {
- if (!e_client_remove_sync (E_CLIENT (cal_clients[ii]), NULL, &error)) {
- report_error ("client remove sync", &error);
- while (ii < NUM_CLIENTS) {
- g_object_unref (cal_clients[ii]);
- ii++;
- }
- return 1;
- }
-
- g_object_unref (cal_clients[ii]);
- }
-
- return 0;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <libecal/libecal.h>
-
-#include "client-test-utils.h"
-
-#define NUM_CLIENTS 200
-
-gint
-main (gint argc,
- gchar **argv)
-{
- ECalClientSourceType source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
- GError *error = NULL;
- gint ii;
-
- main_initialize ();
-
- /* Serially create, open, (close), and remove many cals */
- for (ii = 0; ii < NUM_CLIENTS; ii++) {
- ECalClient *cal_client = new_temp_client (source_type, NULL);
- g_return_val_if_fail (cal_client != NULL, 1);
-
- if (!e_client_open_sync (E_CLIENT (cal_client), FALSE, NULL, &error)) {
- report_error ("client open sync", &error);
- return 1;
- }
-
- if (!e_client_remove_sync (E_CLIENT (cal_client), NULL, &error)) {
- report_error ("client remove sync", &error);
- g_object_unref (cal_client);
- return 1;
- }
-
- g_object_unref (cal_client);
- }
-
- return 0;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdlib.h>
-#include <libecal/libecal.h>
-
-#include "client-test-utils.h"
-
-#define NUM_OPENS 200
-
-gint
-main (gint argc,
- gchar **argv)
-{
-#if 0 /* ACCOUNT_MGMT */
- ECalClientSourceType source_type = E_CAL_CLIENT_SOURCE_TYPE_EVENTS;
- gchar *uri = NULL;
- ECalClient *cal_client;
- GError *error = NULL;
- gint ii;
-
- main_initialize ();
-
- cal_client = new_temp_client (source_type, &uri);
- g_return_val_if_fail (cal_client != NULL, 1);
- g_return_val_if_fail (uri != NULL, 1);
-
- g_object_unref (cal_client);
-
- /* open and close the same cal repeatedly */
- for (ii = 0; ii < NUM_OPENS; ii++) {
- cal_client = e_cal_client_new_from_uri (uri, source_type, &error);
- if (!cal_client) {
- report_error ("new from uri", &error);
- break;
- }
-
- if (!e_client_open_sync (E_CLIENT (cal_client), FALSE, NULL, &error)) {
- report_error ("client open sync", &error);
- g_object_unref (cal_client);
- break;
- }
-
- g_object_unref (cal_client);
- }
-
- cal_client = e_cal_client_new_from_uri (uri, source_type, &error);
- if (!cal_client) {
- g_clear_error (&error);
- } else if (!e_client_open_sync (E_CLIENT (cal_client), FALSE, NULL, &error)) {
- report_error ("client open sync", &error);
- g_object_unref (cal_client);
- g_free (uri);
- return 1;
- } else if (!e_client_remove_sync (E_CLIENT (cal_client), NULL, &error)) {
- report_error ("client remove sync", &error);
- g_object_unref (cal_client);
- g_free (uri);
- return 1;
- }
-
- g_free (uri);
- g_object_unref (cal_client);
-
- return ii == NUM_OPENS ? 0 : 1;
-#endif /* ACCOUNT_MGMT */
-
- return 0;
-}
+++ /dev/null
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-
-#include <stdlib.h>
-#include <libecal/libecal.h>
-
-#include "client-test-utils.h"
-
-#define NUM_VIEWS 200
-
-#if 0 /* ACCOUNT_MGMT */
-static void
-objects_added (ECalClientView *cal_view,
- const GSList *objects)
-{
- const GSList *l;
-
- for (l = objects; l; l = l->next) {
- print_icomp (l->data);
- }
-}
-
-static void
-objects_removed (ECalClientView *view,
- const GSList *ids)
-{
- const GSList *l;
-
- for (l = ids; l; l = l->next) {
- printf (" Removed contact: %s\n", (gchar *) l->data);
- }
-}
-
-static void
-complete (ECalClientView *view,
- const GError *error)
-{
- printf ("view_complete (status == %d, error_msg == %s%s%s)\n", error ? error->code : 0, error ? "'" : "", error ? error->message : "NULL", error ? "'" : "");
-}
-
-static gint
-stress_cal_views (ECalClient *cal_client,
- gboolean in_thread)
-{
- ECalClientView *view = NULL;
- ECalClientView *new_view;
- gint i;
-
- g_return_val_if_fail (cal_client != NULL, -1);
- g_return_val_if_fail (E_IS_CAL_CLIENT (cal_client), -1);
-
- for (i = 0; i < NUM_VIEWS; i++) {
- GError *error = NULL;
-
- if (!e_cal_client_get_view_sync (cal_client, "#t", &new_view, NULL, &error)) {
- report_error ("get cal view sync", &error);
- g_object_unref (view);
- return 1;
- }
-
- g_signal_connect (new_view, "objects_added", G_CALLBACK (objects_added), NULL);
- g_signal_connect (new_view, "objects_removed", G_CALLBACK (objects_removed), NULL);
- g_signal_connect (new_view, "complete", G_CALLBACK (complete), NULL);
-
- e_cal_client_view_start (new_view, NULL);
-
- if (view) {
- /* wait 100 ms when in a thread */
- if (in_thread)
- g_usleep (100000);
-
- e_cal_client_view_stop (view, NULL);
- g_object_unref (view);
- }
-
- view = new_view;
- }
-
- e_cal_client_view_stop (view, NULL);
- g_object_unref (view);
-
- return 0;
-}
-
-static gpointer
-stress_cal_views_thread (gpointer user_data)
-{
- stop_main_loop (stress_cal_views (user_data, TRUE));
-
- return NULL;
-}
-#endif /* ACCOUNT_MGMT */
-
-gint
-main (gint argc,
- gchar **argv)
-{
-#if 0 /* ACCOUNT_MGMT */
- ECalClient *cal_client;
- GError *error = NULL;
-
- main_initialize ();
-
- cal_client = e_cal_client_new_system (E_CAL_CLIENT_SOURCE_TYPE_EVENTS, &error);
- if (!cal_client) {
- report_error ("create local calendar", &error);
- return 1;
- }
-
- if (!e_client_open_sync (E_CLIENT (cal_client), FALSE, NULL, &error)) {
- g_object_unref (cal_client);
- report_error ("open client sync", &error);
- return 1;
- }
-
- /* test from main thread */
- stress_cal_views (cal_client, FALSE);
-
- /* test from dedicated thread */
- start_in_thread_with_main_loop (stress_cal_views_thread, cal_client);
-
- g_object_unref (cal_client);
-
- return get_main_loop_stop_result ();
-#endif /* ACCOUNT_MGMT */
-
- return 0;
-}