Commit 655f5912 authored by jehan's avatar jehan

add test to chatroom tester to simulate chat room deletion after app restart

parent e39313ae
......@@ -1971,19 +1971,9 @@ void linphone_core_set_state(LinphoneCore *lc, LinphoneGlobalState gstate, const
static void misc_config_read(LinphoneCore *lc) {
LpConfig *config=lc->config;
const char *uuid;
lc->max_call_logs=lp_config_get_int(config,"misc","history_max_size",LINPHONE_MAX_CALL_HISTORY_SIZE);
lc->max_calls=lp_config_get_int(config,"misc","max_calls",NB_MAX_CALLS);
uuid=lp_config_get_string(config,"misc","uuid",NULL);
if (!uuid){
char tmp[64];
lc->sal->create_uuid(tmp,sizeof(tmp));
lp_config_set_string(config,"misc","uuid",tmp);
}else if (strcmp(uuid,"0")!=0) /*to allow to disable sip.instance*/
lc->sal->set_uuid(uuid);
lc->user_certificates_path=ms_strdup(lp_config_get_string(config,"misc","user_certificates_path","."));
lc->send_call_stats_periodical_updates = !!lp_config_get_int(config, "misc", "send_call_stats_periodical_updates", 0);
}
......@@ -2322,6 +2312,15 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig
void linphone_core_start (LinphoneCore *lc) {
linphone_core_set_state(lc,LinphoneGlobalStartup,"Starting up");
//to give a chance to change uuid before starting
const char* uuid=lp_config_get_string(lc->config,"misc","uuid",NULL);
if (!uuid){
char tmp[64];
lc->sal->create_uuid(tmp,sizeof(tmp));
lp_config_set_string(lc->config,"misc","uuid",tmp);
}else if (strcmp(uuid,"0")!=0) /*to allow to disable sip.instance*/
lc->sal->set_uuid(uuid);
if (lc->sal->get_root_ca()) {
belle_tls_crypto_config_set_root_ca(lc->http_crypto_config, lc->sal->get_root_ca());
belle_http_provider_set_tls_crypto_config(lc->http_provider, lc->http_crypto_config);
......
......@@ -2362,7 +2362,7 @@ static void group_chat_room_unique_one_to_one_chat_room (void) {
linphone_core_manager_destroy(pauline);
}
static void group_chat_room_unique_one_to_one_chat_room_recreated_from_message (void) {
static void group_chat_room_unique_one_to_one_chat_room_recreated_from_message_base (bool_t with_app_restart) {
LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc");
LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc");
bctbx_list_t *coresManagerList = NULL;
......@@ -2393,6 +2393,23 @@ static void group_chat_room_unique_one_to_one_chat_room_recreated_from_message (
BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageReceived, initialPaulineStats.number_of_LinphoneMessageReceived + 1, 10000));
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text(pauline->stat.last_received_chat_message), message);
if (with_app_restart) {
//to simulate dialog removal
linphone_core_set_network_reachable(marie->lc, FALSE);
//linphone_core_set_network_reachable(marie->lc, TRUE);
coresList=bctbx_list_remove(coresList, marie->lc);
linphone_core_manager_reinit(marie,TRUE);
bctbx_list_t *tmpCoresManagerList = bctbx_list_append(NULL, marie);
init_core_for_conference(tmpCoresManagerList);
bctbx_list_free(tmpCoresManagerList);
coresList = bctbx_list_append(coresList, marie->lc);
linphone_core_manager_start(marie,TRUE);
wait_for_list(coresList, 0, 1, 2000);
LinphoneChatRoom *oldMarieCr = marieCr;
marieCr = linphone_core_get_chat_room(marie->lc, linphone_chat_room_get_peer_address(oldMarieCr));
}
// Marie deletes the chat room
linphone_core_manager_delete_chat_room(marie, marieCr, coresList);
wait_for_list(coresList, 0, 1, 2000);
......@@ -2424,6 +2441,14 @@ static void group_chat_room_unique_one_to_one_chat_room_recreated_from_message (
linphone_core_manager_destroy(pauline);
}
static void group_chat_room_unique_one_to_one_chat_room_recreated_from_message(void) {
group_chat_room_unique_one_to_one_chat_room_recreated_from_message_base(FALSE);
}
static void group_chat_room_unique_one_to_one_chat_room_recreated_from_message_with_app_restart(void) {
group_chat_room_unique_one_to_one_chat_room_recreated_from_message_base(TRUE);
}
static void group_chat_room_new_unique_one_to_one_chat_room_after_both_participants_left (void) {
LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc");
LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc");
......@@ -2513,6 +2538,7 @@ test_t group_chat_tests[] = {
TEST_TWO_TAGS("Send file + text", group_chat_room_send_file_plus_text, "Server", "LeaksMemory"),
TEST_TWO_TAGS("Unique one-to-one chatroom", group_chat_room_unique_one_to_one_chat_room, "Server", "LeaksMemory"),
TEST_TWO_TAGS("Unique one-to-one chatroom recreated from message", group_chat_room_unique_one_to_one_chat_room_recreated_from_message, "Server", "LeaksMemory"),
TEST_TWO_TAGS("Unique one-to-one chatroom recreated from message with app restart",group_chat_room_unique_one_to_one_chat_room_recreated_from_message_with_app_restart, "Server", "LeaksMemory"),
TEST_TWO_TAGS("New unique one-to-one chatroom after both participants left", group_chat_room_new_unique_one_to_one_chat_room_after_both_participants_left, "Server", "LeaksMemory")
};
......
......@@ -329,6 +329,7 @@ LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, bool_t chec
LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, bool_t check_for_proxies);
LinphoneCoreManager* linphone_core_manager_new(const char* rc_file);
void linphone_core_manager_stop(LinphoneCoreManager *mgr);
void linphone_core_manager_reinit(LinphoneCoreManager *mgr, bool_t check_for_proxies);
void linphone_core_manager_restart(LinphoneCoreManager *mgr, bool_t check_for_proxies);
void linphone_core_manager_uninit(LinphoneCoreManager *mgr);
void linphone_core_manager_wait_for_stun_resolution(LinphoneCoreManager *mgr);
......
......@@ -459,11 +459,24 @@ void linphone_core_manager_stop(LinphoneCoreManager *mgr){
}
}
void linphone_core_manager_restart(LinphoneCoreManager *mgr, bool_t check_for_proxies) {
if (mgr->lc)
void linphone_core_manager_reinit(LinphoneCoreManager *mgr, bool_t check_for_proxies) {
char* uuid = NULL;
if (mgr->lc) {
if (lp_config_get_string(linphone_core_get_config(mgr->lc),"misc","uuid",NULL)) {
uuid = bctbx_strdup(lp_config_get_string(linphone_core_get_config(mgr->lc),"misc","uuid",NULL));
}
linphone_core_unref(mgr->lc);
}
linphone_core_manager_configure(mgr);
reset_counters(&mgr->stat);
//to make sure gruu is preserved
lp_config_set_string(linphone_core_get_config(mgr->lc),"misc","uuid",uuid);
if (uuid)
bctbx_free(uuid);
}
void linphone_core_manager_restart(LinphoneCoreManager *mgr, bool_t check_for_proxies) {
linphone_core_manager_reinit(mgr, check_for_proxies);
linphone_core_manager_start(mgr, check_for_proxies);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment