Commit fa500371 authored by Don Gagne's avatar Don Gagne

Unit Tests run from there own QSettings space

This is done by tweaking the application name when running unit test
parent 04dd2d7d
...@@ -92,9 +92,15 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) : ...@@ -92,9 +92,15 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) :
_app = this; _app = this;
// Set application information // Set application information
this->setApplicationName(QGC_APPLICATION_NAME); if (_runningUnitTests) {
this->setOrganizationName(QGC_ORG_NAME); // We don't want unit tests to use the same QSettings space as the normal app. So we tweak the app
this->setOrganizationDomain(QGC_ORG_DOMAIN); // name. Also we want to run unit tests with clean settings every time.
setApplicationName(QString("%1_unittest").arg(QGC_APPLICATION_NAME));
} else {
setApplicationName(QGC_APPLICATION_NAME);
}
setOrganizationName(QGC_ORG_NAME);
setOrganizationDomain(QGC_ORG_DOMAIN);
// Version string is build from component parts. Format is: // Version string is build from component parts. Format is:
// vMajor.Minor.BuildNumber BuildType // vMajor.Minor.BuildNumber BuildType
...@@ -121,10 +127,8 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) : ...@@ -121,10 +127,8 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) :
// The setting will delete all settings on this boot // The setting will delete all settings on this boot
fClearSettingsOptions |= settings.contains(_deleteAllSettingsKey); fClearSettingsOptions |= settings.contains(_deleteAllSettingsKey);
// We don't want unit tests to use the same QSettings space as the normal app. So we tweak the app
// name. Also we want to run unit tests with clean settings every time.
if (_runningUnitTests) { if (_runningUnitTests) {
setApplicationName(applicationName().append("UnitTest")); // Unit tests run with clean settings
fClearSettingsOptions = true; fClearSettingsOptions = true;
} }
...@@ -133,7 +137,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) : ...@@ -133,7 +137,6 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) :
settings.clear(); settings.clear();
settings.setValue(_settingsVersionKey, QGC_SETTINGS_VERSION); settings.setValue(_settingsVersionKey, QGC_SETTINGS_VERSION);
} }
} }
QGCApplication::~QGCApplication() QGCApplication::~QGCApplication()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment