[telepathy-qt4/master] Removed pinocchio tests.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Thu Oct 8 15:36:20 PDT 2009
Reasons:
1 - telepathy-pinocchio does not even work with latest telepathy-python
2 - All tests covered by test/pinocchio are already covered by tests in
tests/dbus
---
README | 1 -
TelepathyQt4/main.dox | 2 -
configure.ac | 7 -
tests/Makefile.am | 3 +-
tests/README | 3 -
tests/pinocchio/Makefile.am | 73 ------
tests/pinocchio/accounts/empty/contacts.xml | 2 -
tests/pinocchio/cm-basics.cpp | 145 ------------
tests/pinocchio/conn-basics.cpp | 310 -------------------------
tests/pinocchio/do-nothing.cpp | 63 -----
tests/pinocchio/handles.cpp | 325 ---------------------------
tests/pinocchio/lib.cpp | 123 ----------
tests/pinocchio/lib.h | 48 ----
13 files changed, 1 insertions(+), 1104 deletions(-)
delete mode 100644 tests/pinocchio/Makefile.am
delete mode 100644 tests/pinocchio/accounts/empty/contacts.xml
delete mode 100644 tests/pinocchio/cm-basics.cpp
delete mode 100644 tests/pinocchio/conn-basics.cpp
delete mode 100644 tests/pinocchio/do-nothing.cpp
delete mode 100644 tests/pinocchio/handles.cpp
delete mode 100644 tests/pinocchio/lib.cpp
delete mode 100644 tests/pinocchio/lib.h
diff --git a/README b/README
index 0e8e659..ce8e220 100644
--- a/README
+++ b/README
@@ -31,7 +31,6 @@ Building telepathy-qt4 requires:
For the full set of regression tests to run, you'll also need:
telepathy-glib <http://telepathy.freedesktop.org/releases/telepathy-glib/>
- telepathy-pinocchio <http://telepathy.freedesktop.org/releases/telepathy-pinocchio/>
and to build the example VoIP call UI (examples/call), you'll need:
telepathy-glib <http://telepathy.freedesktop.org/releases/telepathy-glib/>
diff --git a/TelepathyQt4/main.dox b/TelepathyQt4/main.dox
index 9786c5e..1814b64 100644
--- a/TelepathyQt4/main.dox
+++ b/TelepathyQt4/main.dox
@@ -77,8 +77,6 @@
*
* For the full set of regression tests to run, you'll also need:
* \li telepathy-glib <http://telepathy.freedesktop.org/releases/telepathy-glib/>
- * \li telepathy-pinocchio
- * <http://telepathy.freedesktop.org/releases/telepathy-pinocchio/>
*
* and to build the example VoIP call UI (examples/call), you'll need:
* \li telepathy-glib <http://telepathy.freedesktop.org/releases/telepathy-glib/>
diff --git a/configure.ac b/configure.ac
index f7b87d5..e93d621 100644
--- a/configure.ac
+++ b/configure.ac
@@ -229,12 +229,6 @@ AM_CONDITIONAL([ENABLE_TP_FARSIGHT],
[test yes = "$have_tp_glib" && test yes = "$have_tp_fs" &&
test yes = "$have_qt_glib_main_loop"])
-AC_PATH_PROGS([PINOCCHIO], [telepathy-pinocchio], [none],
- [$PATH:/usr/local/libexec:/usr/libexec:/usr/lib/telepathy])
-AC_PATH_PROGS([PINOCCHIO_CTL], [pinocchio-ctl], [none])
-AM_CONDITIONAL([HAVE_PINOCCHIO],
- [test none != "$PINOCCHIO" && test none != "$PINOCCHIO_CTL"])
-
dnl Check for code generation tools
AM_PATH_PYTHON([2.5])
@@ -289,6 +283,5 @@ AC_OUTPUT([
tests/lib/csh/Makefile
tests/lib/echo/Makefile
tests/lib/echo2/Makefile
- tests/pinocchio/Makefile
tools/Makefile
])
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f22fc40..fcffed8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,8 +1,7 @@
# compile lib/ first, so it can be used by tests in the other directories
SUBDIRS = \
lib \
- dbus \
- pinocchio
+ dbus
# Standalone tests that don't touch D-Bus
TESTS = \
diff --git a/tests/README b/tests/README
index 0246e9c..31e6a6f 100644
--- a/tests/README
+++ b/tests/README
@@ -9,8 +9,5 @@ Where to put new tests:
* /tests/dbus/ if they touch the session bus (a temporary session bus will be
used)
-* /tests/pinocchio/ if they touch the session bus, and also require
- telepathy-pinocchio to be available
-
/tests/lib/ contains support code, some of it taken from the telepathy-glib
examples and regression tests.
diff --git a/tests/pinocchio/Makefile.am b/tests/pinocchio/Makefile.am
deleted file mode 100644
index 321a3a7..0000000
--- a/tests/pinocchio/Makefile.am
+++ /dev/null
@@ -1,73 +0,0 @@
-# Tests that need telepathy-pinocchio, run under their own dbus-daemon
-
-if HAVE_PINOCCHIO
-
-EXTRA_DIST = \
- accounts/empty/contacts.xml \
- lib.h
-
-TESTS = \
- test-cm-basics \
- test-conn-basics \
- test-do-nothing \
- test-handles
-
-BUILT_SOURCES = \
- _gen/cm-basics.cpp.moc.hpp \
- _gen/conn-basics.cpp.moc.hpp \
- _gen/do-nothing.cpp.moc.hpp \
- _gen/handles.cpp.moc.hpp \
- _gen/lib.h.moc.hpp
-
-_gen/%.moc.hpp: %
- $(mkdir_p) _gen
- $(MOC) $(AM_CPPFLAGS) -i $< -o $@
-
-noinst_PROGRAMS = $(TESTS)
-
-test_cm_basics_SOURCES = cm-basics.cpp lib.cpp
-
-test_conn_basics_SOURCES = conn-basics.cpp lib.cpp
-
-test_do_nothing_SOURCES = do-nothing.cpp lib.cpp
-
-test_handles_SOURCES = handles.cpp lib.cpp
-
-AM_CPPFLAGS = \
- -I$(top_srcdir) -I$(top_builddir) \
- $(QTCORE_CFLAGS) \
- $(QTDBUS_CFLAGS) \
- $(QTTEST_CFLAGS)
-
-LDADD = \
- $(QTCORE_LIBS) \
- $(QTDBUS_LIBS) \
- $(QTTEST_LIBS) \
- ${top_builddir}/tests/lib/libtp-qt4-tests.la \
- ${top_builddir}/TelepathyQt4/libtelepathy-qt4.la
-
-AM_CXXFLAGS = \
- $(ERROR_CXXFLAGS)
-
-# FIXME: XDG_DATA_DIRS should not depend on external setup
-TESTS_ENV = \
- abs_top_builddir=@abs_top_builddir@ \
- abs_top_srcdir=@abs_top_srcdir@ \
- XDG_DATA_HOME=@abs_top_builddir@/tests \
- XDG_DATA_DIRS=@abs_top_srcdir@/tests:$(XDG_DATA_DIRS) \
- PINOCCHIO=@PINOCCHIO@ \
- PINOCCHIO_CTL=@PINOCCHIO_CTL@ \
- PINOCCHIO_DATA_DIR=@abs_srcdir@ \
- PINOCCHIO_SAVE_DIR=@abs_builddir@/_tmp
-
-TESTS_ENVIRONMENT = \
- $(TESTS_ENV) \
- sh $(top_srcdir)/tools/with-session-bus.sh --session --
-
-CLEANFILES = \
- $(BUILT_SOURCES)
-
-distclean-local:
- rm -rf _gen _tmp
-
-endif
diff --git a/tests/pinocchio/accounts/empty/contacts.xml b/tests/pinocchio/accounts/empty/contacts.xml
deleted file mode 100644
index 29868b5..0000000
--- a/tests/pinocchio/accounts/empty/contacts.xml
+++ /dev/null
@@ -1,2 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<roster/>
diff --git a/tests/pinocchio/cm-basics.cpp b/tests/pinocchio/cm-basics.cpp
deleted file mode 100644
index fc9d447..0000000
--- a/tests/pinocchio/cm-basics.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-#include <QtCore/QDebug>
-#include <QtCore/QTimer>
-
-#include <QtDBus/QtDBus>
-
-#include <TelepathyQt4/ConnectionManager>
-#include <TelepathyQt4/PendingConnection>
-#include <TelepathyQt4/PendingReady>
-#include <TelepathyQt4/PendingStringList>
-
-#include <tests/pinocchio/lib.h>
-
-using namespace Tp;
-
-class TestCmBasics : public PinocchioTest
-{
- Q_OBJECT
-
-private:
- Tp::ConnectionManagerPtr mCM;
-
-protected Q_SLOTS:
- void onListNames(Tp::PendingOperation*);
-
-private Q_SLOTS:
- void initTestCase();
- void init();
-
- void testBasics();
-
- void cleanup();
- void cleanupTestCase();
-};
-
-
-void TestCmBasics::initTestCase()
-{
- initTestCaseImpl();
-
- // Wait for the CM to start up
- QVERIFY(waitForPinocchio(5000));
-}
-
-
-void TestCmBasics::init()
-{
- initImpl();
-}
-
-void TestCmBasics::onListNames(Tp::PendingOperation *operation)
-{
- Tp::PendingStringList *p = static_cast<Tp::PendingStringList*>(operation);
- QCOMPARE(p->result().contains("pinocchio"), QBool(true));
- // Check for bug 23040: Running Connection Managers appear twice in ConnectionManager::listNames().
- QCOMPARE(p->result().count("pinocchio"), 1);
- mLoop->exit(0);
-}
-
-
-void TestCmBasics::testBasics()
-{
- connect(ConnectionManager::listNames(),
- SIGNAL(finished(Tp::PendingOperation *)),
- this,
- SLOT(onListNames(Tp::PendingOperation *)));
- QCOMPARE(mLoop->exec(), 0);
-
- mCM = ConnectionManager::create("pinocchio");
- QCOMPARE(mCM->isReady(), false);
-
- connect(mCM->becomeReady(),
- SIGNAL(finished(Tp::PendingOperation *)),
- this,
- SLOT(expectSuccessfulCall(Tp::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(Tp::PendingOperation *)),
- this,
- SLOT(expectSuccessfulCall(Tp::PendingOperation *)));
- QCOMPARE(mLoop->exec(), 0);
- QCOMPARE(mCM->isReady(), true);
-
- QCOMPARE(mCM->interfaces(), QStringList());
- QCOMPARE(mCM->supportedProtocols(), QStringList() << "dummy");
-
- Q_FOREACH (ProtocolInfo *info, mCM->protocols()) {
- QVERIFY(info != 0);
- QVERIFY(info->cmName() == "pinocchio");
- QVERIFY(info->name() == "dummy");
-
- QCOMPARE(info->hasParameter("account"), true);
- QCOMPARE(info->hasParameter("not-there"), false);
-
- Q_FOREACH (ProtocolParameter *param, info->parameters()) {
- if (param->name() == "account") {
- QCOMPARE(param->dbusSignature().signature(),
- QLatin1String("s"));
- QCOMPARE(param->isRequired(), true);
- QCOMPARE(param->isSecret(), false);
- }
- else if (param->name() == "password") {
- QCOMPARE(param->isRequired(), false);
- QCOMPARE(param->isSecret(), true);
- }
- }
- QCOMPARE(info->canRegister(), false);
- }
-
- QCOMPARE(mCM->supportedProtocols(), QStringList() << "dummy");
-
- QVariantMap parameters;
- parameters.insert(QLatin1String("account"),
- QVariant::fromValue(QString::fromAscii("empty")));
- parameters.insert(QLatin1String("password"),
- QVariant::fromValue(QString::fromAscii("s3kr1t")));
-
- PendingConnection *pconn = mCM->requestConnection("dummy", parameters);
- connect(pconn,
- SIGNAL(finished(Tp::PendingOperation *)),
- this,
- SLOT(expectSuccessfulCall(Tp::PendingOperation *)));
- QCOMPARE(mLoop->exec(), 0);
-
- QVERIFY(pconn->connection());
-}
-
-
-void TestCmBasics::cleanup()
-{
- cleanupImpl();
-}
-
-
-void TestCmBasics::cleanupTestCase()
-{
- cleanupTestCaseImpl();
-}
-
-
-QTEST_MAIN(TestCmBasics)
-#include "_gen/cm-basics.cpp.moc.hpp"
diff --git a/tests/pinocchio/conn-basics.cpp b/tests/pinocchio/conn-basics.cpp
deleted file mode 100644
index 4c44464..0000000
--- a/tests/pinocchio/conn-basics.cpp
+++ /dev/null
@@ -1,310 +0,0 @@
-#include <QtCore/QDebug>
-#include <QtCore/QTimer>
-
-#include <QtDBus/QtDBus>
-
-#include <TelepathyQt4/Constants>
-#include <TelepathyQt4/DBus>
-#include <TelepathyQt4/Connection>
-#include <TelepathyQt4/ConnectionManager>
-#include <TelepathyQt4/PendingReady>
-
-#include <tests/pinocchio/lib.h>
-
-using Tp::Connection;
-using Tp::ConnectionPtr;
-using Tp::Client::ConnectionManagerInterface;
-using Tp::Client::DBus::PeerInterface;
-using Tp::Client::DBus::PropertiesInterface;
-using Tp::Features;
-
-class TestConnBasics : public PinocchioTest
-{
- Q_OBJECT
-
-private:
- ConnectionManagerInterface* mCM;
- QString mConnBusName;
- QString mConnObjectPath;
- ConnectionPtr mConn;
-
-protected Q_SLOTS:
- void expectReady(uint, uint);
-
-private Q_SLOTS:
- void initTestCase();
- void init();
-
- void testInitialIntrospection();
- void testConnect();
- void testSpecifiedBus();
- void testAlreadyConnected();
- void testInterfaceFactory();
-
- void cleanup();
- void cleanupTestCase();
-};
-
-
-/*
- * Missing test coverage on existing Connection code includes:
- *
- * - pre-Connected introspection (needs Pinocchio support or another CM)
- * - introspecting a Connection that's already Connecting (needs Pinocchio
- * support or another CM)
- *
- * Out of scope for this test, should be in another test:
- *
- * - SimplePresence introspection (needs Pinocchio support or another CM)
- * - aliasFlags(), presenceStatuses(), simplePresenceStatuses() accessors
- * - requesting a channel
- */
-
-
-void TestConnBasics::initTestCase()
-{
- initTestCaseImpl();
-
- // Wait for the CM to start up
- QVERIFY(waitForPinocchio(5000));
-
- // Escape to the low-level API to make a Connection; this uses
- // pseudo-blocking calls for simplicity. Do not do this in production code
-
- mCM = new ConnectionManagerInterface(
- pinocchioBusName(), pinocchioObjectPath());
-
- QDBusPendingReply<QString, QDBusObjectPath> reply;
- QVariantMap parameters;
- parameters.insert(QLatin1String("account"),
- QVariant::fromValue(QString::fromAscii("empty")));
- parameters.insert(QLatin1String("password"),
- QVariant::fromValue(QString::fromAscii("s3kr1t")));
-
- reply = mCM->RequestConnection("dummy", parameters);
- reply.waitForFinished();
- if (!reply.isValid()) {
- qWarning().nospace() << reply.error().name()
- << ": " << reply.error().message();
- QVERIFY(reply.isValid());
- }
- mConnBusName = reply.argumentAt<0>();
- mConnObjectPath = reply.argumentAt<1>().path();
-}
-
-
-void TestConnBasics::init()
-{
- initImpl();
-}
-
-
-void TestConnBasics::testInitialIntrospection()
-{
- mConn = Connection::create(mConnBusName, mConnObjectPath);
-
- QCOMPARE(static_cast<uint>(mConn->status()),
- static_cast<uint>(Connection::StatusUnknown));
-
- mConn.reset();
-}
-
-
-void TestConnBasics::expectReady(uint newStatus, uint newStatusReason)
-{
- switch (newStatus) {
- case Connection::StatusDisconnected:
- qWarning() << "Disconnected";
- mLoop->exit(1);
- break;
- case Connection::StatusConnecting:
- /* do nothing */
- break;
- case Connection::StatusConnected:
- qDebug() << "Ready";
- mLoop->exit(0);
- break;
- default:
- qWarning().nospace() << "What sort of status is "
- << newStatus << "?!";
- mLoop->exit(2);
- break;
- }
-}
-
-
-void TestConnBasics::testConnect()
-{
- mConn = Connection::create(mConnBusName, mConnObjectPath);
- QCOMPARE(mConn->isReady(), false);
-
- QCOMPARE(static_cast<uint>(mConn->status()),
- static_cast<uint>(Connection::StatusUnknown));
-
- qDebug() << "calling Connect()";
- QVERIFY(connect(mConn->requestConnect(),
- SIGNAL(finished(Tp::PendingOperation*)),
- this,
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
-
- QVERIFY(connect(mConn->becomeReady(),
- SIGNAL(finished(Tp::PendingOperation*)),
- this,
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QCOMPARE(mConn->isReady(), true);
-
- if (mConn->status() != Connection::StatusConnected) {
- QVERIFY(connect(mConn.data(),
- SIGNAL(statusChanged(uint, uint)),
- SLOT(expectReady(uint, uint))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn.data(),
- SIGNAL(statusChanged(uint, uint)),
- this,
- SLOT(expectReady(uint, uint))));
- QCOMPARE(mConn->status(), (uint) Connection::StatusConnected);
- }
-
- Features features = Features() << Connection::FeatureSimplePresence;
- QVERIFY(connect(mConn->becomeReady(features),
- SIGNAL(finished(Tp::PendingOperation*)),
- this,
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QCOMPARE(mConn->isReady(features), true);
- QVERIFY(mConn->missingFeatures() == features);
-
- QCOMPARE(static_cast<uint>(mConn->status()),
- static_cast<uint>(Connection::StatusConnected));
- QCOMPARE(static_cast<uint>(mConn->statusReason()),
- static_cast<uint>(Tp::ConnectionStatusReasonRequested));
-
- QStringList interfaces = mConn->interfaces();
- QVERIFY(interfaces.contains(QLatin1String(
- TELEPATHY_INTERFACE_CONNECTION_INTERFACE_ALIASING)));
- QVERIFY(interfaces.contains(QLatin1String(
- TELEPATHY_INTERFACE_CONNECTION_INTERFACE_AVATARS)));
- QVERIFY(interfaces.contains(QLatin1String(
- TELEPATHY_INTERFACE_CONNECTION_INTERFACE_CAPABILITIES)));
-
- QVERIFY(connect(mConn->requestDisconnect(),
- SIGNAL(finished(Tp::PendingOperation*)),
- this,
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
-
- QCOMPARE(static_cast<uint>(mConn->status()),
- static_cast<uint>(Connection::StatusDisconnected));
- QCOMPARE(static_cast<uint>(mConn->statusReason()),
- static_cast<uint>(Tp::ConnectionStatusReasonRequested));
-
- mConn.reset();
-}
-
-
-void TestConnBasics::testAlreadyConnected()
-{
- mConn = Connection::create(mConnBusName, mConnObjectPath);
-
- qDebug() << "calling Connect()";
- QVERIFY(connect(mConn->requestConnect(),
- SIGNAL(finished(Tp::PendingOperation*)),
- this,
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
-
- QVERIFY(connect(mConn->becomeReady(),
- SIGNAL(finished(Tp::PendingOperation*)),
- this,
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QCOMPARE(mConn->isReady(), true);
-
- if (mConn->status() != Connection::StatusConnected) {
- QVERIFY(connect(mConn.data(),
- SIGNAL(statusChanged(uint, uint)),
- SLOT(expectReady(uint, uint))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn.data(),
- SIGNAL(statusChanged(uint, uint)),
- this,
- SLOT(expectReady(uint, uint))));
- QCOMPARE(mConn->status(), (uint) Connection::StatusConnected);
- }
-
- // delete proxy, make a new one
- mConn.reset();
- mConn = Connection::create(mConnBusName, mConnObjectPath);
-
- // Wait for introspection to run (readiness changes to Full immediately)
- QVERIFY(connect(mConn.data(), SIGNAL(statusChanged(uint, uint)),
- this, SLOT(expectReady(uint, uint))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn.data(), SIGNAL(statusChanged(uint, uint)),
- this, SLOT(expectReady(uint, uint))));
-
- QVERIFY(connect(mConn->requestDisconnect(),
- SIGNAL(finished(Tp::PendingOperation*)),
- this,
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
-
- mConn.reset();
-}
-
-
-void TestConnBasics::testInterfaceFactory()
-{
- mConn = Connection::create(QDBusConnection::sessionBus(),
- mConnBusName, mConnObjectPath);
-
- QCOMPARE(static_cast<uint>(mConn->status()),
- static_cast<uint>(Connection::StatusUnknown));
-
- PropertiesInterface* props = mConn->propertiesInterface();
- QVERIFY(props != NULL);
-
- PropertiesInterface* props2 =
- mConn->optionalInterface<PropertiesInterface>(Connection::BypassInterfaceCheck);
- QVERIFY(props2 == props);
-
- PeerInterface* notListed = mConn->optionalInterface<PeerInterface>();
- QVERIFY(notListed == NULL);
- notListed = mConn->optionalInterface<PeerInterface>(Connection::BypassInterfaceCheck);
- QVERIFY(notListed != NULL);
-
- mConn.reset();
-}
-
-
-void TestConnBasics::cleanup()
-{
- cleanupImpl();
-}
-
-
-void TestConnBasics::testSpecifiedBus()
-{
- mConn = Connection::create(QDBusConnection::sessionBus(),
- mConnBusName, mConnObjectPath);
-
- QCOMPARE(static_cast<uint>(mConn->status()),
- static_cast<uint>(Connection::StatusUnknown));
-
- mConn.reset();
-}
-
-
-void TestConnBasics::cleanupTestCase()
-{
- delete mCM;
- mCM = NULL;
-
- cleanupTestCaseImpl();
-}
-
-
-QTEST_MAIN(TestConnBasics)
-#include "_gen/conn-basics.cpp.moc.hpp"
diff --git a/tests/pinocchio/do-nothing.cpp b/tests/pinocchio/do-nothing.cpp
deleted file mode 100644
index 64bb1a3..0000000
--- a/tests/pinocchio/do-nothing.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
-#include <QtCore/QDebug>
-#include <QtCore/QTimer>
-
-#include <QtDBus/QtDBus>
-
-#include <tests/pinocchio/lib.h>
-
-class TestDoNothing : public PinocchioTest
-{
- Q_OBJECT
-
-private slots:
- void initTestCase();
- void init();
-
- void doNothing();
- void doNothing2();
-
- void cleanup();
- void cleanupTestCase();
-};
-
-
-void TestDoNothing::initTestCase()
-{
- initTestCaseImpl();
-}
-
-
-void TestDoNothing::init()
-{
- initImpl();
-}
-
-
-void TestDoNothing::doNothing()
-{
- QTimer::singleShot(0, mLoop, SLOT(quit()));
- QCOMPARE(mLoop->exec(), 0);
-}
-
-
-void TestDoNothing::doNothing2()
-{
- QTimer::singleShot(0, mLoop, SLOT(quit()));
- QCOMPARE(mLoop->exec(), 0);
-}
-
-
-void TestDoNothing::cleanup()
-{
- cleanupImpl();
-}
-
-
-void TestDoNothing::cleanupTestCase()
-{
- cleanupTestCaseImpl();
-}
-
-
-QTEST_MAIN(TestDoNothing)
-#include "_gen/do-nothing.cpp.moc.hpp"
diff --git a/tests/pinocchio/handles.cpp b/tests/pinocchio/handles.cpp
deleted file mode 100644
index d9670a7..0000000
--- a/tests/pinocchio/handles.cpp
+++ /dev/null
@@ -1,325 +0,0 @@
-#include <list>
-
-#include <QDebug>
-#include <QStringList>
-
-#include <QDBusPendingCallWatcher>
-#include <QDBusConnection>
-#include <QDBusObjectPath>
-#include <QDBusPendingReply>
-
-#include <TelepathyQt4/Constants>
-#include <TelepathyQt4/Connection>
-#include <TelepathyQt4/ConnectionManager>
-#include <TelepathyQt4/PendingHandles>
-#include <TelepathyQt4/PendingReady>
-#include <TelepathyQt4/ReferencedHandles>
-
-#include <tests/pinocchio/lib.h>
-
-using namespace Tp;
-using namespace Tp::Client;
-
-class TestHandles : public PinocchioTest
-{
- Q_OBJECT
-
-private:
- ConnectionManagerInterface *mCM;
-
- // Bus connection 1, proxy a
- ConnectionPtr mConn1a;
- // Bus connection 1, proxy b
- ConnectionPtr mConn1b;
- // Bus connection 2
- ConnectionPtr mConn2;
-
- // Temporary storage to move ReferencedHandles away from their self-destructive parents in the
- // finished() handlers
- ReferencedHandles mHandles;
-
-protected Q_SLOTS:
- // these ought to be private, but if they were, QTest would think they
- // were test cases. So, they're protected instead
- void expectConnReady(uint, uint);
- void expectPendingHandlesFinished(Tp::PendingOperation*);
-
-private Q_SLOTS:
- void initTestCase();
- void init();
-
- void testBasics();
- void testReferences();
-
- void cleanup();
- void cleanupTestCase();
-};
-
-void TestHandles::expectConnReady(uint newStatus, uint newStatusReason)
-{
- switch (newStatus) {
- case Connection::StatusDisconnected:
- qWarning() << "Disconnected";
- mLoop->exit(1);
- break;
- case Connection::StatusConnecting:
- /* do nothing */
- break;
- case Connection::StatusConnected:
- qDebug() << "Ready";
- mLoop->exit(0);
- break;
- default:
- qWarning().nospace() << "What sort of readiness is "
- << newStatus << "?!";
- mLoop->exit(2);
- break;
- }
-}
-
-void TestHandles::initTestCase()
-{
- initTestCaseImpl();
-
- // Wait for the CM to start up
- QVERIFY(waitForPinocchio(5000));
-
- // Escape to the low-level API to make a Connection; this uses
- // pseudo-blocking calls for simplicity. Do not do this in production code
-
- mCM = new ConnectionManagerInterface(
- pinocchioBusName(), pinocchioObjectPath());
-
- QDBusPendingReply<QString, QDBusObjectPath> reply;
- QVariantMap parameters;
- parameters.insert(QLatin1String("account"),
- QVariant::fromValue(QString::fromAscii("empty")));
- parameters.insert(QLatin1String("password"),
- QVariant::fromValue(QString::fromAscii("s3kr1t")));
-
- reply = mCM->RequestConnection("dummy", parameters);
- reply.waitForFinished();
- if (!reply.isValid()) {
- qWarning().nospace() << reply.error().name()
- << ": " << reply.error().message();
- QVERIFY(reply.isValid());
- }
- QString busName = reply.argumentAt<0>();
- QString objectPath = reply.argumentAt<1>().path();
-
- // Get a few connections connected
- mConn1a = Connection::create(busName, objectPath);
- mConn1b = Connection::create(busName, objectPath);
- QDBusConnection privateBus =
- QDBusConnection::connectToBus(QDBusConnection::SessionBus,
- "tpqt4_handles_test_private_bus");
- mConn2 = Connection::create(privateBus, busName, objectPath);
-
- // Connecting one connects them all
- QVERIFY(connect(mConn1a->requestConnect(),
- SIGNAL(finished(Tp::PendingOperation*)),
- this,
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
-
- ConnectionPtr connections[3] = {mConn1a, mConn1b, mConn2};
- for (int i = 0; i < 3; ++i) {
- ConnectionPtr conn = connections[i];
-
- if (conn->status() == Connection::StatusConnected) {
- qDebug() << conn << "Already ready";
- continue;
- }
-
- QVERIFY(connect(conn.data(), SIGNAL(statusChanged(uint, uint)),
- this, SLOT(expectConnReady(uint, uint))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(conn.data(), SIGNAL(statusChanged(uint, uint)),
- this, SLOT(expectConnReady(uint, uint))));
- }
-}
-
-void TestHandles::init()
-{
- initImpl();
-}
-
-void TestHandles::expectPendingHandlesFinished(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;
- }
-
- qDebug() << "finished";
- PendingHandles *pending = qobject_cast<PendingHandles*>(op);
- mHandles = pending->handles();
- mLoop->exit(0);
-}
-
-void TestHandles::testBasics()
-{
- // Get a reference to compare against (synchronously, don't do this in real applications)
- QStringList ids = QStringList() << "friend" << "buddy" << "associate" << "dude" << "guy";
- ConnectionInterface iface(mConn1a->busName(), mConn1a->objectPath());
- Tp::UIntList shouldBe = iface.RequestHandles(Tp::HandleTypeContact, ids);
-
- // Try and get the same handles asynchronously using the convenience API
- PendingHandles *pending = mConn1a->requestHandles(Tp::HandleTypeContact, ids);
-
- // Check that the closure is consistent with what we asked for
- QVERIFY(pending->isRequest());
- QCOMPARE(pending->namesRequested(), ids);
- QCOMPARE(pending->connection(), mConn1a);
- QCOMPARE(pending->handleType(), static_cast<uint>(Tp::HandleTypeContact));
-
- // Finish the request and extract the resulting ReferencedHandles
- QVERIFY(connect(pending, SIGNAL(finished(Tp::PendingOperation*)),
- this, SLOT(expectPendingHandlesFinished(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(pending, SIGNAL(finished(Tp::PendingOperation*)),
- this, SLOT(expectPendingHandlesFinished(Tp::PendingOperation*))));
- ReferencedHandles handles = mHandles;
- mHandles = ReferencedHandles();
-
- // Check that the ReferencedHandles are what we asked for
- QCOMPARE(handles.connection(), mConn1a);
- QCOMPARE(handles.handleType(), static_cast<uint>(Tp::HandleTypeContact));
- QVERIFY(handles == shouldBe);
-
- // Check that a copy of the received ReferencedHandles is also what we asked for (it's supposed
- // to be equivalent with one that we already verified as being that)
- ReferencedHandles copy = handles;
- QCOMPARE(copy.connection(), mConn1a);
- QCOMPARE(copy.handleType(), static_cast<uint>(Tp::HandleTypeContact));
-
- QVERIFY(copy == handles);
- QVERIFY(copy == shouldBe);
-}
-
-void TestHandles::testReferences()
-{
- // Used for verifying the handles we get actually work and continue to do so after various
- // operations which are supposed to preserve them
- ConnectionInterface iface(mConn1a->busName(), mConn1a->objectPath());
-
- // Declare some IDs to use as a test case
- QStringList ids = QStringList() << "mate" << "contact" << "partner" << "bloke" << "fellow";
-
- // Get referenced handles for all 5 of the IDs
- PendingHandles *allPending = mConn1a->requestHandles(Tp::HandleTypeContact, ids);
- QVERIFY(connect(allPending, SIGNAL(finished(Tp::PendingOperation*)),
- this, SLOT(expectPendingHandlesFinished(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(allPending, SIGNAL(finished(Tp::PendingOperation*)),
- this, SLOT(expectPendingHandlesFinished(Tp::PendingOperation*))));
- ReferencedHandles allHandles = mHandles;
- mHandles = ReferencedHandles();
-
- // Check that we actually have 5 handles
- QCOMPARE(allHandles.size(), 5);
-
- // ... and that they're valid at this point by inspecting them
- QDBusReply<QStringList> inspectReply = iface.InspectHandles(Tp::HandleTypeContact,
- Tp::UIntList::fromStdList(std::list<uint>(allHandles.begin(),
- allHandles.end())));
- QVERIFY(inspectReply.isValid());
- QCOMPARE(inspectReply.value().size(), 5);
-
- // Get another fresh reference to the middle three using the Connection
- PendingHandles *middlePending = mConn1a->referenceHandles(Tp::HandleTypeContact,
- Tp::UIntList() << allHandles[1] << allHandles[2] << allHandles[3]);
- QVERIFY(connect(middlePending, SIGNAL(finished(Tp::PendingOperation*)),
- this, SLOT(expectPendingHandlesFinished(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(middlePending, SIGNAL(finished(Tp::PendingOperation*)),
- this, SLOT(expectPendingHandlesFinished(Tp::PendingOperation*))));
- ReferencedHandles middleHandles = mHandles;
- mHandles = ReferencedHandles();
-
- // ... and another reference to the last three using ReferencedHandles RAII magic
- ReferencedHandles lastHandles = allHandles.mid(2);
-
- // Check that they actually contain the right handles
- QCOMPARE(middleHandles.size(), 3);
- QCOMPARE(lastHandles.size(), 3);
-
- QCOMPARE(middleHandles[0], allHandles[1]);
- QCOMPARE(middleHandles[1], allHandles[2]);
- QCOMPARE(middleHandles[2], allHandles[3]);
-
- QCOMPARE(lastHandles[0], allHandles[2]);
- QCOMPARE(lastHandles[1], allHandles[3]);
- QCOMPARE(lastHandles[2], allHandles[4]);
-
- // Ok, so at this point they're valid handles, because they're the same we already checked as
- // being valid - but what if we nuke the original ReferencedHandles containing all of the
- // handles? Let's save its first one though...
- uint firstHandle = allHandles.first();
- allHandles = ReferencedHandles();
-
- // Let's process the now-queued events first so what's going to be released is released
- mLoop->processEvents();
-
- // Now check that our middle and last handles can still be inspected
- inspectReply = iface.InspectHandles(Tp::HandleTypeContact,
- Tp::UIntList::fromStdList(std::list<uint>(middleHandles.begin(),
- middleHandles.end())));
- QVERIFY(inspectReply.isValid());
- QCOMPARE(inspectReply.value().size(), 3);
-
- inspectReply = iface.InspectHandles(Tp::HandleTypeContact,
- Tp::UIntList::fromStdList(std::list<uint>(lastHandles.begin(),
- lastHandles.end())));
- QVERIFY(inspectReply.isValid());
- QCOMPARE(inspectReply.value().size(), 3);
-
- // Because we know that in this self-contained test, nobody else can possibly be holding the
- // first handle, and we have dropped the last ReferencedHandles having it, it should be invalid
- //
- // However, the telepathy-python 0.15.3 ReleaseHandles implementation is made of cheese. I know
- // how to fix it, but until we've released tp-python with the fix, and added a dependency on
- // that new version of tp-python for the tests, we can't enable this.
- // inspectReply = iface.InspectHandles(Tp::HandleTypeContact,
- // Tp::UIntList() << firstHandle);
- // QVERIFY(!inspectReply.isValid());
- Q_UNUSED(firstHandle);
-}
-
-void TestHandles::cleanup()
-{
- cleanupImpl();
-}
-
-void TestHandles::cleanupTestCase()
-{
- // Disconnecting one disconnects them all, because they all poke the same
- // remote Connection
- QVERIFY(connect(mConn1a->requestDisconnect(),
- SIGNAL(finished(Tp::PendingOperation*)),
- this,
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
-
- delete mCM;
- mCM = NULL;
-
- cleanupTestCaseImpl();
-}
-
-QTEST_MAIN(TestHandles)
-#include "_gen/handles.cpp.moc.hpp"
diff --git a/tests/pinocchio/lib.cpp b/tests/pinocchio/lib.cpp
deleted file mode 100644
index 227dbb8..0000000
--- a/tests/pinocchio/lib.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-#include "tests/pinocchio/lib.h"
-
-#include <cstdlib>
-
-#include <QtCore/QTimer>
-
-#include <TelepathyQt4/Types>
-#include <TelepathyQt4/Debug>
-#include <TelepathyQt4/DBus>
-
-using Tp::Client::DBus::DBusDaemonInterface;
-using Tp::PendingOperation;
-
-PinocchioTest::PinocchioTest(QObject *parent)
- : Test(parent)
-{
-}
-
-PinocchioTest::~PinocchioTest()
-{
-}
-
-void PinocchioTest::initTestCaseImpl()
-{
- Test::initTestCaseImpl();
-
- mPinocchioPath = QString::fromLocal8Bit(::getenv("PINOCCHIO"));
- mPinocchioCtlPath = QString::fromLocal8Bit(::getenv("PINOCCHIO_CTL"));
- QString pinocchioSavePath = QString::fromLocal8Bit(
- ::getenv("PINOCCHIO_SAVE_DIR"));
-
- QVERIFY2(!mPinocchioPath.isEmpty(), "Put $PINOCCHIO in your environment");
- QVERIFY2(!mPinocchioCtlPath.isEmpty(),
- "Put $PINOCCHIO_CTL in your environment");
- QVERIFY2(!pinocchioSavePath.isEmpty(),
- "Put $PINOCCHIO_SAVE_DIR in your environment");
-
- QDir dir;
- dir.mkpath(pinocchioSavePath);
- dir.cd(pinocchioSavePath);
- dir.remove(QLatin1String("empty/contacts.xml"));
-
- mPinocchio.setProcessChannelMode(QProcess::ForwardedChannels);
- mPinocchio.start(mPinocchioPath, QStringList());
-
- QVERIFY(mPinocchio.waitForStarted(5000));
- mPinocchio.closeWriteChannel();
-
- qDebug() << "Started Pinocchio";
-}
-
-void PinocchioTest::gotNameOwner(QDBusPendingCallWatcher* watcher)
-{
- QDBusPendingReply<QString> reply = *watcher;
-
- if (reply.isError()) {
- return;
- }
-
- if (reply.value() != "") {
- // it has an owner now
- mLoop->exit(1);
- }
-}
-
-
-void PinocchioTest::onNameOwnerChanged(const QString& name,
- const QString& old, const QString& owner)
-{
- if (name != pinocchioBusName()) {
- return;
- }
-
- if (owner != "") {
- // it has an owner now
- mLoop->exit(1);
- }
-}
-
-
-bool PinocchioTest::waitForPinocchio(uint timeoutMs)
-{
- QTimer timer;
-
- connect(&timer, SIGNAL(timeout()), mLoop, SLOT(quit()));
- timer.setSingleShot(true);
- timer.start(timeoutMs);
-
- DBusDaemonInterface busDaemon("org.freedesktop.DBus", "/org/freedesktop/DBus");
- connect(&busDaemon,
- SIGNAL(NameOwnerChanged(const QString&, const QString&, const QString&)),
- this,
- SLOT(onNameOwnerChanged(const QString&, const QString&, const QString&)));
- QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(
- busDaemon.GetNameOwner(pinocchioBusName()));
- connect(watcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
- this, SLOT(gotNameOwner(QDBusPendingCallWatcher*)));
-
- bool ret = (mLoop->exec() == 1);
-
- timer.stop();
-
- // signals will automatically be disconnected as timer and busDaemon
- // go out of scope
-
- return ret;
-}
-
-
-void PinocchioTest::cleanupTestCaseImpl()
-{
- qDebug() << "Terminating Pinocchio";
-
- mPinocchio.terminate();
-
- if (!mPinocchio.waitForFinished(1000)) {
- mPinocchio.kill();
- }
-
- Test::cleanupTestCaseImpl();
-}
-
-#include "_gen/lib.h.moc.hpp"
diff --git a/tests/pinocchio/lib.h b/tests/pinocchio/lib.h
deleted file mode 100644
index 08654ec..0000000
--- a/tests/pinocchio/lib.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#include <QtCore/QProcess>
-
-#include <QtDBus/QtDBus>
-
-#include <QtTest/QtTest>
-
-#include <TelepathyQt4/PendingOperation>
-#include <TelepathyQt4/Constants>
-
-#include "tests/lib/test.h"
-
-class PinocchioTest : public Test
-{
- Q_OBJECT
-
-public:
-
- PinocchioTest(QObject *parent = 0);
-
- virtual ~PinocchioTest();
-
- static inline QLatin1String pinocchioBusName()
- {
- return QLatin1String(
- TELEPATHY_CONNECTION_MANAGER_BUS_NAME_BASE "pinocchio");
- }
-
- static inline QLatin1String pinocchioObjectPath()
- {
- return QLatin1String(
- TELEPATHY_CONNECTION_MANAGER_OBJECT_PATH_BASE "pinocchio");
- }
-
- bool waitForPinocchio(uint timeoutMs = 5000);
-
-protected:
- QString mPinocchioPath;
- QString mPinocchioCtlPath;
- QProcess mPinocchio;
-
- virtual void initTestCaseImpl();
-
- virtual void cleanupTestCaseImpl();
-
-protected Q_SLOTS:
- void gotNameOwner(QDBusPendingCallWatcher* watcher);
- void onNameOwnerChanged(const QString&, const QString&, const QString&);
-};
--
1.5.6.5
More information about the telepathy-commits
mailing list