forked from mirrors/linphone-iphone
Add test reproducing an issue where a one-to-one chatroom is recreated while some inactivate devices have not yet joined the chatroom.
This commit is contained in:
parent
4b111911ed
commit
556fb1a6fa
1 changed files with 87 additions and 0 deletions
|
|
@ -2760,6 +2760,92 @@ static void group_chat_room_unique_one_to_one_chat_room_recreated_from_message_w
|
|||
group_chat_room_unique_one_to_one_chat_room_recreated_from_message_base(TRUE);
|
||||
}
|
||||
|
||||
static void group_chat_room_unique_one_to_one_chat_room_recreated_from_message_2 (void) {
|
||||
LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc");
|
||||
LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc");
|
||||
/*create a second device for marie, but it is inactive after registration in this test*/
|
||||
LinphoneCoreManager *marie2 = linphone_core_manager_create("marie_rc");
|
||||
/*Create a seconde device for pauline, but again inactivate after registration*/
|
||||
LinphoneCoreManager *pauline2 = linphone_core_manager_create("marie_rc");
|
||||
bctbx_list_t *coresManagerList = NULL;
|
||||
bctbx_list_t *participantsAddresses = NULL;
|
||||
coresManagerList = bctbx_list_append(coresManagerList, marie);
|
||||
coresManagerList = bctbx_list_append(coresManagerList, pauline);
|
||||
coresManagerList = bctbx_list_append(coresManagerList, marie2);
|
||||
coresManagerList = bctbx_list_append(coresManagerList, pauline2);
|
||||
bctbx_list_t *coresList = init_core_for_conference(coresManagerList);
|
||||
start_core_for_conference(coresManagerList);
|
||||
participantsAddresses = bctbx_list_append(participantsAddresses, linphone_address_new(linphone_core_get_identity(pauline->lc)));
|
||||
stats initialMarieStats = marie->stat;
|
||||
stats initialPaulineStats = pauline->stat;
|
||||
|
||||
|
||||
linphone_core_set_network_reachable(marie2->lc, FALSE);
|
||||
linphone_core_set_network_reachable(pauline2->lc, FALSE);
|
||||
|
||||
// Marie creates a new group chat room
|
||||
const char *initialSubject = "Pauline";
|
||||
LinphoneChatRoom *marieCr = create_chat_room_client_side(coresList, marie, &initialMarieStats, participantsAddresses, initialSubject, -1);
|
||||
BC_ASSERT_TRUE(linphone_chat_room_get_capabilities(marieCr) & LinphoneChatRoomCapabilitiesOneToOne);
|
||||
|
||||
LinphoneAddress *confAddr = linphone_address_clone(linphone_chat_room_get_conference_address(marieCr));
|
||||
|
||||
// Check that the chat room is correctly created on Pauline's side and that the participants are added
|
||||
LinphoneChatRoom *paulineCr = check_creation_chat_room_client_side(coresList, pauline, &initialPaulineStats, confAddr, initialSubject, 1, FALSE);
|
||||
BC_ASSERT_TRUE(linphone_chat_room_get_capabilities(paulineCr) & LinphoneChatRoomCapabilitiesOneToOne);
|
||||
|
||||
// Marie sends a message
|
||||
const char *message = "Hello";
|
||||
_send_message(marieCr, message);
|
||||
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageDelivered, initialMarieStats.number_of_LinphoneMessageDelivered + 1, 10000));
|
||||
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);
|
||||
|
||||
// Marie deletes the chat room
|
||||
linphone_core_manager_delete_chat_room(marie, marieCr, coresList);
|
||||
wait_for_list(coresList, 0, 1, 2000);
|
||||
BC_ASSERT_EQUAL(pauline->stat.number_of_participants_removed, initialPaulineStats.number_of_participants_removed, int, "%d");
|
||||
|
||||
// Marie sends a new message
|
||||
participantsAddresses = NULL;
|
||||
participantsAddresses = bctbx_list_append(participantsAddresses, linphone_address_new(linphone_core_get_identity(pauline->lc)));
|
||||
initialMarieStats = marie->stat;
|
||||
initialPaulineStats = pauline->stat;
|
||||
marieCr = create_chat_room_client_side(coresList, marie, &initialMarieStats, participantsAddresses, initialSubject, -1);
|
||||
// Check that the chat room has been correctly recreated on Marie's side
|
||||
marieCr = check_creation_chat_room_client_side(coresList, marie, &initialMarieStats, confAddr, initialSubject, 1, FALSE);
|
||||
if (BC_ASSERT_PTR_NOT_NULL(marieCr)){
|
||||
BC_ASSERT_TRUE(linphone_chat_room_get_capabilities(marieCr) & LinphoneChatRoomCapabilitiesOneToOne);
|
||||
|
||||
message = "Hey you";
|
||||
_send_message(marieCr, message);
|
||||
BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneMessageDelivered, initialMarieStats.number_of_LinphoneMessageDelivered + 1, 10000));
|
||||
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);
|
||||
|
||||
// Clean db from chat room
|
||||
linphone_core_manager_delete_chat_room(marie, marieCr, coresList);
|
||||
}
|
||||
linphone_core_manager_delete_chat_room(pauline, paulineCr, coresList);
|
||||
|
||||
wait_for_list(coresList, 0, 1, 2000);
|
||||
BC_ASSERT_EQUAL(linphone_core_get_call_history_size(marie->lc), 0, int,"%i");
|
||||
BC_ASSERT_EQUAL(linphone_core_get_call_history_size(pauline->lc), 0, int,"%i");
|
||||
BC_ASSERT_PTR_NULL(linphone_core_get_call_logs(marie->lc));
|
||||
BC_ASSERT_PTR_NULL(linphone_core_get_call_logs(pauline->lc));
|
||||
|
||||
linphone_address_unref(confAddr);
|
||||
bctbx_list_free(coresList);
|
||||
bctbx_list_free(coresManagerList);
|
||||
linphone_core_set_network_reachable(marie2->lc, TRUE);
|
||||
linphone_core_set_network_reachable(pauline2->lc, TRUE);
|
||||
linphone_core_manager_destroy(marie);
|
||||
linphone_core_manager_destroy(pauline);
|
||||
linphone_core_manager_destroy(marie2);
|
||||
linphone_core_manager_destroy(pauline2);
|
||||
}
|
||||
|
||||
|
||||
static void group_chat_room_join_one_to_one_chat_room_with_a_new_device (void) {
|
||||
LinphoneCoreManager *marie1 = linphone_core_manager_create("marie_rc");
|
||||
LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc");
|
||||
|
|
@ -3099,6 +3185,7 @@ test_t group_chat_tests[] = {
|
|||
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("Join one-to-one chat room with a new device", group_chat_room_join_one_to_one_chat_room_with_a_new_device, "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"),
|
||||
TEST_TWO_TAGS("Unique one-to-one chatroom re-created from the party that deleted it, with inactive devices", group_chat_room_unique_one_to_one_chat_room_recreated_from_message_2, "Server", "LeaksMemory"),
|
||||
TEST_TWO_TAGS("IMDN for group chat room", imdn_for_group_chat_room, "Server", "LeaksMemory"),
|
||||
TEST_TWO_TAGS("Find one to one chat room", find_one_to_one_chat_room, "Server", "LeaksMemory")
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue