Apple OS: Resolve QStandardPaths test data locations based on real locations

Instead of the manual logic for computing test data locations, we use the
locations from baseWritableLocation, but make sure to put them all under
'.qttest' in the home directory. This approach handles more cases for test
data, and also plays nice with locations that are not in the home directory
due to being containerized (and hence do not need a separate test data scope).

Change-Id: Iea4f21acb75c0191be35a3619c05143e8929bd6e
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
This commit is contained in:
Tor Arne Vestbø 2016-10-04 15:30:08 +02:00 committed by Tor Arne Vestbø
parent 6c8f32388b
commit f2b90b4e82

View File

@ -168,36 +168,11 @@ static QString baseWritableLocation(QStandardPaths::StandardLocation type,
QString QStandardPaths::writableLocation(StandardLocation type)
{
if (isTestModeEnabled()) {
const QString qttestDir = QDir::homePath() + QLatin1String("/.qttest");
QString path;
switch (type) {
case GenericDataLocation:
case AppDataLocation:
case AppLocalDataLocation:
path = qttestDir + QLatin1String("/Application Support");
if (type != GenericDataLocation)
appendOrganizationAndApp(path);
return path;
case GenericCacheLocation:
case CacheLocation:
path = qttestDir + QLatin1String("/Cache");
if (type == CacheLocation)
appendOrganizationAndApp(path);
return path;
case GenericConfigLocation:
case ConfigLocation:
case AppConfigLocation:
path = qttestDir + QLatin1String("/Preferences");
if (type == AppConfigLocation)
appendOrganizationAndApp(path);
return path;
default:
break;
}
}
QString location = baseWritableLocation(type, NSUserDomainMask, true);
if (isTestModeEnabled())
location = location.replace(QDir::homePath(), QDir::homePath() + QLatin1String("/.qttest"));
return baseWritableLocation(type, NSUserDomainMask, true);
return location;
}
QStringList QStandardPaths::standardLocations(StandardLocation type)