Unit test fix

* Use correct version of loadAndResolveP3DSimConnect/loadAndResolveFsxSimConnect
* use CLogCategory::driver() for SimConnectSymbols
* added load(common_pre/post)
This commit is contained in:
Klaus Basan
2018-11-12 03:06:07 +01:00
parent db05388bea
commit fe28c220fa
3 changed files with 17 additions and 7 deletions

View File

@@ -10,6 +10,7 @@
#include "simconnectsymbols.h" #include "simconnectsymbols.h"
#include "blackmisc/stringutils.h" #include "blackmisc/stringutils.h"
#include "blackmisc/logmessage.h" #include "blackmisc/logmessage.h"
#include "blackmisc/logcategory.h"
#include <QLibrary> #include <QLibrary>
#include <Windows.h> #include <Windows.h>
#include <SimConnect.h> #include <SimConnect.h>
@@ -117,7 +118,7 @@ bool resolveSimConnectSymbol(QLibrary &library, FuncPtr &funcPtr, const char *fu
funcPtr = reinterpret_cast<FuncPtr>(library.resolve(funcName)); funcPtr = reinterpret_cast<FuncPtr>(library.resolve(funcName));
if (! funcPtr) if (! funcPtr)
{ {
CLogMessage(static_cast<SimConnectSymbols *>(nullptr)).error("Failed to resolve %1: %2") << funcName << library.errorString(); CLogMessage(CLogCategory::driver()).error("Failed to resolve %1: %2") << funcName << library.errorString();
return false; return false;
} }
return true; return true;
@@ -208,21 +209,21 @@ bool loadAndResolveP3DSimConnect(P3DSimConnectVersion version)
const bool resolvedP3DSimConnectSymbols = resolveP3DSimConnectSymbols(simConnectDll); const bool resolvedP3DSimConnectSymbols = resolveP3DSimConnectSymbols(simConnectDll);
if (!resolvedCommon) if (!resolvedCommon)
{ {
CLogMessage(static_cast<SimConnectSymbols *>(nullptr)).error("Failed to resolve common symbols from SimConnect.dll: '%1'") << simConnectFileName; CLogMessage(CLogCategory::driver()).error("Failed to resolve common symbols from SimConnect.dll: '%1'") << simConnectFileName;
return false; return false;
} }
if (!resolvedP3DSimConnectSymbols) if (!resolvedP3DSimConnectSymbols)
{ {
CLogMessage(static_cast<SimConnectSymbols *>(nullptr)).error("Failed to resolve P3D symbols from SimConnect.dll: '%1'") << simConnectFileName; CLogMessage(CLogCategory::driver()).error("Failed to resolve P3D symbols from SimConnect.dll: '%1'") << simConnectFileName;
return false; return false;
} }
CLogMessage(static_cast<SimConnectSymbols *>(nullptr)).info("Loaded and resolved P3D symbols from SimConnect.dll: '%1'") << simConnectFileName; CLogMessage(CLogCategory::driver()).info("Loaded and resolved P3D symbols from SimConnect.dll: '%1'") << simConnectFileName;
return resolvedCommon && resolvedP3DSimConnectSymbols; return resolvedCommon && resolvedP3DSimConnectSymbols;
} }
else else
{ {
CLogMessage(static_cast<SimConnectSymbols *>(nullptr)).error("Failed to load SimConnect.dll: '%1' '%2'") << simConnectFileName << simConnectDll.errorString(); CLogMessage(CLogCategory::driver()).error("Failed to load SimConnect.dll: '%1' '%2'") << simConnectFileName << simConnectDll.errorString();
return false; return false;
} }
} }
@@ -286,7 +287,7 @@ bool loadAndResolveFsxSimConnect(bool manifestProbing)
} }
else else
{ {
CLogMessage(static_cast<SimConnectSymbols *>(nullptr)).error("Failed to load SimConnect.dll: %1") << simConnectDll.errorString(); CLogMessage(CLogCategory::driver()).error("Failed to load SimConnect.dll: %1") << simConnectDll.errorString();
return false; return false;
} }
} }

View File

@@ -18,6 +18,7 @@
#include "plugins/simulator/fsxcommon/simconnectdatadefinition.h" #include "plugins/simulator/fsxcommon/simconnectdatadefinition.h"
#include "plugins/simulator/fsxcommon/simconnectsymbols.h" #include "plugins/simulator/fsxcommon/simconnectsymbols.h"
#include "plugins/simulator/fsxcommon/simulatorfsxcommon.h" #include "plugins/simulator/fsxcommon/simulatorfsxcommon.h"
#include <QTest> #include <QTest>
using namespace BlackSimPlugin::FsxCommon; using namespace BlackSimPlugin::FsxCommon;
@@ -26,7 +27,11 @@ namespace BlackSimPluginFsxP3D
{ {
void CSimPluginFsxP3d::resolveSymbols() void CSimPluginFsxP3d::resolveSymbols()
{ {
QVERIFY2(loadAndResolveSimConnect(false), "Could not load and resolve SimConnect library!"); #ifdef Q_OS_WIN64
QVERIFY2(loadAndResolveP3DSimConnect(P3DSimConnectv42), "Could not load and resolve SimConnect library!");
#else
QVERIFY2(loadAndResolveFsxSimConnect(false), "Could not load and resolve SimConnect library!");
#endif
HANDLE hSimConnect; HANDLE hSimConnect;
SimConnect_Open(&hSimConnect, "Test", nullptr, 0, nullptr, 0); SimConnect_Open(&hSimConnect, "Test", nullptr, 0, nullptr, 0);
SimConnect_Close(hSimConnect); SimConnect_Close(hSimConnect);

View File

@@ -1,3 +1,5 @@
load(common_pre)
TEMPLATE = subdirs TEMPLATE = subdirs
CONFIG += ordered CONFIG += ordered
@@ -13,3 +15,5 @@ contains(BLACK_CONFIG,FSX|P3D) {
SUBDIRS += testsimpluginfsxp3d SUBDIRS += testsimpluginfsxp3d
testsimpluginfsxp3d.file = blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro testsimpluginfsxp3d.file = blacksimpluginfsxp3d/testblacksimpluginfsxp3d.pro
} }
load(common_post)