mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-08-11 12:15:36 +08:00
committed by
Mathew Sutcliffe
parent
978f3c88e5
commit
c6da7b0d35
@@ -1,66 +0,0 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "testnetmediators.h"
|
||||
#include "blackmisc/context.h"
|
||||
#include <QObject>
|
||||
|
||||
namespace BlackCoreTest
|
||||
{
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Geo;
|
||||
|
||||
void CTestNetMediators::initTestCase()
|
||||
{
|
||||
m_context.setObject<INetwork>(m_networkDummy);
|
||||
}
|
||||
|
||||
void CTestNetMediators::cleanupTestCase()
|
||||
{
|
||||
m_context.removeObject<INetwork>();
|
||||
}
|
||||
|
||||
void CTestNetMediators::atcListManagerTest()
|
||||
{
|
||||
CAtcListManager mgr(m_context);
|
||||
AtcListConsumer cons;
|
||||
|
||||
QObject::connect(&mgr, &IAtcListManager::listChanged, &cons, &AtcListConsumer::listChanged);
|
||||
|
||||
QVERIFY(cons.m_list.constMap().size() == 0);
|
||||
|
||||
emit m_networkDummy.atcPositionUpdate("EGLL_TWR", CFrequency(118.7, CFrequencyUnit::MHz()), CCoordinateGeodetic(51.4775, 0.46139, 0), CLength(50, CLengthUnit::m()));
|
||||
QCoreApplication::processEvents();
|
||||
QVERIFY(cons.m_list.constMap().size() == 1);
|
||||
|
||||
emit m_networkDummy.atcPositionUpdate("EGLL_GND", CFrequency(121.9, CFrequencyUnit::MHz()), CCoordinateGeodetic(51.4775, 0.46139, 0), CLength(20, CLengthUnit::m()));
|
||||
QCoreApplication::processEvents();
|
||||
QVERIFY(cons.m_list.constMap().size() == 2);
|
||||
|
||||
emit m_networkDummy.atcPositionUpdate("EGLL_TWR", CFrequency(118.5, CFrequencyUnit::MHz()), CCoordinateGeodetic(51.4775, 0.46139, 0), CLength(50, CLengthUnit::m()));
|
||||
QCoreApplication::processEvents();
|
||||
QVERIFY(cons.m_list.constMap().size() == 2);
|
||||
|
||||
emit m_networkDummy.atcDisconnected("EGLL_TWR");
|
||||
QCoreApplication::processEvents();
|
||||
QVERIFY(cons.m_list.constMap().size() == 1);
|
||||
|
||||
emit m_networkDummy.connectionStatusDisconnected();
|
||||
QCoreApplication::processEvents();
|
||||
QVERIFY(cons.m_list.constMap().size() == 0);
|
||||
|
||||
emit m_networkDummy.atcPositionUpdate("EGLL_TWR", CFrequency(118.5, CFrequencyUnit::MHz()), CCoordinateGeodetic(51.4775, 0.46139, 0), CLength(50, CLengthUnit::m()));
|
||||
QCoreApplication::processEvents();
|
||||
QVERIFY(cons.m_list.constMap().contains("EGLL_TWR"));
|
||||
QVERIFY(cons.m_list.constMap()["EGLL_TWR"].getCallsign() == "EGLL_TWR");
|
||||
QVERIFY(cons.m_list.constMap()["EGLL_TWR"].getFrequency() == CFrequency(118.5, CFrequencyUnit::MHz()));
|
||||
QVERIFY(cons.m_list.constMap()["EGLL_TWR"].getPosition() == CCoordinateGeodetic(51.4775, 0.46139, 0));
|
||||
QVERIFY(cons.m_list.constMap()["EGLL_TWR"].getAtcRange() == CLength(50, CLengthUnit::m()));
|
||||
}
|
||||
|
||||
} //namespace BlackCoreTest
|
||||
@@ -1,76 +0,0 @@
|
||||
/* Copyright (C) 2013 VATSIM Community / contributors
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef BLACKCORETEST_TESTNETMEDIATORS_H
|
||||
#define BLACKCORETEST_TESTNETMEDIATORS_H
|
||||
|
||||
#include "blackcore/atclistmgr.h"
|
||||
#include "blackcoretest.h"
|
||||
#include "blackcore/network.h"
|
||||
#include <QtTest/QtTest>
|
||||
|
||||
namespace BlackCoreTest
|
||||
{
|
||||
|
||||
/*!
|
||||
* Network mediator classes tests
|
||||
*/
|
||||
class CTestNetMediators : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/*!
|
||||
* Constructor.
|
||||
* \param parent
|
||||
*/
|
||||
explicit CTestNetMediators(QObject *parent = 0) : QObject(parent) {}
|
||||
|
||||
private slots:
|
||||
/*!
|
||||
* Called before the first test.
|
||||
*/
|
||||
void initTestCase();
|
||||
|
||||
/*!
|
||||
* Test CAtcListManager
|
||||
*/
|
||||
void atcListManagerTest();
|
||||
|
||||
/*!
|
||||
* Called after the last test.
|
||||
*/
|
||||
void cleanupTestCase();
|
||||
|
||||
private:
|
||||
BlackMisc::CApplicationContext m_context;
|
||||
BlackCore::NetworkDummy m_networkDummy;
|
||||
};
|
||||
|
||||
/*!
|
||||
* Helper class that connects to CAtcListManager signals
|
||||
*/
|
||||
class AtcListConsumer : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! List is updated by the slot
|
||||
BlackMisc::CAtcList m_list;
|
||||
|
||||
public slots:
|
||||
/*!
|
||||
* Slot updates the list
|
||||
* \param list
|
||||
*/
|
||||
void listChanged(const BlackMisc::CAtcList &list)
|
||||
{
|
||||
m_list = list;
|
||||
}
|
||||
};
|
||||
|
||||
} //namespace BlackCoreTest
|
||||
|
||||
#endif //BLACKCORETEST_TESTNETMEDIATORS_H
|
||||
Reference in New Issue
Block a user