summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/Controllers/Chat/UnitTest')
-rw-r--r--Swift/Controllers/Chat/UnitTest/MUCControllerTest.cpp61
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_;