mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 01:35:45 +08:00
[AFV] Fix context UNIT test crash
* crash: A crash occurred in C:\jenkins\workspace\swift_wip_fsd_and_afv_client\build\out\release\bin\testcontext.exe. * ASSERT in const QList<QAudioDeviceInfo> allQtDevices2 = QAudioDeviceInfo::availableDevices(QAudio::AudioInput) * figured out it fails in a Qt console app, runs in a widget app * see https://discordapp.com/channels/539048679160676382/623947987822837779/631939335255752704
This commit is contained in:
committed by
Mat Sutcliffe
parent
e109106102
commit
1d9cd50463
@@ -17,6 +17,10 @@
|
|||||||
#include "test.h"
|
#include "test.h"
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include "comdef.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackMisc::Aviation;
|
using namespace BlackMisc::Aviation;
|
||||||
using namespace BlackMisc::Simulation;
|
using namespace BlackMisc::Simulation;
|
||||||
@@ -48,6 +52,9 @@ namespace BlackCoreTest
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CContextAudioProxy::unitTestRelaySignals() crashes in QAudioDeviceInfo::availableDevices(QAudio::AudioInput)
|
||||||
|
// discussion https://discordapp.com/channels/539048679160676382/623947987822837779/631940817669455903
|
||||||
|
// solved if unit test initializes a QGuiApplication
|
||||||
CContextAudioProxy::unitTestRelaySignals();
|
CContextAudioProxy::unitTestRelaySignals();
|
||||||
CContextNetworkProxy::unitTestRelaySignals();
|
CContextNetworkProxy::unitTestRelaySignals();
|
||||||
CContextOwnAircraftProxy::unitTestRelaySignals();
|
CContextOwnAircraftProxy::unitTestRelaySignals();
|
||||||
@@ -79,7 +86,18 @@ namespace BlackCoreTest
|
|||||||
//! main
|
//! main
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QCoreApplication app(argc, argv);
|
// QCoreApplication app(argc, argv);
|
||||||
|
// discussion https://discordapp.com/channels/539048679160676382/623947987822837779/631940817669455903
|
||||||
|
// QDeviceInfo crashes using QCoreApplication
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
QGuiApplication app(argc, argv);
|
||||||
|
const HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
|
||||||
|
Q_UNUSED(hr)
|
||||||
|
#else
|
||||||
|
QCoreApplication app(argc, argv); // using QGuiApplication fails on Jenkins Linux, no display
|
||||||
|
#endif
|
||||||
|
|
||||||
BLACKTEST_INIT(BlackCoreTest::CTestContext)
|
BLACKTEST_INIT(BlackCoreTest::CTestContext)
|
||||||
CApplication a(CApplicationInfo::UnitTest);
|
CApplication a(CApplicationInfo::UnitTest);
|
||||||
a.addVatlibOptions();
|
a.addVatlibOptions();
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
load(common_pre)
|
load(common_pre)
|
||||||
|
|
||||||
QT += core dbus network testlib multimedia
|
QT += core dbus network testlib multimedia gui
|
||||||
|
|
||||||
TARGET = testcontext
|
TARGET = testcontext
|
||||||
CONFIG -= app_bundle
|
CONFIG -= app_bundle
|
||||||
|
|||||||
Reference in New Issue
Block a user