summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2009-11-22 11:31:57 (GMT)
committerKevin Smith <git@kismith.co.uk>2009-11-22 11:32:21 (GMT)
commit4bfb75b3dd40bdbfc3a142dc43ecfbebedcc4d3a (patch)
tree5eed81cdd65d47a30deaa9400a13b43d678f0e0c /Swiften
parenta393a4ac64abb24b0fc2cb0e3e154706013d7803 (diff)
downloadswift-contrib-4bfb75b3dd40bdbfc3a142dc43ecfbebedcc4d3a.zip
swift-contrib-4bfb75b3dd40bdbfc3a142dc43ecfbebedcc4d3a.tar.bz2
Testing the XMPPRoster.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Roster/UnitTest/XMPPRosterTest.cpp46
1 files changed, 42 insertions, 4 deletions
diff --git a/Swiften/Roster/UnitTest/XMPPRosterTest.cpp b/Swiften/Roster/UnitTest/XMPPRosterTest.cpp
index 51166b9..96de30c 100644
--- a/Swiften/Roster/UnitTest/XMPPRosterTest.cpp
+++ b/Swiften/Roster/UnitTest/XMPPRosterTest.cpp
@@ -71,6 +71,8 @@ class XMPPRosterTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(XMPPRosterTest);
CPPUNIT_TEST(testJIDAdded);
+ CPPUNIT_TEST(testJIDRemoved);
+ CPPUNIT_TEST(testJIDUpdated);
CPPUNIT_TEST_SUITE_END();
private:
@@ -104,21 +106,57 @@ class XMPPRosterTest : public CppUnit::TestFixture
CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent());
CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID());
CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid1_));
- //CPPUNIT_ASSERT_EQUAL(groups1_, roster_->getGroupsForJID(jid1_));
+ CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_));
handler_->reset();
roster_->addContact(jid2_, "NameTwo", groups1_);
CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent());
CPPUNIT_ASSERT_EQUAL(jid2_, handler_->getLastJID());
CPPUNIT_ASSERT_EQUAL(String("NameTwo"), roster_->getNameForJID(jid2_));
CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid1_));
- //CPPUNIT_ASSERT_EQUAL(groups1_, roster_->getGroupsForJID(jid2_));
- //CPPUNIT_ASSERT_EQUAL(groups1_, roster_->getGroupsForJID(jid1_));
+ CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid2_));
+ CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_));
handler_->reset();
roster_->addContact(jid3_, "NewName", groups2_);
CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent());
CPPUNIT_ASSERT_EQUAL(jid3_, handler_->getLastJID());
CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid3_));
- //CPPUNIT_ASSERT_EQUAL(groups2_, roster_->getGroupsForJID(jid3_));
+ CPPUNIT_ASSERT(groups2_ == roster_->getGroupsForJID(jid3_));
+ }
+
+ void testJIDRemoved() {
+ roster_->addContact(jid1_, "NewName", groups1_);
+ handler_->reset();
+ roster_->removeContact(jid1_);
+ CPPUNIT_ASSERT_EQUAL(Remove, handler_->getLastEvent());
+ CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID());
+ handler_->reset();
+ roster_->addContact(jid1_, "NewName2", groups1_);
+ CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent());
+ CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID());
+ CPPUNIT_ASSERT_EQUAL(String("NewName2"), roster_->getNameForJID(jid1_));
+ roster_->addContact(jid2_, "NewName3", groups1_);
+ handler_->reset();
+ roster_->removeContact(jid2_);
+ CPPUNIT_ASSERT_EQUAL(Remove, handler_->getLastEvent());
+ CPPUNIT_ASSERT_EQUAL(jid2_, handler_->getLastJID());
+ handler_->reset();
+ roster_->removeContact(jid1_);
+ CPPUNIT_ASSERT_EQUAL(Remove, handler_->getLastEvent());
+ CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID());
+ }
+
+ void testJIDUpdated() {
+ roster_->addContact(jid1_, "NewName", groups1_);
+ CPPUNIT_ASSERT_EQUAL(Add, handler_->getLastEvent());
+ CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID());
+ CPPUNIT_ASSERT_EQUAL(String("NewName"), roster_->getNameForJID(jid1_));
+ CPPUNIT_ASSERT(groups1_ == roster_->getGroupsForJID(jid1_));
+ handler_->reset();
+ roster_->addContact(jid1_, "NameTwo", groups2_);
+ CPPUNIT_ASSERT_EQUAL(Update, handler_->getLastEvent());
+ CPPUNIT_ASSERT_EQUAL(jid1_, handler_->getLastJID());
+ CPPUNIT_ASSERT_EQUAL(String("NameTwo"), roster_->getNameForJID(jid1_));
+ CPPUNIT_ASSERT(groups2_ == roster_->getGroupsForJID(jid1_));
}
};