230
test_query_events_async_cb (GDataService *service, GAsyncResult *async_result, GMainLoop *main_loop)
233
GError *error = NULL;
235
feed = gdata_service_query_finish (service, async_result, &error);
236
g_assert_no_error (error);
237
g_assert (GDATA_IS_CALENDAR_FEED (feed));
240
g_main_loop_quit (main_loop);
242
g_object_unref (feed);
246
test_query_events_async (gconstpointer service)
248
GDataCalendarCalendar *calendar;
249
GMainLoop *main_loop;
250
GError *error = NULL;
252
calendar = get_calendar (service, &error);
253
main_loop = g_main_loop_new (NULL, TRUE);
255
gdata_calendar_service_query_events_async (GDATA_CALENDAR_SERVICE (service), calendar, NULL, NULL, NULL, NULL,
256
(GAsyncReadyCallback) test_query_events_async_cb, main_loop);
257
g_main_loop_run (main_loop);
259
g_main_loop_unref (main_loop);
260
g_object_unref (calendar);
230
264
test_insert_simple (gconstpointer service)
232
266
GDataCalendarEvent *event, *new_event;
256
289
g_object_unref (when);
258
291
/* Check the XML */
259
xml = gdata_parsable_get_xml (GDATA_PARSABLE (event));
260
g_assert_cmpstr (xml, ==,
292
gdata_test_assert_xml (event,
261
293
"<?xml version='1.0' encoding='UTF-8'?>"
262
294
"<entry xmlns='http://www.w3.org/2005/Atom' "
263
295
"xmlns:gd='http://schemas.google.com/g/2005' "
327
test_insert_simple_async_cb (GDataService *service, GAsyncResult *result, GMainLoop *main_loop)
330
GError *error = NULL;
332
event = gdata_service_insert_entry_finish (service, result, &error);
333
g_assert_no_error (error);
334
g_assert (GDATA_IS_CALENDAR_EVENT (event));
336
/* Check the event is correct */
337
g_assert_cmpstr (gdata_entry_get_title (event), ==, "Tennis with Beth");
339
g_main_loop_quit (main_loop);
341
g_object_unref (event);
345
test_insert_simple_async (gconstpointer service)
347
GDataCalendarEvent *event;
351
GTimeVal start_time, end_time;
352
GMainLoop *main_loop;
354
event = gdata_calendar_event_new (NULL);
356
gdata_entry_set_title (GDATA_ENTRY (event), "Tennis with Beth");
357
gdata_entry_set_content (GDATA_ENTRY (event), "Meet for a quick lesson.");
358
gdata_calendar_event_set_transparency (event, GDATA_GD_EVENT_TRANSPARENCY_OPAQUE);
359
gdata_calendar_event_set_status (event, GDATA_GD_EVENT_STATUS_CONFIRMED);
360
where = gdata_gd_where_new (NULL, "Rolling Lawn Courts", NULL);
361
gdata_calendar_event_add_place (event, where);
362
g_object_unref (where);
363
who = gdata_gd_who_new (GDATA_GD_WHO_EVENT_ORGANIZER, "John Smith‽", "john.smith@example.com");
364
gdata_calendar_event_add_person (event, who);
365
g_object_unref (who);
366
g_time_val_from_iso8601 ("2009-04-17T15:00:00.000Z", &start_time);
367
g_time_val_from_iso8601 ("2009-04-17T17:00:00.000Z", &end_time);
368
when = gdata_gd_when_new (start_time.tv_sec, end_time.tv_sec, FALSE);
369
gdata_calendar_event_add_time (event, when);
370
g_object_unref (when);
372
main_loop = g_main_loop_new (NULL, TRUE);
374
/* Insert the event */
375
gdata_calendar_service_insert_event_async (GDATA_CALENDAR_SERVICE (service), event, NULL, (GAsyncReadyCallback) test_insert_simple_async_cb,
377
g_main_loop_run (main_loop);
379
g_main_loop_unref (main_loop);
380
g_object_unref (event);
296
384
test_xml_dates (void)
298
386
GDataCalendarEvent *event;
299
387
GList *times, *i;
300
388
GDataGDWhen *when;
303
390
GError *error = NULL;
305
392
event = GDATA_CALENDAR_EVENT (gdata_parsable_new_from_xml (GDATA_TYPE_CALENDAR_EVENT,
357
444
g_assert (gdata_gd_when_get_reminders (when) == NULL);
359
446
/* Check the XML */
360
xml = gdata_parsable_get_xml (GDATA_PARSABLE (event));
361
g_assert_cmpstr (xml, ==,
447
gdata_test_assert_xml (event,
362
448
"<?xml version='1.0' encoding='UTF-8'?>"
363
449
"<entry xmlns='http://www.w3.org/2005/Atom' "
364
450
"xmlns:gd='http://schemas.google.com/g/2005' "
533
test_calendar_escaping (void)
535
GDataCalendarCalendar *calendar;
537
calendar = gdata_calendar_calendar_new (NULL);
538
gdata_calendar_calendar_set_timezone (calendar, "<timezone>");
540
/* Check the outputted XML is escaped properly */
541
gdata_test_assert_xml (calendar,
542
"<?xml version='1.0' encoding='UTF-8'?>"
543
"<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
544
"xmlns:gCal='http://schemas.google.com/gCal/2005' xmlns:app='http://www.w3.org/2007/app'>"
545
"<title type='text'></title>"
546
"<category term='http://schemas.google.com/gCal/2005#calendarmeta' scheme='http://schemas.google.com/g/2005#kind'/>"
547
"<gCal:timezone value='<timezone>'/>"
548
"<gCal:hidden value='false'/>"
549
"<gCal:color value='#000000'/>"
550
"<gCal:selected value='false'/>"
552
g_object_unref (calendar);
556
test_event_escaping (void)
558
GDataCalendarEvent *event;
560
event = gdata_calendar_event_new (NULL);
561
gdata_calendar_event_set_status (event, "<status>");
562
gdata_calendar_event_set_visibility (event, "<visibility>");
563
gdata_calendar_event_set_transparency (event, "<transparency>");
564
gdata_calendar_event_set_uid (event, "<uid>");
565
gdata_calendar_event_set_recurrence (event, "<recurrence>");
567
/* Check the outputted XML is escaped properly */
568
gdata_test_assert_xml (event,
569
"<?xml version='1.0' encoding='UTF-8'?>"
570
"<entry xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
571
"xmlns:gCal='http://schemas.google.com/gCal/2005' xmlns:app='http://www.w3.org/2007/app'>"
572
"<title type='text'></title>"
573
"<category term='http://schemas.google.com/g/2005#event' scheme='http://schemas.google.com/g/2005#kind'/>"
574
"<gd:eventStatus value='<status>'/>"
575
"<gd:visibility value='<visibility>'/>"
576
"<gd:transparency value='<transparency>'/>"
577
"<gCal:uid value='<uid>'/>"
578
"<gCal:guestsCanModify value='false'/>"
579
"<gCal:guestsCanInviteOthers value='false'/>"
580
"<gCal:guestsCanSeeGuests value='false'/>"
581
"<gCal:anyoneCanAddSelf value='false'/>"
582
"<gd:recurrence><recurrence></gd:recurrence>"
584
g_object_unref (event);
448
588
test_query_uri (void)
587
726
g_assert_cmpstr (scope_value, ==, "darcy@gmail.com");
589
728
/* Check the XML */
590
xml = gdata_parsable_get_xml (GDATA_PARSABLE (rule));
591
g_assert_cmpstr (xml, ==,
729
gdata_test_assert_xml (rule,
592
730
"<?xml version='1.0' encoding='UTF-8'?>"
593
731
"<entry xmlns='http://www.w3.org/2005/Atom' "
594
732
"xmlns:gd='http://schemas.google.com/g/2005' "
769
906
gdata_entry_set_title (GDATA_ENTRY (event), "Fooish Bar");
771
908
gdata_test_batch_operation_insertion (operation, GDATA_ENTRY (event), &inserted_entry, NULL);
772
g_assert (gdata_batch_operation_run (operation, NULL, &error) == TRUE);
909
g_assert (gdata_test_batch_operation_run (operation, NULL, &error) == TRUE);
773
910
g_assert_no_error (error);
775
912
g_clear_error (&error);
787
924
g_assert_cmpuint (op_id, !=, op_id2);
789
g_assert (gdata_batch_operation_run (operation, NULL, &error) == TRUE);
926
g_assert (gdata_test_batch_operation_run (operation, NULL, &error) == TRUE);
790
927
g_assert_no_error (error);
792
929
g_clear_error (&error);
805
942
g_assert_cmpuint (op_id, !=, op_id3);
806
943
g_assert_cmpuint (op_id2, !=, op_id3);
808
g_assert (gdata_batch_operation_run (operation, NULL, &error) == TRUE);
945
g_assert (gdata_test_batch_operation_run (operation, NULL, &error) == TRUE);
809
946
g_assert_no_error (error);
811
948
g_assert_error (entry_error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_PROTOCOL_ERROR);
821
958
/* Turns out that we can't run this test, because the Calendar service sucks with ETags and doesn't error. */
822
959
/*operation = gdata_batchable_create_operation (GDATA_BATCHABLE (service), "https://www.google.com/calendar/feeds/default/private/full/batch");
823
960
gdata_test_batch_operation_update (operation, inserted_entry2, NULL, &entry_error);
824
g_assert (gdata_batch_operation_run (operation, NULL, &error) == TRUE);
961
g_assert (gdata_test_batch_operation_run (operation, NULL, &error) == TRUE);
825
962
g_assert_no_error (error);
827
964
g_assert_error (entry_error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_CONFLICT);
834
971
/* Run a final batch operation to delete the second entry */
835
972
operation = gdata_batchable_create_operation (GDATA_BATCHABLE (service), "https://www.google.com/calendar/feeds/default/private/full/batch");
836
973
gdata_test_batch_operation_deletion (operation, inserted_entry3, NULL);
837
g_assert (gdata_batch_operation_run (operation, NULL, &error) == TRUE);
974
g_assert (gdata_test_batch_operation_run (operation, NULL, &error) == TRUE);
838
975
g_assert_no_error (error);
840
977
g_clear_error (&error);
871
1008
GError *error = NULL;
873
g_assert (gdata_batch_operation_run_finish (operation, async_result, &error) == TRUE);
1010
/* Clear all pending events (such as callbacks for the operations) */
1011
while (g_main_context_iteration (NULL, FALSE) == TRUE);
1013
g_assert (gdata_test_batch_operation_run_finish (operation, async_result, &error) == TRUE);
874
1014
g_assert_no_error (error);
875
1015
g_clear_error (&error);
904
1044
GError *error = NULL;
906
g_assert (gdata_batch_operation_run_finish (operation, async_result, &error) == FALSE);
1046
/* Clear all pending events (such as callbacks for the operations) */
1047
while (g_main_context_iteration (NULL, FALSE) == TRUE);
1049
g_assert (gdata_test_batch_operation_run_finish (operation, async_result, &error) == FALSE);
907
1050
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
908
1051
g_clear_error (&error);
918
1061
GMainLoop *main_loop;
919
1062
GCancellable *cancellable;
1063
GError *error = NULL;
921
1065
/* Run an async query operation on the event */
922
1066
operation = gdata_batchable_create_operation (GDATA_BATCHABLE (service), "https://www.google.com/calendar/feeds/default/private/full/batch");
923
1067
op_id = gdata_test_batch_operation_query (operation, gdata_entry_get_id (GDATA_ENTRY (data->new_event)), GDATA_TYPE_CALENDAR_EVENT,
924
GDATA_ENTRY (data->new_event), NULL, NULL);
1068
GDATA_ENTRY (data->new_event), NULL, &error);
926
1070
main_loop = g_main_loop_new (NULL, TRUE);
927
1071
cancellable = g_cancellable_new ();
930
1074
g_cancellable_cancel (cancellable); /* this should cancel the operation before it even starts, as we haven't run the main loop yet */
932
1076
g_main_loop_run (main_loop);
1078
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED);
1079
g_clear_error (&error);
933
1081
g_main_loop_unref (main_loop);
934
1082
g_object_unref (cancellable);
935
1083
g_object_unref (operation);
968
1116
g_test_add_data_func ("/calendar/query/own_calendars", service, test_query_own_calendars);
969
1117
g_test_add_data_func ("/calendar/query/own_calendars_async", service, test_query_own_calendars_async);
970
1118
g_test_add_data_func ("/calendar/query/events", service, test_query_events);
1119
g_test_add_data_func ("/calendar/query/events_async", service, test_query_events_async);
972
1121
g_test_add_data_func ("/calendar/insert/simple", service, test_insert_simple);
1122
g_test_add_data_func ("/calendar/insert/simple/async", service, test_insert_simple_async);
974
1124
g_test_add_data_func ("/calendar/acls/get_rules", service, test_acls_get_rules);
975
1125
g_test_add_data_func ("/calendar/acls/insert_rule", service, test_acls_insert_rule);
985
1135
g_test_add_func ("/calendar/xml/dates", test_xml_dates);
986
1136
g_test_add_func ("/calendar/xml/recurrence", test_xml_recurrence);
1138
g_test_add_func ("/calendar/calendar/escaping", test_calendar_escaping);
1139
g_test_add_func ("/calendar/event/escaping", test_event_escaping);
988
1141
g_test_add_func ("/calendar/query/uri", test_query_uri);
989
1142
g_test_add_func ("/calendar/query/etag", test_query_etag);