WinRT: implement QStandardPaths
need to leave some items out like media folder access, as this is not available by default and also requires certain capabilities to use those. Furthermore updated the tests for sandboxing as well as skip cmd.exe related tests as that does not exist on WinRT. Change-Id: I992b1e195b79615bea0be4f84f56cfb8f0d902bf Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
This commit is contained in:
parent
7ea584f830
commit
c784ec00fa
@ -48,6 +48,17 @@
|
|||||||
|
|
||||||
#include <qt_windows.h>
|
#include <qt_windows.h>
|
||||||
|
|
||||||
|
#include <wrl.h>
|
||||||
|
#include <windows.foundation.h>
|
||||||
|
#include <windows.storage.h>
|
||||||
|
#include <Windows.ApplicationModel.h>
|
||||||
|
|
||||||
|
using namespace Microsoft::WRL;
|
||||||
|
using namespace Microsoft::WRL::Wrappers;
|
||||||
|
using namespace ABI::Windows::Foundation;
|
||||||
|
using namespace ABI::Windows::Storage;
|
||||||
|
using namespace ABI::Windows::ApplicationModel;
|
||||||
|
|
||||||
#ifndef QT_NO_STANDARDPATHS
|
#ifndef QT_NO_STANDARDPATHS
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -59,9 +70,51 @@ static QString convertCharArray(const wchar_t *path)
|
|||||||
|
|
||||||
QString QStandardPaths::writableLocation(StandardLocation type)
|
QString QStandardPaths::writableLocation(StandardLocation type)
|
||||||
{
|
{
|
||||||
Q_UNUSED(type)
|
QString result;
|
||||||
Q_UNIMPLEMENTED();
|
|
||||||
return QString();
|
switch (type) {
|
||||||
|
case ConfigLocation: // same as DataLocation, on Windows
|
||||||
|
case DataLocation:
|
||||||
|
case GenericDataLocation: {
|
||||||
|
ComPtr<IApplicationDataStatics> applicationDataStatics;
|
||||||
|
if (FAILED(GetActivationFactory(HString::MakeReference(RuntimeClass_Windows_Storage_ApplicationData).Get(), &applicationDataStatics)))
|
||||||
|
break;
|
||||||
|
ComPtr<IApplicationData> applicationData;
|
||||||
|
if (FAILED(applicationDataStatics->get_Current(&applicationData)))
|
||||||
|
break;
|
||||||
|
ComPtr<IStorageFolder> settingsFolder;
|
||||||
|
if (FAILED(applicationData->get_LocalFolder(&settingsFolder)))
|
||||||
|
break;
|
||||||
|
ComPtr<IStorageItem> settingsFolderItem;
|
||||||
|
if (FAILED(settingsFolder.As(&settingsFolderItem)))
|
||||||
|
break;
|
||||||
|
HSTRING path;
|
||||||
|
if (FAILED(settingsFolderItem->get_Path(&path)))
|
||||||
|
break;
|
||||||
|
result = convertCharArray(WindowsGetStringRawBuffer(path, nullptr));
|
||||||
|
if (isTestModeEnabled())
|
||||||
|
result += QLatin1String("/qttest");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CacheLocation:
|
||||||
|
return writableLocation(DataLocation) + QLatin1String("/cache");
|
||||||
|
|
||||||
|
case GenericCacheLocation:
|
||||||
|
return writableLocation(GenericDataLocation) + QLatin1String("/cache");
|
||||||
|
|
||||||
|
case RuntimeLocation:
|
||||||
|
case HomeLocation:
|
||||||
|
result = QDir::homePath();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TempLocation:
|
||||||
|
result = QDir::tempPath();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Q_UNIMPLEMENTED();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList QStandardPaths::standardLocations(StandardLocation type)
|
QStringList QStandardPaths::standardLocations(StandardLocation type)
|
||||||
|
@ -283,9 +283,9 @@ void tst_qstandardpaths::testDataLocation()
|
|||||||
{
|
{
|
||||||
// On all platforms, DataLocation should be GenericDataLocation / organization name / app name
|
// On all platforms, DataLocation should be GenericDataLocation / organization name / app name
|
||||||
// This allows one app to access the data of another app.
|
// This allows one app to access the data of another app.
|
||||||
// Blackberry OS is an exception to this case, owing to the fact that
|
// Blackberry OS and WinRT are an exception to this case, owing to the fact that
|
||||||
// applications are sandboxed.
|
// applications are sandboxed.
|
||||||
#ifndef Q_OS_BLACKBERRY
|
#if !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_WINRT)
|
||||||
const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
|
||||||
QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/tst_qstandardpaths");
|
QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/tst_qstandardpaths");
|
||||||
QCoreApplication::instance()->setOrganizationName("Qt");
|
QCoreApplication::instance()->setOrganizationName("Qt");
|
||||||
@ -329,6 +329,7 @@ void tst_qstandardpaths::testFindExecutable_data()
|
|||||||
QTest::addColumn<QString>("needle");
|
QTest::addColumn<QString>("needle");
|
||||||
QTest::addColumn<QString>("expected");
|
QTest::addColumn<QString>("expected");
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
# ifndef Q_OS_WINRT
|
||||||
const QFileInfo cmdFi = QFileInfo(QDir::cleanPath(QString::fromLocal8Bit(qgetenv("COMSPEC"))));
|
const QFileInfo cmdFi = QFileInfo(QDir::cleanPath(QString::fromLocal8Bit(qgetenv("COMSPEC"))));
|
||||||
const QString cmdPath = cmdFi.absoluteFilePath();
|
const QString cmdPath = cmdFi.absoluteFilePath();
|
||||||
|
|
||||||
@ -352,6 +353,7 @@ void tst_qstandardpaths::testFindExecutable_data()
|
|||||||
QTest::newRow("win8-logo-nosuffix")
|
QTest::newRow("win8-logo-nosuffix")
|
||||||
<< QString() << logo << logoPath;
|
<< QString() << logo << logoPath;
|
||||||
}
|
}
|
||||||
|
# endif // Q_OS_WINRT
|
||||||
#else
|
#else
|
||||||
const QFileInfo shFi = findSh();
|
const QFileInfo shFi = findSh();
|
||||||
Q_ASSERT(shFi.exists());
|
Q_ASSERT(shFi.exists());
|
||||||
|
Loading…
Reference in New Issue
Block a user