diff --git a/coreapi/tester_utils.cpp b/coreapi/tester_utils.cpp index ffa63a644..8b9f89bd7 100644 --- a/coreapi/tester_utils.cpp +++ b/coreapi/tester_utils.cpp @@ -21,10 +21,11 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "private.h" #include "call/call-p.h" -#include "chat/chat-room/chat-room.h" +#include "chat/chat-room/chat-room-p.h" #include "core/core-p.h" #include "c-wrapper/c-wrapper.h" #include "conference/session/media-session-p.h" +#include "event-log/conference/conference-chat-message-event.h" using namespace std; @@ -159,3 +160,18 @@ void _linphone_chat_room_enable_migration(LinphoneChatRoom *cr, bool_t enable) { shared_ptr acr = L_GET_CPP_PTR_FROM_C_OBJECT(cr); L_GET_PRIVATE(acr->getCore())->mainDb->enableChatRoomMigration(acr->getChatRoomId(), !!enable); } + +int _linphone_chat_room_get_transient_message_count (const LinphoneChatRoom *cr) { + shared_ptr chatRoom = static_pointer_cast(L_GET_CPP_PTR_FROM_C_OBJECT(cr)); + return (int)L_GET_PRIVATE(chatRoom)->transientEvents.size(); +} + +LinphoneChatMessage * _linphone_chat_room_get_first_transient_message (const LinphoneChatRoom *cr) { + shared_ptr chatRoom = static_pointer_cast(L_GET_CPP_PTR_FROM_C_OBJECT(cr)); + if (L_GET_PRIVATE(chatRoom)->transientEvents.empty()) + return nullptr; + shared_ptr event = static_pointer_cast( + L_GET_PRIVATE(chatRoom)->transientEvents.front() + ); + return L_GET_C_BACK_PTR(event->getChatMessage()); +} \ No newline at end of file diff --git a/coreapi/tester_utils.h b/coreapi/tester_utils.h index f6d836b5f..966adccab 100644 --- a/coreapi/tester_utils.h +++ b/coreapi/tester_utils.h @@ -104,6 +104,8 @@ LINPHONE_PUBLIC LinphoneQualityReporting *linphone_call_log_get_quality_reportin LINPHONE_PUBLIC reporting_session_report_t **linphone_quality_reporting_get_reports(LinphoneQualityReporting *qreporting); LINPHONE_PUBLIC void _linphone_chat_room_enable_migration(LinphoneChatRoom *cr, bool_t enable); +LINPHONE_PUBLIC int _linphone_chat_room_get_transient_message_count (const LinphoneChatRoom *cr); +LINPHONE_PUBLIC LinphoneChatMessage * _linphone_chat_room_get_first_transient_message (const LinphoneChatRoom *cr); LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_from_db(LinphoneCore *lc, LinphoneFriendList *list); LINPHONE_PUBLIC MSList* linphone_core_fetch_friends_lists_from_db(LinphoneCore *lc); diff --git a/src/chat/chat-room/chat-room-p.h b/src/chat/chat-room/chat-room-p.h index 6504e7fff..8f76557b2 100644 --- a/src/chat/chat-room/chat-room-p.h +++ b/src/chat/chat-room/chat-room-p.h @@ -66,6 +66,7 @@ public: void onIsRemoteComposingStateChanged (const Address &remoteAddress, bool isComposing) override; std::list remoteIsComposing; + std::list> transientEvents; ChatRoomId chatRoomId; @@ -79,7 +80,6 @@ private: std::unique_ptr isComposingHandler; bool isComposing = false; - std::list> transientEvents; L_DECLARE_PUBLIC(ChatRoom); }; diff --git a/tester/message_tester.c b/tester/message_tester.c index 294963f1c..818a20bec 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -365,7 +365,6 @@ static void text_message_with_privacy(void) { linphone_proxy_config_set_privacy(linphone_core_get_default_proxy_config(pauline->lc),LinphonePrivacyId); text_message_base(marie, pauline); - BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageReceivedLegacy,1, int, "%d"); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); @@ -420,15 +419,15 @@ static void text_message_with_send_error(void) { linphone_chat_room_send_chat_message(chat_room,msg); /* check transient msg list: the msg should be in it, and should be the only one */ - /*BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_chat_room_get_transient_messages(chat_room)), 1, unsigned int, "%u"); - BC_ASSERT_PTR_EQUAL(bctbx_list_nth_data(linphone_chat_room_get_transient_messages(chat_room),0), msg);*/ + BC_ASSERT_EQUAL(_linphone_chat_room_get_transient_message_count(chat_room), 1, int, "%d"); + BC_ASSERT_PTR_EQUAL(_linphone_chat_room_get_first_transient_message(chat_room), msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageNotDelivered,1)); /*BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageInProgress,1, int, "%d");*/ BC_ASSERT_EQUAL(pauline->stat.number_of_LinphoneMessageReceived,0, int, "%d"); /* the msg should have been discarded from transient list after an error */ - //BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(linphone_chat_room_get_transient_messages(chat_room)), 0, unsigned int, "%u"); + BC_ASSERT_EQUAL(_linphone_chat_room_get_transient_message_count(chat_room), 0, int, "%d"); sal_set_send_error(linphone_core_get_sal(marie->lc), 0); @@ -436,6 +435,7 @@ static void text_message_with_send_error(void) { linphone_core_refresh_registers(marie->lc); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneRegistrationOk,marie->stat.number_of_LinphoneRegistrationOk + 1)); + linphone_chat_message_unref(msg); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }