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>
This commit is contained in:
parent
f835b5aa9c
commit
f90d6445a0
@ -1896,10 +1896,10 @@ void tst_QSettings::testChildKeysAndGroups()
|
|||||||
|
|
||||||
void tst_QSettings::testUpdateRequestEvent()
|
void tst_QSettings::testUpdateRequestEvent()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WINRT
|
|
||||||
const QString oldCur = QDir::currentPath();
|
const QString oldCur = QDir::currentPath();
|
||||||
QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
|
QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
||||||
#endif
|
QVERIFY(QDir::root().mkpath(dataLocation));
|
||||||
|
QDir::setCurrent(dataLocation);
|
||||||
|
|
||||||
QFile::remove("foo");
|
QFile::remove("foo");
|
||||||
QVERIFY(!QFile::exists("foo"));
|
QVERIFY(!QFile::exists("foo"));
|
||||||
@ -1927,9 +1927,7 @@ void tst_QSettings::testUpdateRequestEvent()
|
|||||||
|
|
||||||
QTRY_COMPARE(QFileInfo("foo").size(), qint64(0));
|
QTRY_COMPARE(QFileInfo("foo").size(), qint64(0));
|
||||||
|
|
||||||
#ifdef Q_OS_WINRT
|
|
||||||
QDir::setCurrent(oldCur);
|
QDir::setCurrent(oldCur);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const int NumIterations = 5;
|
const int NumIterations = 5;
|
||||||
@ -2228,13 +2226,10 @@ void tst_QSettings::fromFile()
|
|||||||
{
|
{
|
||||||
QFETCH(QSettings::Format, format);
|
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();
|
const QString oldCur = QDir::currentPath();
|
||||||
QDir::setCurrent(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
|
QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation);
|
||||||
#endif
|
QVERIFY(QDir::root().mkpath(dataLocation));
|
||||||
|
QDir::setCurrent(dataLocation);
|
||||||
|
|
||||||
QFile::remove("foo");
|
QFile::remove("foo");
|
||||||
QVERIFY(!QFile::exists("foo"));
|
QVERIFY(!QFile::exists("foo"));
|
||||||
@ -2283,9 +2278,8 @@ void tst_QSettings::fromFile()
|
|||||||
QCOMPARE(settings1.value("gamma/foo.bar").toInt(), 4);
|
QCOMPARE(settings1.value("gamma/foo.bar").toInt(), 4);
|
||||||
QCOMPARE(settings1.allKeys().size(), 3);
|
QCOMPARE(settings1.allKeys().size(), 3);
|
||||||
}
|
}
|
||||||
#ifdef Q_OS_WINRT
|
|
||||||
QDir::setCurrent(oldCur);
|
QDir::setCurrent(oldCur);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef QT_BUILD_INTERNAL
|
#ifdef QT_BUILD_INTERNAL
|
||||||
|
Loading…
x
Reference in New Issue
Block a user