add test for message-expires

This commit is contained in:
Danmei Chen 2017-12-21 16:39:55 +01:00
parent de9bf370d6
commit 7f518c9e0f
3 changed files with 54 additions and 0 deletions

View file

@ -202,6 +202,46 @@ static void message_forking_with_all_recipients_unreachable(void) {
bctbx_list_free(lcs);
}
static void text_message_expires(void) {
LinphoneCoreManager* marie = linphone_core_manager_new4("marie_rc",TRUE,NULL,"message-expires=60",3);
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
linphone_core_set_network_reachable(marie->lc, FALSE);
/* Wait for 5 seconds for surely cut marie of network */
wait_for_until(pauline->lc, marie->lc, NULL, NULL, 5000);
linphone_chat_room_send_message(linphone_core_get_chat_room(pauline->lc,marie->identity), "hello");
linphone_core_set_network_reachable(marie->lc, TRUE);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceivedLegacy,1));
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void text_call_expires(void) {
LinphoneCoreManager* marie = linphone_core_manager_new4("marie_rc",TRUE,NULL,"message-expires=60",3);
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc");
bctbx_list_t* lcs=bctbx_list_append(NULL,pauline->lc);
lcs=bctbx_list_append(lcs,marie->lc);
linphone_core_set_network_reachable(marie->lc, FALSE);
/* Wait for 5 seconds for surely cut marie of network */
wait_for_until(pauline->lc, marie->lc, NULL, NULL, 5000);
linphone_core_invite_address(pauline->lc,marie->identity);
linphone_core_set_network_reachable(marie->lc, TRUE);
/*pauline shouldn't hear ringback*/
BC_ASSERT_FALSE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingRinging,1,5000));
/*all devices from Marie shouldn't be ringing*/
BC_ASSERT_FALSE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallIncomingReceived,1,5000));
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
bctbx_list_free(lcs);
}
static void call_forking(void){
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
@ -1398,6 +1438,8 @@ test_t flexisip_tests[] = {
TEST_NO_TAG("Message forking", message_forking),
TEST_NO_TAG("Message forking with unreachable recipients", message_forking_with_unreachable_recipients),
TEST_NO_TAG("Message forking with all recipients unreachable", message_forking_with_all_recipients_unreachable),
TEST_NO_TAG("Message expires", text_message_expires),
TEST_NO_TAG("Call expires", text_call_expires),
TEST_NO_TAG("Call forking", call_forking),
TEST_NO_TAG("Call forking cancelled", call_forking_cancelled),
TEST_NO_TAG("Call forking declined globaly", call_forking_declined_globaly),

View file

@ -300,6 +300,7 @@ void liblinphone_tester_add_suites(void);
void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file, const char* phone_alias);
void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies);
LinphoneCoreManager* linphone_core_manager_new4(const char* rc_file, int check_for_proxies, const char* phone_aliasconst, const char* contact_params, int expires);
LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, int check_for_proxies, const char* phone_alias);
LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_for_proxies);
LinphoneCoreManager* linphone_core_manager_new(const char* rc_file);

View file

@ -420,6 +420,17 @@ void linphone_core_manager_start(LinphoneCoreManager *mgr, int check_for_proxies
}
LinphoneCoreManager* linphone_core_manager_new4(const char* rc_file, int check_for_proxies, const char* phone_alias, const char* contact_params, int expires) {
/* This function is for testing purposes. */
LinphoneCoreManager *manager = ms_new0(LinphoneCoreManager, 1);
linphone_core_manager_init(manager, rc_file, phone_alias);
linphone_proxy_config_set_contact_parameters(linphone_core_get_default_proxy_config(manager->lc), contact_params);
linphone_proxy_config_set_expires(linphone_core_get_default_proxy_config(manager->lc), expires);
linphone_core_manager_start(manager, check_for_proxies);
return manager;
}
LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, int check_for_proxies, const char* phone_alias) {
LinphoneCoreManager *manager = ms_new0(LinphoneCoreManager, 1);