From f90d6445a078de264de292f117c87677f831f768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 4 Oct 2016 15:38:02 +0200 Subject: 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 Reviewed-by: Richard Moe Gustavsen --- tests/auto/corelib/io/qsettings/tst_qsettings.cpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'tests/auto/corelib/io/qsettings/tst_qsettings.cpp') 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 -- cgit v1.2.3