From 18d0c4ad209986afeba500e8013c11782b1bf32c Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 7 Mar 2018 17:16:20 +0100 Subject: [PATCH] improve message tester for file transfer --- .../file-transfer-chat-message-modifier.cpp | 4 +-- tester/message_tester.c | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/chat/modifier/file-transfer-chat-message-modifier.cpp b/src/chat/modifier/file-transfer-chat-message-modifier.cpp index f0293d67a..44b1a3090 100644 --- a/src/chat/modifier/file-transfer-chat-message-modifier.cpp +++ b/src/chat/modifier/file-transfer-chat-message-modifier.cpp @@ -361,8 +361,8 @@ void FileTransferChatMessageModifier::processResponseFromPostFile (const belle_h fileTransferContent->setContentType(ContentType::FileTransfer); fileTransferContent->setFileContent(fileContent); - message->removeContent(*fileContent); - message->addContent(*fileTransferContent); + message->getPrivate()->removeContent(*fileContent); + message->getPrivate()->addContent(*fileTransferContent); message->getPrivate()->setState(ChatMessage::State::FileTransferDone); releaseHttpRequest(); diff --git a/tester/message_tester.c b/tester/message_tester.c index df54f9160..0d639eac0 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -533,6 +533,7 @@ void transfer_message_base2(LinphoneCoreManager* marie, LinphoneCoreManager* pau /* wait for a long time in case the DNS SRV resolution takes times - it should be immediate though */ if (BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1,55000))) { compare_files(send_filepath, receive_filepath); + } } } @@ -1587,6 +1588,8 @@ void crash_during_file_transfer(void) { /* Create a new core and check that the message stored in the saved database is in the not delivered state */ linphone_core_manager_restart(pauline, TRUE); + linphone_core_set_file_transfer_server(pauline->lc, "https://www.linphone.org:444/lft.php"); + //BC_ASSERT_TRUE(wait_for(pauline->lc, pauline->lc, &pauline->stat.number_of_LinphoneRegistrationOk, 1)); chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity); @@ -1596,9 +1599,36 @@ void crash_during_file_transfer(void) { msg_list = linphone_chat_room_get_history(chat_room, 0); LinphoneChatMessage *sent_msg = (LinphoneChatMessage *)bctbx_list_get_data(msg_list); BC_ASSERT_EQUAL((int)linphone_chat_message_get_state(sent_msg), (int)LinphoneChatMessageStateNotDelivered, int, "%d"); + //resend + LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(sent_msg); + linphone_chat_message_cbs_set_file_transfer_send(cbs, tester_file_transfer_send); + linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed); + linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication); + linphone_chat_message_send(sent_msg); + if (BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1, 60000))) { + linphone_core_manager_stop(marie); + /* Create a new core and check that the message stored in the saved database is in the not delivered state */ + linphone_core_manager_restart(marie, TRUE); + LinphoneChatRoom *marie_room = linphone_core_get_chat_room(marie->lc, pauline->identity); + bctbx_list_t *msg_list_2 = linphone_chat_room_get_history(marie_room,1); + BC_ASSERT_PTR_NOT_NULL(msg_list_2); + LinphoneChatMessage *recv_msg = (LinphoneChatMessage *)msg_list_2->data; + LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(recv_msg); + linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed); + linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received); + linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication); + linphone_chat_message_download_file(recv_msg); + /* wait for a long time in case the DNS SRV resolution takes times - it should be immediate though */ + if (BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1,55000))) { + BC_ASSERT_PTR_NULL(linphone_chat_message_get_external_body_url(recv_msg)); + } + bctbx_list_free_with_data(msg_list_2, (bctbx_list_free_func)linphone_chat_message_unref); + } } + bctbx_list_free_with_data(msg_list, (bctbx_list_free_func)linphone_chat_message_unref); + linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie);