From a21d7d863df199dd385120426a13dc336835bb0e Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 1 Jul 2014 22:00:41 +0200 Subject: [PATCH] improve message tester --- tester/liblinphone_tester.h | 2 ++ tester/message_tester.c | 30 ++++++++++++++----- tester/rcfiles/marie_remote_default_values_rc | 3 ++ tester/remote_provisioning_tester.c | 11 +++++-- 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 239e30e0b..8fbeafc31 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -124,6 +124,7 @@ typedef struct _stats { int number_of_LinphoneTransferCallError; int number_of_LinphoneMessageReceived; + int number_of_LinphoneMessageReceivedWithFile; int number_of_LinphoneMessageReceivedLegacy; int number_of_LinphoneMessageExtBodyReceived; int number_of_LinphoneMessageInProgress; @@ -191,6 +192,7 @@ typedef struct _stats { int number_of_LinphoneCallEncryptedOn; int number_of_LinphoneCallEncryptedOff; + LinphoneChatMessage* last_received_chat_message; }stats; typedef struct _LinphoneCoreManager { diff --git a/tester/message_tester.c b/tester/message_tester.c index 85b5f2e00..daafac426 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -40,20 +40,22 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMess stats* counters; const char *text=linphone_chat_message_get_text(message); const char *external_body_url=linphone_chat_message_get_external_body_url(message); - const LinphoneContent *file_transfer_info=linphone_chat_message_get_file_transfer_information(message); - ms_message("Message from [%s] is [%s] , external URL [%s]",from?from:"" ,text?text:"" ,external_body_url?external_body_url:""); ms_free(from); counters = get_stats(lc); counters->number_of_LinphoneMessageReceived++; - if (file_transfer_info) { /* if we have a file transfer in RCS mode, start the download */ - linphone_chat_message_start_file_download(message); - } else if (linphone_chat_message_get_external_body_url(message)) { + if (linphone_chat_message_get_file_transfer_information(message)) + counters->number_of_LinphoneMessageReceivedWithFile++; + if (counters->last_received_chat_message) linphone_chat_message_unref(counters->last_received_chat_message); + linphone_chat_message_ref(counters->last_received_chat_message=message); + if (linphone_chat_message_get_external_body_url(message)) { counters->number_of_LinphoneMessageExtBodyReceived++; - if (message_external_body_url) + if (message_external_body_url) { CU_ASSERT_STRING_EQUAL(linphone_chat_message_get_external_body_url(message),message_external_body_url); + message_external_body_url=NULL; + } } } @@ -349,6 +351,8 @@ static void file_transfer_message(void) { 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"); + reset_counters(&marie->stat); + reset_counters(&pauline->stat); for (i=0;iidentity); chat_room = linphone_core_create_chat_room(pauline->lc,to); - + ms_free(to); /* create a file transfer message */ memset(&content,0,sizeof(content)); content.type="text"; @@ -372,7 +376,10 @@ static void file_transfer_message(void) { 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); - CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageExtBodyReceived,1)); + CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedWithFile,1)); + if (marie->stat.last_received_info_message ) { + linphone_chat_message_start_file_download((const LinphoneChatMessage*)marie->stat.last_received_info_message); + } CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneMessageDelivered,1)); CU_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress,1); @@ -391,6 +398,8 @@ static void file_transfer_message_io_error(void) { 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"); + reset_counters(&marie->stat); + reset_counters(&pauline->stat); /* setting dummy file content to something */ for (i=0;iidentity); LinphoneChatRoom* chat_room = linphone_core_create_chat_room(marie->lc,to); LinphoneChatMessage* message = linphone_chat_room_create_message(chat_room,"Bli bli bli \n blu"); + reset_counters(&marie->stat); + reset_counters(&pauline->stat); + /*simultate a network error*/ sal_set_send_error(marie->lc->sal, -1); linphone_chat_room_send_message2(chat_room,message,liblinphone_tester_chat_message_state_change,marie->lc); @@ -463,6 +475,8 @@ static void text_message_denied(void) { char* to = linphone_address_as_string(pauline->identity); LinphoneChatRoom* chat_room = linphone_core_create_chat_room(marie->lc,to); LinphoneChatMessage* message = linphone_chat_room_create_message(chat_room,"Bli bli bli \n blu"); + reset_counters(&marie->stat); + reset_counters(&pauline->stat); /*pauline doesn't want to be disturbed*/ linphone_core_disable_chat(pauline->lc,LinphoneReasonDoNotDisturb); diff --git a/tester/rcfiles/marie_remote_default_values_rc b/tester/rcfiles/marie_remote_default_values_rc index ec5e4f633..966d116fd 100644 --- a/tester/rcfiles/marie_remote_default_values_rc +++ b/tester/rcfiles/marie_remote_default_values_rc @@ -1,2 +1,5 @@ [misc] config-uri=http://smtp.linphone.org/marie_default + +[app] +toto=titi diff --git a/tester/remote_provisioning_tester.c b/tester/remote_provisioning_tester.c index d81df94d4..21e9a3f6a 100644 --- a/tester/remote_provisioning_tester.c +++ b/tester/remote_provisioning_tester.c @@ -84,9 +84,14 @@ static void remote_provisioning_default_values(void) { lpc = linphone_core_create_proxy_config(marie->lc); CU_ASSERT_TRUE(lpc->reg_sendregister == TRUE); CU_ASSERT_TRUE(lpc->expires == 604800); - CU_ASSERT_TRUE(strcmp(lpc->reg_proxy, "") == 0); - CU_ASSERT_TRUE(strcmp(lpc->reg_route, "") == 0); - CU_ASSERT_TRUE(strcmp(lpc->reg_identity, "sip:?@sip.linphone.org") == 0); + CU_ASSERT_STRING_EQUAL(lpc->reg_proxy, ""); + CU_ASSERT_STRING_EQUAL(lpc->reg_route, ""); + CU_ASSERT_STRING_EQUAL(lpc->reg_identity, "sip:?@sip.linphone.org"); + { + LpConfig* lp = linphone_core_get_config(marie->lc); + CU_ASSERT_STRING_EQUAL(lp_config_get_string(lp,"app","toto","empty"),"titi"); + } + linphone_core_manager_destroy(marie); }