summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-04-12 09:50:20 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-04-12 12:07:45 (GMT)
commit6dcca70b2f9ed13817e3600d96dbc9af3b597241 (patch)
tree94a9083a787d83d0d2bf987d2135238177e177a8 /Swift
parentb4604f14389aa6276f6d2c3bff2a873b4dfe0913 (diff)
downloadswift-6dcca70b2f9ed13817e3600d96dbc9af3b597241.zip
swift-6dcca70b2f9ed13817e3600d96dbc9af3b597241.tar.bz2
RosterController testing.
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/UnitTest/RosterControllerTest.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/Swift/Controllers/UnitTest/RosterControllerTest.cpp b/Swift/Controllers/UnitTest/RosterControllerTest.cpp
index e4d6775..1177bd7 100644
--- a/Swift/Controllers/UnitTest/RosterControllerTest.cpp
+++ b/Swift/Controllers/UnitTest/RosterControllerTest.cpp
@@ -29,6 +29,8 @@ class RosterControllerTest : public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE(RosterControllerTest);
CPPUNIT_TEST(testAdd);
+ CPPUNIT_TEST(testAddSubscription);
+ CPPUNIT_TEST(testRename);
CPPUNIT_TEST_SUITE_END();
public:
@@ -55,7 +57,6 @@ class RosterControllerTest : public CppUnit::TestFixture
void tearDown() {
delete rosterController_;
delete nickResolver_;
- delete treeWidgetFactory_;
delete mainWindowFactory_;
delete avatarManager_;
delete channel_;
@@ -64,6 +65,7 @@ class RosterControllerTest : public CppUnit::TestFixture
delete presenceOracle_;
delete stanzaChannel_;
delete uiEventStream_;
+ delete treeWidgetFactory_;
};
void testAdd() {
@@ -76,6 +78,36 @@ class RosterControllerTest : public CppUnit::TestFixture
//CPPUNIT_ASSERT_EQUAL(String("Bob"), xmppRoster_->getNameForJID(JID("foo@bar.com")));
};
+ void testAddSubscription() {
+ std::vector<String> groups;
+ JID jid("test@testdomain.com");
+ xmppRoster_->addContact(jid, "name", groups, RosterItemPayload::None);
+
+ CPPUNIT_ASSERT_EQUAL(1, (int)treeWidgetFactory_->getGroups().size());
+ CPPUNIT_ASSERT_EQUAL(1, (int)treeWidgetFactory_->getGroupMembers("Contacts").size());
+ xmppRoster_->addContact(jid, "name", groups, RosterItemPayload::To);
+ CPPUNIT_ASSERT_EQUAL(1, (int)treeWidgetFactory_->getGroups().size());
+ CPPUNIT_ASSERT_EQUAL(1, (int)treeWidgetFactory_->getGroupMembers("Contacts").size());
+
+ xmppRoster_->addContact(jid, "name", groups, RosterItemPayload::Both);
+ CPPUNIT_ASSERT_EQUAL(1, (int)treeWidgetFactory_->getGroups().size());
+ CPPUNIT_ASSERT_EQUAL(1, (int)treeWidgetFactory_->getGroupMembers("Contacts").size());
+
+ };
+
+ void testRename() {
+ std::vector<String> groups;
+ JID jid("test@testdomain.com");
+ xmppRoster_->addContact(jid, "name", groups, RosterItemPayload::Both);
+
+ CPPUNIT_ASSERT_EQUAL(1, (int)treeWidgetFactory_->getGroups().size());
+ CPPUNIT_ASSERT_EQUAL(1, (int)treeWidgetFactory_->getGroupMembers("Contacts").size());
+ xmppRoster_->addContact(jid, "NewName", groups, RosterItemPayload::Both);
+ CPPUNIT_ASSERT_EQUAL(1, (int)treeWidgetFactory_->getGroups().size());
+ CPPUNIT_ASSERT_EQUAL(1, (int)treeWidgetFactory_->getGroupMembers("Contacts").size());
+ CPPUNIT_ASSERT_EQUAL(String("NewName"), treeWidgetFactory_->getGroupMembers("Contacts")[0]->getText());
+ };
+
private:
JID jid_;
boost::shared_ptr<XMPPRoster> xmppRoster_;
@@ -91,3 +123,5 @@ class RosterControllerTest : public CppUnit::TestFixture
EventController* eventController_;
UIEventStream* uiEventStream_;
};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(RosterControllerTest);