diff options
-rw-r--r-- | tests/dbus/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/dbus/base-cm.cpp | 92 |
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" |