summaryrefslogtreecommitdiff
path: root/qt4/tests/lib/test.h
diff options
context:
space:
mode:
authorMarco Barisione <marco@barisione.org>2010-10-13 13:55:17 +0100
committerOlli Salli <ollisal@gmail.com>2010-11-04 15:27:36 +0200
commit828dad08ed1a63ac0a25b80773c89a9bb01c18b6 (patch)
treeae0b012eafd82b1b637a42e24656c6317176ccd9 /qt4/tests/lib/test.h
parent5648c472119d96f7a3f134a441d817a11c179b90 (diff)
Add utility functions to test the value of DBus properties
Diffstat (limited to 'qt4/tests/lib/test.h')
-rw-r--r--qt4/tests/lib/test.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/qt4/tests/lib/test.h b/qt4/tests/lib/test.h
index 736213e72..77b3d34e8 100644
--- a/qt4/tests/lib/test.h
+++ b/qt4/tests/lib/test.h
@@ -3,6 +3,7 @@
#include <QtTest>
#include <TelepathyQt4/PendingOperation>
+#include <TelepathyQt4/PendingVariant>
#include <TelepathyQt4/Constants>
namespace Tp
@@ -23,10 +24,14 @@ public:
QEventLoop *mLoop;
void processDBusQueue(Tp::DBusProxy *proxy);
+protected:
+ template<typename T> bool waitForProperty(Tp::PendingVariant *pv, T *value);
+
protected Q_SLOTS:
void expectSuccessfulCall(QDBusPendingCallWatcher*);
void expectSuccessfulCall(Tp::PendingOperation*);
void expectFailure(Tp::PendingOperation*);
+ void expectSuccessfulProperty(Tp::PendingOperation *op);
void onWatchdog();
virtual void initTestCaseImpl();
@@ -34,4 +39,24 @@ protected Q_SLOTS:
virtual void cleanupImpl();
virtual void cleanupTestCaseImpl();
+
+private:
+ // The property retrieved by expectSuccessfulProperty()
+ QVariant mPropertyValue;
};
+
+template<typename T>
+bool Test::waitForProperty(Tp::PendingVariant *pv, T *value)
+{
+ connect(pv,
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(expectSuccessfulProperty(Tp::PendingOperation*)));
+ if (mLoop->exec() == 0) {
+ *value = qdbus_cast<T>(mPropertyValue);
+ return true;
+ }
+ else {
+ *value = T();
+ return false;
+ }
+}