2 * @file utest_contact.h
3 * @author Adenilson Cavalcanti da Silva <adenilson.silva@indt.org.br>
4 * @date Started on May 25 2008
6 * @brief Module for google contacts utests.
9 #include "utest_contact.h"
13 #include "gcal_parser.h"
18 static struct gcal_resource
*ptr_gcal
= NULL
;
20 static void setup(void)
22 /* here goes any common data allocation */
23 ptr_gcal
= gcal_construct(GCONTACT
);
26 static void teardown(void)
28 /* and here we clean up */
29 gcal_destroy(ptr_gcal
);
33 START_TEST (test_contact_dump
)
36 result
= gcal_get_authentication(ptr_gcal
, "gcal4tester", "66libgcal");
38 fail_if(1, "Authentication should work");
40 result
= gcal_dump(ptr_gcal
, "GData-Version: 3.0");
41 fail_if(result
!= 0, "Failed dumping contacts");
47 START_TEST (test_contact_authenticate
)
52 result
= gcal_get_authentication(ptr_gcal
, "gcal4tester", "66libgcal");
53 fail_if(result
!= 0, "Authentication should work");
55 result
= gcal_get_authentication(ptr_gcal
, "gcal4tester", "fail_fail");
56 fail_if(result
== 0, "Authentication must fail");
62 START_TEST (test_contact_entries
)
64 /* obs: this test is a copy of utest_gcal.c:test_gcal_event */
66 char *contacts_emails
[] = { "gcal4tester@gmail.com",
67 "gcalntester@gmail.com",
68 "cavalcantii@gmail.com" };
70 int contacts_count
= 3;
72 result
= gcal_get_authentication(ptr_gcal
, "gcal4tester", "66libgcal");
74 fail_if(1, "Authentication should work");
76 result
= gcal_dump(ptr_gcal
, "GData-Version: 3.0");
77 fail_if(result
!= 0, "Failed dumping contacts");
79 result
= gcal_entry_number(ptr_gcal
);
80 fail_if(result
!= 3, "Got wrong number of contacts");
82 for (i
= 0; i
< contacts_count
; ++i
)
83 if (!(ptr
= strstr(gcal_access_buffer(ptr_gcal
),
85 fail_if(1, "Can't find contact in atom stream. "
86 "Position = %i\n", i
);
93 START_TEST (test_contact_extract
)
97 struct gcal_contact
*contacts
;
98 char *contacts_email
[] = { "gcal4tester@gmail.com",
99 "gcalntester@gmail.com",
100 "cavalcantii@gmail.com" };
101 char *contacts_name
[] = { "", /* its valid not having a name */
103 "Adenilson Cavalcanti" };
104 char *temp
= (char *)malloc(255);
105 size_t contacts_count
= 3, found_count
= 0;
107 result
= gcal_get_authentication(ptr_gcal
, "gcal4tester", "66libgcal");
108 fail_if(result
== -1, "Authentication should work");
110 result
= gcal_dump(ptr_gcal
, "GData-Version: 3.0");
111 fail_if(result
!= 0, "Failed dumping contacts");
113 contacts
= gcal_get_all_contacts(ptr_gcal
, &count
);
114 fail_if(contacts
== NULL
, "Failed extracting the contacts vector!");
116 for (i
= 0; i
< contacts_count
; ++i
) {
117 for (j
= 0; j
< count
; ++j
) {
118 if(contacts
[i
].structured_name
)
119 temp
= gcal_contact_get_structured_entry(contacts
[i
].structured_name
,0,1,"fullName");
122 if ((!(strcmp(contacts
[i
].emails_field
[0],
123 contacts_email
[j
]))) &&
130 fail_if(found_count
!= contacts_count
, "Cannot find all 3 contacts!");
131 gcal_destroy_contacts(contacts
, count
);
136 START_TEST (test_contact_xml
)
138 int result
, length
, address_nr
, address_count
;
139 struct gcal_contact contact
;
140 char *xml
= NULL
, *ptr
;
142 // contact.common.title = "John Doe";
143 contact
.common
.title
= NULL
;
145 contact
.structured_name
=(struct gcal_structured_subvalues
*)malloc(sizeof(struct gcal_structured_subvalues
));
146 contact
.structured_name
->field_typenr
= 0;
147 contact
.structured_name
->field_key
= malloc(sizeof(char*));
148 contact
.structured_name
->field_key
= NULL
;
149 contact
.structured_name
->field_value
= malloc(sizeof(char*));
150 contact
.structured_name
->field_value
= NULL
;
151 contact
.structured_name_nr
= 1;
152 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"givenName","John");
153 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"additionalName","W.");
154 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"familyName","Doe");
155 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"namePrefix","Dr.");
156 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"fullName","Dr. John W. Doe");
158 contact
.emails_field
= malloc(sizeof(char*));
159 contact
.emails_field
[0] = "john.doe@foo.bar.com";
160 contact
.emails_nr
= 1;
161 /* TODO: set etag as NULL in all utests here */
162 contact
.common
.id
= contact
.common
.updated
= contact
.common
.edit_uri
= contact
.common
.etag
= NULL
;
163 contact
.photo
= contact
.photo_data
= NULL
;
165 contact
.nickname
= "The Fox";
166 contact
.content
= "A very interesting person";
167 contact
.org_name
= "Foo software";
168 contact
.org_title
= "Software engineer";
169 contact
.occupation
= "Programmer";
170 contact
.phone_numbers_field
= malloc(sizeof(char*));
171 contact
.phone_numbers_field
[0] = "+9977554422119900";
172 contact
.emails_type
= malloc(sizeof(char*));
173 contact
.emails_type
[0] = "Home";
174 contact
.phone_numbers_nr
= 1;
175 contact
.phone_numbers_type
= malloc(sizeof(char*));
176 contact
.phone_numbers_type
[0] = "Home";
177 contact
.groupMembership
= malloc(sizeof(char*));
178 contact
.groupMembership
[0] = "http://www.google.com/m8/feeds/groups/gcal4tester%40gmail.com/base/6";
179 contact
.groupMembership_nr
= 1;
180 contact
.birthday
= "1980-10-10";
181 contact
.im
= "john_skype";
182 contact
.homepage
= "www.homegage.com";
183 contact
.blog
= "myblog.homegage.com";
184 contact
.post_address
= NULL
;
185 contact
.structured_address
=(struct gcal_structured_subvalues
*)malloc(sizeof(struct gcal_structured_subvalues
));
186 contact
.structured_address
->field_typenr
= 0;
187 contact
.structured_address
->field_key
= malloc(sizeof(char*));
188 contact
.structured_address
->field_key
= NULL
;
189 contact
.structured_address
->field_value
= malloc(sizeof(char*));
190 contact
.structured_address
->field_value
= NULL
;
191 contact
.structured_address_nr
= 0;
192 contact
.structured_address_type
= (char**)malloc(sizeof(char*));
193 address_nr
= gcal_contact_set_structured_address_nr(&contact
,A_HOME
);
194 address_count
= contact
.structured_address_nr
;
195 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"street","Unknown Av St, n 69");
196 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"pobox","PO BOX 123 456");
197 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"city","Dirty Old Town");
198 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"region","Somewhere");
199 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"postcode","ABC 12345-D");
200 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"country","Madagascar");
201 address_nr
= gcal_contact_set_structured_address_nr(&contact
,A_WORK
);
202 address_count
= contact
.structured_address_nr
;
203 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"street","This One St, n 23");
204 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"pobox","PO BOX 333 444 5");
205 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"city","My Hometown");
206 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"region","Hereorthere");
207 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"postcode","XYZ 98765-C");
208 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"country","Island");
210 result
= xmlcontact_create(&contact
, &xml
, &length
);
211 fail_if(result
== -1 || xml
== NULL
,
212 "Failed creating XML for a new contact!");
214 ptr
= strstr(xml
, "Dr. John W. Doe");
215 fail_if(ptr
== NULL
, "XML lacks a field: gd:name/gd:fullName\n");
216 ptr
= strstr(xml
, contact
.emails_field
[0]);
217 fail_if(ptr
== NULL
, "XML lacks a field: %s\n", contact
.emails_field
[0]);
218 ptr
= strstr(xml
, contact
.content
);
219 fail_if(ptr
== NULL
, "XML lacks a field: %s\n", contact
.content
);
220 ptr
= strstr(xml
, contact
.org_name
);
221 fail_if(ptr
== NULL
, "XML lacks a field: %s\n", contact
.org_name
);
222 ptr
= strstr(xml
, contact
.org_title
);
223 fail_if(ptr
== NULL
, "XML lacks a field: %s\n", contact
.org_title
);
224 ptr
= strstr(xml
, contact
.phone_numbers_field
[0]);
225 fail_if(ptr
== NULL
, "XML lacks a field: %s\n", contact
.phone_numbers_field
[0]);
226 ptr
= strstr(xml
, "This One St, n 23");
227 fail_if(ptr
== NULL
, "XML lacks a field: street\n");
228 ptr
= strstr(xml
, "PO BOX 333 444 5");
229 fail_if(ptr
== NULL
, "XML lacks a field: pobox\n");
230 ptr
= strstr(xml
, "My Hometown");
231 fail_if(ptr
== NULL
, "XML lacks a field: city\n");
232 ptr
= strstr(xml
, "Hereorthere");
233 fail_if(ptr
== NULL
, "XML lacks a field: region\n");
234 ptr
= strstr(xml
, "XYZ 98765-C");
235 fail_if(ptr
== NULL
, "XML lacks a field: postcode\n");
236 ptr
= strstr(xml
, "Island");
237 fail_if(ptr
== NULL
, "XML lacks a field: country\n");
238 ptr
= strstr(xml
, contact
.birthday
);
239 fail_if(ptr
== NULL
, "XML lacks a field: %s\n", contact
.birthday
);
240 /* TODO: im requires a new field for service type (i.e. AIM, yahoo,
243 // ptr = strstr(xml, contact.im);
244 // fail_if(ptr == NULL, "XML lacks a field: %s\n", contact.im);
251 START_TEST (test_contact_add
)
253 int result
, address_nr
, address_count
;
254 struct gcal_contact contact
;
256 // contact.common.title = "John Doe";
257 contact
.common
.title
= NULL
;
259 contact
.structured_name
=(struct gcal_structured_subvalues
*)malloc(sizeof(struct gcal_structured_subvalues
));
260 contact
.structured_name
->field_typenr
= 0;
261 contact
.structured_name
->field_key
= malloc(sizeof(char*));
262 contact
.structured_name
->field_key
= NULL
;
263 contact
.structured_name
->field_value
= malloc(sizeof(char*));
264 contact
.structured_name
->field_value
= NULL
;
265 contact
.structured_name_nr
= 1;
266 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"givenName","John");
267 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"additionalName","W.");
268 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"familyName","Doe");
269 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"namePrefix","Dr.");
270 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"nameSuffix","IV.");
272 contact
.emails_field
= malloc(sizeof(char*));
273 contact
.emails_field
[0] = "john.doe@foo.bar.com";
274 contact
.emails_type
= malloc(sizeof(char*));
275 contact
.emails_type
[0] = "home";
276 contact
.emails_nr
= 1;
277 contact
.pref_email
= 0;
278 contact
.common
.id
= contact
.common
.updated
= contact
.common
.edit_uri
= contact
.common
.etag
= NULL
;
279 contact
.photo
= contact
.photo_data
= NULL
;
281 contact
.nickname
= "The Fox";
282 contact
.content
= "A very interesting person";
283 contact
.org_name
= "Foo software";
284 contact
.org_title
= "Software engineer";
285 contact
.occupation
= "Programmer";
287 contact
.phone_numbers_field
= malloc(sizeof(char*));
288 contact
.phone_numbers_field
[0] = "+9977554422119900";
289 contact
.phone_numbers_type
= malloc(sizeof(char*));
290 contact
.phone_numbers_type
[0] = "home";
291 contact
.phone_numbers_nr
= 1;
292 contact
.groupMembership
= malloc(sizeof(char*));
293 contact
.groupMembership
[0] = "http://www.google.com/m8/feeds/groups/gcalntester%40gmail.com/base/6";
294 contact
.groupMembership_nr
= 1;
295 contact
.birthday
= "1980-10-10";
296 contact
.homepage
= "www.homegage.com";
297 contact
.blog
= "myblog.homegage.com";
298 contact
.structured_address
=(struct gcal_structured_subvalues
*)malloc(sizeof(struct gcal_structured_subvalues
));
299 contact
.structured_address
->field_typenr
= 0;
300 contact
.structured_address
->field_key
= malloc(sizeof(char*));
301 contact
.structured_address
->field_key
= NULL
;
302 contact
.structured_address
->field_value
= malloc(sizeof(char*));
303 contact
.structured_address
->field_value
= NULL
;
304 contact
.structured_address_nr
= 0;
305 contact
.structured_address_type
= (char**)malloc(sizeof(char*));
306 address_nr
= gcal_contact_set_structured_address_nr(&contact
,A_HOME
);
307 address_count
= contact
.structured_address_nr
;
308 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"street","Unknown Av St, n 69");
309 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"pobox","PO BOX 123 456");
310 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"city","Dirty Old Town");
311 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"region","Somewhere");
312 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"postcode","ABC 12345-D");
313 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"country","Madagascar");
314 address_nr
= gcal_contact_set_structured_address_nr(&contact
,A_WORK
);
315 address_count
= contact
.structured_address_nr
;
316 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"street","This One St, n 23");
317 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"pobox","PO BOX 333 444 5");
318 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"city","My Hometown");
319 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"region","Hereorthere");
320 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"postcode","XYZ 98765-C");
321 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"country","Island");
323 result
= gcal_get_authentication(ptr_gcal
, "gcalntester", "77libgcal");
324 fail_if(result
== -1, "Authentication should work.");
326 result
= gcal_create_contact(ptr_gcal
, &contact
, NULL
);
327 fail_if(result
== -1, "Failed creating a new contact!");
329 /* I commented this test because it prints too much error
330 * information to stderr. I must add a logging of some sort
333 /* Trying to insert another contact with same email
334 * should trigger HTTP 409 Conflict code.
336 /* result = gcal_create_contact(&contact, ptr_gcal); */
337 /* fail_if(result != -1, "Adding the same contact must conflict!"); */
343 START_TEST (test_contact_delete
)
345 /* This test assumes that 'test_contact_add' worked fine:
346 * I'm going to delete that contact.
348 char *test_title
= "Dr. John W. Doe IV.", *temp
= (char *)malloc(255);;
349 char *test_email
= "john.doe@foo.bar.com";
350 struct gcal_contact
*contacts
;
351 int i
, result
, entry_index
= -1;
354 result
= gcal_get_authentication(ptr_gcal
, "gcalntester", "77libgcal");
355 fail_if(result
== -1, "Authentication should work.");
357 result
= gcal_dump(ptr_gcal
, "GData-Version: 3.0");
358 fail_if(result
!= 0, "Failed dumping contacts");
360 contacts
= gcal_get_all_contacts(ptr_gcal
, &count
);
361 fail_if(contacts
== NULL
, "Failed extracting contacts vector!");
363 for (i
= 0; i
< (int)count
; ++i
) {
364 if (contacts
[i
].structured_name
)
365 temp
= gcal_contact_get_structured_entry(contacts
[i
].structured_name
,0,1,"fullName");
369 if (contacts
[i
].emails_field
&& temp
) {
370 if ((!(strcmp(contacts
[i
].emails_field
[0], test_email
))) &&
371 (!(strcmp(temp
, test_title
)))) {
378 temp
= (char *)malloc(255);
379 sprintf(temp
, "Cannot locate the newly added contact!\nindex = %d\tname = %s\n", entry_index
,
380 contacts
[entry_index
].common
.title
);
381 fail_if(entry_index
== -1, temp
);
384 result
= gcal_delete_contact(ptr_gcal
, (contacts
+ entry_index
));
385 fail_if(result
== -1, "Failed deleting contact!");
387 gcal_destroy_contacts(contacts
, count
);
391 START_TEST (test_contact_edit
)
393 int result
, address_nr
, address_count
;
394 struct gcal_contact contact
, contact_new
, updated
;
396 // contact.common.title = "Johny Doe";
397 contact
.common
.title
= NULL
;
399 contact
.structured_name
=(struct gcal_structured_subvalues
*)malloc(sizeof(struct gcal_structured_subvalues
));
400 contact
.structured_name
->field_typenr
= 0;
401 contact
.structured_name
->field_key
= malloc(sizeof(char*));
402 contact
.structured_name
->field_key
= NULL
;
403 contact
.structured_name
->field_value
= malloc(sizeof(char*));
404 contact
.structured_name
->field_value
= NULL
;
405 contact
.structured_name_nr
= 1;
406 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"givenName","John");
407 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"additionalName","W.");
408 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"familyName","Doe");
409 gcal_contact_set_structured_entry(contact
.structured_name
,0,1,"namePrefix","Dr.");
411 contact
.photo
= contact
.photo_data
= NULL
;
412 contact
.photo_length
= 0;
413 contact
.emails_field
= malloc(sizeof(char*));
414 contact
.emails_field
[0] = "johny.doe@foo.bar.com";
415 contact
.emails_nr
= 1;
416 contact
.pref_email
= 0;
417 contact
.emails_type
= malloc(sizeof(char*));
418 contact
.emails_type
[0] = "home";
419 contact
.common
.id
= contact
.common
.updated
= contact
.common
.edit_uri
= contact
.common
.etag
= NULL
;
421 contact
.nickname
= "The Fox";
422 contact
.content
= "A very interesting person";
423 contact
.org_name
= "Foo software";
424 contact
.org_title
= "Software engineer";
425 contact
.occupation
= "Programmer";
426 contact
.im
= "johny";
427 contact
.phone_numbers_field
= malloc(sizeof(char*));
428 contact
.phone_numbers_field
[0] = "+9977554422119900";
429 contact
.phone_numbers_type
= malloc(sizeof(char*));
430 contact
.phone_numbers_type
[0] = "home";
431 contact
.phone_numbers_nr
= 1;
432 contact
.groupMembership
= malloc(sizeof(char*));
433 contact
.groupMembership
[0] = "http://www.google.com/m8/feeds/groups/gcalntester%40gmail.com/base/6";
434 contact
.groupMembership_nr
= 1;
435 contact
.birthday
= "1980-10-10";
436 contact
.homepage
= "www.homegage.com";
437 contact
.blog
= "myblog.homegage.com";
438 contact
.structured_address
=(struct gcal_structured_subvalues
*)malloc(sizeof(struct gcal_structured_subvalues
));
439 contact
.structured_address
->field_typenr
= 0;
440 contact
.structured_address
->field_key
= malloc(sizeof(char*));
441 contact
.structured_address
->field_key
= NULL
;
442 contact
.structured_address
->field_value
= malloc(sizeof(char*));
443 contact
.structured_address
->field_value
= NULL
;
444 contact
.structured_address_nr
= 0;
445 contact
.structured_address_type
= (char**)malloc(sizeof(char*));
446 address_nr
= gcal_contact_set_structured_address_nr(&contact
,A_HOME
);
447 address_count
= contact
.structured_address_nr
;
448 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"street","Unknown Av St, n 69");
449 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"pobox","PO BOX 123 456");
450 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"city","Dirty Old Town");
451 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"region","Somewhere");
452 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"postcode","ABC 12345-D");
453 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"country","Madagascar");
454 address_nr
= gcal_contact_set_structured_address_nr(&contact
,A_WORK
);
455 address_count
= contact
.structured_address_nr
;
456 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"street","This One St, n 23");
457 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"pobox","PO BOX 333 444 5");
458 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"city","My Hometown");
459 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"region","Hereorthere");
460 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"postcode","XYZ 98765-C");
461 gcal_contact_set_structured_entry(contact
.structured_address
,address_nr
,address_count
,"country","Island");
463 /* Authenticate and add a new contact */
464 result
= gcal_get_authentication(ptr_gcal
, "gcalntester", "77libgcal");
465 fail_if(result
== -1, "Authentication should work.");
466 result
= gcal_create_contact(ptr_gcal
, &contact
, &contact_new
);
469 // if(contact_new.common.title)
470 // free(contact_new.common.title);
471 // contact_new.common.title = strdup("Johny 'the mad' Doe");
472 contact_new
.structured_name
=(struct gcal_structured_subvalues
*)malloc(sizeof(struct gcal_structured_subvalues
));
473 contact_new
.structured_name
->field_typenr
= 0;
474 contact_new
.structured_name
->field_key
= malloc(sizeof(char*));
475 contact_new
.structured_name
->field_key
= NULL
;
476 contact_new
.structured_name
->field_value
= malloc(sizeof(char*));
477 contact_new
.structured_name
->field_value
= NULL
;
478 contact_new
.structured_name_nr
= 1;
479 gcal_contact_set_structured_entry(contact_new
.structured_name
,0,1,"givenName","Johny");
480 gcal_contact_set_structured_entry(contact_new
.structured_name
,0,1,"additionalName","'the mad'");
481 gcal_contact_set_structured_entry(contact_new
.structured_name
,0,1,"familyName","Doe");
483 result
= gcal_edit_contact(ptr_gcal
, &contact_new
, &updated
);
484 fail_if(result
== -1, "Failed editing contact!");
486 gcal_structured_subvalues_t structured_entry
;
488 structured_entry
= gcal_contact_get_structured_address(&contact
);
489 gcal_contact_delete_structured_entry(structured_entry
,gcal_contact_get_structured_address_count_obj(&contact
),gcal_contact_get_structured_address_type_obj(&contact
));
491 structured_entry
= gcal_contact_get_structured_name(&contact
);
492 gcal_contact_delete_structured_entry(structured_entry
,NULL
,NULL
);
494 /* Delete the contact: pay attention that each edit changes
495 * the "edit_url" field!
497 result
= gcal_delete_contact(ptr_gcal
, &updated
);
498 fail_if(result
== -1, "Failed deleting contact!");
500 /* Do memory clean up */
501 gcal_destroy_contact(&contact_new
);
502 gcal_destroy_contact(&updated
);
507 TCase
*gcontact_tcase_create(void)
510 int timeout_seconds
= 50;
511 tc
= tcase_create("gcontact");
512 tcase_add_checked_fixture(tc
, setup
, teardown
);
513 tcase_set_timeout (tc
, timeout_seconds
);
514 tcase_add_test(tc
, test_contact_authenticate
);
515 tcase_add_test(tc
, test_contact_dump
);
516 tcase_add_test(tc
, test_contact_entries
);
517 tcase_add_test(tc
, test_contact_extract
);
518 tcase_add_test(tc
, test_contact_xml
);
519 tcase_add_test(tc
, test_contact_add
);
520 tcase_add_test(tc
, test_contact_delete
);
521 tcase_add_test(tc
, test_contact_edit
);