From 45ff93019055fbeaed853367c89efea96dedfc0e Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 17 Dec 2015 10:10:39 +0100 Subject: [PATCH] Improved import/export test --- tester/vcard_tester.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/tester/vcard_tester.c b/tester/vcard_tester.c index 992c03015..e7931c7c7 100644 --- a/tester/vcard_tester.c +++ b/tester/vcard_tester.c @@ -20,32 +20,40 @@ #include "private.h" #include "liblinphone_tester.h" -static void linphone_vcard_import_friends_test(void) { +static char *create_filepath(const char *dir, const char *filename, const char *ext) { + return ms_strdup_printf("%s/%s.%s", dir, filename, ext); +} + +static void linphone_vcard_import_export_friends_test(void) { LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE); + char *import_filepath = bc_tester_res("common/vcards.vcf"); + char *export_filepath = create_filepath(bc_tester_get_writable_dir_prefix(), "export_vcards", "vcf"); const MSList *friends = linphone_core_get_friend_list(manager->lc); int count = 0; BC_ASSERT_EQUAL(ms_list_size(friends), 0, int, "%d"); - count = linphone_core_import_friends_from_vcard4_file(manager->lc, bc_tester_res("common/vcards.vcf")); + count = linphone_core_import_friends_from_vcard4_file(manager->lc, import_filepath); BC_ASSERT_EQUAL(count, 3, int, "%d"); friends = linphone_core_get_friend_list(manager->lc); BC_ASSERT_EQUAL(ms_list_size(friends), 3, int, "%d"); + linphone_core_export_friends_as_vcard4_file(manager->lc, export_filepath); + + manager->lc->friends = ms_list_free(manager->lc->friends); + friends = linphone_core_get_friend_list(manager->lc); + BC_ASSERT_EQUAL(ms_list_size(friends), 0, int, "%d"); + + count = linphone_core_import_friends_from_vcard4_file(manager->lc, export_filepath); + BC_ASSERT_EQUAL(count, 3, int, "%d"); + friends = linphone_core_get_friend_list(manager->lc); + BC_ASSERT_EQUAL(ms_list_size(friends), 3, int, "%d"); + + remove(export_filepath); linphone_core_manager_destroy(manager); } -static void linphone_vcard_export_friends_test(void) { - -} - -static void linphone_vcard_create_edit_friends_test(void) { - -} - test_t vcard_tests[] = { - { "Import friends from vCards", linphone_vcard_import_friends_test }, - { "Export friends to vCards", linphone_vcard_export_friends_test }, - { "Create and edit friends' vCards", linphone_vcard_create_edit_friends_test }, + { "Import / Export friends from vCards", linphone_vcard_import_export_friends_test }, }; test_suite_t vcard_test_suite = {