mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
refs #875, unit tests for DBus
This commit is contained in:
committed by
Mathew Sutcliffe
parent
7bfc9810cb
commit
e28056ac2f
@@ -17,8 +17,9 @@
|
||||
#include "testblackcoremain.h"
|
||||
#include "testnetwork.h"
|
||||
#include "testreaders.h"
|
||||
#include "testcontext.h"
|
||||
#include "testdbus.h"
|
||||
#include "blackmisc/test.h"
|
||||
|
||||
#include <QStringList>
|
||||
#include <QtTest>
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
46
tests/blackcore/testdbus.h
Normal file
46
tests/blackcore/testdbus.h
Normal file
@@ -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 <QObject>
|
||||
|
||||
//! \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
|
||||
Reference in New Issue
Block a user