diff --git a/tester/group_chat_tester.c b/tester/group_chat_tester.c index 641454617..f40fe50e6 100644 --- a/tester/group_chat_tester.c +++ b/tester/group_chat_tester.c @@ -1304,7 +1304,7 @@ static void group_chat_room_create_room_with_disconnected_friends_and_initial_me group_chat_room_create_room_with_disconnected_friends_base(TRUE); } -static void group_chat_room_reinvited_after_removed (void) { +static void group_chat_room_reinvited_after_removed_base (bool_t offline_when_removed) { LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc"); LinphoneCoreManager *laure = linphone_core_manager_create("laure_tcp_rc"); @@ -1320,6 +1320,7 @@ static void group_chat_room_reinvited_after_removed (void) { stats initialMarieStats = marie->stat; stats initialPaulineStats = pauline->stat; stats initialLaureStats = laure->stat; + char *savedLaureUuid = NULL; // Marie creates a new group chat room const char *initialSubject = "Colleagues"; @@ -1333,23 +1334,44 @@ static void group_chat_room_reinvited_after_removed (void) { // Check that the chat room is correctly created on Laure's side and that the participants are added LinphoneChatRoom *laureCr = check_creation_chat_room_client_side(coresList, laure, &initialLaureStats, confAddr, initialSubject, 2, 0); - // Marie removes Laure from the chat room LinphoneAddress *laureAddr = linphone_address_new(linphone_core_get_identity(laure->lc)); + if (offline_when_removed) { + savedLaureUuid = bctbx_strdup(lp_config_get_string(linphone_core_get_config(laure->lc), "misc", "uuid", NULL)); + coresList = bctbx_list_remove(coresList, laure->lc); + coresManagerList = bctbx_list_remove(coresManagerList, laure); + linphone_core_set_network_reachable(laure->lc, FALSE); + linphone_core_manager_stop(laure); + } + + // Marie removes Laure from the chat room LinphoneParticipant *laureParticipant = linphone_chat_room_find_participant(marieCr, laureAddr); linphone_address_unref(laureAddr); BC_ASSERT_PTR_NOT_NULL(laureParticipant); linphone_chat_room_remove_participant(marieCr, laureParticipant); - BC_ASSERT_TRUE(wait_for_list(coresList, &laure->stat.number_of_LinphoneChatRoomStateTerminated, initialLaureStats.number_of_LinphoneChatRoomStateTerminated + 1, 3000)); BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_participants_removed, initialMarieStats.number_of_participants_removed + 1, 1000)); BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_participants_removed, initialPaulineStats.number_of_participants_removed + 1, 1000)); + if (offline_when_removed) { + linphone_core_manager_configure(laure); + lp_config_set_string(linphone_core_get_config(laure->lc), "misc", "uuid", savedLaureUuid); + bctbx_free(savedLaureUuid); + bctbx_list_t *tmpCoresManagerList = bctbx_list_append(NULL, laure); + init_core_for_conference(tmpCoresManagerList); + bctbx_list_free(tmpCoresManagerList); + linphone_core_manager_start(laure, TRUE); + coresList = bctbx_list_append(coresList, laure->lc); + coresManagerList = bctbx_list_append(coresManagerList, laure); + initialLaureStats = laure->stat; + } + BC_ASSERT_TRUE(wait_for_list(coresList, &laure->stat.number_of_LinphoneChatRoomStateTerminated, initialLaureStats.number_of_LinphoneChatRoomStateTerminated + 1, 3000)); + // Marie adds Laure to the chat room participantsAddresses = bctbx_list_append(participantsAddresses, linphone_address_new(linphone_core_get_identity(laure->lc))); linphone_chat_room_add_participants(marieCr, participantsAddresses); bctbx_list_free_with_data(participantsAddresses, (bctbx_list_free_func)linphone_address_unref); participantsAddresses = NULL; - BC_ASSERT_TRUE(wait_for_list(coresList, &laure->stat.number_of_LinphoneChatRoomStateCreationPending, initialLaureStats.number_of_LinphoneChatRoomStateCreationPending + 2, 5000)); - BC_ASSERT_TRUE(wait_for_list(coresList, &laure->stat.number_of_LinphoneChatRoomStateCreated, initialLaureStats.number_of_LinphoneChatRoomStateCreated + 2, 5000)); + BC_ASSERT_TRUE(wait_for_list(coresList, &laure->stat.number_of_LinphoneChatRoomStateCreationPending, initialLaureStats.number_of_LinphoneChatRoomStateCreationPending + 1, 5000)); + BC_ASSERT_TRUE(wait_for_list(coresList, &laure->stat.number_of_LinphoneChatRoomStateCreated, initialLaureStats.number_of_LinphoneChatRoomStateCreated + 1, 5000)); BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_participants_added, initialMarieStats.number_of_participants_added + 1, 1000)); BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_participants_added, initialPaulineStats.number_of_participants_added + 1, 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_nb_participants(marieCr), 2, int, "%d"); @@ -1357,13 +1379,14 @@ static void group_chat_room_reinvited_after_removed (void) { laureAddr = linphone_address_new(linphone_core_get_device_identity(laure->lc)); LinphoneChatRoom *newLaureCr = linphone_core_find_chat_room(laure->lc, confAddr, laureAddr); linphone_address_unref(laureAddr); - BC_ASSERT_PTR_EQUAL(newLaureCr, laureCr); + if (!offline_when_removed) + BC_ASSERT_PTR_EQUAL(newLaureCr, laureCr); BC_ASSERT_EQUAL(linphone_chat_room_get_nb_participants(newLaureCr), 2, int, "%d"); BC_ASSERT_STRING_EQUAL(linphone_chat_room_get_subject(newLaureCr), initialSubject); // Clean db from chat room linphone_core_manager_delete_chat_room(marie, marieCr, coresList); - linphone_core_manager_delete_chat_room(laure, laureCr, coresList); + linphone_core_manager_delete_chat_room(laure, newLaureCr, coresList); linphone_core_manager_delete_chat_room(pauline, paulineCr, coresList); bctbx_list_free(coresList); @@ -1373,6 +1396,14 @@ static void group_chat_room_reinvited_after_removed (void) { linphone_core_manager_destroy(laure); } +static void group_chat_room_reinvited_after_removed (void) { + group_chat_room_reinvited_after_removed_base(FALSE); +} + +static void group_chat_room_reinvited_after_removed_while_offline (void) { + group_chat_room_reinvited_after_removed_base(TRUE); +} + static void group_chat_room_notify_after_disconnection (void) { LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc"); LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc"); @@ -2401,15 +2432,14 @@ static void group_chat_room_unique_one_to_one_chat_room_recreated_from_message_b 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); + linphone_core_manager_reinit(marie); 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); + 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)); } @@ -2424,7 +2454,7 @@ static void group_chat_room_unique_one_to_one_chat_room_recreated_from_message_b initialMarieStats = marie->stat; initialPaulineStats = pauline->stat; - // Marie sends a new message + // Pauline sends a new message message = "Hey you"; _send_message(paulineCr, message); BC_ASSERT_TRUE(wait_for_list(coresList, &pauline->stat.number_of_LinphoneMessageDelivered, initialPaulineStats.number_of_LinphoneMessageDelivered + 1, 10000)); @@ -2534,6 +2564,7 @@ test_t group_chat_tests[] = { TEST_TWO_TAGS("Create chat room with disconnected friends", group_chat_room_create_room_with_disconnected_friends, "Server", "LeaksMemory"), TEST_TWO_TAGS("Create chat room with disconnected friends and initial message", group_chat_room_create_room_with_disconnected_friends_and_initial_message, "Server", "LeaksMemory"), TEST_TWO_TAGS("Reinvited after removed from group chat room", group_chat_room_reinvited_after_removed, "Server", "LeaksMemory"), + TEST_TWO_TAGS("Reinvited after removed from group chat room while offline", group_chat_room_reinvited_after_removed_while_offline, "Server", "LeaksMemory"), TEST_TWO_TAGS("Notify after disconnection", group_chat_room_notify_after_disconnection, "Server", "LeaksMemory"), TEST_TWO_TAGS("Send refer to all participants devices", group_chat_room_send_refer_to_all_devices, "Server", "LeaksMemory"), // TODO: Use when we support adding a new device in created conf @@ -2549,7 +2580,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("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") }; diff --git a/tester/liblinphone_tester.h b/tester/liblinphone_tester.h index 050462630..7e07493d0 100644 --- a/tester/liblinphone_tester.h +++ b/tester/liblinphone_tester.h @@ -322,6 +322,7 @@ typedef struct _LinphoneCallTestParams { 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_configure (LinphoneCoreManager *mgr); void linphone_core_manager_start(LinphoneCoreManager *mgr, bool_t check_for_proxies); LinphoneCoreManager* linphone_core_manager_create2(const char* rc_file, const char* phone_alias); LinphoneCoreManager* linphone_core_manager_create(const char* rc_file); @@ -329,7 +330,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_reinit(LinphoneCoreManager *mgr); 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); diff --git a/tester/tester.c b/tester/tester.c index 50d3bd6d4..71b7a7d65 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -459,24 +459,23 @@ void linphone_core_manager_stop(LinphoneCoreManager *mgr){ } } -void linphone_core_manager_reinit(LinphoneCoreManager *mgr, bool_t check_for_proxies) { - char* uuid = NULL; +void linphone_core_manager_reinit(LinphoneCoreManager *mgr) { + 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)); - } + 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); + // Make sure gruu is preserved + lp_config_set_string(linphone_core_get_config(mgr->lc), "misc", "uuid", uuid); if (uuid) - bctbx_free(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_reinit(mgr); linphone_core_manager_start(mgr, check_for_proxies); }