summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp')
-rw-r--r--Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
index 8f6c3a8..e06a3c7 100644
--- a/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
+++ b/Swift/Controllers/Chat/UnitTest/ChatsManagerTest.cpp
@@ -749,61 +749,61 @@ public:
presence->setShow(StatusShow::None);
presence->setType(Presence::Unavailable);
stanzaChannel_->onPresenceReceived(presence);
CPPUNIT_ASSERT_EQUAL(std::string("participantA has gone offline."), MockChatWindow::bodyFromMessage(window->lastReplacedLastMessage_));
}
void testChatControllerMucPmUnavailableErrorHandling() {
auto mucJID = JID("test@rooms.test.com");
auto participantA = mucJID.withResource("participantA");
auto participantB = mucJID.withResource("participantB");
auto mucWindow = new MockChatWindow();
mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(mucJID, uiEventStream_).Return(mucWindow);
uiEventStream_->send(std::make_shared<JoinMUCUIEvent>(mucJID, participantB.getResource()));
CPPUNIT_ASSERT_EQUAL(true, mucWindow->mucType_.is_initialized());
auto window = new MockChatWindow();
mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(participantA, uiEventStream_).Return(window);
uiEventStream_->send(std::make_shared<RequestChatUIEvent>(participantA));
CPPUNIT_ASSERT_EQUAL(false, window->mucType_.is_initialized());
Presence::ref presence = Presence::create();
presence->setFrom(participantA);
presence->setShow(StatusShow::Online);
stanzaChannel_->onPresenceReceived(presence);
CPPUNIT_ASSERT_EQUAL(std::string("participantA has become available."), MockChatWindow::bodyFromMessage(window->lastAddedPresence_));
// send message to participantA
auto messageBody = std::string("message body to send");
window->onSendMessageRequest(messageBody, false);
- auto sendMessageStanza = stanzaChannel_->getStanzaAtIndex<Message>(2);
+ auto sendMessageStanza = stanzaChannel_->getStanzaAtIndex<Message>(3);
CPPUNIT_ASSERT_EQUAL(messageBody, *sendMessageStanza->getBody());
// receive reply with error
auto messageErrorReply = std::make_shared<Message>();
messageErrorReply->setID(stanzaChannel_->getNewIQID());
messageErrorReply->setType(Message::Error);
messageErrorReply->setFrom(participantA);
messageErrorReply->setTo(jid_);
messageErrorReply->addPayload(std::make_shared<ErrorPayload>(ErrorPayload::ItemNotFound, ErrorPayload::Cancel, "Recipient not in room"));
auto lastMUCWindowErrorMessageBeforeError = MockChatWindow::bodyFromMessage(mucWindow->lastAddedErrorMessage_);
manager_->handleIncomingMessage(messageErrorReply);
// assert that error is not routed to MUC window
CPPUNIT_ASSERT_EQUAL(lastMUCWindowErrorMessageBeforeError, MockChatWindow::bodyFromMessage(mucWindow->lastAddedErrorMessage_));
// assert that error is routed to PM
CPPUNIT_ASSERT_EQUAL(std::string("This user could not be found in the room."), MockChatWindow::bodyFromMessage(window->lastAddedErrorMessage_));
}
void testLocalMUCServiceDiscoveryResetOnDisconnect() {
JID ownJID("test@test.com/resource");
JID sender("foo@test.com");
manager_->setOnline(true);
// Open chat window to a sender.
MockChatWindow* window = new MockChatWindow();
mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(sender, uiEventStream_).Return(window);
uiEventStream_->send(std::make_shared<RequestChatUIEvent>(sender));
@@ -1510,61 +1510,65 @@ public:
mucMirrored->addPayload(std::make_shared<Replace>("fooBlaID_2"));
manager_->handleIncomingMessage(mucMirrored);
}
CPPUNIT_ASSERT_EQUAL(std::string("Some correctly spelled message."), window->bodyFromMessage(window->lastReplacedMessage_));
}
void impromptuChatSetup(MockChatWindow* window) {
stanzaChannel_->uniqueIDs_ = true;
JID mucJID("795B7BBE-9099-4A0D-81BA-C816F78E275C@test.com");
manager_->setOnline(true);
std::shared_ptr<IQ> infoRequest = std::dynamic_pointer_cast<IQ>(stanzaChannel_->sentStanzas[1]);
CPPUNIT_ASSERT(infoRequest);
std::shared_ptr<IQ> infoResponse = IQ::createResult(infoRequest->getFrom(), infoRequest->getTo(), infoRequest->getID());
DiscoInfo info;
info.addIdentity(DiscoInfo::Identity("Shakespearean Chat Service", "conference", "text"));
info.addFeature("http://jabber.org/protocol/muc");
infoResponse->addPayload(std::make_shared<DiscoInfo>(info));
stanzaChannel_->onIQReceived(infoResponse);
std::vector<JID> jids;
jids.emplace_back("foo@test.com");
jids.emplace_back("bar@test.com");
mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(mucJID, uiEventStream_).Return(window);
uiEventStream_->send(std::make_shared<CreateImpromptuMUCUIEvent>(jids, mucJID, ""));
CPPUNIT_ASSERT_EQUAL(std::string("bar@test.com, foo@test.com"), manager_->getRecentChats()[0].getTitle());
- auto mucJoinPresence = std::dynamic_pointer_cast<Presence>(stanzaChannel_->sentStanzas[2]);
+ // Check the MUC security marking request
+ auto mucInfoRequest = std::dynamic_pointer_cast<IQ>(stanzaChannel_->sentStanzas[2]);
+ CPPUNIT_ASSERT(mucInfoRequest);
+
+ auto mucJoinPresence = std::dynamic_pointer_cast<Presence>(stanzaChannel_->sentStanzas[3]);
CPPUNIT_ASSERT(mucJoinPresence);
// MUC presence reply
auto mucResponse = Presence::create();
mucResponse->setTo(jid_);
mucResponse->setFrom(mucJoinPresence->getTo());
mucResponse->addPayload([]() {
auto mucUser = std::make_shared<MUCUserPayload>();
mucUser->addItem(MUCItem(MUCOccupant::Member, MUCOccupant::Participant));
mucUser->addStatusCode(MUCUserPayload::StatusCode(110));
mucUser->addStatusCode(MUCUserPayload::StatusCode(210));
return mucUser;
}());
stanzaChannel_->onPresenceReceived(mucResponse);
// Before people join the impromptu room, the title is based on names coming from Roster
CPPUNIT_ASSERT_EQUAL(std::string("bar@test.com, foo@test.com"), manager_->getRecentChats()[0].getTitle());
auto mucParticipantJoined = [&](const JID& jid) {
auto participantJoinedPresence = Presence::create();
participantJoinedPresence->setTo(jid_);
participantJoinedPresence->setFrom(mucJID.withResource(jid.toString()));
auto mucUser = std::make_shared<MUCUserPayload>();
mucUser->addItem(MUCItem(MUCOccupant::Member, MUCOccupant::Participant));
participantJoinedPresence->addPayload(mucUser);
return participantJoinedPresence;
};
for (const auto& participantJID : jids) {
stanzaChannel_->onPresenceReceived(mucParticipantJoined(participantJID));