mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-22 05:38:14 +00:00
Move file + text test to group chat suite
This commit is contained in:
parent
33c88916a4
commit
2664c720a5
2 changed files with 64 additions and 69 deletions
|
|
@ -174,6 +174,25 @@ static void _send_file(LinphoneChatRoom* cr, const char *sendFilepath) {
|
|||
linphone_content_unref(content);
|
||||
}
|
||||
|
||||
static void _send_file_plus_text(LinphoneChatRoom* cr, const char *sendFilepath, const char *text) {
|
||||
LinphoneChatMessage *msg;
|
||||
LinphoneChatMessageCbs *cbs;
|
||||
LinphoneContent *content = linphone_core_create_content(linphone_chat_room_get_core(cr));
|
||||
belle_sip_object_set_name(BELLE_SIP_OBJECT(content), "sintel trailer content");
|
||||
linphone_content_set_type(content,"video");
|
||||
linphone_content_set_subtype(content,"mkv");
|
||||
linphone_content_set_name(content,"sintel_trailer_opus_h264.mkv");
|
||||
|
||||
msg = linphone_chat_room_create_file_transfer_message(cr, content);
|
||||
linphone_chat_message_set_file_transfer_filepath(msg, sendFilepath);
|
||||
cbs = linphone_chat_message_get_callbacks(msg);
|
||||
linphone_chat_message_cbs_set_file_transfer_send(cbs, tester_file_transfer_send);
|
||||
linphone_chat_message_cbs_set_msg_state_changed(cbs,liblinphone_tester_chat_message_msg_state_changed);
|
||||
linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication);
|
||||
linphone_chat_room_send_chat_message_2(cr, msg);
|
||||
linphone_content_unref(content);
|
||||
}
|
||||
|
||||
static void _receive_file(bctbx_list_t *coresList, LinphoneCoreManager *lcm, stats *receiverStats, const char *receive_filepath, const char *sendFilepath) {
|
||||
if (BC_ASSERT_TRUE(wait_for_list(coresList, &lcm->stat.number_of_LinphoneMessageReceivedWithFile, receiverStats->number_of_LinphoneMessageReceivedWithFile+1, 10000))) {
|
||||
LinphoneChatMessageCbs *cbs;
|
||||
|
|
@ -192,6 +211,27 @@ static void _receive_file(bctbx_list_t *coresList, LinphoneCoreManager *lcm, sta
|
|||
}
|
||||
}
|
||||
|
||||
static void _receive_file_plus_text(bctbx_list_t *coresList, LinphoneCoreManager *lcm, stats *receiverStats, const char *receive_filepath, const char *sendFilepath, const char *text) {
|
||||
if (BC_ASSERT_TRUE(wait_for_list(coresList, &lcm->stat.number_of_LinphoneMessageReceivedWithFile, receiverStats->number_of_LinphoneMessageReceivedWithFile+1, 10000))) {
|
||||
LinphoneChatMessageCbs *cbs;
|
||||
LinphoneChatMessage *msg = lcm->stat.last_received_chat_message;
|
||||
|
||||
BC_ASSERT_TRUE(linphone_chat_message_has_text_content(msg));
|
||||
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text_content(msg), text);
|
||||
|
||||
cbs = linphone_chat_message_get_callbacks(msg);
|
||||
linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
|
||||
linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received);
|
||||
linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication);
|
||||
linphone_chat_message_set_file_transfer_filepath(msg, receive_filepath);
|
||||
linphone_chat_message_download_file(msg);
|
||||
|
||||
if (BC_ASSERT_TRUE(wait_for_list(coresList, &lcm->stat.number_of_LinphoneFileTransferDownloadSuccessful,receiverStats->number_of_LinphoneFileTransferDownloadSuccessful + 1, 20000))) {
|
||||
compare_files(sendFilepath, receive_filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Configure list of core manager for conference and add the listener
|
||||
static bctbx_list_t * init_core_for_conference(bctbx_list_t *coreManagerList) {
|
||||
bctbx_list_t *coresList = NULL;
|
||||
|
|
@ -1900,7 +1940,7 @@ static void group_chat_donot_room_migrate_from_basic_chat_room (void) {
|
|||
linphone_core_manager_destroy(pauline);
|
||||
}
|
||||
|
||||
static void group_chat_room_send_file (void) {
|
||||
static void group_chat_room_send_file_with_or_without_text (bool_t with_text) {
|
||||
LinphoneCoreManager *marie = linphone_core_manager_create("marie_rc");
|
||||
LinphoneCoreManager *pauline = linphone_core_manager_create("pauline_rc");
|
||||
LinphoneCoreManager *chloe = linphone_core_manager_create("chloe_rc");
|
||||
|
|
@ -1910,6 +1950,7 @@ static void group_chat_room_send_file (void) {
|
|||
char *sendFilepath = bc_tester_res("sounds/sintel_trailer_opus_h264.mkv");
|
||||
char *receivePaulineFilepath = bc_tester_file("receive_file_pauline.dump");
|
||||
char *receiveChloeFilepath = bc_tester_file("receive_file_chloe.dump");
|
||||
const char *text = "Hello Group !";
|
||||
|
||||
/* Globally configure an http file transfer server. */
|
||||
linphone_core_set_file_transfer_server(marie->lc, "https://www.linphone.org:444/lft.php");
|
||||
|
|
@ -1940,13 +1981,22 @@ static void group_chat_room_send_file (void) {
|
|||
LinphoneChatRoom *chloeCr = check_creation_chat_room_client_side(coresList, chloe, &initialChloeStats, confAddr, initialSubject, 2, 0);
|
||||
|
||||
// Sending file
|
||||
_send_file(marieCr, sendFilepath);
|
||||
if (with_text) {
|
||||
_send_file_plus_text(marieCr, sendFilepath, text);
|
||||
} else {
|
||||
_send_file(marieCr, sendFilepath);
|
||||
}
|
||||
|
||||
wait_for_list(coresList, &dummy, 1, 10000);
|
||||
|
||||
// Check that chat rooms have received the file
|
||||
_receive_file(coresList, pauline, &initialPaulineStats, receivePaulineFilepath, sendFilepath);
|
||||
_receive_file(coresList, chloe, &initialChloeStats, receiveChloeFilepath, sendFilepath);
|
||||
if (with_text) {
|
||||
_receive_file_plus_text(coresList, pauline, &initialPaulineStats, receivePaulineFilepath, sendFilepath, text);
|
||||
_receive_file_plus_text(coresList, chloe, &initialChloeStats, receiveChloeFilepath, sendFilepath, text);
|
||||
} else {
|
||||
_receive_file(coresList, pauline, &initialPaulineStats, receivePaulineFilepath, sendFilepath);
|
||||
_receive_file(coresList, chloe, &initialChloeStats, receiveChloeFilepath, sendFilepath);
|
||||
}
|
||||
|
||||
// Clean db from chat room
|
||||
linphone_core_delete_chat_room(marie->lc, marieCr);
|
||||
|
|
@ -1964,6 +2014,14 @@ static void group_chat_room_send_file (void) {
|
|||
linphone_core_manager_destroy(chloe);
|
||||
}
|
||||
|
||||
static void group_chat_room_send_file (void) {
|
||||
group_chat_room_send_file_with_or_without_text(FALSE);
|
||||
}
|
||||
|
||||
static void group_chat_room_send_file_plus_text(void) {
|
||||
group_chat_room_send_file_with_or_without_text(TRUE);
|
||||
}
|
||||
|
||||
test_t group_chat_tests[] = {
|
||||
TEST_TWO_TAGS("Group chat room creation server", group_chat_room_creation_server, "Server", "LeaksMemory"),
|
||||
TEST_TWO_TAGS("Send message", group_chat_room_send_message, "Server", "LeaksMemory"),
|
||||
|
|
@ -1988,7 +2046,8 @@ test_t group_chat_tests[] = {
|
|||
TEST_TWO_TAGS("Migrate basic chat room to client group chat room", group_chat_room_migrate_from_basic_chat_room, "Server", "LeaksMemory"),
|
||||
TEST_TWO_TAGS("Migrate basic chat room to client group chat room failure", group_chat_room_migrate_from_basic_to_client_fail, "Server", "LeaksMemory"),
|
||||
TEST_TWO_TAGS("Migrate basic chat room to client group chat room not needed", group_chat_donot_room_migrate_from_basic_chat_room, "Server", "LeaksMemory"),
|
||||
TEST_TWO_TAGS("Send file", group_chat_room_send_file, "Server", "LeaksMemory")
|
||||
TEST_TWO_TAGS("Send file", group_chat_room_send_file, "Server", "LeaksMemory"),
|
||||
TEST_TWO_TAGS("Send file + text", group_chat_room_send_file_plus_text, "Server", "LeaksMemory")
|
||||
};
|
||||
|
||||
test_suite_t group_chat_test_suite = {
|
||||
|
|
|
|||
|
|
@ -2338,71 +2338,7 @@ void im_encryption_engine_b64_async(void) {
|
|||
im_encryption_engine_b64_base(TRUE);
|
||||
}
|
||||
|
||||
void file_and_text_message(void) {
|
||||
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
|
||||
LinphoneCoreManager* pauline = linphone_core_manager_new("pauline_tcp_rc");
|
||||
|
||||
LpConfig *config = linphone_core_get_config(pauline->lc);
|
||||
lp_config_set_int(config, "sip", "use_cpim", 1);
|
||||
|
||||
char *send_filepath = bc_tester_res("sounds/sintel_trailer_opus_h264.mkv");
|
||||
char *receive_filepath = bc_tester_file("receive_file.dump");
|
||||
LinphoneChatRoom* chat_room;
|
||||
LinphoneChatMessage* msg;
|
||||
LinphoneChatMessageCbs *cbs;
|
||||
|
||||
/* Remove any previously downloaded file */
|
||||
remove(receive_filepath);
|
||||
|
||||
/* Globally configure an http file transfer server. */
|
||||
linphone_core_set_file_transfer_server(pauline->lc,"https://www.linphone.org:444/lft.php");
|
||||
|
||||
/* create a chatroom on pauline's side */
|
||||
chat_room = linphone_core_get_chat_room(pauline->lc, marie->identity);
|
||||
|
||||
/* create a file transfer msg */
|
||||
msg = create_file_transfer_message_from_sintel_trailer(chat_room);
|
||||
linphone_chat_message_add_text_content(msg, "Text message");
|
||||
|
||||
BC_ASSERT_TRUE(linphone_chat_message_has_text_content(msg));
|
||||
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text_content(msg), "Text message");
|
||||
|
||||
linphone_chat_room_send_chat_message(chat_room, msg);
|
||||
|
||||
BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneMessageReceived, 1, 60000));
|
||||
|
||||
if (marie->stat.last_received_chat_message) {
|
||||
LinphoneChatMessage *recv_msg;
|
||||
recv_msg = marie->stat.last_received_chat_message;
|
||||
|
||||
BC_ASSERT_TRUE(linphone_chat_message_has_text_content(recv_msg));
|
||||
BC_ASSERT_STRING_EQUAL(linphone_chat_message_get_text_content(recv_msg), "Text message");
|
||||
|
||||
cbs = linphone_chat_message_get_callbacks(recv_msg);
|
||||
linphone_chat_message_cbs_set_msg_state_changed(cbs, liblinphone_tester_chat_message_msg_state_changed);
|
||||
linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received);
|
||||
linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication);
|
||||
linphone_chat_message_set_file_transfer_filepath(recv_msg, receive_filepath);
|
||||
linphone_chat_message_download_file(recv_msg);
|
||||
|
||||
/* wait for a long time in case the DNS SRV resolution takes times - it should be immediate though */
|
||||
if (BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneFileTransferDownloadSuccessful, 1, 55000))) {
|
||||
compare_files(send_filepath, receive_filepath);
|
||||
}
|
||||
}
|
||||
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageInProgress, 2, int, "%d"); //sent twice because of file transfer
|
||||
BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageDelivered, 1, int, "%d");
|
||||
|
||||
remove(receive_filepath);
|
||||
bc_free(send_filepath);
|
||||
bc_free(receive_filepath);
|
||||
|
||||
linphone_core_manager_destroy(pauline);
|
||||
linphone_core_manager_destroy(marie);
|
||||
}
|
||||
|
||||
test_t message_tests[] = {
|
||||
TEST_NO_TAG("File + Text message", file_and_text_message),
|
||||
TEST_NO_TAG("Text message", text_message),
|
||||
TEST_NO_TAG("Text message with credentials from auth callback", text_message_with_credential_from_auth_callback),
|
||||
TEST_NO_TAG("Text message with privacy", text_message_with_privacy),
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue