summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2016-10-04 15:38:02 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2016-10-10 16:06:42 +0000
commitf90d6445a078de264de292f117c87677f831f768 (patch)
treef3e1bfac170905d1b91e453c4edf0814eb9c7c5f /tests/auto/corelib/io/qsettings/tst_qsettings.cpp
parentf835b5aa9cba2665423e6e96a45d97c3c80296a5 (diff)
tst_QSettings: Fix tests on sandboxed platforms such as iOS
WinRT is not the only sandboxed platform. Since it doesn't hurt to keep the test data in a well known location, we enable the code for all platforms. We also make sure to mkpath the location, since writableLocation doesn't guarantee that the location exists. Change-Id: Ie8d90c5fbdf3b7fbf85ba6be25372b0ef7c4da55 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Diffstat (limited to 'tests/auto/corelib/io/qsettings/tst_qsettings.cpp')
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp20
1 files changed, 7 insertions, 13 deletions
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index 3a164e8ce4..b98b48c5c1 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -1896,10 +1896,10 @@ void tst_QSettings::testChildKeysAndGroups()
void tst_QSettings::testUpdateRequestEvent()
{
-#ifdef Q_OS_WINRT
const QString oldCur = QDir::currentPath();
- QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
-#endif
+ QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
+ QVERIFY(QDir::root().mkpath(dataLocation));
+ QDir::setCurrent(dataLocation);
QFile::remove("foo");
QVERIFY(!QFile::exists("foo"));
@@ -1927,9 +1927,7 @@ void tst_QSettings::testUpdateRequestEvent()
QTRY_COMPARE(QFileInfo("foo").size(), qint64(0));
-#ifdef Q_OS_WINRT
QDir::setCurrent(oldCur);
-#endif
}
const int NumIterations = 5;
@@ -2228,13 +2226,10 @@ void tst_QSettings::fromFile()
{
QFETCH(QSettings::Format, format);
- // Sandboxed WinRT applications cannot write into the
- // application directory. Hence reset the current
- // directory
-#ifdef Q_OS_WINRT
const QString oldCur = QDir::currentPath();
- QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
-#endif
+ QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
+ QVERIFY(QDir::root().mkpath(dataLocation));
+ QDir::setCurrent(dataLocation);
QFile::remove("foo");
QVERIFY(!QFile::exists("foo"));
@@ -2283,9 +2278,8 @@ void tst_QSettings::fromFile()
QCOMPARE(settings1.value("gamma/foo.bar").toInt(), 4);
QCOMPARE(settings1.allKeys().size(), 3);
}
-#ifdef Q_OS_WINRT
+
QDir::setCurrent(oldCur);
-#endif
}
#ifdef QT_BUILD_INTERNAL