Commit 45ff9301 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Improved import/export test

parent 8c823fc0
......@@ -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_manager_destroy(manager);
}
static void linphone_vcard_export_friends_test(void) {
linphone_core_export_friends_as_vcard4_file(manager->lc, export_filepath);
}
static void linphone_vcard_create_edit_friends_test(void) {
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);
}
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 = {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment