From 8f245057665a74afd9b62d838a17d0cb730db8f6 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 25 Jan 2018 16:55:01 +0100 Subject: [PATCH] Fix some group chat testers. --- .../basic-to-client-group-chat-room.cpp | 6 ++++++ tester/group_chat_tester.c | 17 +++-------------- tester/tester.c | 14 ++++++-------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/chat/chat-room/basic-to-client-group-chat-room.cpp b/src/chat/chat-room/basic-to-client-group-chat-room.cpp index 9d779839a..827d9b3d9 100644 --- a/src/chat/chat-room/basic-to-client-group-chat-room.cpp +++ b/src/chat/chat-room/basic-to-client-group-chat-room.cpp @@ -46,6 +46,12 @@ public: // Do not insert the client group chat room in database, the migration will do it } + void onChatRoomDeleteRequested (const shared_ptr &chatRoom) override { + L_Q(); + q->getCore()->deleteChatRoom(q->getSharedFromThis()); + setState(AbstractChatRoom::State::Deleted); + } + void sendChatMessage (const shared_ptr &chatMessage) override { ProxyChatRoomPrivate::sendChatMessage(chatMessage); const char *specs = linphone_core_get_linphone_specs(chatMessage->getCore()->getCCore()); diff --git a/tester/group_chat_tester.c b/tester/group_chat_tester.c index f8e946f93..d585b1602 100644 --- a/tester/group_chat_tester.c +++ b/tester/group_chat_tester.c @@ -59,16 +59,6 @@ static void chat_room_participant_removed (LinphoneChatRoom *cr, const LinphoneE manager->stat.number_of_participants_removed++; } -static void chat_room_message_received (LinphoneChatRoom *cr, LinphoneChatMessage *msg) { - LinphoneCore *core = linphone_chat_room_get_core(cr); - LinphoneCoreManager *manager = (LinphoneCoreManager *)linphone_core_get_user_data(core); - if (linphone_chat_message_get_file_transfer_information(msg) || linphone_chat_message_get_external_body_url(msg)) { - manager->stat.number_of_LinphoneMessageReceivedWithFile++; - } else { - manager->stat.number_of_LinphoneMessageReceived++; - } -} - static void chat_room_state_changed (LinphoneChatRoom *cr, LinphoneChatRoomState newState) { LinphoneCore *core = linphone_chat_room_get_core(cr); LinphoneCoreManager *manager = (LinphoneCoreManager *)linphone_core_get_user_data(core); @@ -114,7 +104,6 @@ static void core_chat_room_state_changed (LinphoneCore *core, LinphoneChatRoom * linphone_chat_room_cbs_set_participant_removed(cbs, chat_room_participant_removed); linphone_chat_room_cbs_set_state_changed(cbs, chat_room_state_changed); linphone_chat_room_cbs_set_subject_changed(cbs, chat_room_subject_changed); - linphone_chat_room_cbs_set_message_received(cbs, chat_room_message_received); } } @@ -1743,8 +1732,8 @@ static void group_chat_room_migrate_from_basic_to_client_fail (void) { // Check that the group chat room creation fails and that a fallback to a basic chat room is done BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreationPending, initialMarieStats.number_of_LinphoneChatRoomStateCreationPending + 1, 10000)); - BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreationFailed, initialMarieStats.number_of_LinphoneChatRoomStateCreationFailed + 1, 10000)); BC_ASSERT_TRUE(wait_for_list(coresList, &marie->stat.number_of_LinphoneChatRoomStateCreated, initialMarieStats.number_of_LinphoneChatRoomStateCreated + 1, 10000)); + BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneChatRoomStateCreationFailed, initialMarieStats.number_of_LinphoneChatRoomStateCreationFailed, int, "%d"); BC_ASSERT_EQUAL(linphone_chat_room_get_nb_participants(marieCr), 1, int, "%d"); BC_ASSERT_TRUE(linphone_chat_room_get_capabilities(marieCr) & LinphoneChatRoomCapabilitiesBasic); bctbx_list_free_with_data(participantsAddresses, (bctbx_list_free_func)linphone_address_unref); @@ -1909,8 +1898,8 @@ static void group_chat_donot_room_migrate_from_basic_chat_room (void) { } // Clean db from chat room - linphone_core_manager_delete_chat_room(marie, marieCr, coresList); - linphone_core_manager_delete_chat_room(pauline, paulineCr, coresList); + linphone_core_delete_chat_room(marie->lc, marieCr); + linphone_core_delete_chat_room(pauline->lc, paulineCr); bctbx_list_free(coresList); bctbx_list_free(coresManagerList); diff --git a/tester/tester.c b/tester/tester.c index 472c0df46..9d3abda2a 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -339,19 +339,17 @@ void linphone_core_manager_configure (LinphoneCoreManager *mgr) { linphone_core_set_user_certificates_path(mgr->lc,bc_tester_get_writable_dir_prefix()); /*for now, we need the periodical updates facility to compute bandwidth measurements correctly during tests*/ linphone_core_enable_send_call_stats_periodical_updates(mgr->lc, TRUE); + + LinphoneConfig *config = linphone_core_get_config(mgr->lc); + linphone_config_set_string(config, "storage", "backend", "sqlite3"); + linphone_config_set_string(config, "storage", "uri", mgr->database_path); } -static void configure_random_database_path (LinphoneCoreManager *mgr) { - LinphoneConfig *config = linphone_core_get_config(mgr->lc); - +static void generate_random_database_path (LinphoneCoreManager *mgr) { char random_id[32]; belle_sip_random_token(random_id, sizeof random_id); char *database_path_format = bctbx_strdup_printf("linphone_%s.db", random_id); mgr->database_path = bc_tester_file(database_path_format); - - linphone_config_set_string(config, "storage", "backend", "sqlite3"); - linphone_config_set_string(config, "storage", "uri", mgr->database_path); - bctbx_free(database_path_format); } @@ -393,8 +391,8 @@ void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file, c manager_count++; + generate_random_database_path(mgr); linphone_core_manager_configure(mgr); - configure_random_database_path(mgr); } #if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4) #pragma GCC diagnostic pop