From efe2cb6d20857573b58d3d3716fa7c8bc7925179 Mon Sep 17 00:00:00 2001 From: Benjamin Reis Date: Mon, 9 Oct 2017 17:18:15 +0200 Subject: [PATCH] add subject changed notify tests --- .../local-conference-event-handler.cpp | 3 - .../remote-conference-event-handler.cpp | 3 + tester/conference-event-tester.cpp | 61 ++++++++++++++++++- 3 files changed, 63 insertions(+), 4 deletions(-) diff --git a/src/conference/local-conference-event-handler.cpp b/src/conference/local-conference-event-handler.cpp index 8f46293ce..22b532b75 100644 --- a/src/conference/local-conference-event-handler.cpp +++ b/src/conference/local-conference-event-handler.cpp @@ -97,7 +97,6 @@ string LocalConferenceEventHandlerPrivate::createNotifyFullState () { string LocalConferenceEventHandlerPrivate::createNotifyParticipantAdded (const Address &addr) { string entity = this->conf->getConferenceAddress()->asStringUriOnly(); - string subject = this->conf->getSubject(); ConferenceType confInfo = ConferenceType(entity); UsersType users; confInfo.setUsers(users); @@ -115,7 +114,6 @@ string LocalConferenceEventHandlerPrivate::createNotifyParticipantAdded (const A string LocalConferenceEventHandlerPrivate::createNotifyParticipantRemoved (const Address &addr) { string entity = this->conf->getConferenceAddress()->asStringUriOnly(); - string subject = this->conf->getSubject(); ConferenceType confInfo = ConferenceType(entity); UsersType users; confInfo.setUsers(users); @@ -130,7 +128,6 @@ string LocalConferenceEventHandlerPrivate::createNotifyParticipantRemoved (const string LocalConferenceEventHandlerPrivate::createNotifyParticipantAdmined (const Address &addr, bool isAdmin) { string entity = this->conf->getConferenceAddress()->asStringUriOnly(); - string subject = this->conf->getSubject(); ConferenceType confInfo = ConferenceType(entity); UsersType users; confInfo.setUsers(users); diff --git a/src/conference/remote-conference-event-handler.cpp b/src/conference/remote-conference-event-handler.cpp index a409fe1d5..216e8e568 100644 --- a/src/conference/remote-conference-event-handler.cpp +++ b/src/conference/remote-conference-event-handler.cpp @@ -76,6 +76,9 @@ void RemoteConferenceEventHandler::notifyReceived(string xmlBody) { if(confInfo->getConferenceDescription().present() && confInfo->getConferenceDescription().get().getSubject().present()) d->listener->onSubjectChanged(confInfo->getConferenceDescription().get().getSubject().get()); + if(!confInfo->getUsers().present()) + return; + for (const auto &user : confInfo->getUsers()->getUser()) { LinphoneAddress *cAddr = linphone_core_interpret_url(d->core, user.getEntity()->c_str()); char *cAddrStr = linphone_address_as_string(cAddr); diff --git a/tester/conference-event-tester.cpp b/tester/conference-event-tester.cpp index 9cd2f8e09..b578aa018 100644 --- a/tester/conference-event-tester.cpp +++ b/tester/conference-event-tester.cpp @@ -489,6 +489,7 @@ void first_notify_parsing() { delete[] notify; + BC_ASSERT_STRING_EQUAL(tester.confSubject.c_str(), "Agenda: This month's goals"); BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d"); BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(bobAddr)) != tester.participants.end()); BC_ASSERT_TRUE(tester.participants.find(linphone_address_as_string(aliceAddr)) != tester.participants.end()); @@ -763,6 +764,7 @@ void send_first_notify() { CallSessionParams params; localConf.addParticipant(bobAddr, ¶ms, false); localConf.addParticipant(aliceAddr, ¶ms, false); + localConf.setSubject("A random test subject"); shared_ptr alice = localConf.findParticipant(aliceAddr); alice->setAdmin(true); LocalConferenceEventHandlerPrivate *localHandlerPrivate = L_GET_PRIVATE(localConf.getEventHandler()); @@ -773,6 +775,7 @@ void send_first_notify() { L_ATTR_GET(remoteHandlerPrivate, confAddress) = addr; tester.handler->notifyReceived(notify); + BC_ASSERT_STRING_EQUAL(tester.confSubject.c_str(), "A random test subject"); BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d"); BC_ASSERT_TRUE(tester.participants.find(bobAddr.asString()) != tester.participants.end()); BC_ASSERT_TRUE(tester.participants.find(aliceAddr.asString()) != tester.participants.end()); @@ -992,6 +995,61 @@ void send_unadmined_notify() { linphone_core_manager_destroy(pauline); } +void send_subject_changed_notify () { + LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc"); + LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); + char *identityStr = linphone_address_as_string(pauline->identity); + Address addr(identityStr); + bctbx_free(identityStr); + ConferenceEventTester tester(marie->lc, addr); + LocalConference localConf(pauline->lc, addr); + LinphoneAddress *cBobAddr = linphone_core_interpret_url(marie->lc, bobUri); + char *bobAddrStr = linphone_address_as_string(cBobAddr); + Address bobAddr(bobAddrStr); + bctbx_free(bobAddrStr); + linphone_address_unref(cBobAddr); + LinphoneAddress *cAliceAddr = linphone_core_interpret_url(marie->lc, aliceUri); + char *aliceAddrStr = linphone_address_as_string(cAliceAddr); + Address aliceAddr(aliceAddrStr); + bctbx_free(aliceAddrStr); + linphone_address_unref(cAliceAddr); + + CallSessionParams params; + localConf.addParticipant(bobAddr, ¶ms, false); + localConf.addParticipant(aliceAddr, ¶ms, false); + localConf.setSubject("A random test subject"); + shared_ptr alice = localConf.findParticipant(aliceAddr); + alice->setAdmin(true); + LocalConferenceEventHandlerPrivate *localHandlerPrivate = L_GET_PRIVATE(localConf.getEventHandler()); + L_ATTR_GET(static_cast(localConf), conferenceAddress) = addr; + string notify = localHandlerPrivate->createNotifyFullState(); + + RemoteConferenceEventHandlerPrivate *remoteHandlerPrivate = L_GET_PRIVATE(tester.handler); + L_ATTR_GET(remoteHandlerPrivate, confAddress) = addr; + tester.handler->notifyReceived(notify); + + BC_ASSERT_STRING_EQUAL(tester.confSubject.c_str(), "A random test subject"); + BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d"); + BC_ASSERT_TRUE(tester.participants.find(bobAddr.asString()) != tester.participants.end()); + BC_ASSERT_TRUE(tester.participants.find(aliceAddr.asString()) != tester.participants.end()); + BC_ASSERT_TRUE(!tester.participants.find(bobAddr.asString())->second); + BC_ASSERT_TRUE(tester.participants.find(aliceAddr.asString())->second); + + localConf.setSubject("Another random test subject..."); + notify = localHandlerPrivate->createNotifySubjectChanged(); + tester.handler->notifyReceived(notify); + + BC_ASSERT_STRING_EQUAL(tester.confSubject.c_str(), "Another random test subject..."); + BC_ASSERT_EQUAL(tester.participants.size(), 2, int, "%d"); + BC_ASSERT_TRUE(tester.participants.find(bobAddr.asString()) != tester.participants.end()); + BC_ASSERT_TRUE(tester.participants.find(aliceAddr.asString()) != tester.participants.end()); + BC_ASSERT_TRUE(!tester.participants.find(bobAddr.asString())->second); + BC_ASSERT_TRUE(tester.participants.find(aliceAddr.asString())->second); + + linphone_core_manager_destroy(marie); + linphone_core_manager_destroy(pauline); +} + test_t conference_event_tests[] = { TEST_NO_TAG("First notify parsing", first_notify_parsing), TEST_NO_TAG("First notify parsing wrong conf", first_notify_parsing_wrong_conf), @@ -1004,7 +1062,8 @@ test_t conference_event_tests[] = { TEST_NO_TAG("Send participant added notify", send_added_notify), TEST_NO_TAG("Send participant removed notify", send_removed_notify), TEST_NO_TAG("Send participant admined notify", send_admined_notify), - TEST_NO_TAG("Send participant unadmined notify", send_unadmined_notify) + TEST_NO_TAG("Send participant unadmined notify", send_unadmined_notify), + TEST_NO_TAG("Send subject changed notify", send_subject_changed_notify) }; test_suite_t conference_event_test_suite = {