summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-12-24 22:49:06 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-12-24 22:49:06 (GMT)
commit21532c3557a3dc43f5f0376bf6554f6895c71a03 (patch)
treec073034e5c0a81937c71f6de60009697d8f24ab9 /Swift/Controllers
parentf08d7dc30a1242ea5a148377c5593188a8fb1317 (diff)
downloadswift-contrib-21532c3557a3dc43f5f0376bf6554f6895c71a03.zip
swift-contrib-21532c3557a3dc43f5f0376bf6554f6895c71a03.tar.bz2
Some more tests for the chat routing.
Resolves: #140
Diffstat (limited to 'Swift/Controllers')
-rw-r--r--Swift/Controllers/UnitTest/ChatsManagerTest.cpp51
1 files changed, 48 insertions, 3 deletions
diff --git a/Swift/Controllers/UnitTest/ChatsManagerTest.cpp b/Swift/Controllers/UnitTest/ChatsManagerTest.cpp
index 6f6958e..071cd5b 100644
--- a/Swift/Controllers/UnitTest/ChatsManagerTest.cpp
+++ b/Swift/Controllers/UnitTest/ChatsManagerTest.cpp
@@ -26,7 +26,10 @@ using namespace Swift;
class ChatsManagerTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(ChatsManagerTest);
- CPPUNIT_TEST(testFirstOpenWindow);
+ CPPUNIT_TEST(testFirstOpenWindowIncoming);
+ CPPUNIT_TEST(testFirstOpenWindowOutgoing);
+ CPPUNIT_TEST(testFirstOpenWindowBareToFull);
+ CPPUNIT_TEST(testSecondWindow);
CPPUNIT_TEST_SUITE_END();
public:
@@ -58,14 +61,13 @@ public:
delete presenceOracle_;
delete nickResolver_;
delete treeWidgetFactory_;
- //delete chatWindowFactory_;
delete stanzaChannel_;
delete iqChannel_;
delete iqRouter_;
delete mocks_;
}
- void testFirstOpenWindow() {
+ void testFirstOpenWindowIncoming() {
JID messageJID("testling@test.com/resource1");
ChatWindow* window = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>();
@@ -76,6 +78,49 @@ public:
message->setBody("This is a legible message.");
manager_->handleIncomingMessage(message);
}
+
+ void testFirstOpenWindowOutgoing() {
+ String messageJIDString("testling@test.com");
+
+ ChatWindow* window = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>();
+ mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString)).Return(window);
+
+ manager_->handleChatRequest(messageJIDString);
+ }
+
+
+ void testFirstOpenWindowBareToFull() {
+ String bareJIDString("testling@test.com");
+ String fullJIDString("testling@test.com/resource1");
+
+ MockChatWindow* window = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>();
+ mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(bareJIDString)).Return(window);
+ manager_->handleChatRequest(bareJIDString);
+
+ boost::shared_ptr<Message> message(new Message());
+ message->setFrom(JID(fullJIDString));
+ message->setBody("This is a legible message.");
+ manager_->handleIncomingMessage(message);
+ /*FIXME: check the message got through. For now, checking that there isn't a new window created is useful enough.*/
+ //CPPUNIT_ASSERT_EQUAL(fullJIDString, window->name_);
+ }
+
+ void testSecondWindow() {
+ String messageJIDString1("testling1@test.com");
+
+ ChatWindow* window1 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>();
+ mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString1)).Return(window1);
+
+ manager_->handleChatRequest(messageJIDString1);
+
+ String messageJIDString2("testling2@test.com");
+
+ ChatWindow* window2 = new MockChatWindow();//mocks_->InterfaceMock<ChatWindow>();
+ mocks_->ExpectCall(chatWindowFactory_, ChatWindowFactory::createChatWindow).With(JID(messageJIDString2)).Return(window2);
+
+ manager_->handleChatRequest(messageJIDString2);
+ }
+
private:
JID jid_;