mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-19 20:18:09 +00:00
Added test for import vcards from buffer
This commit is contained in:
parent
d458258237
commit
2f9f545163
2 changed files with 30 additions and 2 deletions
|
|
@ -8476,7 +8476,6 @@ BDAY:19840316
|
|||
EMAIL:kesha.tuggle@essefeugait.org
|
||||
N:Tuggle;Kesha;;;
|
||||
ORG:South Studio Vision
|
||||
IMPP:sip:kesha@sip.linphone.org
|
||||
FN:Kesha Tuggle
|
||||
TEL:tel:(865)414-7674
|
||||
END:VCARD
|
||||
|
|
@ -8539,4 +8538,5 @@ N:Kimbrough;Deidra;;;
|
|||
FN:Deidra Kimbrough
|
||||
ORG:Pacific Bell
|
||||
TEL:tel:(413)543-7430
|
||||
IMPP:sip:kimbrough@sip.linphone.org
|
||||
END:VCARD
|
||||
|
|
|
|||
|
|
@ -64,6 +64,9 @@ static void linphone_vcard_import_a_lot_of_friends_test(void) {
|
|||
clock_t start, end;
|
||||
double elapsed = 0;
|
||||
const MSList *friends = NULL;
|
||||
FILE *infile;
|
||||
char *buffer;
|
||||
long numbytes;
|
||||
|
||||
start = clock();
|
||||
linphone_friend_list_import_friends_from_vcard4_file(lfl, import_filepath);
|
||||
|
|
@ -73,11 +76,36 @@ static void linphone_vcard_import_a_lot_of_friends_test(void) {
|
|||
BC_ASSERT_EQUAL(ms_list_size(friends), 482, int, "%i"); // Thousand vcards contains 482 contacts with a SIP URI
|
||||
|
||||
elapsed = (double)(end - start);
|
||||
ms_error("Imported a thousand of vCards (only %i friends with SIP address found) in %f seconds", ms_list_size(friends), elapsed / CLOCKS_PER_SEC);
|
||||
ms_error("Imported a thousand of vCards from file (only %i friends with SIP address found) in %f seconds", ms_list_size(friends), elapsed / CLOCKS_PER_SEC);
|
||||
#ifndef ANDROID
|
||||
BC_ASSERT_TRUE(elapsed < 1500000); // 1.5 seconds
|
||||
#endif
|
||||
|
||||
lfl = linphone_core_create_friend_list(manager->lc);
|
||||
infile = fopen(import_filepath, "r");
|
||||
fseek(infile, 0L, SEEK_END);
|
||||
numbytes = ftell(infile);
|
||||
fseek(infile, 0L, SEEK_SET);
|
||||
buffer = (char*)ms_malloc(numbytes * sizeof(char));
|
||||
numbytes = fread(buffer, sizeof(char), numbytes, infile);
|
||||
fclose(infile);
|
||||
|
||||
start = clock();
|
||||
linphone_friend_list_import_friends_from_vcard4_buffer(lfl, buffer);
|
||||
end = clock();
|
||||
|
||||
friends = linphone_friend_list_get_friends(lfl);
|
||||
BC_ASSERT_EQUAL(ms_list_size(friends), 482, int, "%i"); // Thousand vcards contains 482 contacts with a SIP URI
|
||||
|
||||
elapsed = (double)(end - start);
|
||||
ms_error("Imported a thousand of vCards from buffer (only %i friends with SIP address found) in %f seconds", ms_list_size(friends), elapsed / CLOCKS_PER_SEC);
|
||||
#ifndef ANDROID
|
||||
BC_ASSERT_TRUE(elapsed < 1500000); // 1.5 seconds
|
||||
#endif
|
||||
|
||||
ms_free(buffer);
|
||||
linphone_friend_list_unref(lfl);
|
||||
|
||||
ms_free(import_filepath);
|
||||
linphone_core_manager_destroy(manager);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue