summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2023-04-20 12:26:24 +0200
committerAhmad Samir <a.samirh78@gmail.com>2023-04-22 20:04:31 +0200
commite320280f6183cea519b213d2fd35146db920b29b (patch)
tree73e44a7772f3716adc01b11170b275004ba62279
parentb9786f21b816ed33ad671230624821b8998be2ff (diff)
QStandardPaths/Unix: restore org and app names in unittests
Some unittests set a custom Organization and Application names and then clears them. Instead used init() method to "reset" those two names to the original values before each unittest is run. Pick-to: 6.5 Change-Id: I359f3911dd50a2aecfd8dde22e2d591adc6e224e Reviewed-by: David Faure <david.faure@kdab.com>
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index 444af8f9f6..3284b8479a 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -36,6 +36,7 @@ class tst_qstandardpaths : public QObject
private slots:
void initTestCase();
void dump();
+ void init();
void testDefaultLocations();
void testCustomLocations();
void enableTestMode();
@@ -140,6 +141,16 @@ void tst_qstandardpaths::dump()
}
}
+void tst_qstandardpaths::init()
+{
+ // Some unittests set a custom org/app names, restore the original ones
+ // before each unittest is run
+ static const QString org = QCoreApplication::organizationName();
+ static const QString app = QCoreApplication::applicationName();
+ QCoreApplication::setOrganizationName(org);
+ QCoreApplication::setApplicationName(app);
+}
+
void tst_qstandardpaths::testDefaultLocations()
{
#ifdef Q_XDG_PLATFORM
@@ -308,10 +319,6 @@ void tst_qstandardpaths::testDataLocation()
QCOMPARE(appDataDirs.at(1), QString::fromLatin1("/usr/local/share/Qt/QtTest"));
QCOMPARE(appDataDirs.at(2), QString::fromLatin1("/usr/share/Qt/QtTest"));
#endif
-
- // reset for other tests
- QCoreApplication::setOrganizationName(QString());
- QCoreApplication::setApplicationName(QString());
}
void tst_qstandardpaths::testAppConfigLocation()
@@ -325,9 +332,6 @@ void tst_qstandardpaths::testAppConfigLocation()
QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation), base + "/Qt/tst_qstandardpaths");
QCoreApplication::setApplicationName("QtTest");
QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation), base + "/Qt/QtTest");
- // reset for other tests
- QCoreApplication::setOrganizationName(QString());
- QCoreApplication::setApplicationName(QString());
#endif
}