/*
* conference-event-tester.cpp
* Copyright (C) 2017 Belledonne Communications SARL
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#include
#include
#include "address/identity-address.h"
#include "conference/conference-listener.h"
#include "conference/handlers/local-conference-event-handler-p.h"
#include "conference/handlers/remote-conference-event-handler-p.h"
#include "conference/local-conference-p.h"
#include "conference/local-conference.h"
#include "conference/participant-p.h"
#include "conference/remote-conference.h"
#include "liblinphone_tester.h"
#include "linphone/core.h"
#include "private.h"
#include "tester_utils.h"
#include "tools/private-access.h"
#include "tools/tester.h"
using namespace LinphonePrivate;
using namespace std;
static const char *first_notify = \
" "\
" "\
" "\
" "\
" Agenda: This month's goals "\
" "\
" "\
" http://sharepoint/salesgroup/ "\
" web-page "\
" "\
" "\
" "\
" "\
" "\
" 33 "\
" "\
" "\
" "\
" "\
" Bob Hoskins "\
" "\
" "\
" Bob's Laptop "\
" disconnected "\
" departed "\
" "\
" 2005-03-04T20:00:00Z "\
" bad voice quality "\
" sip:mike@example.com "\
" "\
" "\
" "\
" main audio "\
" audio "\
" 34567 "\
" 432424 "\
" sendrecv "\
" "\
" "\
" "\
" "\
" "\
" Alice "\
" "\
" admin "\
" participant "\
" "\
" "\
" "\
" connected "\
" dialed-out "\
" "\
" 2005-03-04T20:00:00Z "\
" sip:mike@example.com "\
" "\
" "\
" "\
" main audio "\
" audio "\
" 34567 "\
" 534232 "\
" sendrecv "\
" "\
" "\
" "\
" connected "\
" dialed-out "\
" "\
" 2005-03-04T20:00:00Z "\
" sip:mike@example.com "\
" "\
" "\
" "\
" main audio "\
" audio "\
" 34567 "\
" 534232 "\
" sendrecv "\
" "\
" "\
" "\
" "\
" ";
static const char *participant_added_notify = \
" "\
" "\
" "\
" "\
" Agenda: This month's goals "\
" "\
" "\
" http://sharepoint/salesgroup/ "\
" web-page "\
" "\
" "\
" "\
" "\
" "\
" 33 "\
" "\
" "\
" "\
" "\
" Bob Hoskins "\
" "\
" "\
" Frank's Laptop "\
" disconnected "\
" departed "\
" "\
" 2005-03-04T20:00:00Z "\
" bad voice quality "\
" sip:mike@example.com "\
" "\
" "\
" "\
" main audio "\
" audio "\
" 34567 "\
" 432424 "\
" sendrecv "\
" "\
" "\
" "\
" "\
" ";
static const char *participant_not_added_notify = \
" "\
" "\
" "\
" "\
" Agenda: This month's goals "\
" "\
" "\
" http://sharepoint/salesgroup/ "\
" web-page "\
" "\
" "\
" "\
" "\
" "\
" 33 "\
" "\
" "\
" "\
" "\
" Bob Hoskins "\
" "\
" "\
" Frank's Laptop "\
" disconnected "\
" departed "\
" "\
" 2005-03-04T20:00:00Z "\
" bad voice quality "\
" sip:mike@example.com "\
" "\
" "\
" "\
" main audio "\
" audio "\
" 34567 "\
" 432424 "\
" sendrecv "\
" "\
" "\
" "\
" "\
" ";
static const char *participant_deleted_notify = \
" "\
" "\
" "\
" "\
" Agenda: This month's goals "\
" "\
" "\
" http://sharepoint/salesgroup/ "\
" web-page "\
" "\
" "\
" "\
" "\
" "\
" 33 "\
" "\
" "\
" "\
" "\
" Bob Hoskins "\
" "\
" "\
" Bob's Laptop "\
" disconnected "\
" departed "\
" "\
" 2005-03-04T20:00:00Z "\
" bad voice quality "\
" sip:mike@example.com "\
" "\
" "\
" "\
" main audio "\
" audio "\
" 34567 "\
" 432424 "\
" sendrecv "\
" "\
" "\
" "\
" "\
" ";
static const char *participant_admined_notify = \
" "\
" "\
" "\
" "\
" Agenda: This month's goals "\
" "\
" "\
" http://sharepoint/salesgroup/ "\
" web-page "\
" "\
" "\
" "\
" "\
" "\
" 33 "\
" "\
" "\
" "\
" "\
" Bob Hoskins "\
" "\
" participant "\
" admin "\
" "\
" "\
" "\
" Bob's Laptop "\
" disconnected "\
" departed "\
" "\
" 2005-03-04T20:00:00Z "\
" bad voice quality "\
" sip:mike@example.com "\
" "\
" "\
" "\
" main audio "\
" audio "\
" 34567 "\
" 432424 "\
" sendrecv "\
" "\
" "\
" "\
" "\
" ";
static const char *participant_unadmined_notify = \
" "\
" "\
" "\
" "\
" Agenda: This month's goals "\
" "\
" "\
" http://sharepoint/salesgroup/ "\
" web-page "\
" "\
" "\
" "\
" "\
" "\
" 33 "\
" "\
" "\
" "\
" "\
" Alice Hoskins "\
" "\
" participant "\
" "\
" "\
" "\
" Alice's Laptop "\
" disconnected "\
" departed "\
" "\
" 2005-03-04T20:00:00Z "\
" bad voice quality "\
" sip:mike@example.com "\
" "\
" "\
" "\
" main audio "\
" audio "\
" 34567 "\
" 432424 "\
" sendrecv "\
" "\
" "\
" "\
" "\
" ";
static const char *bobUri = "sip:bob@example.com";
static const char *aliceUri = "sip:alice@example.com";
static const char *frankUri = "sip:frank@example.com";
static const char *confUri = "sips:conf233@example.com";
L_ENABLE_ATTR_ACCESS(LocalConferencePrivate, unique_ptr, eventHandler);
class ConferenceEventTester : public RemoteConference {
public:
ConferenceEventTester (const shared_ptr &core, const Address &confAddr);
~ConferenceEventTester ();
private:
void onConferenceCreated (const IdentityAddress &addr) override;
void onConferenceKeywordsChanged (const vector &keywords) override;
void onConferenceTerminated (const IdentityAddress &addr) override;
void onFirstNotifyReceived (const IdentityAddress &addr) override;
void onParticipantAdded (const shared_ptr &event, bool isFullState) override;
void onParticipantRemoved (const shared_ptr &event, bool isFullState) override;
void onParticipantSetAdmin (const shared_ptr &event, bool isFullState) override;
void onSubjectChanged (const shared_ptr &event, bool isFullState) override;
void onParticipantDeviceAdded (const shared_ptr &event, bool isFullState) override;
void onParticipantDeviceRemoved (const shared_ptr &event, bool isFullState) override;
public:
RemoteConferenceEventHandler *handler;
map participants;
map participantDevices;
string confSubject;
bool oneToOne = false;
};
ConferenceEventTester::ConferenceEventTester (const shared_ptr &core, const Address &confAddr)
: RemoteConference(core, confAddr, nullptr) {
handler = new RemoteConferenceEventHandler(this);
}
ConferenceEventTester::~ConferenceEventTester () {
delete handler;
}
void ConferenceEventTester::onConferenceCreated (const IdentityAddress &addr) {}
void ConferenceEventTester::onConferenceKeywordsChanged (const vector &keywords) {
for (const auto &k : keywords) {
if (k == "one-to-one")
oneToOne = true;
}
}
void ConferenceEventTester::onConferenceTerminated (const IdentityAddress &addr) {}
void ConferenceEventTester::onFirstNotifyReceived (const IdentityAddress &addr) {}
void ConferenceEventTester::onParticipantAdded (const shared_ptr &event, bool isFullState) {
(void)isFullState; // unused
const IdentityAddress addr = event->getParticipantAddress();
participants.insert(pair(addr.asString(), FALSE));
participantDevices.insert(pair(addr.asString(), 0));
}
void ConferenceEventTester::onParticipantRemoved (const shared_ptr &event, bool isFullState) {
(void)isFullState; // unused
const IdentityAddress addr = event->getParticipantAddress();
participants.erase(addr.asString());
participantDevices.erase(addr.asString());
}
void ConferenceEventTester::onParticipantSetAdmin (const shared_ptr &event, bool isFullState) {
(void)isFullState; // unused
const IdentityAddress addr = event->getParticipantAddress();
auto it = participants.find(addr.asString());
if (it != participants.end())
it->second = (event->getType() == EventLog::Type::ConferenceParticipantSetAdmin);
}
void ConferenceEventTester::onSubjectChanged(const shared_ptr &event, bool isFullState) {
(void)isFullState; // unused
confSubject = event->getSubject();
}
void ConferenceEventTester::onParticipantDeviceAdded (const shared_ptr &event, bool isFullState) {
(void)isFullState; // unused
const IdentityAddress addr = event->getParticipantAddress();
auto it = participantDevices.find(addr.asString());
if (it != participantDevices.end())
it->second++;
}
void ConferenceEventTester::onParticipantDeviceRemoved (const shared_ptr &event, bool isFullState) {
(void)isFullState; // unused
const IdentityAddress addr = event->getParticipantAddress();
auto it = participantDevices.find(addr.asString());
if (it != participantDevices.end() && it->second > 0)
it->second--;
}
void first_notify_parsing() {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneAddress *confAddress = linphone_core_interpret_url(marie->lc, confUri);
char *confAddressStr = linphone_address_as_string(confAddress);
Address addr(confAddressStr);
bctbx_free(confAddressStr);
linphone_address_unref(confAddress);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
size_t size = strlen(first_notify) + strlen(confUri);
char *notify = new char[size];
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
snprintf(notify, size, first_notify, confUri);
tester->handler->notifyReceived(notify);
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());
BC_ASSERT_TRUE(!tester->participants.find(linphone_address_as_string(bobAddr))->second);
BC_ASSERT_TRUE(tester->participants.find(linphone_address_as_string(aliceAddr))->second);
BC_ASSERT_EQUAL(tester->participantDevices.size(), 2, int, "%d");
BC_ASSERT_TRUE(tester->participantDevices.find(linphone_address_as_string(bobAddr)) != tester->participantDevices.end());
BC_ASSERT_TRUE(tester->participantDevices.find(linphone_address_as_string(aliceAddr)) != tester->participantDevices.end());
BC_ASSERT_EQUAL(tester->participantDevices.find(linphone_address_as_string(bobAddr))->second, 1, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.find(linphone_address_as_string(aliceAddr))->second, 2, int, "%d");
linphone_address_unref(bobAddr);
linphone_address_unref(aliceAddr);
tester = nullptr;
linphone_core_manager_destroy(marie);
}
void first_notify_parsing_wrong_conf() {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneAddress *confAddress = linphone_core_interpret_url(marie->lc, "sips:conf322@example.com");
char *confAddressStr = linphone_address_as_string(confAddress);
Address addr(confAddressStr);
bctbx_free(confAddressStr);
linphone_address_unref(confAddress);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
size_t size = strlen(first_notify) + strlen(confUri);
char *notify = new char[size];
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
snprintf(notify, size, first_notify, confUri);
tester->handler->notifyReceived(notify);
delete[] notify;
BC_ASSERT_EQUAL(tester->participants.size(), 0, int, "%d");
BC_ASSERT_FALSE(tester->participants.find(linphone_address_as_string(bobAddr)) != tester->participants.end());
BC_ASSERT_FALSE(tester->participants.find(linphone_address_as_string(aliceAddr)) != tester->participants.end());
linphone_address_unref(bobAddr);
linphone_address_unref(aliceAddr);
tester = nullptr;
linphone_core_manager_destroy(marie);
}
void participant_added_parsing() {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneAddress *confAddress = linphone_core_interpret_url(marie->lc, confUri);
char *confAddressStr = linphone_address_as_string(confAddress);
Address addr(confAddressStr);
bctbx_free(confAddressStr);
linphone_address_unref(confAddress);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
LinphoneAddress *frankAddr = linphone_core_interpret_url(marie->lc, frankUri);
size_t size = strlen(first_notify) + strlen(confUri);
char *notify = new char[size];
size_t size2 = strlen(participant_added_notify) + strlen(confUri);
char *notify_added = new char[size2];
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
snprintf(notify, size, first_notify, confUri);
tester->handler->notifyReceived(notify);
delete[] notify;
BC_ASSERT_EQUAL(tester->participants.size(), 2, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.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());
BC_ASSERT_TRUE(!tester->participants.find(linphone_address_as_string(bobAddr))->second);
BC_ASSERT_TRUE(tester->participants.find(linphone_address_as_string(aliceAddr))->second);
snprintf(notify_added, size2, participant_added_notify, confUri);
tester->handler->notifyReceived(notify_added);
delete[] notify_added;
BC_ASSERT_EQUAL(tester->participants.size(), 3, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.size(), 3, int, "%d");
BC_ASSERT_TRUE(tester->participants.find(linphone_address_as_string(frankAddr)) != tester->participants.end());
BC_ASSERT_TRUE(!tester->participants.find(linphone_address_as_string(frankAddr))->second);
linphone_address_unref(bobAddr);
linphone_address_unref(aliceAddr);
linphone_address_unref(frankAddr);
tester = nullptr;
linphone_core_manager_destroy(marie);
}
void participant_not_added_parsing() {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneAddress *confAddress = linphone_core_interpret_url(marie->lc, confUri);
char *confAddressStr = linphone_address_as_string(confAddress);
Address addr(confAddressStr);
bctbx_free(confAddressStr);
linphone_address_unref(confAddress);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
LinphoneAddress *frankAddr = linphone_core_interpret_url(marie->lc, frankUri);
size_t size = strlen(first_notify) + strlen(confUri);
char *notify = new char[size];
size_t size2 = strlen(participant_not_added_notify) + strlen(confUri);
char *notify_not_added = new char[size2];
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
snprintf(notify, size, first_notify, confUri);
tester->handler->notifyReceived(notify);
delete[] notify;
BC_ASSERT_EQUAL(tester->participants.size(), 2, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.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());
BC_ASSERT_TRUE(!tester->participants.find(linphone_address_as_string(bobAddr))->second);
BC_ASSERT_TRUE(tester->participants.find(linphone_address_as_string(aliceAddr))->second);
snprintf(notify_not_added, size2, participant_not_added_notify, confUri);
tester->handler->notifyReceived(notify_not_added);
delete[] notify_not_added;
BC_ASSERT_EQUAL(tester->participants.size(), 2, int, "%d");
BC_ASSERT_FALSE(tester->participants.find(linphone_address_as_string(frankAddr)) != tester->participants.end());
linphone_address_unref(bobAddr);
linphone_address_unref(aliceAddr);
linphone_address_unref(frankAddr);
tester = nullptr;
linphone_core_manager_destroy(marie);
}
void participant_deleted_parsing() {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneAddress *confAddress = linphone_core_interpret_url(marie->lc, confUri);
char *confAddressStr = linphone_address_as_string(confAddress);
Address addr(confAddressStr);
bctbx_free(confAddressStr);
linphone_address_unref(confAddress);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
size_t size = strlen(first_notify) + strlen(confUri);
char *notify = new char[size];
size_t size2 = strlen(participant_deleted_notify) + strlen(confUri);
char *notify_deleted = new char[size2];
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
snprintf(notify, size, first_notify, confUri);
tester->handler->notifyReceived(notify);
delete[] notify;
BC_ASSERT_EQUAL(tester->participants.size(), 2, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.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());
BC_ASSERT_TRUE(!tester->participants.find(linphone_address_as_string(bobAddr))->second);
BC_ASSERT_TRUE(tester->participants.find(linphone_address_as_string(aliceAddr))->second);
snprintf(notify_deleted, size2, participant_deleted_notify, confUri);
tester->handler->notifyReceived(notify_deleted);
delete[] notify_deleted;
BC_ASSERT_EQUAL(tester->participants.size(), 1, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.size(), 1, int, "%d");
BC_ASSERT_FALSE(tester->participants.find(linphone_address_as_string(bobAddr)) != tester->participants.end());
linphone_address_unref(bobAddr);
linphone_address_unref(aliceAddr);
tester = nullptr;
linphone_core_manager_destroy(marie);
}
void participant_admined_parsing() {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneAddress *confAddress = linphone_core_interpret_url(marie->lc, confUri);
char *confAddressStr = linphone_address_as_string(confAddress);
Address addr(confAddressStr);
bctbx_free(confAddressStr);
linphone_address_unref(confAddress);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
size_t size = strlen(first_notify) + strlen(confUri);
char *notify = new char[size];
size_t size2 = strlen(participant_admined_notify) + strlen(confUri);
char *notify_admined = new char[size2];
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
snprintf(notify, size, first_notify, confUri);
tester->handler->notifyReceived(notify);
delete[] notify;
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());
BC_ASSERT_TRUE(!tester->participants.find(linphone_address_as_string(bobAddr))->second);
BC_ASSERT_TRUE(tester->participants.find(linphone_address_as_string(aliceAddr))->second);
snprintf(notify_admined, size2, participant_admined_notify, confUri);
tester->handler->notifyReceived(notify_admined);
delete[] notify_admined;
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(bobAddr))->second);
linphone_address_unref(bobAddr);
linphone_address_unref(aliceAddr);
tester = nullptr;
linphone_core_manager_destroy(marie);
}
void participant_unadmined_parsing() {
LinphoneCoreManager *marie = linphone_core_manager_new("marie_rc");
LinphoneAddress *confAddress = linphone_core_interpret_url(marie->lc, confUri);
char *confAddressStr = linphone_address_as_string(confAddress);
Address addr(confAddressStr);
bctbx_free(confAddressStr);
linphone_address_unref(confAddress);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
LinphoneAddress *bobAddr = linphone_core_interpret_url(marie->lc, bobUri);
LinphoneAddress *aliceAddr = linphone_core_interpret_url(marie->lc, aliceUri);
size_t size = strlen(first_notify) + strlen(confUri);
char *notify = new char[size];
size_t size2 = strlen(participant_unadmined_notify) + strlen(confUri);
char *notify_unadmined = new char[size2];
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
snprintf(notify, size, first_notify, confUri);
tester->handler->notifyReceived(notify);
delete[] notify;
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());
BC_ASSERT_TRUE(!tester->participants.find(linphone_address_as_string(bobAddr))->second);
BC_ASSERT_TRUE(tester->participants.find(linphone_address_as_string(aliceAddr))->second);
snprintf(notify_unadmined, size2, participant_unadmined_notify, confUri);
tester->handler->notifyReceived(notify_unadmined);
delete[] notify_unadmined;
BC_ASSERT_EQUAL(tester->participants.size(), 2, int, "%d");
BC_ASSERT_TRUE(tester->participants.find(linphone_address_as_string(aliceAddr)) != tester->participants.end());
BC_ASSERT_TRUE(!tester->participants.find(linphone_address_as_string(aliceAddr))->second);
linphone_address_unref(bobAddr);
linphone_address_unref(aliceAddr);
tester = nullptr;
linphone_core_manager_destroy(marie);
}
void send_first_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);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
shared_ptr localConf = make_shared(pauline->lc->cppPtr, addr, nullptr);
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);
L_GET_PRIVATE(alice)->setAdmin(true);
LocalConferenceEventHandlerPrivate *localHandlerPrivate = L_GET_PRIVATE(
L_ATTR_GET(L_GET_PRIVATE(localConf), eventHandler)
);
const_cast(localConf->getConferenceAddress()) = addr;
string notify = localHandlerPrivate->createNotifyFullState();
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = 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);
tester = nullptr;
localConf = nullptr;
alice = nullptr;
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
void send_added_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);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
shared_ptr localConf = make_shared(pauline->lc->cppPtr, addr, nullptr);
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);
LinphoneAddress *cFrankAddr = linphone_core_interpret_url(marie->lc, frankUri);
char *frankAddrStr = linphone_address_as_string(cFrankAddr);
Address frankAddr(frankAddrStr);
bctbx_free(frankAddrStr);
linphone_address_unref(cFrankAddr);
CallSessionParams params;
localConf->addParticipant(bobAddr, ¶ms, false);
localConf->addParticipant(aliceAddr, ¶ms, false);
shared_ptr alice = localConf->findParticipant(aliceAddr);
L_GET_PRIVATE(alice)->setAdmin(true);
LocalConferenceEventHandlerPrivate *localHandlerPrivate = L_GET_PRIVATE(
L_ATTR_GET(L_GET_PRIVATE(localConf), eventHandler)
);
const_cast(localConf->getConferenceAddress()) = addr;
string notify = localHandlerPrivate->createNotifyFullState();
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
tester->handler->notifyReceived(notify);
BC_ASSERT_EQUAL(tester->participants.size(), 2, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.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);
notify = localHandlerPrivate->createNotifyParticipantAdded(frankAddr);
tester->handler->notifyReceived(notify);
BC_ASSERT_EQUAL(tester->participants.size(), 3, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.size(), 3, 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(frankAddr.asString()) != tester->participants.end());
BC_ASSERT_TRUE(!tester->participants.find(bobAddr.asString())->second);
BC_ASSERT_TRUE(tester->participants.find(aliceAddr.asString())->second);
BC_ASSERT_TRUE(!tester->participants.find(frankAddr.asString())->second);
tester = nullptr;
localConf = nullptr;
alice = nullptr;
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
void send_removed_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);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
shared_ptr localConf = make_shared(pauline->lc->cppPtr, addr, nullptr);
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);
shared_ptr alice = localConf->findParticipant(aliceAddr);
L_GET_PRIVATE(alice)->setAdmin(true);
LocalConferenceEventHandlerPrivate *localHandlerPrivate = L_GET_PRIVATE(
L_ATTR_GET(L_GET_PRIVATE(localConf), eventHandler)
);
const_cast(localConf->getConferenceAddress()) = addr;
string notify = localHandlerPrivate->createNotifyFullState();
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
tester->handler->notifyReceived(notify);
BC_ASSERT_EQUAL(tester->participants.size(), 2, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.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);
notify = localHandlerPrivate->createNotifyParticipantRemoved(bobAddr);
tester->handler->notifyReceived(notify);
BC_ASSERT_EQUAL(tester->participants.size(), 1, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.size(), 1, int, "%d");
BC_ASSERT_FALSE(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(aliceAddr.asString())->second);
tester = nullptr;
localConf = nullptr;
alice = nullptr;
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
void send_admined_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);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
shared_ptr localConf = make_shared(pauline->lc->cppPtr, addr, nullptr);
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);
shared_ptr alice = localConf->findParticipant(aliceAddr);
L_GET_PRIVATE(alice)->setAdmin(true);
LocalConferenceEventHandlerPrivate *localHandlerPrivate = L_GET_PRIVATE(
L_ATTR_GET(L_GET_PRIVATE(localConf), eventHandler)
);
const_cast(localConf->getConferenceAddress()) = addr;
string notify = localHandlerPrivate->createNotifyFullState();
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
tester->handler->notifyReceived(notify);
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);
notify = localHandlerPrivate->createNotifyParticipantAdminStatusChanged(bobAddr, true);
tester->handler->notifyReceived(notify);
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(aliceAddr.asString())->second);
BC_ASSERT_TRUE(tester->participants.find(bobAddr.asString())->second);
tester = nullptr;
localConf = nullptr;
alice = nullptr;
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
void send_unadmined_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);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
shared_ptr localConf = make_shared(pauline->lc->cppPtr, addr, nullptr);
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);
shared_ptr alice = localConf->findParticipant(aliceAddr);
L_GET_PRIVATE(alice)->setAdmin(true);
LocalConferenceEventHandlerPrivate *localHandlerPrivate = L_GET_PRIVATE(
L_ATTR_GET(L_GET_PRIVATE(localConf), eventHandler)
);
const_cast(localConf->getConferenceAddress()) = addr;
string notify = localHandlerPrivate->createNotifyFullState();
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
tester->handler->notifyReceived(notify);
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);
notify = localHandlerPrivate->createNotifyParticipantAdminStatusChanged(aliceAddr, false);
tester->handler->notifyReceived(notify);
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(aliceAddr.asString())->second);
BC_ASSERT_TRUE(!tester->participants.find(bobAddr.asString())->second);
tester = nullptr;
localConf = nullptr;
alice = nullptr;
linphone_core_manager_destroy(marie);
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);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
shared_ptr localConf = make_shared(pauline->lc->cppPtr, addr, nullptr);
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);
L_GET_PRIVATE(alice)->setAdmin(true);
LocalConferenceEventHandlerPrivate *localHandlerPrivate = L_GET_PRIVATE(
L_ATTR_GET(L_GET_PRIVATE(localConf), eventHandler)
);
const_cast(localConf->getConferenceAddress()) = addr;
string notify = localHandlerPrivate->createNotifyFullState();
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = 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_EQUAL(tester->handler->getLastNotify(), 1, int, "%d");
BC_ASSERT_EQUAL(localHandlerPrivate->getLastNotify(), 1, 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_EQUAL(tester->handler->getLastNotify(), 2, int, "%d");
BC_ASSERT_EQUAL(localHandlerPrivate->getLastNotify(), 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);
tester = nullptr;
localConf = nullptr;
alice = nullptr;
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
void send_device_added_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);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
shared_ptr localConf = make_shared(pauline->lc->cppPtr, addr, nullptr);
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);
shared_ptr alice = localConf->findParticipant(aliceAddr);
L_GET_PRIVATE(alice)->setAdmin(true);
LocalConferenceEventHandlerPrivate *localHandlerPrivate = L_GET_PRIVATE(
L_ATTR_GET(L_GET_PRIVATE(localConf), eventHandler)
);
const_cast(localConf->getConferenceAddress()) = addr;
string notify = localHandlerPrivate->createNotifyFullState();
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
tester->handler->notifyReceived(notify);
BC_ASSERT_EQUAL(tester->participantDevices.size(), 2, int, "%d");
BC_ASSERT_TRUE(tester->participantDevices.find(bobAddr.asString()) != tester->participantDevices.end());
BC_ASSERT_TRUE(tester->participantDevices.find(aliceAddr.asString()) != tester->participantDevices.end());
BC_ASSERT_EQUAL(tester->participantDevices.find(bobAddr.asString())->second, 0, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.find(aliceAddr.asString())->second, 0, int, "%d");
BC_ASSERT_TRUE(!tester->participants.find(bobAddr.asString())->second);
BC_ASSERT_TRUE(tester->participants.find(aliceAddr.asString())->second);
notify = localHandlerPrivate->createNotifyParticipantDeviceAdded(aliceAddr, aliceAddr);
tester->handler->notifyReceived(notify);
BC_ASSERT_EQUAL(tester->participantDevices.size(), 2, int, "%d");
BC_ASSERT_TRUE(tester->participantDevices.find(bobAddr.asString()) != tester->participantDevices.end());
BC_ASSERT_TRUE(tester->participantDevices.find(aliceAddr.asString()) != tester->participantDevices.end());
BC_ASSERT_EQUAL(tester->participantDevices.find(bobAddr.asString())->second, 0, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.find(aliceAddr.asString())->second, 1, int, "%d");
BC_ASSERT_TRUE(!tester->participants.find(bobAddr.asString())->second);
BC_ASSERT_TRUE(tester->participants.find(aliceAddr.asString())->second);
tester = nullptr;
localConf = nullptr;
alice = nullptr;
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
void send_device_removed_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);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
shared_ptr localConf = make_shared(pauline->lc->cppPtr, addr, nullptr);
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);
L_GET_PRIVATE(alice)->setAdmin(true);
LocalConferenceEventHandlerPrivate *localHandlerPrivate = L_GET_PRIVATE(
L_ATTR_GET(L_GET_PRIVATE(localConf), eventHandler)
);
const_cast(localConf->getConferenceAddress()) = addr;
string notify = localHandlerPrivate->createNotifyFullState();
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
tester->handler->notifyReceived(notify);
BC_ASSERT_EQUAL(tester->participantDevices.size(), 2, int, "%d");
BC_ASSERT_TRUE(tester->participantDevices.find(bobAddr.asString()) != tester->participantDevices.end());
BC_ASSERT_TRUE(tester->participantDevices.find(aliceAddr.asString()) != tester->participantDevices.end());
BC_ASSERT_EQUAL(tester->participantDevices.find(bobAddr.asString())->second, 0, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.find(aliceAddr.asString())->second, 0, int, "%d");
BC_ASSERT_TRUE(!tester->participants.find(bobAddr.asString())->second);
BC_ASSERT_TRUE(tester->participants.find(aliceAddr.asString())->second);
notify = localHandlerPrivate->createNotifyParticipantDeviceAdded(aliceAddr, aliceAddr);
tester->handler->notifyReceived(notify);
BC_ASSERT_EQUAL(tester->participantDevices.size(), 2, int, "%d");
BC_ASSERT_TRUE(tester->participantDevices.find(bobAddr.asString()) != tester->participantDevices.end());
BC_ASSERT_TRUE(tester->participantDevices.find(aliceAddr.asString()) != tester->participantDevices.end());
BC_ASSERT_EQUAL(tester->participantDevices.find(bobAddr.asString())->second, 0, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.find(aliceAddr.asString())->second, 1, int, "%d");
BC_ASSERT_TRUE(!tester->participants.find(bobAddr.asString())->second);
BC_ASSERT_TRUE(tester->participants.find(aliceAddr.asString())->second);
notify = localHandlerPrivate->createNotifyParticipantDeviceRemoved(aliceAddr, aliceAddr);
tester->handler->notifyReceived(notify);
BC_ASSERT_EQUAL(tester->participantDevices.size(), 2, int, "%d");
BC_ASSERT_TRUE(tester->participantDevices.find(bobAddr.asString()) != tester->participantDevices.end());
BC_ASSERT_TRUE(tester->participantDevices.find(aliceAddr.asString()) != tester->participantDevices.end());
BC_ASSERT_EQUAL(tester->participantDevices.find(bobAddr.asString())->second, 0, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.find(aliceAddr.asString())->second, 0, int, "%d");
BC_ASSERT_TRUE(!tester->participants.find(bobAddr.asString())->second);
BC_ASSERT_TRUE(tester->participants.find(aliceAddr.asString())->second);
notify = localHandlerPrivate->createNotifyParticipantDeviceRemoved(aliceAddr, aliceAddr);
tester->handler->notifyReceived(notify);
BC_ASSERT_EQUAL(tester->participantDevices.size(), 2, int, "%d");
BC_ASSERT_TRUE(tester->participantDevices.find(bobAddr.asString()) != tester->participantDevices.end());
BC_ASSERT_TRUE(tester->participantDevices.find(aliceAddr.asString()) != tester->participantDevices.end());
BC_ASSERT_EQUAL(tester->participantDevices.find(bobAddr.asString())->second, 0, int, "%d");
BC_ASSERT_EQUAL(tester->participantDevices.find(aliceAddr.asString())->second, 0, int, "%d");
BC_ASSERT_TRUE(!tester->participants.find(bobAddr.asString())->second);
BC_ASSERT_TRUE(tester->participants.find(aliceAddr.asString())->second);
tester = nullptr;
localConf = nullptr;
alice = nullptr;
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
void one_to_one_keyword () {
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);
shared_ptr tester = make_shared(marie->lc->cppPtr, addr);
shared_ptr localConf = make_shared(pauline->lc->cppPtr, addr, nullptr);
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);
CallSessionParams params;
localConf->addParticipant(bobAddr, ¶ms, false);
LocalConferenceEventHandlerPrivate *localHandlerPrivate = L_GET_PRIVATE(
L_ATTR_GET(L_GET_PRIVATE(localConf), eventHandler)
);
const_cast(localConf->getConferenceAddress()) = addr;
string notify = localHandlerPrivate->createNotifyFullState(-1, true);
const_cast(tester->handler->getChatRoomId().getPeerAddress()) = addr;
tester->handler->notifyReceived(notify);
BC_ASSERT_EQUAL(tester->participantDevices.size(), 1, int, "%d");
BC_ASSERT_TRUE(tester->participantDevices.find(bobAddr.asString()) != tester->participantDevices.end());
BC_ASSERT_EQUAL(tester->participantDevices.find(bobAddr.asString())->second, 0, int, "%d");
BC_ASSERT_TRUE(tester->oneToOne);
tester = nullptr;
localConf = nullptr;
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),
TEST_NO_TAG("Participant added", participant_added_parsing),
TEST_NO_TAG("Participant not added", participant_not_added_parsing),
TEST_NO_TAG("Participant deleted", participant_deleted_parsing),
TEST_NO_TAG("Participant admined", participant_admined_parsing),
TEST_NO_TAG("Participant unadmined", participant_unadmined_parsing),
TEST_NO_TAG("Send first notify", send_first_notify),
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 subject changed notify", send_subject_changed_notify),
TEST_NO_TAG("Send device added notify", send_device_added_notify),
TEST_NO_TAG("Send device removed notify", send_device_removed_notify),
TEST_NO_TAG("one-to-one keyword", one_to_one_keyword)
};
test_suite_t conference_event_test_suite = {
"Conference event",
nullptr,
nullptr,
liblinphone_tester_before_each,
liblinphone_tester_after_each,
sizeof(conference_event_tests) / sizeof(conference_event_tests[0]), conference_event_tests
};