Skip to content

Commit 2c1b954

Browse files
committed
Simple boot test now verifies gstreamer
1 parent 103a1a3 commit 2c1b954

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

src/QGCApplication.cc

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,10 @@ static QObject *mavlinkSingletonFactory(QQmlEngine*, QJSEngine*)
102102
return new QGCMAVLink();
103103
}
104104

105-
QGCApplication::QGCApplication(int &argc, char *argv[], bool unitTesting)
105+
QGCApplication::QGCApplication(int &argc, char *argv[], bool unitTesting, bool simpleBootTest)
106106
: QApplication(argc, argv)
107107
, _runningUnitTests(unitTesting)
108+
, _simpleBootTest(simpleBootTest)
108109
{
109110
_msecsElapsedTime.start();
110111

@@ -135,7 +136,7 @@ QGCApplication::QGCApplication(int &argc, char *argv[], bool unitTesting)
135136

136137
// Set application information
137138
QString applicationName;
138-
if (_runningUnitTests) {
139+
if (_runningUnitTests || simpleBootTest) {
139140
// We don't want unit tests to use the same QSettings space as the normal app. So we tweak the app
140141
// name. Also we want to run unit tests with clean settings every time.
141142
applicationName = QStringLiteral("%1_unittest").arg(QGC_APP_NAME);
@@ -168,7 +169,7 @@ QGCApplication::QGCApplication(int &argc, char *argv[], bool unitTesting)
168169
// The setting will delete all settings on this boot
169170
fClearSettingsOptions |= settings.contains(_deleteAllSettingsKey);
170171

171-
if (_runningUnitTests) {
172+
if (_runningUnitTests || simpleBootTest) {
172173
// Unit tests run with clean settings
173174
fClearSettingsOptions = true;
174175
}
@@ -324,20 +325,30 @@ void QGCApplication::init()
324325
qCWarning(QGCApplicationLog) << "Could not load /fonts/opensans-demibold font";
325326
}
326327

327-
if (!_runningUnitTests) {
328+
if (_simpleBootTest) {
329+
// Since GStream builds are so problematic we initialize video during the simple boot test
330+
// to make sure it works and verfies plugin availability.
331+
_initVideo();
332+
} else if (!_runningUnitTests) {
328333
_initForNormalAppBoot();
329334
}
330335
}
331336

332-
void QGCApplication::_initForNormalAppBoot()
337+
void QGCApplication::_initVideo()
333338
{
334339
#ifdef QGC_GST_STREAMING
335340
// Gstreamer video playback requires OpenGL
336341
QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGL);
337342
#endif
338343

339-
QGCCorePlugin::instance(); // CorePlugin must be initialized before VideoManager for Video Cleanup
340-
VideoManager::instance(); // GStreamer must be initialized before QmlEngine
344+
QGCCorePlugin::instance(); // CorePlugin must be initialized before VideoManager for Video Cleanup
345+
VideoManager::instance();
346+
_videoManagerInitialized = true;
347+
}
348+
349+
void QGCApplication::_initForNormalAppBoot()
350+
{
351+
_initVideo(); // GStreamer must be initialized before QmlEngine
341352

342353
QQuickStyle::setStyle("Basic");
343354
QGCCorePlugin::instance()->init();
@@ -747,7 +758,9 @@ void QGCApplication::shutdown()
747758
{
748759
qCDebug(QGCApplicationLog) << "Exit";
749760

750-
VideoManager::instance()->cleanup();
761+
if (_videoManagerInitialized) {
762+
VideoManager::instance()->cleanup();
763+
}
751764

752765
// This is bad, but currently qobject inheritances are incorrect and cause crashes on exit without
753766
delete _qmlAppEngine;

src/QGCApplication.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class QGCApplication : public QApplication
4848
/// Unit Test have access to creating and destroying singletons
4949
friend class UnitTest;
5050
public:
51-
QGCApplication(int &argc, char *argv[], bool unitTesting);
51+
QGCApplication(int &argc, char *argv[], bool unitTesting, bool simpleBootTest);
5252
~QGCApplication();
5353

5454
/// Sets the persistent flag to delete all settings the next time QGroundControl is started.
@@ -57,8 +57,8 @@ class QGCApplication : public QApplication
5757
/// Clears the persistent flag to delete all settings the next time QGroundControl is started.
5858
void clearDeleteAllSettingsNextBoot();
5959

60-
/// Returns true if unit tests are being run
6160
bool runningUnitTests() const { return _runningUnitTests; }
61+
bool simpleBootTest() const { return _simpleBootTest; }
6262

6363
/// Returns true if Qt debug output should be logged to a file
6464
bool logOutput() const { return _logOutput; }
@@ -128,13 +128,16 @@ private slots:
128128
private:
129129
bool compressEvent(QEvent *event, QObject *receiver, QPostEventList *postedEvents) final;
130130

131+
void _initVideo();
132+
131133
/// Initialize the application for normal application boot. Or in other words we are not going to run unit tests.
132134
void _initForNormalAppBoot();
133135

134136
QObject *_rootQmlObject();
135137
void _checkForNewVersion();
136138

137-
bool _runningUnitTests = false; ///< true: running unit tests, false: normal app
139+
bool _runningUnitTests = false;
140+
bool _simpleBootTest = false;
138141
static constexpr int _missingParamsDelayedDisplayTimerTimeout = 1000; ///< Timeout to wait for next missing fact to come in before display
139142
QTimer _missingParamsDelayedDisplayTimer; ///< Timer use to delay missing fact display
140143
QList<QPair<int,QString>> _missingParams; ///< List of missing parameter component id:name
@@ -153,6 +156,7 @@ private slots:
153156
bool _error = false;
154157
bool _showErrorsInToolbar = false;
155158
QElapsedTimer _msecsElapsedTime;
159+
bool _videoManagerInitialized = false;
156160

157161
QList<QPair<QString /* title */, QString /* message */>> _delayedAppMessages;
158162

src/VideoManager/VideoReceiver/GStreamer/GStreamer.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "QGCLoggingCategory.h"
1414
#include "SettingsManager.h"
1515
#include "VideoSettings.h"
16+
#include "QGCApplication.h"
1617
#ifdef Q_OS_IOS
1718
#include "gst_ios_init.h"
1819
#endif
@@ -313,6 +314,10 @@ bool initialize()
313314

314315
if (!_verifyPlugins()) {
315316
qCCritical(GStreamerLog) << "Failed to Init GStreamer Plugins";
317+
if (qgcApp()->simpleBootTest()) {
318+
qCCritical(GStreamerLog) << "Exiting out of simple boot test due to failed plugin verification";
319+
exit(1);
320+
}
316321
return false;
317322
}
318323

src/main.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ int main(int argc, char *argv[])
133133
#endif
134134

135135
bool runUnitTests = false;
136-
bool simpleBootTest = false;
136+
bool simpleBootTest = true;
137137

138138
#ifdef QT_DEBUG
139139
// We parse a small set of command line options here prior to QGCApplication in order to handle the ones
@@ -174,7 +174,7 @@ int main(int argc, char *argv[])
174174
ParseCmdLineOptions(argc, argv, rgCmdLineOptions, std::size(rgCmdLineOptions), false);
175175
#endif // QT_DEBUG
176176

177-
QGCApplication app(argc, argv, runUnitTests || simpleBootTest);
177+
QGCApplication app(argc, argv, runUnitTests, simpleBootTest);
178178

179179
#ifdef Q_OS_LINUX
180180
#ifndef Q_OS_ANDROID

0 commit comments

Comments
 (0)