Change platform selectors to match qmake selectors
Previously matched Qt.platform.os, however that can only provide one string. Multiple selectors can be present at once, so we can provide both unix and linux instead of having to pick the most specialized one. Task-number: QTBUG-34796 Change-Id: I219517d740fa7385e923a9e09cb7e241378fbaee Reviewed-by: David Faure <david.faure@kdab.com>
This commit is contained in:
parent
63824d2e00
commit
7d72516b52
@ -348,22 +348,28 @@ void QFileSelectorPrivate::updateSelectors()
|
||||
QStringList QFileSelectorPrivate::platformSelectors()
|
||||
{
|
||||
QStringList ret;
|
||||
#if defined(Q_OS_LINUX_ANDROID)
|
||||
ret << QStringLiteral("android");
|
||||
#elif defined(Q_OS_BLACKBERRY)
|
||||
ret << QStringLiteral("blackberry");
|
||||
#elif defined(Q_OS_IOS)
|
||||
ret << QStringLiteral("ios");
|
||||
#elif defined(Q_OS_WINCE)
|
||||
ret << QStringLiteral("wince");
|
||||
#elif defined(Q_OS_WIN)
|
||||
#if defined(Q_OS_WIN)
|
||||
ret << QStringLiteral("windows");
|
||||
#elif defined(Q_OS_LINUX)
|
||||
ret << QStringLiteral("linux");
|
||||
#elif defined(Q_OS_OSX)
|
||||
ret << QStringLiteral("osx");
|
||||
# if defined(Q_OS_WINCE)
|
||||
ret << QStringLiteral("wince");
|
||||
# endif
|
||||
#elif defined(Q_OS_UNIX)
|
||||
ret << QStringLiteral("generic_unix");
|
||||
ret << QStringLiteral("unix");
|
||||
# if defined(Q_OS_LINUX_ANDROID)
|
||||
ret << QStringLiteral("android");
|
||||
# elif defined(Q_OS_BLACKBERRY)
|
||||
ret << QStringLiteral("blackberry");
|
||||
# elif defined(Q_OS_IOS)
|
||||
ret << QStringLiteral("ios");
|
||||
# elif defined(Q_OS_LINUX)
|
||||
ret << QStringLiteral("linux");
|
||||
# elif defined(Q_OS_MAC)
|
||||
ret << QStringLiteral("mac");
|
||||
# else
|
||||
struct utsname u;
|
||||
if (uname(&u) != -1)
|
||||
ret << QString::fromLatin1(u.sysname).toLower();
|
||||
# endif
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
0
tests/auto/corelib/io/qfileselector/platforms/test2
Normal file
0
tests/auto/corelib/io/qfileselector/platforms/test2
Normal file
@ -11,13 +11,27 @@
|
||||
<file>extras/+custom3/+custom5/test</file>
|
||||
<file>extras/+custom5/+custom3/test</file>
|
||||
<file>platforms/test</file>
|
||||
<file>platforms/+unix/+android/test</file>
|
||||
<file>platforms/+unix/+blackberry/test</file>
|
||||
<file>platforms/+unix/+ios/test</file>
|
||||
<file>platforms/+unix/+mac/test</file>
|
||||
<file>platforms/+windows/+wince/test</file>
|
||||
<file>platforms/+windows/test</file>
|
||||
<file>platforms/+windows/test2</file>
|
||||
<file>platforms/+unix/+linux/test</file>
|
||||
<file>platforms/+unix/test</file>
|
||||
<file>platforms/test2</file>
|
||||
<file>platforms/+android/test2</file>
|
||||
<file>platforms/+blackberry/test2</file>
|
||||
<file>platforms/+ios/test2</file>
|
||||
<file>platforms/+mac/test2</file>
|
||||
<file>platforms/+linux/test2</file>
|
||||
<file>platforms/+wince/test2</file>
|
||||
<file>platforms/+android/test</file>
|
||||
<file>platforms/+blackberry/test</file>
|
||||
<file>platforms/+ios/test</file>
|
||||
<file>platforms/+osx/test</file>
|
||||
<file>platforms/+wince/test</file>
|
||||
<file>platforms/+windows/test</file>
|
||||
<file>platforms/+mac/test</file>
|
||||
<file>platforms/+linux/test</file>
|
||||
<file>platforms/+generic_unix/test</file>
|
||||
<file>platforms/+wince/test</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
@ -91,9 +91,33 @@ void tst_QFileSelector::basicTest_data()
|
||||
QTest::addColumn<QString>("expectedPath");
|
||||
|
||||
QString test("/test");// '/' is here so dir string can also be selector string
|
||||
QTest::newRow("platform") << QString(":/platforms/test") << QStringList()
|
||||
<< QString(":/platforms/") + QLatin1Char(selectorIndicator)
|
||||
+ QFileSelectorPrivate::platformSelectors().first() + test;
|
||||
QString test2("/test2");
|
||||
QString expectedPlatform1File(":/platforms");
|
||||
QString expectedPlatform2File(""); //Only the last selector
|
||||
#if defined(Q_OS_UNIX) && !defined(Q_OS_ANDROID) && !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_IOS) && !defined(Q_OS_LINUX) && !defined(Q_OS_MAC)
|
||||
/* We are only aware of specific unixes, and do not have test files for any of the others.
|
||||
However those unixes can get a selector added from the result of a uname call, so this will
|
||||
lead to a case where we don't have that file so we can't expect the concatenation of platform
|
||||
selectors to work. It should just find the +unix/test file.*/
|
||||
expectedPlatform1File = QString(":/platforms/") + QLatin1Char(selectorIndicator)
|
||||
+ QString("unix/test");
|
||||
expectedPlatform2File = QString(":/platforms/test2");
|
||||
#else
|
||||
foreach (const QString &selector, QFileSelectorPrivate::platformSelectors()) {
|
||||
expectedPlatform1File = expectedPlatform1File + QLatin1Char('/') + QLatin1Char(selectorIndicator)
|
||||
+ selector;
|
||||
expectedPlatform2File = selector;
|
||||
}
|
||||
expectedPlatform1File += test;
|
||||
expectedPlatform2File = QLatin1String(":/platforms/") + QLatin1Char(selectorIndicator)
|
||||
+ expectedPlatform2File + test2;
|
||||
#endif
|
||||
|
||||
QTest::newRow("platform1") << QString(":/platforms/test") << QStringList()
|
||||
<< expectedPlatform1File;
|
||||
|
||||
QTest::newRow("platform2") << QString(":/platforms/test2") << QStringList()
|
||||
<< expectedPlatform2File;
|
||||
|
||||
QString resourceTestPath(":/extras/test");
|
||||
QString custom1("custom1");
|
||||
|
Loading…
Reference in New Issue
Block a user