[Telepathy-commits] [telepathy-qt4/master] Connection: Make Connection::baseInterface() protected.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Sun Jan 25 12:48:39 PST 2009
Connection: Make Connection::baseInterface() protected and changed tests to use
high-level interface.
---
TelepathyQt4/Client/connection.h | 2 +-
tests/dbus/handles.cpp | 11 ++---
tests/pinocchio/chan-basics.cpp | 82 +++++++++++++++++++++++++++++++------
3 files changed, 74 insertions(+), 21 deletions(-)
diff --git a/TelepathyQt4/Client/connection.h b/TelepathyQt4/Client/connection.h
index 62e56d9..8950085 100644
--- a/TelepathyQt4/Client/connection.h
+++ b/TelepathyQt4/Client/connection.h
@@ -153,7 +153,7 @@ public:
Q_SIGNALS:
void statusChanged(uint newStatus, uint newStatusReason);
-public:
+protected:
ConnectionInterface *baseInterface() const;
private Q_SLOTS:
diff --git a/tests/dbus/handles.cpp b/tests/dbus/handles.cpp
index 441ca01..0d7e852 100644
--- a/tests/dbus/handles.cpp
+++ b/tests/dbus/handles.cpp
@@ -196,12 +196,11 @@ void TestHandles::testRequestAndRelease()
handles = ReferencedHandles();
mLoop->processEvents();
- // Make sure the service side has processed the release as well, by calling a getter
- PendingVoidMethodCall *call =
- new PendingVoidMethodCall(mConn, mConn->baseInterface()->GetProtocol());
- QVERIFY(this->connect(call,
- SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation*))));
+ // Make sure the service side has processed the release as well, by calling a method
+ QVERIFY(connect(mConn->requestConnect(),
+ SIGNAL(finished(Telepathy::Client::PendingOperation*)),
+ this,
+ SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation*))));
QCOMPARE(mLoop->exec(), 0);
// Check that the handles have been released
diff --git a/tests/pinocchio/chan-basics.cpp b/tests/pinocchio/chan-basics.cpp
index 6381448..aa0c6a1 100644
--- a/tests/pinocchio/chan-basics.cpp
+++ b/tests/pinocchio/chan-basics.cpp
@@ -9,6 +9,7 @@
#include <TelepathyQt4/Client/Connection>
#include <TelepathyQt4/Client/ConnectionManager>
#include <TelepathyQt4/Client/PendingChannel>
+#include <TelepathyQt4/Client/PendingHandles>
#include <tests/pinocchio/lib.h>
@@ -36,6 +37,8 @@ protected Q_SLOTS:
void expectChanReady(uint);
void expectPendingChannelFinished(Telepathy::Client::PendingOperation*);
void expectPendingChannelError(Telepathy::Client::PendingOperation*);
+ void expectRequestHandlesFinished(Telepathy::Client::PendingOperation*);
+ void expectRequestChannelFinished(Telepathy::Client::PendingOperation*);
private Q_SLOTS:
void initTestCase();
@@ -119,20 +122,19 @@ void TestChanBasics::initTestCase()
QVERIFY(disconnect(mConn, SIGNAL(statusChanged(uint, uint)),
this, SLOT(expectConnReady(uint, uint))));
- // Using direct access to low-level stuff here, so we can test the
- // Channel constructor directly
- QDBusPendingReply<Telepathy::UIntList> requestHandlesReply =
- mConn->baseInterface()->RequestHandles(Telepathy::HandleTypeList,
- QStringList() << "subscribe");
- requestHandlesReply.waitForFinished();
- mSubscribeHandle = requestHandlesReply.value().at(0);
-
- QDBusPendingReply<QDBusObjectPath> requestChannelReply =
- mConn->baseInterface()->RequestChannel(
- TELEPATHY_INTERFACE_CHANNEL_TYPE_CONTACT_LIST,
- Telepathy::HandleTypeList, mSubscribeHandle, true);
- requestChannelReply.waitForFinished();
- mSubscribeChanObjectPath = requestChannelReply.value().path();
+ QVERIFY(connect(mConn->requestHandles(Telepathy::HandleTypeList,
+ QStringList() << "subscribe"),
+ SIGNAL(finished(Telepathy::Client::PendingOperation*)),
+ this,
+ SLOT(expectRequestHandlesFinished(Telepathy::Client::PendingOperation*))));
+ QCOMPARE(mLoop->exec(), 0);
+
+ connect(mConn->requestChannel(TELEPATHY_INTERFACE_CHANNEL_TYPE_CONTACT_LIST,
+ Telepathy::HandleTypeList, mSubscribeHandle),
+ SIGNAL(finished(Telepathy::Client::PendingOperation*)),
+ this,
+ SLOT(expectRequestChannelFinished(Telepathy::Client::PendingOperation*)));
+ QCOMPARE(mLoop->exec(), 0);
}
@@ -223,6 +225,58 @@ void TestChanBasics::expectPendingChannelFinished(PendingOperation* op)
mLoop->exit(0);
}
+void TestChanBasics::expectRequestHandlesFinished(PendingOperation* op)
+{
+ if (!op->isFinished()) {
+ qWarning() << "unfinished";
+ mLoop->exit(1);
+ return;
+ }
+
+ if (op->isError()) {
+ qWarning().nospace() << op->errorName()
+ << ": " << op->errorMessage();
+ mLoop->exit(2);
+ return;
+ }
+
+ if (!op->isValid()) {
+ qWarning() << "inconsistent results";
+ mLoop->exit(3);
+ return;
+ }
+
+ PendingHandles *ph = qobject_cast<PendingHandles*>(op);
+ mSubscribeHandle = ph->handles().at(0);
+ mLoop->exit(0);
+}
+
+void TestChanBasics::expectRequestChannelFinished(PendingOperation* op)
+{
+ if (!op->isFinished()) {
+ qWarning() << "unfinished";
+ mLoop->exit(1);
+ return;
+ }
+
+ if (op->isError()) {
+ qWarning().nospace() << op->errorName()
+ << ": " << op->errorMessage();
+ mLoop->exit(2);
+ return;
+ }
+
+ if (!op->isValid()) {
+ qWarning() << "inconsistent results";
+ mLoop->exit(3);
+ return;
+ }
+
+ PendingChannel *pc = qobject_cast<PendingChannel*>(op);
+ Channel *chan = pc->channel();
+ mSubscribeChanObjectPath = chan->objectPath();
+ mLoop->exit(0);
+}
void TestChanBasics::testPendingChannel()
{
--
1.5.6.5
More information about the Telepathy-commits
mailing list