diff options
author | Travis Reitter <treitter@gmail.com> | 2009-12-17 17:23:58 -0800 |
---|---|---|
committer | Travis Reitter <treitter@gmail.com> | 2010-01-15 13:29:59 -0800 |
commit | 8a89cf11f4872ac79cb3841fbe3fee9b652b52a5 (patch) | |
tree | 7ded4bf473949a0bad66fb37098863b61ee010df | |
parent | 96ccffe5c4de4effee80f12449ffd9cfd83f31c2 (diff) | |
download | evolution-data-server-8a89cf11f4872ac79cb3841fbe3fee9b652b52a5.tar.gz |
Add test for EDataCal method 'getDefaultObject'.
-rw-r--r-- | calendar/tests/ecal/Makefile.am | 3 | ||||
-rw-r--r-- | calendar/tests/ecal/ecal-test-utils.c | 19 | ||||
-rw-r--r-- | calendar/tests/ecal/ecal-test-utils.h | 3 | ||||
-rw-r--r-- | calendar/tests/ecal/test-ecal-get-default-object.c | 31 |
4 files changed, 56 insertions, 0 deletions
diff --git a/calendar/tests/ecal/Makefile.am b/calendar/tests/ecal/Makefile.am index c98ee45ba..93e16dbf1 100644 --- a/calendar/tests/ecal/Makefile.am +++ b/calendar/tests/ecal/Makefile.am @@ -38,6 +38,7 @@ TESTS = \ test-ecal-get-cal-address \ test-ecal-get-ldap-attribute \ test-ecal-get-capabilities \ + test-ecal-get-default-object \ test-ecal-set-mode \ $(NULL) @@ -53,6 +54,8 @@ test_ecal_get_alarm_email_address_LDADD=$(TEST_ECAL_LIBS) test_ecal_get_alarm_email_address_CPPFLAGS=$(TEST_ECAL_CPPFLAGS) test_ecal_get_cal_address_LDADD=$(TEST_ECAL_LIBS) test_ecal_get_cal_address_CPPFLAGS=$(TEST_ECAL_CPPFLAGS) +test_ecal_get_default_object_LDADD=$(TEST_ECAL_LIBS) +test_ecal_get_default_object_CPPFLAGS=$(TEST_ECAL_CPPFLAGS) test_ecal_get_ldap_attribute_LDADD=$(TEST_ECAL_LIBS) test_ecal_get_ldap_attribute_CPPFLAGS=$(TEST_ECAL_CPPFLAGS) test_ecal_get_capabilities_LDADD=$(TEST_ECAL_LIBS) diff --git a/calendar/tests/ecal/ecal-test-utils.c b/calendar/tests/ecal/ecal-test-utils.c index d399bea15..3bdd96e57 100644 --- a/calendar/tests/ecal/ecal-test-utils.c +++ b/calendar/tests/ecal/ecal-test-utils.c @@ -263,6 +263,25 @@ ecal_test_utils_cal_get_capabilities (ECal *cal) ); } +icalcomponent* +ecal_test_utils_cal_get_default_object (ECal *cal) +{ + GError *error = NULL; + icalcomponent *component = NULL; + + if (!e_cal_get_default_object (cal, &component, &error)) { + g_warning ("failed to get default icalcomponent object; %s\n", error->message); + exit(1); + } + if (!icalcomponent_is_valid (component)) { + g_warning ("default icalcomponent is invalid\n"); + exit(1); + } + g_print ("successfully got the default icalcomponent object\n"); + + return component; +} + static void cal_set_mode_cb (ECal *cal, ECalendarStatus status, diff --git a/calendar/tests/ecal/ecal-test-utils.h b/calendar/tests/ecal/ecal-test-utils.h index 5e69a85a7..3e82c5296 100644 --- a/calendar/tests/ecal/ecal-test-utils.h +++ b/calendar/tests/ecal/ecal-test-utils.h @@ -60,6 +60,9 @@ ecal_test_utils_cal_get_ldap_attribute (ECal *cal); void ecal_test_utils_cal_get_capabilities (ECal *cal); +icalcomponent* +ecal_test_utils_cal_get_default_object (ECal *cal); + void ecal_test_utils_cal_set_mode (ECal *cal, CalMode mode, diff --git a/calendar/tests/ecal/test-ecal-get-default-object.c b/calendar/tests/ecal/test-ecal-get-default-object.c new file mode 100644 index 000000000..39d0afa35 --- /dev/null +++ b/calendar/tests/ecal/test-ecal-get-default-object.c @@ -0,0 +1,31 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + +#include <stdlib.h> +#include <libecal/e-cal.h> +#include <libical/ical.h> + +#include "ecal-test-utils.h" + +gint +main (gint argc, gchar **argv) +{ + ECal *cal; + char *uri = NULL; + icalcomponent *component; + char *component_string; + + g_type_init (); + + cal = ecal_test_utils_cal_new_temp (&uri, E_CAL_SOURCE_TYPE_EVENT); + ecal_test_utils_cal_open (cal, FALSE); + + component = ecal_test_utils_cal_get_default_object (cal); + component_string = icalcomponent_as_ical_string (component); + g_print ("default object:\n%s", component_string); + + ecal_test_utils_cal_remove (cal); + + g_free (component_string); + + return 0; +} |