[Telepathy-commits] [telepathy-qt4/master] Renamed tests/dbus/chan-basics.cpp to tests/dbus/conn-requests.cpp.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Tue Jan 27 07:26:32 PST 2009
---
tests/dbus/Makefile.am | 10 +-
tests/dbus/chan-basics.cpp | 311 ------------------------------------------
tests/dbus/conn-requests.cpp | 311 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 316 insertions(+), 316 deletions(-)
delete mode 100644 tests/dbus/chan-basics.cpp
create mode 100644 tests/dbus/conn-requests.cpp
diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am
index 867389d..2f60126 100644
--- a/tests/dbus/Makefile.am
+++ b/tests/dbus/Makefile.am
@@ -38,30 +38,30 @@ if ENABLE_TP_GLIB_TESTS
# Tests which can only be run if we have telepathy-glib, and Qt was compiled
# to use the GLib main loop
TESTS += \
- test-chan-basics \
test-cm-basics \
test-conn-basics \
+ test-conn-requests \
test-handles \
test-stateful-proxy
BUILT_SOURCES += \
- _gen/chan-basics.cpp.moc.hpp \
_gen/cm-basics.cpp.moc.hpp \
_gen/conn-basics.cpp.moc.hpp \
+ _gen/conn-requests.cpp.moc.hpp \
_gen/handles.cpp.moc.hpp \
_gen/stateful-proxy.cpp.moc.hpp
MOC_INCLUDES += $(TP_GLIB_CFLAGS)
-test_chan_basics_SOURCES = chan-basics.cpp
-test_chan_basics_LDADD = $(LDADD) $(top_builddir)/tests/lib/echo2/libtp-glib-echo2-tests.la
-
test_cm_basics_SOURCES = cm-basics.cpp
test_cm_basics_LDADD = $(LDADD) $(top_builddir)/tests/lib/libtp-glib-tests.la
test_conn_basics_SOURCES = conn-basics.cpp
test_conn_basics_LDADD = $(LDADD) $(top_builddir)/tests/lib/libtp-glib-tests.la
+test_conn_requests_SOURCES = conn-requests.cpp
+test_conn_requests_LDADD = $(LDADD) $(top_builddir)/tests/lib/echo2/libtp-glib-echo2-tests.la
+
test_handles_SOURCES = handles.cpp
test_handles_LDADD = $(LDADD) $(top_builddir)/tests/lib/libtp-glib-tests.la
diff --git a/tests/dbus/chan-basics.cpp b/tests/dbus/chan-basics.cpp
deleted file mode 100644
index 2baa3dc..0000000
--- a/tests/dbus/chan-basics.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-#include <QtCore/QDebug>
-#include <QtCore/QTimer>
-
-#include <QtDBus/QtDBus>
-
-#include <QtTest/QtTest>
-
-#include <TelepathyQt4/Client/Channel>
-#include <TelepathyQt4/Client/Connection>
-#include <TelepathyQt4/Client/PendingChannel>
-#include <TelepathyQt4/Client/PendingHandles>
-#include <TelepathyQt4/Debug>
-
-#include <telepathy-glib/debug.h>
-
-#include <tests/lib/echo2/conn.h>
-#include <tests/lib/test.h>
-
-using namespace Telepathy::Client;
-
-class TestChanBasics : public Test
-{
- Q_OBJECT
-
-public:
- TestChanBasics(QObject *parent = 0)
- : Test(parent), mConnService(0), mConn(0), mHandle(0)
- { }
-
-protected Q_SLOTS:
- void expectConnReady(uint, uint);
- void expectConnInvalidated();
- void expectPendingHandleFinished(Telepathy::Client::PendingOperation*);
- void expectCreateChannelFinished(Telepathy::Client::PendingOperation *);
- void expectEnsureChannelFinished(Telepathy::Client::PendingOperation *);
-
-private Q_SLOTS:
- void initTestCase();
- void init();
-
- void testRequestHandle();
- void testCreateChannel();
- void testEnsureChannel();
-
- void cleanup();
- void cleanupTestCase();
-
-private:
- QString mConnName, mConnPath;
- ExampleEcho2Connection *mConnService;
- Connection *mConn;
- QString mChanObjectPath;
- uint mHandle;
-};
-
-void TestChanBasics::expectConnReady(uint newStatus, uint newStatusReason)
-{
- qDebug() << "connection changed to status" << newStatus;
- 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 TestChanBasics::expectConnInvalidated()
-{
- mLoop->exit(0);
-}
-
-void TestChanBasics::expectPendingHandleFinished(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);
- mHandle = pending->handles().at(0);
- mLoop->exit(0);
-}
-
-void TestChanBasics::expectCreateChannelFinished(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();
- mChanObjectPath = chan->objectPath();
- mLoop->exit(0);
-}
-
-void TestChanBasics::expectEnsureChannelFinished(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();
- QCOMPARE(pc->yours(), false);
- QCOMPARE(chan->objectPath(), mChanObjectPath);
- mLoop->exit(0);
-}
-
-void TestChanBasics::initTestCase()
-{
- initTestCaseImpl();
-
- g_type_init();
- g_set_prgname("conn-basics");
- tp_debug_set_flags("all");
-
- gchar *name;
- gchar *connPath;
- GError *error = 0;
-
- mConnService = EXAMPLE_ECHO_2_CONNECTION(g_object_new(
- EXAMPLE_TYPE_ECHO_2_CONNECTION,
- "account", "me at example.com",
- "protocol", "contacts",
- 0));
- QVERIFY(mConnService != 0);
- QVERIFY(tp_base_connection_register(TP_BASE_CONNECTION(mConnService),
- "contacts", &name, &connPath, &error));
- QVERIFY(error == 0);
-
- QVERIFY(name != 0);
- QVERIFY(connPath != 0);
-
- mConnName = name;
- mConnPath = connPath;
-
- g_free(name);
- g_free(connPath);
-
- mConn = new Connection(mConnName, mConnPath);
- QCOMPARE(mConn->isReady(), false);
-
- mConn->requestConnect();
-
- QVERIFY(connect(mConn->becomeReady(),
- SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QCOMPARE(mConn->isReady(), true);
-
- if (mConn->status() != Connection::StatusConnected) {
- QVERIFY(connect(mConn,
- SIGNAL(statusChanged(uint, uint)),
- SLOT(expectConnReady(uint, uint))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(mConn,
- SIGNAL(statusChanged(uint, uint)),
- this,
- SLOT(expectConnReady(uint, uint))));
- QCOMPARE(mConn->status(), (uint) Connection::StatusConnected);
- }
-
- QVERIFY(mConn->requestsInterface() != 0);
-}
-
-void TestChanBasics::init()
-{
- initImpl();
-}
-
-void TestChanBasics::testRequestHandle()
-{
- // Test identifiers
- QStringList ids = QStringList() << "alice";
-
- // Request handles for the identifiers and wait for the request to process
- PendingHandles *pending = mConn->requestHandles(Telepathy::HandleTypeContact, ids);
- QVERIFY(connect(pending,
- SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- SLOT(expectPendingHandleFinished(Telepathy::Client::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QVERIFY(disconnect(pending,
- SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- this,
- SLOT(expectPendingHandleFinished(Telepathy::Client::PendingOperation*))));
- QVERIFY(mHandle != 0);
-}
-
-void TestChanBasics::testCreateChannel()
-{
- QVariantMap request;
- request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType"),
- TELEPATHY_INTERFACE_CHANNEL_TYPE_TEXT);
- request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandleType"),
- Telepathy::HandleTypeContact);
- request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandle"),
- mHandle);
- QVERIFY(connect(mConn->createChannel(request),
- SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- SLOT(expectCreateChannelFinished(Telepathy::Client::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
-}
-
-void TestChanBasics::testEnsureChannel()
-{
- QVariantMap request;
- request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType"),
- TELEPATHY_INTERFACE_CHANNEL_TYPE_TEXT);
- request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandleType"),
- Telepathy::HandleTypeContact);
- request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandle"),
- mHandle);
- QVERIFY(connect(mConn->ensureChannel(request),
- SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- SLOT(expectEnsureChannelFinished(Telepathy::Client::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
-}
-
-void TestChanBasics::cleanup()
-{
- cleanupImpl();
-}
-
-void TestChanBasics::cleanupTestCase()
-{
- if (mConn != 0) {
- // Disconnect and wait for the readiness change
- QVERIFY(connect(mConn->requestDisconnect(),
- SIGNAL(finished(Telepathy::Client::PendingOperation*)),
- SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
-
- if (mConn->isValid()) {
- QVERIFY(connect(mConn,
- SIGNAL(invalidated(Telepathy::Client::DBusProxy *proxy,
- QString errorName, QString errorMessage)),
- SLOT(expectConnInvalidated())));
- QCOMPARE(mLoop->exec(), 0);
- }
-
- delete mConn;
- mConn = 0;
- }
-
- if (mConnService != 0) {
- g_object_unref(mConnService);
- mConnService = 0;
- }
-
- cleanupTestCaseImpl();
-}
-
-QTEST_MAIN(TestChanBasics)
-#include "_gen/chan-basics.cpp.moc.hpp"
diff --git a/tests/dbus/conn-requests.cpp b/tests/dbus/conn-requests.cpp
new file mode 100644
index 0000000..ccbb1a7
--- /dev/null
+++ b/tests/dbus/conn-requests.cpp
@@ -0,0 +1,311 @@
+#include <QtCore/QDebug>
+#include <QtCore/QTimer>
+
+#include <QtDBus/QtDBus>
+
+#include <QtTest/QtTest>
+
+#include <TelepathyQt4/Client/Channel>
+#include <TelepathyQt4/Client/Connection>
+#include <TelepathyQt4/Client/PendingChannel>
+#include <TelepathyQt4/Client/PendingHandles>
+#include <TelepathyQt4/Debug>
+
+#include <telepathy-glib/debug.h>
+
+#include <tests/lib/echo2/conn.h>
+#include <tests/lib/test.h>
+
+using namespace Telepathy::Client;
+
+class TestConnRequests : public Test
+{
+ Q_OBJECT
+
+public:
+ TestConnRequests(QObject *parent = 0)
+ : Test(parent), mConnService(0), mConn(0), mHandle(0)
+ { }
+
+protected Q_SLOTS:
+ void expectConnReady(uint, uint);
+ void expectConnInvalidated();
+ void expectPendingHandleFinished(Telepathy::Client::PendingOperation*);
+ void expectCreateChannelFinished(Telepathy::Client::PendingOperation *);
+ void expectEnsureChannelFinished(Telepathy::Client::PendingOperation *);
+
+private Q_SLOTS:
+ void initTestCase();
+ void init();
+
+ void testRequestHandle();
+ void testCreateChannel();
+ void testEnsureChannel();
+
+ void cleanup();
+ void cleanupTestCase();
+
+private:
+ QString mConnName, mConnPath;
+ ExampleEcho2Connection *mConnService;
+ Connection *mConn;
+ QString mChanObjectPath;
+ uint mHandle;
+};
+
+void TestConnRequests::expectConnReady(uint newStatus, uint newStatusReason)
+{
+ qDebug() << "connection changed to status" << newStatus;
+ 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 TestConnRequests::expectConnInvalidated()
+{
+ mLoop->exit(0);
+}
+
+void TestConnRequests::expectPendingHandleFinished(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);
+ mHandle = pending->handles().at(0);
+ mLoop->exit(0);
+}
+
+void TestConnRequests::expectCreateChannelFinished(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();
+ mChanObjectPath = chan->objectPath();
+ mLoop->exit(0);
+}
+
+void TestConnRequests::expectEnsureChannelFinished(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();
+ QCOMPARE(pc->yours(), false);
+ QCOMPARE(chan->objectPath(), mChanObjectPath);
+ mLoop->exit(0);
+}
+
+void TestConnRequests::initTestCase()
+{
+ initTestCaseImpl();
+
+ g_type_init();
+ g_set_prgname("conn-basics");
+ tp_debug_set_flags("all");
+
+ gchar *name;
+ gchar *connPath;
+ GError *error = 0;
+
+ mConnService = EXAMPLE_ECHO_2_CONNECTION(g_object_new(
+ EXAMPLE_TYPE_ECHO_2_CONNECTION,
+ "account", "me at example.com",
+ "protocol", "contacts",
+ 0));
+ QVERIFY(mConnService != 0);
+ QVERIFY(tp_base_connection_register(TP_BASE_CONNECTION(mConnService),
+ "contacts", &name, &connPath, &error));
+ QVERIFY(error == 0);
+
+ QVERIFY(name != 0);
+ QVERIFY(connPath != 0);
+
+ mConnName = name;
+ mConnPath = connPath;
+
+ g_free(name);
+ g_free(connPath);
+
+ mConn = new Connection(mConnName, mConnPath);
+ QCOMPARE(mConn->isReady(), false);
+
+ mConn->requestConnect();
+
+ QVERIFY(connect(mConn->becomeReady(),
+ SIGNAL(finished(Telepathy::Client::PendingOperation*)),
+ SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation*))));
+ QCOMPARE(mLoop->exec(), 0);
+ QCOMPARE(mConn->isReady(), true);
+
+ if (mConn->status() != Connection::StatusConnected) {
+ QVERIFY(connect(mConn,
+ SIGNAL(statusChanged(uint, uint)),
+ SLOT(expectConnReady(uint, uint))));
+ QCOMPARE(mLoop->exec(), 0);
+ QVERIFY(disconnect(mConn,
+ SIGNAL(statusChanged(uint, uint)),
+ this,
+ SLOT(expectConnReady(uint, uint))));
+ QCOMPARE(mConn->status(), (uint) Connection::StatusConnected);
+ }
+
+ QVERIFY(mConn->requestsInterface() != 0);
+}
+
+void TestConnRequests::init()
+{
+ initImpl();
+}
+
+void TestConnRequests::testRequestHandle()
+{
+ // Test identifiers
+ QStringList ids = QStringList() << "alice";
+
+ // Request handles for the identifiers and wait for the request to process
+ PendingHandles *pending = mConn->requestHandles(Telepathy::HandleTypeContact, ids);
+ QVERIFY(connect(pending,
+ SIGNAL(finished(Telepathy::Client::PendingOperation*)),
+ SLOT(expectPendingHandleFinished(Telepathy::Client::PendingOperation*))));
+ QCOMPARE(mLoop->exec(), 0);
+ QVERIFY(disconnect(pending,
+ SIGNAL(finished(Telepathy::Client::PendingOperation*)),
+ this,
+ SLOT(expectPendingHandleFinished(Telepathy::Client::PendingOperation*))));
+ QVERIFY(mHandle != 0);
+}
+
+void TestConnRequests::testCreateChannel()
+{
+ QVariantMap request;
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType"),
+ TELEPATHY_INTERFACE_CHANNEL_TYPE_TEXT);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandleType"),
+ Telepathy::HandleTypeContact);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandle"),
+ mHandle);
+ QVERIFY(connect(mConn->createChannel(request),
+ SIGNAL(finished(Telepathy::Client::PendingOperation*)),
+ SLOT(expectCreateChannelFinished(Telepathy::Client::PendingOperation*))));
+ QCOMPARE(mLoop->exec(), 0);
+}
+
+void TestConnRequests::testEnsureChannel()
+{
+ QVariantMap request;
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".ChannelType"),
+ TELEPATHY_INTERFACE_CHANNEL_TYPE_TEXT);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandleType"),
+ Telepathy::HandleTypeContact);
+ request.insert(QLatin1String(TELEPATHY_INTERFACE_CHANNEL ".TargetHandle"),
+ mHandle);
+ QVERIFY(connect(mConn->ensureChannel(request),
+ SIGNAL(finished(Telepathy::Client::PendingOperation*)),
+ SLOT(expectEnsureChannelFinished(Telepathy::Client::PendingOperation*))));
+ QCOMPARE(mLoop->exec(), 0);
+}
+
+void TestConnRequests::cleanup()
+{
+ cleanupImpl();
+}
+
+void TestConnRequests::cleanupTestCase()
+{
+ if (mConn != 0) {
+ // Disconnect and wait for the readiness change
+ QVERIFY(connect(mConn->requestDisconnect(),
+ SIGNAL(finished(Telepathy::Client::PendingOperation*)),
+ SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation*))));
+ QCOMPARE(mLoop->exec(), 0);
+
+ if (mConn->isValid()) {
+ QVERIFY(connect(mConn,
+ SIGNAL(invalidated(Telepathy::Client::DBusProxy *proxy,
+ QString errorName, QString errorMessage)),
+ SLOT(expectConnInvalidated())));
+ QCOMPARE(mLoop->exec(), 0);
+ }
+
+ delete mConn;
+ mConn = 0;
+ }
+
+ if (mConnService != 0) {
+ g_object_unref(mConnService);
+ mConnService = 0;
+ }
+
+ cleanupTestCaseImpl();
+}
+
+QTEST_MAIN(TestConnRequests)
+#include "_gen/conn-requests.cpp.moc.hpp"
--
1.5.6.5
More information about the Telepathy-commits
mailing list