mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-29 00:59:20 +00:00
improve message tester
This commit is contained in:
parent
71d498fd95
commit
a21d7d863d
4 changed files with 35 additions and 11 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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;i<sizeof(big_file);i+=strlen(big_file_content))
|
||||
memcpy(big_file+i, big_file_content, strlen(big_file_content));
|
||||
|
|
@ -362,7 +366,7 @@ static void file_transfer_message(void) {
|
|||
/* create a chatroom on pauline's side */
|
||||
to = linphone_address_as_string(marie->identity);
|
||||
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;i<sizeof(big_file);i+=strlen(big_file_content))
|
||||
|
|
@ -436,6 +445,9 @@ static void text_message_with_send_error(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);
|
||||
|
||||
/*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);
|
||||
|
|
|
|||
|
|
@ -1,2 +1,5 @@
|
|||
[misc]
|
||||
config-uri=http://smtp.linphone.org/marie_default
|
||||
|
||||
[app]
|
||||
toto=titi
|
||||
|
|
|
|||
|
|
@ -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, "<sip:sip.linphone.org:5223;transport=tls>") == 0);
|
||||
CU_ASSERT_TRUE(strcmp(lpc->reg_route, "<sip:sip.linphone.org:5223;transport=tls>") == 0);
|
||||
CU_ASSERT_TRUE(strcmp(lpc->reg_identity, "sip:?@sip.linphone.org") == 0);
|
||||
CU_ASSERT_STRING_EQUAL(lpc->reg_proxy, "<sip:sip.linphone.org:5223;transport=tls>");
|
||||
CU_ASSERT_STRING_EQUAL(lpc->reg_route, "<sip:sip.linphone.org:5223;transport=tls>");
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue