~ubuntu-branches/ubuntu/saucy/evolution-data-server/saucy

« back to all changes in this revision

Viewing changes to tests/libecal/ecal-test-utils.c

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-10-08 12:58:16 UTC
  • mfrom: (181.1.7 quantal)
  • Revision ID: package-import@ubuntu.com-20121008125816-i3n76e8c0m64e7xp
Tags: 3.6.0-0ubuntu2
* Fix LP: #1038047 part 1 - Don't abort in e_source_registry_new* when a
  problem occurs connecting to the Dbus service
  - add debian/patches/dont-abort-in-e_source_registry_new.patch
  - update debian/patches/series
* Fix LP: #1038047 part 2 - libedataserver depends on
  evolution-data-server-common to ensure that the GSettings schemas are
  present
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
108
108
                test_print ("calendar server is busy; waiting...");
109
109
                return;
110
110
        } else if (error) {
111
 
                g_warning ("failed to asynchronously remove the calendar: "
112
 
                                "status %d (%s)", error->code, error->message);
 
111
                g_warning ("failed to asynchronously remove the calendar: "
 
112
                                "status %d (%s)", error->code, error->message);
113
113
                exit (1);
114
114
        }
115
115
 
116
116
        closure->cal = cal;
117
117
 
118
 
        test_print ("successfully asynchronously removed the temporary "
119
 
                        "calendar\n");
 
118
        test_print ("successfully asynchronously removed the temporary "
 
119
                        "calendar\n");
120
120
        if (closure->cb)
121
121
                (*closure->cb) (closure);
122
122
 
147
147
        gchar *address = NULL;
148
148
 
149
149
        if (!e_cal_get_alarm_email_address (cal, &address, &error)) {
150
 
                g_warning ("failed to get alarm email address; %s\n", error->message);
 
150
                g_warning ("failed to get alarm email address; %s\n", error->message);
151
151
                exit (1);
152
152
        }
153
 
        test_print ("successfully got the alarm email address\n");
 
153
        test_print ("successfully got the alarm email address\n");
154
154
 
155
155
        return address;
156
156
}
162
162
        gchar *address = NULL;
163
163
 
164
164
        if (!e_cal_get_cal_address (cal, &address, &error)) {
165
 
                g_warning ("failed to get calendar address; %s\n", error->message);
 
165
                g_warning ("failed to get calendar address; %s\n", error->message);
166
166
                exit (1);
167
167
        }
168
 
        test_print ("successfully got the calendar address\n");
 
168
        test_print ("successfully got the calendar address\n");
169
169
 
170
170
        return address;
171
171
}
177
177
        gchar *attr = NULL;
178
178
 
179
179
        if (!e_cal_get_ldap_attribute (cal, &attr, &error)) {
180
 
                g_warning ("failed to get ldap attribute; %s\n", error->message);
 
180
                g_warning ("failed to get ldap attribute; %s\n", error->message);
181
181
                exit (1);
182
182
        }
183
 
        test_print ("successfully got the ldap attribute\n");
 
183
        test_print ("successfully got the ldap attribute\n");
184
184
 
185
185
        return attr;
186
186
}
188
188
static const gchar *
189
189
b2s (gboolean value)
190
190
{
191
 
        return value ? "true" : "false";
 
191
        return value ? "true" : "false";
192
192
}
193
193
 
194
194
void
195
195
ecal_test_utils_cal_get_capabilities (ECal *cal)
196
196
{
197
 
        test_print ("calendar capabilities:\n");
198
 
        test_print ("        One alarm only:                  %s\n"
199
 
                 "        Organizers must attend meetings: %s\n"
200
 
                 "        Organizers must accept meetings: %s\n"
201
 
                 "        Master object for recurrences:   %s\n"
202
 
                 "        Can save schedules:              %s\n"
203
 
                 "        No alarm repeat:                 %s\n"
204
 
                 "        No audio alarms:                 %s\n"
205
 
                 "        No display alarms:               %s\n"
206
 
                 "        No email alarms:                 %s\n"
207
 
                 "        No procedure alarms:             %s\n"
208
 
                 "        No task assignment:              %s\n"
209
 
                 "        No 'this and future':            %s\n"
210
 
                 "        No 'this and prior':             %s\n"
211
 
                 "        No transparency:                 %s\n"
212
 
                 "        Organizer not email address:     %s\n"
213
 
                 "        Remove alarms:                   %s\n"
214
 
                 "        Create messages:                 %s\n"
215
 
                 "        No conv. to assigned task:       %s\n"
216
 
                 "        No conv. to recurring:           %s\n"
217
 
                 "        No general options:              %s\n"
218
 
                 "        Requires send options:           %s\n"
219
 
                 "        Delegate supported:              %s\n"
220
 
                 "        No organizer required:           %s\n"
221
 
                 "        Delegate to many:                %s\n"
222
 
                 "        Has unaccepted meeting:          %s\n"
 
197
        test_print ("calendar capabilities:\n");
 
198
        test_print ("        One alarm only:                  %s\n"
 
199
                 "        Organizers must attend meetings: %s\n"
 
200
                 "        Organizers must accept meetings: %s\n"
 
201
                 "        Master object for recurrences:   %s\n"
 
202
                 "        Can save schedules:              %s\n"
 
203
                 "        No alarm repeat:                 %s\n"
 
204
                 "        No audio alarms:                 %s\n"
 
205
                 "        No display alarms:               %s\n"
 
206
                 "        No email alarms:                 %s\n"
 
207
                 "        No procedure alarms:             %s\n"
 
208
                 "        No task assignment:              %s\n"
 
209
                 "        No 'this and future':            %s\n"
 
210
                 "        No 'this and prior':             %s\n"
 
211
                 "        No transparency:                 %s\n"
 
212
                 "        Organizer not email address:     %s\n"
 
213
                 "        Remove alarms:                   %s\n"
 
214
                 "        Create messages:                 %s\n"
 
215
                 "        No conv. to assigned task:       %s\n"
 
216
                 "        No conv. to recurring:           %s\n"
 
217
                 "        No general options:              %s\n"
 
218
                 "        Requires send options:           %s\n"
 
219
                 "        Delegate supported:              %s\n"
 
220
                 "        No organizer required:           %s\n"
 
221
                 "        Delegate to many:                %s\n"
 
222
                 "        Has unaccepted meeting:          %s\n"
223
223
                 ,
224
224
                 b2s (e_cal_get_one_alarm_only (cal)),
225
225
                 b2s (e_cal_get_organizer_must_attend (cal)),
287
287
        uid_a = icalcomponent_get_uid (a);
288
288
        uid_b = icalcomponent_get_uid (b);
289
289
        if (g_strcmp0 (uid_a, uid_b)) {
290
 
                g_error ("icomponents not equal:\n"
 
290
                g_error ("icomponents not equal:\n"
291
291
                         "        uid A: '%s'\n"
292
292
                         "        uid b: '%s'\n",
293
293
                         uid_a, uid_b);
323
323
        icalcomponent *component = NULL;
324
324
 
325
325
        if (!e_cal_get_object (cal, uid, NULL, &component, &error)) {
326
 
                g_warning ("failed to get icalcomponent object '%s'; %s\n", uid, error->message);
 
326
                g_warning ("failed to get icalcomponent object '%s'; %s\n", uid, error->message);
327
327
                exit (1);
328
328
        }
329
329
        if (!icalcomponent_is_valid (component)) {
330
 
                g_warning ("retrieved icalcomponent is invalid\n");
 
330
                g_warning ("retrieved icalcomponent is invalid\n");
331
331
                exit (1);
332
332
        }
333
 
        test_print ("successfully got the icalcomponent object '%s'\n", uid);
 
333
        test_print ("successfully got the icalcomponent object '%s'\n", uid);
334
334
 
335
335
        return component;
336
336
}
343
343
        GError *error = NULL;
344
344
 
345
345
        if (!icalcomponent_is_valid (component)) {
346
 
                g_warning (G_STRLOC ": icalcomponent argument is invalid\n");
 
346
                g_warning (G_STRLOC ": icalcomponent argument is invalid\n");
347
347
                exit (1);
348
348
        }
349
349
        if (!e_cal_modify_object (cal, component, mod_type, &error)) {
350
 
                g_warning ("failed to modify icalcomponent object; %s\n", error->message);
 
350
                g_warning ("failed to modify icalcomponent object; %s\n", error->message);
351
351
                exit (1);
352
352
        }
353
 
        test_print ("successfully modified the icalcomponent object\n");
 
353
        test_print ("successfully modified the icalcomponent object\n");
354
354
}
355
355
 
356
356
void
360
360
        GError *error = NULL;
361
361
 
362
362
        if (!e_cal_remove_object (cal, uid, &error)) {
363
 
                g_warning ("failed to remove icalcomponent object '%s'; %s\n", uid, error->message);
 
363
                g_warning ("failed to remove icalcomponent object '%s'; %s\n", uid, error->message);
364
364
                exit (1);
365
365
        }
366
 
        test_print ("successfully remoed the icalcomponent object '%s'\n", uid);
 
366
        test_print ("successfully remoed the icalcomponent object '%s'\n", uid);
367
367
}
368
368
 
369
369
icalcomponent *
373
373
        icalcomponent *component = NULL;
374
374
 
375
375
        if (!e_cal_get_default_object (cal, &component, &error)) {
376
 
                g_warning ("failed to get default icalcomponent object; %s\n", error->message);
 
376
                g_warning ("failed to get default icalcomponent object; %s\n", error->message);
377
377
                exit (1);
378
378
        }
379
379
        if (!icalcomponent_is_valid (component)) {
380
 
                g_warning ("default icalcomponent is invalid\n");
 
380
                g_warning ("default icalcomponent is invalid\n");
381
381
                exit (1);
382
382
        }
383
 
        test_print ("successfully got the default icalcomponent object\n");
 
383
        test_print ("successfully got the default icalcomponent object\n");
384
384
 
385
385
        return component;
386
386
}
393
393
        GList *objects = NULL;
394
394
 
395
395
        if (!e_cal_get_object_list (cal, query, &objects, &error)) {
396
 
                g_warning ("failed to get list of icalcomponent objects for query '%s'; %s\n", query, error->message);
 
396
                g_warning ("failed to get list of icalcomponent objects for query '%s'; %s\n", query, error->message);
397
397
                exit (1);
398
398
        }
399
 
        test_print ("successfully got list of icalcomponent objects for the query '%s'\n", query);
 
399
        test_print ("successfully got list of icalcomponent objects for the query '%s'\n", query);
400
400
 
401
401
        return objects;
402
402
}
409
409
        GList *objects = NULL;
410
410
 
411
411
        if (!e_cal_get_objects_for_uid (cal, uid, &objects, &error)) {
412
 
                g_warning ("failed to get icalcomponent objects for UID '%s'; %s\n", uid, error->message);
 
412
                g_warning ("failed to get icalcomponent objects for UID '%s'; %s\n", uid, error->message);
413
413
                exit (1);
414
414
        }
415
 
        test_print ("successfully got objects for the icalcomponent with UID '%s'\n", uid);
 
415
        test_print ("successfully got objects for the icalcomponent with UID '%s'\n", uid);
416
416
 
417
417
        return objects;
418
418
}
426
426
        gchar *ical_string = NULL;
427
427
 
428
428
        if (!icalcomponent_is_valid (component)) {
429
 
                g_warning ("supplied icalcomponent is invalid\n");
 
429
                g_warning ("supplied icalcomponent is invalid\n");
430
430
                exit (1);
431
431
        }
432
432
 
433
433
        if (!e_cal_create_object (cal, component, &uid, &error)) {
434
 
                g_warning ("failed to get create an icalcomponent object; %s\n", error->message);
 
434
                g_warning ("failed to get create an icalcomponent object; %s\n", error->message);
435
435
                exit (1);
436
436
        }
437
437
 
438
438
        ical_string = icalcomponent_as_ical_string (component);
439
 
        test_print ("successfully created icalcomponent object '%s'\n%s\n", uid,
 
439
        test_print ("successfully created icalcomponent object '%s'\n%s\n", uid,
440
440
                        ical_string);
441
441
        g_free (ical_string);
442
442
 
454
454
                test_print ("calendar server is busy; waiting...");
455
455
                return;
456
456
        } else if (status != E_CALENDAR_STATUS_OK) {
457
 
                g_warning ("failed to asynchronously remove the calendar: "
458
 
                                "status %d", status);
 
457
                g_warning ("failed to asynchronously remove the calendar: "
 
458
                                "status %d", status);
459
459
                exit (1);
460
460
        }
461
461
 
462
462
        closure->mode = mode;
463
463
 
464
 
        test_print ("successfully set the calendar mode to %d\n", mode);
 
464
        test_print ("successfully set the calendar mode to %d\n", mode);
465
465
        if (closure->cb)
466
466
                (*closure->cb) (closure);
467
467
 
533
533
                                                 icalcomponent *component)
534
534
{
535
535
        if (!e_cal_component_set_icalcomponent (e_component, component)) {
536
 
                g_error ("Could not set icalcomponent\n");
 
536
                g_error ("Could not set icalcomponent\n");
537
537
        }
538
538
}
539
539
 
545
545
        icaltimezone *zone = NULL;
546
546
 
547
547
        if (!e_cal_get_timezone (cal, tzid, &zone, &error)) {
548
 
                g_warning ("failed to get icaltimezone* for ID '%s'; %s\n", tzid, error->message);
 
548
                g_warning ("failed to get icaltimezone* for ID '%s'; %s\n", tzid, error->message);
549
549
                exit (1);
550
550
        }
551
 
        test_print ("successfully got icaltimezone* for ID '%s'\n", tzid);
 
551
        test_print ("successfully got icaltimezone* for ID '%s'\n", tzid);
552
552
 
553
553
        return zone;
554
554
}
563
563
        name = icaltimezone_get_display_name (zone);
564
564
 
565
565
        if (!e_cal_add_timezone (cal, zone, &error)) {
566
 
                g_warning ("failed to add icaltimezone '%s'; %s\n", name, error->message);
 
566
                g_warning ("failed to add icaltimezone '%s'; %s\n", name, error->message);
567
567
                exit (1);
568
568
        }
569
 
        test_print ("successfully added icaltimezone '%s'\n", name);
 
569
        test_print ("successfully added icaltimezone '%s'\n", name);
570
570
}
571
571
 
572
572
void
579
579
        name = icaltimezone_get_display_name (zone);
580
580
 
581
581
        if (!e_cal_set_default_timezone (cal, zone, &error)) {
582
 
                g_warning ("failed to set default icaltimezone '%s'; %s\n", name, error->message);
 
582
                g_warning ("failed to set default icaltimezone '%s'; %s\n", name, error->message);
583
583
                exit (1);
584
584
        }
585
 
        test_print ("successfully set default icaltimezone '%s'\n", name);
 
585
        test_print ("successfully set default icaltimezone '%s'\n", name);
586
586
}
587
587
 
588
588
GList *