diff options
author | Joanna Hulboj <joanna.hulboj@isode.com> | 2017-02-15 16:21:26 (GMT) |
---|---|---|
committer | Kevin Smith <kevin.smith@isode.com> | 2017-02-23 18:07:40 (GMT) |
commit | 3861c418f95555a623d3e8005c75da9b9bbcd1e1 (patch) | |
tree | d8fbfb1bb6a1a3b1c5d620f0e25d41df215467d1 /Swift/Controllers/Chat/UnitTest | |
parent | 8803538bc29a3b68d3c69d900f41ddd1b383cec6 (diff) | |
download | swift-3861c418f95555a623d3e8005c75da9b9bbcd1e1.zip swift-3861c418f95555a623d3e8005c75da9b9bbcd1e1.tar.bz2 |
Change the logic of displaying chat room subject
Test-Information:
Run Swift and join any MUC room, on join there is no information
displayed regarding room subject.
Choose "Change subject", the following information is displayed
in the chat window: "The room subject
has been removed" after the subject was removed, or "The room subject is
now: some subject" after the room subject was set to "some subject".
Run Swift join any MUC room, disconnect from server (using another Swift
client change subject to "Test") after reconnecting the following
information is displayed in chat window: "The room subject is
now: Test"
Change-Id: Ice901697a6a381464d694147b17830b4e62c8198
Diffstat (limited to 'Swift/Controllers/Chat/UnitTest')
-rw-r--r-- | Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp index 59dcd77..dad021f 100644 --- a/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp +++ b/Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp @@ -64,6 +64,7 @@ class MUCControllerTest : public CppUnit::TestFixture { CPPUNIT_TEST(testSubjectChangeIncorrectC); CPPUNIT_TEST(testHandleOccupantNicknameChanged); CPPUNIT_TEST(testHandleOccupantNicknameChangedRoster); + CPPUNIT_TEST(testHandleChangeSubjectRequest); CPPUNIT_TEST_SUITE_END(); public: @@ -135,6 +136,27 @@ public: stanzaChannel_->onPresenceReceived(presence); } + void joinCompleted() { + std::string messageBody("test message"); + window_->onSendMessageRequest(messageBody, false); + std::shared_ptr<Stanza> rawStanza = stanzaChannel_->sentStanzas[stanzaChannel_->sentStanzas.size() - 1]; + Message::ref message = std::dynamic_pointer_cast<Message>(rawStanza); + CPPUNIT_ASSERT(stanzaChannel_->isAvailable()); /* Otherwise will prevent sends. */ + CPPUNIT_ASSERT(message); + CPPUNIT_ASSERT_EQUAL(messageBody, message->getBody().get_value_or("")); + + { + Message::ref message = std::make_shared<Message>(); + message->setType(Message::Groupchat); + message->setTo(self_); + message->setFrom(mucJID_.withResource("SomeNickname")); + message->setID(iqChannel_->getNewIQID()); + message->setSubject("Initial"); + + controller_->handleIncomingMessage(std::make_shared<MessageEvent>(message)); + } + } + void testAddressedToSelf() { finishJoin(); Message::ref message(new Message()); @@ -404,13 +426,7 @@ public: } void testSubjectChangeCorrect() { - std::string messageBody("test message"); - window_->onSendMessageRequest(messageBody, false); - std::shared_ptr<Stanza> rawStanza = stanzaChannel_->sentStanzas[stanzaChannel_->sentStanzas.size() - 1]; - Message::ref message = std::dynamic_pointer_cast<Message>(rawStanza); - CPPUNIT_ASSERT(stanzaChannel_->isAvailable()); /* Otherwise will prevent sends. */ - CPPUNIT_ASSERT(message); - CPPUNIT_ASSERT_EQUAL(messageBody, message->getBody().get_value_or("")); + joinCompleted(); { Message::ref message = std::make_shared<Message>(); @@ -429,13 +445,7 @@ public: * Test that message stanzas with subject element and non-empty body element do not cause a subject change. */ void testSubjectChangeIncorrectA() { - std::string messageBody("test message"); - window_->onSendMessageRequest(messageBody, false); - std::shared_ptr<Stanza> rawStanza = stanzaChannel_->sentStanzas[stanzaChannel_->sentStanzas.size() - 1]; - Message::ref message = std::dynamic_pointer_cast<Message>(rawStanza); - CPPUNIT_ASSERT(stanzaChannel_->isAvailable()); /* Otherwise will prevent sends. */ - CPPUNIT_ASSERT(message); - CPPUNIT_ASSERT_EQUAL(messageBody, message->getBody().get_value_or("")); + joinCompleted(); { Message::ref message = std::make_shared<Message>(); @@ -455,13 +465,7 @@ public: * Test that message stanzas with subject element and thread element do not cause a subject change. */ void testSubjectChangeIncorrectB() { - std::string messageBody("test message"); - window_->onSendMessageRequest(messageBody, false); - std::shared_ptr<Stanza> rawStanza = stanzaChannel_->sentStanzas[stanzaChannel_->sentStanzas.size() - 1]; - Message::ref message = std::dynamic_pointer_cast<Message>(rawStanza); - CPPUNIT_ASSERT(stanzaChannel_->isAvailable()); /* Otherwise will prevent sends. */ - CPPUNIT_ASSERT(message); - CPPUNIT_ASSERT_EQUAL(messageBody, message->getBody().get_value_or("")); + joinCompleted(); { Message::ref message = std::make_shared<Message>(); @@ -481,13 +485,7 @@ public: * Test that message stanzas with subject element and empty body element do not cause a subject change. */ void testSubjectChangeIncorrectC() { - std::string messageBody("test message"); - window_->onSendMessageRequest(messageBody, false); - std::shared_ptr<Stanza> rawStanza = stanzaChannel_->sentStanzas[stanzaChannel_->sentStanzas.size() - 1]; - Message::ref message = std::dynamic_pointer_cast<Message>(rawStanza); - CPPUNIT_ASSERT(stanzaChannel_->isAvailable()); /* Otherwise will prevent sends. */ - CPPUNIT_ASSERT(message); - CPPUNIT_ASSERT_EQUAL(messageBody, message->getBody().get_value_or("")); + joinCompleted(); { Message::ref message = std::make_shared<Message>(); @@ -575,6 +573,13 @@ public: } } + void testHandleChangeSubjectRequest() { + std::string testStr("New Subject"); + CPPUNIT_ASSERT_EQUAL(std::string(""), muc_->newSubjectSet_); + window_->onChangeSubjectRequest(testStr); + CPPUNIT_ASSERT_EQUAL(testStr, muc_->newSubjectSet_); + } + private: JID self_; JID mucJID_; |