diff --git a/tests/blackcore/testblackcoremain.cpp b/tests/blackcore/testblackcoremain.cpp index 6db02615e..818c7fb1d 100644 --- a/tests/blackcore/testblackcoremain.cpp +++ b/tests/blackcore/testblackcoremain.cpp @@ -17,8 +17,9 @@ #include "testblackcoremain.h" #include "testnetwork.h" #include "testreaders.h" +#include "testcontext.h" +#include "testdbus.h" #include "blackmisc/test.h" - #include #include @@ -27,8 +28,15 @@ namespace BlackCoreTest int CBlackCoreTestMain::unitMain(int argc, char *argv[]) { BlackMisc::CTest test(argc, argv); - int status = 0; + { + CTestDBus dbusTests; + status |= test.exec(&dbusTests, "blackcore_dbus"); + } + { + CTestContext contextTests; + status |= test.exec(&contextTests, "blackcore_context"); + } { CTestReaders readersTests; status |= test.exec(&readersTests, "blackcore_readers"); diff --git a/tests/blackcore/testdbus.cpp b/tests/blackcore/testdbus.cpp index 87831a4fa..b3770fa1d 100644 --- a/tests/blackcore/testdbus.cpp +++ b/tests/blackcore/testdbus.cpp @@ -29,7 +29,15 @@ namespace BlackCoreTest { void CTestDBus::marshallUnmarshall() { - ITestServiceInterface testServiceInterface(CTestService::InterfaceName(), CTestService::ObjectPath(), QDBusConnection::sessionBus()); + QDBusConnection connection = QDBusConnection::sessionBus(); + if (!CTestService::canRegisterTestService(connection)) + { + QSKIP("Cannot register DBus service, skip unit test"); + return; + } + CTestService *testService = CTestService::registerTestService(connection, false, QCoreApplication::instance()); + Q_UNUSED(testService); + ITestServiceInterface testServiceInterface(CTestService::InterfaceName(), CTestService::ObjectPath(), connection); int errors = ITestServiceInterface::pingTests(testServiceInterface, false); QVERIFY2(errors == 0, "DBus Ping tests fail"); } diff --git a/tests/blackcore/testdbus.h b/tests/blackcore/testdbus.h new file mode 100644 index 000000000..e40dba890 --- /dev/null +++ b/tests/blackcore/testdbus.h @@ -0,0 +1,46 @@ +/* Copyright (C) 2017 + * swift project community / contributors + * + * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level + * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, + * including this file, may be copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE file. + */ + +#ifndef BLACKCORETEST_TESTDBUS_H +#define BLACKCORETEST_TESTDBUS_H + +#include "blackmisc/variant.h" +#include + +//! \cond PRIVATE_TESTS +//! \file +//! \ingroup testblackcore + +namespace BlackCoreTest +{ + /*! + * DBus implementation classes tests + */ + class CTestDBus : public QObject + { + Q_OBJECT + + public: + //! Constructor. + explicit CTestDBus(QObject *parent = nullptr) : + QObject(parent) + {} + + private slots: + //! Test marshalling/unmarshalling + void marshallUnmarshall(); + + //! Signature size + void signatureSize(); + }; +} //namespace + +//! \endcond + +#endif // guard