mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-14 09:25:49 +08:00
(will be consolidated with existing utility classes)
This commit is contained in:
committed by
Mathew Sutcliffe
parent
ae5b0310b6
commit
ed820da20d
@@ -18,8 +18,7 @@
|
||||
#include "testnetwork.h"
|
||||
#include "testreaders.h"
|
||||
#include "testcontext.h"
|
||||
#include "testdbus.h"
|
||||
#include "blackmisc/test.h"
|
||||
#include "blackmisc/test/test.h"
|
||||
#include <QStringList>
|
||||
#include <QtTest>
|
||||
|
||||
@@ -27,12 +26,8 @@ namespace BlackCoreTest
|
||||
{
|
||||
int CBlackCoreTestMain::unitMain(int argc, char *argv[])
|
||||
{
|
||||
BlackMisc::CTest test(argc, argv);
|
||||
BlackMisc::Test::CTest test(argc, argv);
|
||||
int status = 0;
|
||||
{
|
||||
CTestDBus dbusTests;
|
||||
status |= test.exec(&dbusTests, "blackcore_dbus");
|
||||
}
|
||||
{
|
||||
CTestContext contextTests;
|
||||
status |= test.exec(&contextTests, "blackcore_context");
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
/* 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.
|
||||
*/
|
||||
|
||||
//! \cond PRIVATE_TESTS
|
||||
|
||||
/*!
|
||||
* \file
|
||||
* \ingroup testblackcore
|
||||
*/
|
||||
|
||||
#include "testdbus.h"
|
||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||
#include "blackcore/test/testutils.h"
|
||||
#include "blackcore/test/testservice.h"
|
||||
#include "blackcore/test/testserviceinterface.h"
|
||||
#include <QDBusConnection>
|
||||
#include <QTest>
|
||||
|
||||
using namespace BlackMisc::Simulation;
|
||||
using namespace BlackCore::Test;
|
||||
|
||||
namespace BlackCoreTest
|
||||
{
|
||||
void CTestDBus::marshallUnmarshall()
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
||||
void CTestDBus::signatureSize()
|
||||
{
|
||||
constexpr int max = 255;
|
||||
QString s;
|
||||
|
||||
// normally CSimulatedAircraftList is expected to be the biggest one
|
||||
const CAircraftModel model;
|
||||
s = CTestUtils::dBusSignature(model);
|
||||
QVERIFY2(s.length() <= max, "Signature CAircraftModel");
|
||||
|
||||
const CSimulatedAircraft aircraft;
|
||||
s = CTestUtils::dBusSignature(aircraft);
|
||||
QVERIFY2(s.length() <= max, "Signature CSimulatedAircraft");
|
||||
|
||||
const CSimulatedAircraftList al;
|
||||
s = CTestUtils::dBusSignature(al);
|
||||
QVERIFY2(s.length() <= max, "Signature CSimulatedAircraftList");
|
||||
}
|
||||
}
|
||||
|
||||
//! \endcond
|
||||
@@ -1,46 +0,0 @@
|
||||
/* 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