summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-05-07 07:59:39 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-05-07 07:59:39 (GMT)
commit5409f27bbc3b32a65b2feed3259b1cc15da888a3 (patch)
tree3f2475d0eac1e3679b5c48c0c3633264f0497700 /Swiften/Roster/UnitTest
parenta49e2a1d4d17c36fad6ac1d1313fac955f675a54 (diff)
downloadswift-contrib-5409f27bbc3b32a65b2feed3259b1cc15da888a3.zip
swift-contrib-5409f27bbc3b32a65b2feed3259b1cc15da888a3.tar.bz2
Fix hang on MUC users leaving
Diffstat (limited to 'Swiften/Roster/UnitTest')
-rw-r--r--Swiften/Roster/UnitTest/RosterTest.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/Swiften/Roster/UnitTest/RosterTest.cpp b/Swiften/Roster/UnitTest/RosterTest.cpp
index f9dff33..2697747 100644
--- a/Swiften/Roster/UnitTest/RosterTest.cpp
+++ b/Swiften/Roster/UnitTest/RosterTest.cpp
@@ -17,6 +17,9 @@ class RosterTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(RosterTest);
CPPUNIT_TEST(testGetGroup);
+ CPPUNIT_TEST(testRemoveContact);
+ CPPUNIT_TEST(testRemoveSecondContact);
+ CPPUNIT_TEST(testRemoveSecondContactSameBare);
CPPUNIT_TEST_SUITE_END();
private:
@@ -51,6 +54,36 @@ class RosterTest : public CppUnit::TestFixture
}
+ void testRemoveContact() {
+ roster_->addContact(jid1_, "Bert", "group1");
+ CPPUNIT_ASSERT_EQUAL(String("Bert"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
+
+ roster_->removeContact(jid1_);
+ CPPUNIT_ASSERT_EQUAL(0, (int)((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren().size());
+ }
+
+ void testRemoveSecondContact() {
+ roster_->addContact(jid1_, "Bert", "group1");
+ roster_->addContact(jid2_, "Cookie", "group1");
+ CPPUNIT_ASSERT_EQUAL(String("Cookie"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName());
+
+ roster_->removeContact(jid2_);
+ CPPUNIT_ASSERT_EQUAL(1, (int)((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren().size());
+ CPPUNIT_ASSERT_EQUAL(String("Bert"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
+ }
+
+ void testRemoveSecondContactSameBare() {
+ JID jid4a("a@b/c");
+ JID jid4b("a@b/d");
+ roster_->addContact(jid4a, "Bert", "group1");
+ roster_->addContact(jid4b, "Cookie", "group1");
+ CPPUNIT_ASSERT_EQUAL(String("Cookie"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[1]->getDisplayName());
+
+ roster_->removeContact(jid4b);
+ CPPUNIT_ASSERT_EQUAL(1, (int)((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren().size());
+ CPPUNIT_ASSERT_EQUAL(String("Bert"), ((GroupRosterItem*)roster_->getRoot()->getChildren()[0])->getChildren()[0]->getDisplayName());
+ }
+
};
CPPUNIT_TEST_SUITE_REGISTRATION(RosterTest);