summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2012-04-09 17:12:12 +0300
committerGeorge Kiagiadakis <george.kiagiadakis@collabora.com>2012-04-09 17:57:40 +0300
commita3ebacbc33eb4c026a90e1191ac8da9c38aebcac (patch)
tree3e3d1a006b208b7ace0f929ba54d44d8dd13345b
parent1c9933cd7dc509779abcc22fd4622cb353798711 (diff)
tests: Add a new test for testing BaseConnectionManager
The test currently contains an adaptation of tp-glib's example-no-protocols test.
-rw-r--r--tests/dbus/CMakeLists.txt4
-rw-r--r--tests/dbus/base-cm.cpp92
2 files changed, 96 insertions, 0 deletions
diff --git a/tests/dbus/CMakeLists.txt b/tests/dbus/CMakeLists.txt
index a7105488..5b87a6c1 100644
--- a/tests/dbus/CMakeLists.txt
+++ b/tests/dbus/CMakeLists.txt
@@ -83,6 +83,10 @@ tpqt_add_dbus_unit_test(CmProtocol cm-protocol)
tpqt_add_dbus_unit_test(ProfileManager profile-manager)
tpqt_add_dbus_unit_test(Types types)
+if(ENABLE_EXPERIMENTAL_SERVICE_SUPPORT)
+ tpqt_add_dbus_unit_test(BaseConnectionManager base-cm telepathy-qt${QT_VERSION_MAJOR}-service)
+endif(ENABLE_EXPERIMENTAL_SERVICE_SUPPORT)
+
# Make check target. In case of check, output on failure and put it into a log
# This target has to stay here for catching all of the tests
add_custom_target(check ctest --output-on-failure -O test.log
diff --git a/tests/dbus/base-cm.cpp b/tests/dbus/base-cm.cpp
new file mode 100644
index 00000000..75064088
--- /dev/null
+++ b/tests/dbus/base-cm.cpp
@@ -0,0 +1,92 @@
+#include <tests/lib/test.h>
+
+#define TP_QT_ENABLE_LOWLEVEL_API
+
+#include <TelepathyQt/BaseConnectionManager>
+#include <TelepathyQt/ConnectionManager>
+#include <TelepathyQt/ConnectionManagerLowlevel>
+#include <TelepathyQt/DBusError>
+#include <TelepathyQt/PendingReady>
+#include <TelepathyQt/PendingConnection>
+
+using namespace Tp;
+
+class TestBaseCM : public Test
+{
+ Q_OBJECT
+public:
+ TestBaseCM(QObject *parent = 0)
+ : Test(parent)
+ { }
+
+private Q_SLOTS:
+ void initTestCase();
+ void init();
+
+ void testNoProtocols();
+
+ void cleanup();
+ void cleanupTestCase();
+
+};
+
+void TestBaseCM::initTestCase()
+{
+ initTestCaseImpl();
+}
+
+void TestBaseCM::init()
+{
+ initImpl();
+}
+
+void TestBaseCM::testNoProtocols()
+{
+ qDebug() << "Introspecting non-existing CM";
+
+ ConnectionManagerPtr cliCM = ConnectionManager::create(
+ QLatin1String("testcm"));
+ PendingReady *pr = cliCM->becomeReady(ConnectionManager::FeatureCore);
+ connect(pr, SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(expectFailure(Tp::PendingOperation*)));
+ QCOMPARE(mLoop->exec(), 0);
+
+ qDebug() << "Creating CM";
+
+ BaseConnectionManagerPtr cm = BaseConnectionManager::create(
+ QLatin1String("testcm"));
+ Tp::DBusError err;
+ QVERIFY(cm->registerObject(&err));
+ QVERIFY(!err.isValid());
+
+ qDebug() << "Introspecting new CM";
+
+ cliCM = ConnectionManager::create(QLatin1String("testcm"));
+ pr = cliCM->becomeReady(ConnectionManager::FeatureCore);
+ connect(pr, SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(expectSuccessfulCall(Tp::PendingOperation*)));
+ QCOMPARE(mLoop->exec(), 0);
+
+ QCOMPARE(cliCM->supportedProtocols().size(), 0);
+
+ qDebug() << "Requesting connection";
+
+ PendingConnection *pc = cliCM->lowlevel()->requestConnection(
+ QLatin1String("jabber"), QVariantMap());
+ connect(pc, SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(expectFailure(Tp::PendingOperation*)));
+ QCOMPARE(mLoop->exec(), 0);
+}
+
+void TestBaseCM::cleanup()
+{
+ cleanupImpl();
+}
+
+void TestBaseCM::cleanupTestCase()
+{
+ cleanupTestCaseImpl();
+}
+
+QTEST_MAIN(TestBaseCM)
+#include "_gen/base-cm.cpp.moc.hpp"