diff options
author | David Faure <faure@kde.org> | 2012-03-25 13:10:48 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-28 11:22:11 +0200 |
commit | a5a80da2238030b5ecbc7c5fba7ecd8cb5f2da1c (patch) | |
tree | 4b27a2112ecc4415a222f96807f462bb077bdf0c /src/corelib/io/qstandardpaths_win.cpp | |
parent | 99e7ad660f23dce51ccd68438adae7528013d23c (diff) |
Allow auto tests to stay away from the user's configuration.
QStandardPaths now knows a "test mode" which changes writable locations
to point to test directories, in order to prevent auto tests from reading from
or writing to the current user's configuration.
This affects the locations into which test programs might write files:
GenericDataLocation, DataLocation, ConfigLocation,
GenericCacheLocation, CacheLocation.
Other locations are not affected.
Change-Id: I29606c2e74714360edd871a8c387a5c1ef7d1f54
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
Diffstat (limited to 'src/corelib/io/qstandardpaths_win.cpp')
-rw-r--r-- | src/corelib/io/qstandardpaths_win.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index 8bd32eb1d4..a2c53a4b4d 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -85,6 +85,13 @@ static QString convertCharArray(const wchar_t *path) return QDir::fromNativeSeparators(QString::fromWCharArray(path)); } +static bool qsp_testMode = false; + +void QStandardPaths::enableTestMode(bool testMode) +{ + qsp_testMode = testMode; +} + QString QStandardPaths::writableLocation(StandardLocation type) { QString result; @@ -105,6 +112,8 @@ QString QStandardPaths::writableLocation(StandardLocation type) if (SHGetSpecialFolderPath(0, path, CSIDL_LOCAL_APPDATA, FALSE)) #endif result = convertCharArray(path); + if (qsp_testMode) + result += QLatin1String("/qttest"); if (type != GenericDataLocation) { if (!QCoreApplication::organizationName().isEmpty()) result += QLatin1Char('/') + QCoreApplication::organizationName(); |