summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r--tests/auto/corelib/io/qfile/test/test.pro2
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.pro1
-rw-r--r--tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro2
-rw-r--r--tests/auto/corelib/io/qprocess/test/test.pro2
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp73
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp2
-rw-r--r--tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp25
7 files changed, 102 insertions, 5 deletions
diff --git a/tests/auto/corelib/io/qfile/test/test.pro b/tests/auto/corelib/io/qfile/test/test.pro
index c0c4b9d5d2..5f1963cf5f 100644
--- a/tests/auto/corelib/io/qfile/test/test.pro
+++ b/tests/auto/corelib/io/qfile/test/test.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT = core-private core testlib
qtHaveModule(network): QT += network
else: DEFINES += QT_NO_NETWORK
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
index 7b83d5dbe8..7a304fe779 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.pro
@@ -1,5 +1,4 @@
CONFIG += testcase
-CONFIG -= app_bundle
TARGET = tst_qlockfile
SOURCES += tst_qlockfile.cpp
diff --git a/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro b/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro
index e46e7e1100..8e46320e0c 100644
--- a/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro
+++ b/tests/auto/corelib/io/qprocess-noapplication/qprocess-noapplication.pro
@@ -1,4 +1,4 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT = core testlib
SOURCES = tst_qprocessnoapplication.cpp
diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro
index 96d105a4b4..7d6a7973dc 100644
--- a/tests/auto/corelib/io/qprocess/test/test.pro
+++ b/tests/auto/corelib/io/qprocess/test/test.pro
@@ -1,5 +1,5 @@
CONFIG += testcase
-CONFIG -= app_bundle debug_and_release_target
+CONFIG -= debug_and_release_target
QT = core-private testlib network
SOURCES = ../tst_qprocess.cpp
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index dadf4b612e..fcff13b416 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -183,6 +183,7 @@ private slots:
void embeddedZeroByte_data();
void embeddedZeroByte();
+ void testXdg();
private:
void cleanupTestFiles();
@@ -3557,5 +3558,77 @@ void tst_QSettings::consistentRegistryStorage()
}
#endif
+#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) && !defined(QT_NO_STANDARDPATHS)
+QT_BEGIN_NAMESPACE
+extern void clearDefaultPaths();
+QT_END_NAMESPACE
+#endif
+void tst_QSettings::testXdg()
+{
+#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_UNIX) && !defined(Q_OS_DARWIN) && !defined(Q_OS_ANDROID) && !defined(QT_NO_STANDARDPATHS)
+ // Note: The XDG_CONFIG_DIRS test must be done before overriding the system path
+ // by QSettings::setPath/setSystemIniPath (used in cleanupTestFiles()).
+ clearDefaultPaths();
+
+ // Initialize the env. variable & populate testing files.
+ const QStringList config_dirs = { settingsPath("xdg_1st"), settingsPath("xdg_2nd"), settingsPath("xdg_3rd") };
+ qputenv("XDG_CONFIG_DIRS", config_dirs.join(':').toUtf8());
+ QList<QSettings *> xdg_orgs, xdg_apps;
+ for (const auto & dir : config_dirs) {
+ xdg_orgs << new QSettings{dir + "/software.org.conf", QSettings::NativeFormat};
+ xdg_apps << new QSettings{dir + "/software.org/KillerAPP.conf", QSettings::NativeFormat};
+ }
+ Q_ASSERT(config_dirs.size() == 3 && xdg_orgs.size() == 3 && xdg_apps.size() == 3);
+ for (int i = 0; i < 3; ++i) {
+ xdg_orgs[i]->setValue("all", QString{"all_org%1"}.arg(i));
+ xdg_apps[i]->setValue("all", QString{"all_app%1"}.arg(i));
+ xdg_orgs[i]->setValue("all_only_org", QString{"all_only_org%1"}.arg(i));
+ xdg_apps[i]->setValue("all_only_app", QString{"all_only_app%1"}.arg(i));
+
+ if (i > 0) {
+ xdg_orgs[i]->setValue("from2nd", QString{"from2nd_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from2nd", QString{"from2nd_app%1"}.arg(i));
+ xdg_orgs[i]->setValue("from2nd_only_org", QString{"from2nd_only_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from2nd_only_app", QString{"from2nd_only_app%1"}.arg(i));
+ }
+
+ if (i > 1) {
+ xdg_orgs[i]->setValue("from3rd", QString{"from3rd_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from3rd", QString{"from3rd_app%1"}.arg(i));
+ xdg_orgs[i]->setValue("from3rd_only_org", QString{"from3rd_only_org%1"}.arg(i));
+ xdg_apps[i]->setValue("from3rd_only_app", QString{"from3rd_only_app%1"}.arg(i));
+ }
+ }
+ qDeleteAll(xdg_apps);
+ qDeleteAll(xdg_orgs);
+
+ // Do the test.
+ QSettings app{QSettings::SystemScope, "software.org", "KillerAPP"}, org{QSettings::SystemScope, "software.org"};
+
+ QVERIFY(app.value("all").toString() == "all_app0");
+ QVERIFY(org.value("all").toString() == "all_org0");
+ QVERIFY(app.value("all_only_org").toString() == "all_only_org0");
+ QVERIFY(org.value("all_only_org").toString() == "all_only_org0");
+ QVERIFY(app.value("all_only_app").toString() == "all_only_app0");
+ QVERIFY(org.value("all_only_app").toString() == QString{});
+
+ QVERIFY(app.value("from2nd").toString() == "from2nd_app1");
+ QVERIFY(org.value("from2nd").toString() == "from2nd_org1");
+ QVERIFY(app.value("from2nd_only_org").toString() == "from2nd_only_org1");
+ QVERIFY(org.value("from2nd_only_org").toString() == "from2nd_only_org1");
+ QVERIFY(app.value("from2nd_only_app").toString() == "from2nd_only_app1");
+ QVERIFY(org.value("from2nd_only_app").toString() == QString{});
+
+ QVERIFY(app.value("from3rd").toString() == "from3rd_app2");
+ QVERIFY(org.value("from3rd").toString() == "from3rd_org2");
+ QVERIFY(app.value("from3rd_only_org").toString() == "from3rd_only_org2");
+ QVERIFY(org.value("from3rd_only_org").toString() == "from3rd_only_org2");
+ QVERIFY(app.value("from3rd_only_app").toString() == "from3rd_only_app2");
+ QVERIFY(org.value("from3rd_only_app").toString() == QString{});
+#else
+ QSKIP("This test is performed in QT_BUILD_INTERNAL on Q_XDG_PLATFORM with use of standard paths only.");
+#endif
+}
+
QTEST_MAIN(tst_QSettings)
#include "tst_qsettings.moc"
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index a7a761a2da..0a00e00d83 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -385,7 +385,7 @@ void tst_qstandardpaths::testFindExecutable_data()
QTest::newRow("win-cmd-nosuffix")
<< QString() << QString::fromLatin1("cmd") << cmdPath;
- if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS8) {
+ if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows8) {
// The logo executable on Windows 8 is perfectly suited for testing that the
// suffix mechanism is not thrown off by dots in the name.
// Note: Requires disabling WOW64 redirection, see initTestCase()
diff --git a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
index 487c13be94..758bbead84 100644
--- a/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
+++ b/tests/auto/corelib/io/qtemporarydir/tst_qtemporarydir.cpp
@@ -57,6 +57,8 @@ private slots:
void fileTemplate_data();
void getSetCheck();
void fileName();
+ void filePath_data();
+ void filePath();
void autoRemove();
void nonWritableCurrentDir();
void openOnRootDrives();
@@ -204,6 +206,29 @@ void tst_QTemporaryDir::fileName()
QCOMPARE(absoluteFilePath, absoluteTempPath);
}
+void tst_QTemporaryDir::filePath_data()
+{
+ QTest::addColumn<QString>("templatePath");
+ QTest::addColumn<QString>("fileName");
+
+ QTest::newRow("0") << QString() << "/tmpfile";
+ QTest::newRow("1") << QString() << "tmpfile";
+ QTest::newRow("2") << "XXXXX" << "tmpfile";
+ QTest::newRow("3") << "YYYYY" << "subdir/file";
+}
+
+void tst_QTemporaryDir::filePath()
+{
+ QFETCH(QString, templatePath);
+ QFETCH(QString, fileName);
+
+ QTemporaryDir dir(templatePath);
+ const QString filePath = dir.filePath(fileName);
+ const QString expectedFilePath = QDir::isAbsolutePath(fileName) ?
+ QString() : dir.path() + QLatin1Char('/') + fileName;
+ QCOMPARE(filePath, expectedFilePath);
+}
+
void tst_QTemporaryDir::autoRemove()
{
// Test auto remove