Forgot to commit changes to message_tester

This commit is contained in:
Sylvain Berfini 2016-11-09 17:27:53 +01:00
parent 127d52d72d
commit 4cb2ddcfad

View file

@ -74,9 +74,17 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMess
* */
void file_transfer_received(LinphoneChatMessage *msg, const LinphoneContent* content, const LinphoneBuffer *buffer){
FILE* file=NULL;
char *receive_file = bc_tester_file("receive_file.dump");
char *receive_file = NULL;
LinphoneChatRoom *cr = linphone_chat_message_get_chat_room(msg);
LinphoneCore *lc = linphone_chat_room_get_core(cr);
if (linphone_chat_message_get_file_transfer_filepath(msg) != NULL) {
stats* counters = get_stats(lc);
counters->number_of_LinphoneFileTransferDownloadSuccessful++;
return;
}
receive_file = bc_tester_file("receive_file.dump");
if (!linphone_chat_message_get_user_data(msg)) {
/*first chunk, creating file*/
file = fopen(receive_file,"wb");
@ -196,7 +204,7 @@ void compare_files(const char *path1, const char *path2) {
buf2 = (uint8_t*)ms_load_path_content(path2, &size2);
BC_ASSERT_PTR_NOT_NULL(buf1);
BC_ASSERT_PTR_NOT_NULL(buf2);
BC_ASSERT_EQUAL((uint8_t)size1, (uint8_t)size2, uint8_t, "%u");
BC_ASSERT_EQUAL((uint8_t)size2, (uint8_t)size1, uint8_t, "%u");
BC_ASSERT_EQUAL(memcmp(buf1, buf2, size1), 0, int, "%d");
ms_free(buf1);
ms_free(buf2);
@ -234,6 +242,30 @@ LinphoneChatMessage* create_message_from_nowebcam(LinphoneChatRoom *chat_room) {
return msg;
}
LinphoneChatMessage* create_file_transfer_message_from_nowebcam(LinphoneChatRoom *chat_room) {
LinphoneChatMessageCbs *cbs;
LinphoneContent* content;
LinphoneChatMessage* msg;
char *send_filepath = bc_tester_res("images/nowebcamCIF.jpg");
content = linphone_core_create_content(chat_room->lc);
belle_sip_object_set_name(&content->base, "nowebcam content");
linphone_content_set_type(content,"image");
linphone_content_set_subtype(content,"jpeg");
linphone_content_set_name(content,"nowebcamCIF.jpg");
msg = linphone_chat_room_create_file_transfer_message(chat_room, content);
linphone_chat_message_set_file_transfer_filepath(msg, send_filepath);
cbs = linphone_chat_message_get_callbacks(msg);
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_content_unref(content);
ms_free(send_filepath);
return msg;
}
void text_message_base(LinphoneCoreManager* marie, LinphoneCoreManager* pauline) {
LinphoneChatMessage* msg = linphone_chat_room_create_message(linphone_core_get_chat_room(pauline->lc,marie->identity),"Bli bli bli \n blu");
LinphoneChatMessageCbs *cbs = linphone_chat_message_get_callbacks(msg);
@ -857,7 +889,7 @@ end:
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_stored_msg) {
void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_stored_msg, bool_t use_file_body_handler) {
FILE *ZIDCacheMarieFD, *ZIDCachePaulineFD;
LinphoneCoreManager *marie, *pauline;
LinphoneChatMessage *msg;
@ -906,7 +938,11 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st
linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php");
/* create a file transfer msg */
msg = create_message_from_nowebcam(linphone_core_get_chat_room(pauline->lc, marie->identity));
if (use_file_body_handler) {
msg = create_file_transfer_message_from_nowebcam(linphone_core_get_chat_room(pauline->lc, marie->identity));
} else {
msg = create_message_from_nowebcam(linphone_core_get_chat_room(pauline->lc, marie->identity));
}
linphone_chat_room_send_chat_message(msg->chat_room, msg);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1));
@ -932,6 +968,10 @@ void lime_transfer_message_base(bool_t encrypt_file,bool_t download_file_from_st
BC_ASSERT_PTR_NOT_NULL(linphone_content_get_key(content));
else
BC_ASSERT_PTR_NULL(linphone_content_get_key(content));
if (use_file_body_handler) {
linphone_chat_message_set_file_transfer_filepath(recv_msg, receive_filepath);
}
linphone_chat_message_download_file(recv_msg);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneFileTransferDownloadSuccessful,1));
compare_files(send_filepath, receive_filepath);
@ -948,15 +988,19 @@ end:
}
static void lime_transfer_message(void) {
lime_transfer_message_base(TRUE,FALSE);
lime_transfer_message_base(TRUE,FALSE,FALSE);
}
static void lime_transfer_message_2(void) {
lime_transfer_message_base(TRUE,FALSE,TRUE);
}
static void lime_transfer_message_from_history(void) {
lime_transfer_message_base(TRUE,TRUE);
lime_transfer_message_base(TRUE,TRUE,FALSE);
}
static void lime_transfer_message_without_encryption(void) {
lime_transfer_message_base(FALSE,FALSE);
lime_transfer_message_base(FALSE,FALSE,FALSE);
}
static void printHex(char *title, uint8_t *data, size_t length) {
@ -1856,6 +1900,7 @@ test_t message_tests[] = {
TEST_NO_TAG("Lime text message", lime_text_message),
TEST_NO_TAG("Lime text message to non lime", lime_text_message_to_non_lime),
TEST_NO_TAG("Lime transfer message", lime_transfer_message),
TEST_NO_TAG("Lime transfer message 2", lime_transfer_message_2),
TEST_NO_TAG("Lime transfer message from history", lime_transfer_message_from_history),
TEST_NO_TAG("Lime transfer message without encryption", lime_transfer_message_without_encryption),
TEST_NO_TAG("Lime unitary", lime_unit),