[Telepathy-commits] [telepathy-qt4/master] Feature: Make it easy to handle Features.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Fri Mar 6 11:54:47 PST 2009


Now it's possible to pass a single feature, without creating a Features var,
to isReady/becomeReady methods.
---
 TelepathyQt4/Client/feature.h |    8 +++++++-
 tests/dbus/account-basics.cpp |   25 ++++++++++---------------
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/TelepathyQt4/Client/feature.h b/TelepathyQt4/Client/feature.h
index 6e2f22a..3334a64 100644
--- a/TelepathyQt4/Client/feature.h
+++ b/TelepathyQt4/Client/feature.h
@@ -53,7 +53,13 @@ private:
     QSharedDataPointer<Private> mPriv;
 };
 
-typedef QSet<Feature> Features;
+class Features : public QSet<Feature>
+{
+public:
+    Features() { }
+    Features(const Feature &feature) { insert(feature); }
+    Features(const QSet<Feature> &s) : QSet<Feature>(s) { }
+};
 
 inline Features operator|(const Feature &feature1, const Feature &feature2)
 {
diff --git a/tests/dbus/account-basics.cpp b/tests/dbus/account-basics.cpp
index 6a02b80..30491dd 100644
--- a/tests/dbus/account-basics.cpp
+++ b/tests/dbus/account-basics.cpp
@@ -98,12 +98,11 @@ void TestAccountBasics::testBasics()
 
     QCOMPARE(acc->displayName(), QString("foobar (account 0)"));
 
-    Features features = Features() << Account::FeatureAvatar;
-    QVERIFY(connect(acc->becomeReady(features),
+    QVERIFY(connect(acc->becomeReady(Account::FeatureAvatar),
                     SIGNAL(finished(Telepathy::Client::PendingOperation *)),
                     SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
     QCOMPARE(mLoop->exec(), 0);
-    QCOMPARE(acc->isReady(features), true);
+    QCOMPARE(acc->isReady(Account::FeatureAvatar), true);
 
     QCOMPARE(acc->avatar().MIMEType, QString("image/png"));
 
@@ -117,12 +116,11 @@ void TestAccountBasics::testBasics()
                     SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
     QCOMPARE(mLoop->exec(), 0);
 
-    features = Features() << Account::FeatureAvatar;
-    QVERIFY(connect(acc->becomeReady(features),
+    QVERIFY(connect(acc->becomeReady(Account::FeatureAvatar),
                     SIGNAL(finished(Telepathy::Client::PendingOperation *)),
                     SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
     QCOMPARE(mLoop->exec(), 0);
-    QCOMPARE(acc->isReady(features), true);
+    QCOMPARE(acc->isReady(Account::FeatureAvatar), true);
 
     // wait for avatarChanged signal
     QCOMPARE(mLoop->exec(), 0);
@@ -143,12 +141,11 @@ void TestAccountBasics::testBasics()
 
     acc = mAM->accountForPath(
             "/org/freedesktop/Telepathy/Account/spurious/normal/Account0");
-    features = Features() << Account::FeatureProtocolInfo;
-    QVERIFY(connect(acc->becomeReady(features),
+    QVERIFY(connect(acc->becomeReady(Account::FeatureProtocolInfo),
                     SIGNAL(finished(Telepathy::Client::PendingOperation *)),
                     SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
     QCOMPARE(mLoop->exec(), 0);
-    QCOMPARE(acc->isReady(features), true);
+    QCOMPARE(acc->isReady(Account::FeatureProtocolInfo), true);
 
     ProtocolInfo *protocolInfo = acc->protocolInfo();
     QCOMPARE((bool) protocolInfo, !((ProtocolInfo *) 0));
@@ -156,21 +153,19 @@ void TestAccountBasics::testBasics()
     QCOMPARE(protocolInfo->hasParameter("password"), true);
     QCOMPARE(protocolInfo->hasParameter("register"), true);
 
-    features = Features() << Account::FeatureAvatar;
-    QVERIFY(connect(acc->becomeReady(features),
+    QVERIFY(connect(acc->becomeReady(Account::FeatureAvatar),
                     SIGNAL(finished(Telepathy::Client::PendingOperation *)),
                     SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
     QCOMPARE(mLoop->exec(), 0);
-    QCOMPARE(acc->isReady(features), true);
+    QCOMPARE(acc->isReady(Account::FeatureAvatar), true);
 
     QCOMPARE(acc->avatar().MIMEType, QString("image/png"));
 
-    features = Features() << Account::FeatureAvatar << Account::FeatureProtocolInfo;
-    QVERIFY(connect(acc->becomeReady(features),
+    QVERIFY(connect(acc->becomeReady(Account::FeatureAvatar | Account::FeatureProtocolInfo),
                     SIGNAL(finished(Telepathy::Client::PendingOperation *)),
                     SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
     QCOMPARE(mLoop->exec(), 0);
-    QCOMPARE(acc->isReady(features), true);
+    QCOMPARE(acc->isReady(Account::FeatureAvatar | Account::FeatureProtocolInfo), true);
 
     QCOMPARE(acc->avatar().MIMEType, QString("image/png"));
     protocolInfo = acc->protocolInfo();
-- 
1.5.6.5



More information about the telepathy-commits mailing list