summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk>2009-07-23 04:26:50 (GMT)
committerAndre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk>2009-07-23 04:26:50 (GMT)
commit979ff78a74bec16d8a0c08f9f51251a60ec60922 (patch)
tree6cff4793f4c210c9536cdd90bf9f6e820a5b585e
parentc581d3303f4d49fbe076f7e0de1ace4fb339c635 (diff)
downloadtelepathy-qt4-979ff78a74bec16d8a0c08f9f51251a60ec60922.tar.gz
telepathy-qt4-979ff78a74bec16d8a0c08f9f51251a60ec60922.tar.xz
roster-groups example: Added tests for adding contacts to a contact list group.
-rw-r--r--tests/dbus/conn-roster-groups.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/dbus/conn-roster-groups.cpp b/tests/dbus/conn-roster-groups.cpp
index e6fbc8b..ebe6385 100644
--- a/tests/dbus/conn-roster-groups.cpp
+++ b/tests/dbus/conn-roster-groups.cpp
@@ -24,11 +24,12 @@ class TestConnRosterGroups : public Test
public:
TestConnRosterGroups(QObject *parent = 0)
- : Test(parent), mConnService(0)
+ : Test(parent), mConnService(0), mContactsAddedToGroup(0)
{ }
protected Q_SLOTS:
void onGroupAdded(const QString &group);
+ void onContactAddedToGroup(const QString &group);
void expectConnInvalidated();
private Q_SLOTS:
@@ -46,6 +47,7 @@ private:
ConnectionPtr mConn;
QString mGroupAdded;
+ int mContactsAddedToGroup;
};
void TestConnRosterGroups::onGroupAdded(const QString &group)
@@ -54,6 +56,12 @@ void TestConnRosterGroups::onGroupAdded(const QString &group)
mLoop->exit(0);
}
+void TestConnRosterGroups::onContactAddedToGroup(const QString &group)
+{
+ mContactsAddedToGroup++;
+ mLoop->exit(0);
+}
+
void TestConnRosterGroups::expectConnInvalidated()
{
mLoop->exit(0);
@@ -187,6 +195,24 @@ void TestConnRosterGroups::testRosterGroups()
groups = contactManager->allKnownGroups();
groups.sort();
QCOMPARE(groups, expectedGroups);
+
+ // add Montreal contacts to group foo
+ Contacts contacts = contactManager->groupContacts("Montreal");
+ foreach (const ContactPtr &contact, contacts) {
+ QVERIFY(connect(contact.data(),
+ SIGNAL(addedToGroup(const QString&)),
+ SLOT(onContactAddedToGroup(const QString&))));
+ }
+ QVERIFY(connect(contactManager->groupAddContacts(group, contacts.toList()),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
+ QCOMPARE(mLoop->exec(), 0);
+ while (mContactsAddedToGroup != contacts.size()) {
+ QCOMPARE(mLoop->exec(), 0);
+ }
+ foreach (const ContactPtr &contact, contacts) {
+ QVERIFY(contact->groups().contains(group));
+ }
}
void TestConnRosterGroups::cleanup()