[Telepathy-commits] [telepathy-qt4/master] TestCmBasics: use becomeReady() instead of listening for ready()
Simon McVittie
simon.mcvittie at collabora.co.uk
Thu Dec 11 04:03:48 PST 2008
This is advantageous because calling becomeReady() on an already-ready
object will just signal finished when the main loop is next re-entered,
reducing the number of code paths required if it is not known whether
an externally provided ConnectionManager is ready.
---
tests/pinocchio/cm-basics.cpp | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/tests/pinocchio/cm-basics.cpp b/tests/pinocchio/cm-basics.cpp
index 69ec5e6..22e858a 100644
--- a/tests/pinocchio/cm-basics.cpp
+++ b/tests/pinocchio/cm-basics.cpp
@@ -62,12 +62,21 @@ void TestCmBasics::testBasics()
mCM = new ConnectionManager("pinocchio");
QCOMPARE(mCM->isReady(), false);
- connect(mCM, SIGNAL(ready(ConnectionManager*)),
- SLOT(onCmReady(ConnectionManager*)));
+ connect(mCM->becomeReady(),
+ SIGNAL(finished(Telepathy::Client::PendingOperation *)),
+ this,
+ SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *)));
+ qDebug() << "enter main loop";
+ QCOMPARE(mLoop->exec(), 0);
+ QCOMPARE(mCM->isReady(), true);
+
+ // calling becomeReady() twice is a no-op
+ connect(mCM->becomeReady(),
+ SIGNAL(finished(Telepathy::Client::PendingOperation *)),
+ this,
+ SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *)));
QCOMPARE(mLoop->exec(), 0);
QCOMPARE(mCM->isReady(), true);
- disconnect(mCM, SIGNAL(ready(ConnectionManager*)),
- this, SLOT(onCmReady(ConnectionManager*)));
QCOMPARE(mCM->interfaces(), QStringList());
QCOMPARE(mCM->supportedProtocols(), QStringList() << "dummy");
--
1.5.6.5
More information about the Telepathy-commits
mailing list