mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-28 08:39:20 +00:00
File transfer : add test for I/O error
This commit is contained in:
parent
17c77cbf5d
commit
58530de9bb
3 changed files with 54 additions and 1 deletions
|
|
@ -49,7 +49,8 @@ static size_t linphone_chat_message_compute_multipart_header_size(const char *fi
|
|||
return strlen(MULTIPART_HEADER_1)+strlen(filename)+strlen(MULTIPART_HEADER_2)+strlen(content_type)+strlen(MULTIPART_HEADER_3);
|
||||
}
|
||||
static void process_io_error(void *data, const belle_sip_io_error_event_t *event){
|
||||
printf("We have a response io error!\n");
|
||||
LinphoneChatMessage* msg=(LinphoneChatMessage *)data;
|
||||
msg->cb(msg, LinphoneChatMessageStateNotDelivered, msg->chat_room->lc);
|
||||
}
|
||||
static void process_auth_requested(void *data, belle_sip_auth_event_t *event){
|
||||
printf("We have a auth requested!\n");
|
||||
|
|
|
|||
|
|
@ -131,6 +131,7 @@ typedef struct _stats {
|
|||
int number_of_LinphoneMessageNotDelivered;
|
||||
int number_of_LinphoneIsComposingActiveReceived;
|
||||
int number_of_LinphoneIsComposingIdleReceived;
|
||||
int progress_of_LinphoneFileTransfer;
|
||||
|
||||
int number_of_IframeDecoded;
|
||||
|
||||
|
|
|
|||
|
|
@ -127,6 +127,8 @@ void file_transfer_progress_indication(LinphoneCore *lc, LinphoneChatMessage *me
|
|||
, content->subtype
|
||||
,(linphone_chat_message_is_outgoing(message)?"to":"from")
|
||||
, address);
|
||||
stats* counters = get_stats(lc);
|
||||
counters->progress_of_LinphoneFileTransfer = progress;
|
||||
free(address);
|
||||
}
|
||||
|
||||
|
|
@ -380,6 +382,54 @@ static void file_transfer_message(void) {
|
|||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
static void file_transfer_message_io_error(void) {
|
||||
int i;
|
||||
char* to;
|
||||
LinphoneChatRoom* chat_room;
|
||||
LinphoneChatMessage* message;
|
||||
LinphoneContent content;
|
||||
const char* big_file_content="big file"; /* setting dummy file content to something */
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
|
||||
|
||||
/* setting dummy file content to something */
|
||||
for (i=0;i<sizeof(big_file);i+=strlen(big_file_content))
|
||||
memcpy(big_file+i, big_file_content, strlen(big_file_content));
|
||||
|
||||
big_file[0]=*"S";
|
||||
big_file[sizeof(big_file)-1]=*"E";
|
||||
|
||||
/* Globally configure an http file transfer server. */
|
||||
linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php");
|
||||
|
||||
/* create a chatroom on pauline's side */
|
||||
to = linphone_address_as_string(marie->identity);
|
||||
chat_room = linphone_core_create_chat_room(pauline->lc,to);
|
||||
|
||||
/* create a file transfer message */
|
||||
memset(&content,0,sizeof(content));
|
||||
content.type="text";
|
||||
content.subtype="plain";
|
||||
content.size=sizeof(big_file); /*total size to be transfered*/
|
||||
content.name = "bigfile.txt";
|
||||
message = linphone_chat_room_create_file_transfer_message(chat_room, &content);
|
||||
|
||||
linphone_chat_room_send_message2(chat_room,message,liblinphone_tester_chat_message_state_change,pauline->lc);
|
||||
|
||||
/*wait for file to be 25% uploaded and simultate a network error*/
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.progress_of_LinphoneFileTransfer,25));
|
||||
sal_set_send_error(pauline->lc->sal, -1);
|
||||
|
||||
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageNotDelivered,1));
|
||||
|
||||
CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageNotDelivered,1);
|
||||
CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageExtBodyReceived,0);
|
||||
|
||||
sal_set_send_error(pauline->lc->sal, 0);
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
static void text_message_with_send_error(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
|
||||
|
|
@ -607,6 +657,7 @@ test_t message_tests[] = {
|
|||
{ "Text message with send error", text_message_with_send_error },
|
||||
{ "Text message with external body", text_message_with_external_body },
|
||||
{ "File transfer message", file_transfer_message },
|
||||
{ "File transfer message with io error", file_transfer_message_io_error },
|
||||
{ "Text message denied", text_message_denied },
|
||||
{ "Info message", info_message },
|
||||
{ "Info message with body", info_message_with_body },
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue