winrt: msvc2015: refactor file handling
msvc2015 reintroduced a couple of functions from the win32 API towards WinRT. Enable usage of those and simplify the file system engine. Furthermore update the autotests. Change-Id: I9eafffba0ddfd05917c184c4a6b9e166f86d71d9 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
This commit is contained in:
parent
f4502fbaf0
commit
f05c597ae5
@ -152,7 +152,11 @@ inline void QDirPrivate::setPath(const QString &path)
|
||||
if (p.endsWith(QLatin1Char('/'))
|
||||
&& p.length() > 1
|
||||
#if defined(Q_OS_WIN)
|
||||
# if defined (Q_OS_WINRT)
|
||||
&& (!(p.toLower() == QDir::rootPath().toLower()))
|
||||
# else
|
||||
&& (!(p.length() == 3 && p.at(1).unicode() == ':' && p.at(0).isLetter()))
|
||||
# endif
|
||||
#endif
|
||||
) {
|
||||
p.truncate(p.length() - 1);
|
||||
@ -885,6 +889,9 @@ bool QDir::cd(const QString &dirName)
|
||||
#if defined (Q_OS_UNIX)
|
||||
//After cleanPath() if path is "/.." or starts with "/../" it means trying to cd above root.
|
||||
if (newPath.startsWith(QLatin1String("/../")) || newPath == QLatin1String("/.."))
|
||||
#elif defined (Q_OS_WINRT)
|
||||
const QString rootPath = QDir::rootPath();
|
||||
if (newPath.size() < rootPath.size() && rootPath.startsWith(newPath))
|
||||
#else
|
||||
/*
|
||||
cleanPath() already took care of replacing '\' with '/'.
|
||||
@ -2187,7 +2194,11 @@ QString QDir::cleanPath(const QString &path)
|
||||
// Strip away last slash except for root directories
|
||||
if (ret.length() > 1 && ret.endsWith(QLatin1Char('/'))) {
|
||||
#if defined (Q_OS_WIN)
|
||||
# if defined(Q_OS_WINRT)
|
||||
if (!((ret.length() == 3 || ret.length() == QDir::rootPath().length()) && ret.at(1) == QLatin1Char(':')))
|
||||
# else
|
||||
if (!(ret.length() == 3 && ret.at(1) == QLatin1Char(':')))
|
||||
# endif
|
||||
#endif
|
||||
ret.chop(1);
|
||||
}
|
||||
|
@ -1095,7 +1095,7 @@ bool QFileInfo::isRoot() const
|
||||
return true;
|
||||
if (d->fileEngine == 0) {
|
||||
if (d->fileEntry.isRoot()) {
|
||||
#if defined(Q_OS_WIN)
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
|
||||
//the path is a drive root, but the drive may not exist
|
||||
//for backward compatibility, return true only if the drive exists
|
||||
if (!d->cache_enabled || !d->metaData.hasFlags(QFileSystemMetaData::ExistsAttribute))
|
||||
|
@ -78,6 +78,11 @@ using namespace Microsoft::WRL::Wrappers;
|
||||
using namespace ABI::Windows::Foundation;
|
||||
using namespace ABI::Windows::Storage;
|
||||
using namespace ABI::Windows::ApplicationModel;
|
||||
|
||||
#if _MSC_VER < 1900
|
||||
#define Q_OS_WINRT_WIN81
|
||||
#endif
|
||||
|
||||
#endif // Q_OS_WINRT
|
||||
|
||||
#ifndef SPI_GETPLATFORMTYPE
|
||||
@ -522,7 +527,7 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path)
|
||||
{
|
||||
// can be //server or //server/share
|
||||
QString absPath;
|
||||
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
|
||||
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
|
||||
QVarLengthArray<wchar_t, MAX_PATH> buf(qMax(MAX_PATH, path.size() + 1));
|
||||
wchar_t *fileName = 0;
|
||||
DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName);
|
||||
@ -532,6 +537,16 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path)
|
||||
}
|
||||
if (retLen != 0)
|
||||
absPath = QString::fromWCharArray(buf.data(), retLen);
|
||||
# if defined(Q_OS_WINRT)
|
||||
// Win32 returns eg C:/ as root directory with a trailing /.
|
||||
// WinRT returns the sandbox root without /.
|
||||
// Also C:/../.. returns C:/ on Win32, while for WinRT it steps outside the package
|
||||
// and goes beyond package root. Hence force the engine to stay inside
|
||||
// the package.
|
||||
const QString rootPath = QDir::toNativeSeparators(QDir::rootPath());
|
||||
if (absPath.size() < rootPath.size() && rootPath.startsWith(absPath))
|
||||
absPath = rootPath;
|
||||
# endif // Q_OS_WINRT
|
||||
#elif !defined(Q_OS_WINCE)
|
||||
if (QDir::isRelativePath(path))
|
||||
absPath = QDir::toNativeSeparators(QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + path));
|
||||
@ -569,7 +584,7 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
|
||||
ret = entry.filePath();
|
||||
#endif
|
||||
} else {
|
||||
#ifndef Q_OS_WINRT
|
||||
#ifndef Q_OS_WINRT_WIN81
|
||||
ret = QDir::cleanPath(QDir::currentPath() + QLatin1Char('/') + entry.filePath());
|
||||
#else
|
||||
// Some WinRT APIs do not support absolute paths (due to sandboxing).
|
||||
@ -1218,8 +1233,8 @@ QString QFileSystemEngine::rootPath()
|
||||
if (FAILED(item->get_Path(finalWinPath.GetAddressOf())))
|
||||
return ret;
|
||||
|
||||
ret = QDir::fromNativeSeparators(QString::fromWCharArray(finalWinPath.GetRawBuffer(nullptr)));
|
||||
|
||||
const QString qtWinPath = QDir::fromNativeSeparators(QString::fromWCharArray(finalWinPath.GetRawBuffer(nullptr)));
|
||||
ret = qtWinPath.endsWith(QLatin1Char('/')) ? qtWinPath : qtWinPath + QLatin1Char('/');
|
||||
#else
|
||||
QString ret = QString::fromLatin1(qgetenv("SystemDrive"));
|
||||
if (ret.isEmpty())
|
||||
@ -1337,7 +1352,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
|
||||
if(!(meta.exists() && meta.isDirectory()))
|
||||
return false;
|
||||
|
||||
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
|
||||
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
|
||||
//TODO: this should really be using nativeFilePath(), but that returns a path in long format \\?\c:\foo
|
||||
//which causes many problems later on when it's returned through currentPath()
|
||||
return ::SetCurrentDirectory(reinterpret_cast<const wchar_t*>(QDir::toNativeSeparators(entry.filePath()).utf16())) != 0;
|
||||
@ -1350,7 +1365,7 @@ bool QFileSystemEngine::setCurrentPath(const QFileSystemEntry &entry)
|
||||
QFileSystemEntry QFileSystemEngine::currentPath()
|
||||
{
|
||||
QString ret;
|
||||
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
|
||||
#if !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT_WIN81)
|
||||
DWORD size = 0;
|
||||
wchar_t currentName[PATH_MAX];
|
||||
size = ::GetCurrentDirectory(PATH_MAX, currentName);
|
||||
@ -1366,17 +1381,17 @@ QFileSystemEntry QFileSystemEngine::currentPath()
|
||||
}
|
||||
if (ret.length() >= 2 && ret[1] == QLatin1Char(':'))
|
||||
ret[0] = ret.at(0).toUpper(); // Force uppercase drive letters.
|
||||
#else // !Q_OS_WINCE && !Q_OS_WINRT
|
||||
#else // !Q_OS_WINCE && !Q_OS_WINRT_WIN81
|
||||
//TODO - a race condition exists when using currentPath / setCurrentPath from multiple threads
|
||||
if (qfsPrivateCurrentDir.isEmpty())
|
||||
#ifndef Q_OS_WINRT
|
||||
#ifndef Q_OS_WINRT_WIN81
|
||||
qfsPrivateCurrentDir = QCoreApplication::applicationDirPath();
|
||||
#else
|
||||
qfsPrivateCurrentDir = QDir::rootPath();
|
||||
#endif
|
||||
|
||||
ret = qfsPrivateCurrentDir;
|
||||
#endif // Q_OS_WINCE || Q_OS_WINRT
|
||||
#endif // Q_OS_WINCE || Q_OS_WINRT_WIN81
|
||||
return QFileSystemEntry(ret, QFileSystemEntry::FromNativePath());
|
||||
}
|
||||
|
||||
|
@ -166,6 +166,12 @@ void QFileSystemEntry::resolveNativeFilePath() const
|
||||
m_nativeFilePath.remove(0,1);
|
||||
if (m_nativeFilePath.isEmpty())
|
||||
m_nativeFilePath.append(QLatin1Char('.'));
|
||||
// WinRT/MSVC2015 allows a maximum of 256 characters for a filepath
|
||||
// unless //?/ is prepended which extends the rule to have a maximum
|
||||
// of 256 characters in the filename plus the preprending path
|
||||
#if _MSC_VER >= 1900
|
||||
m_nativeFilePath.prepend("\\\\?\\");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -283,9 +289,13 @@ bool QFileSystemEntry::isAbsolute() const
|
||||
bool QFileSystemEntry::isDriveRoot() const
|
||||
{
|
||||
resolveFilePath();
|
||||
#ifndef Q_OS_WINRT
|
||||
return (m_filePath.length() == 3
|
||||
&& m_filePath.at(0).isLetter() && m_filePath.at(1) == QLatin1Char(':')
|
||||
&& m_filePath.at(2) == QLatin1Char('/'));
|
||||
#else // !Q_OS_WINRT
|
||||
return m_filePath == QDir::rootPath();
|
||||
#endif // !Q_OS_WINRT
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -67,7 +67,8 @@ QFileSystemIterator::QFileSystemIterator(const QFileSystemEntry &entry, QDir::Fi
|
||||
if (!nativePath.endsWith(QLatin1Char('\\')))
|
||||
nativePath.append(QLatin1Char('\\'));
|
||||
nativePath.append(QLatin1Char('*'));
|
||||
#ifdef Q_OS_WINRT
|
||||
// In MSVC2015+ case we prepend //?/ for longer file-name support
|
||||
#if defined(Q_OS_WINRT) && _MSC_VER < 1900
|
||||
if (nativePath.startsWith(QLatin1Char('\\')))
|
||||
nativePath.remove(0, 1);
|
||||
#endif
|
||||
|
@ -1037,7 +1037,7 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
|
||||
offsetHi, offsetLo, size + extra);
|
||||
#else
|
||||
LPVOID mapAddress = ::MapViewOfFileFromApp(mapHandle, access,
|
||||
(ULONG64(offsetHi) << 32) + offsetLo, size);
|
||||
(ULONG64(offsetHi) << 32) + offsetLo, size + extra);
|
||||
#endif
|
||||
if (mapAddress) {
|
||||
uchar *address = extra + static_cast<uchar*>(mapAddress);
|
||||
|
@ -63,4 +63,5 @@ winrt: SUBDIRS -= \
|
||||
qprocess \
|
||||
qprocess-noapplication \
|
||||
qprocessenvironment \
|
||||
qstorageinfo \
|
||||
qwinoverlappedionotifier
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
, fd_(-1)
|
||||
, stream_(0)
|
||||
{
|
||||
#if defined(QT_LARGEFILE_SUPPORT) && !defined(Q_OS_MAC)
|
||||
#if defined(QT_LARGEFILE_SUPPORT) && !defined(Q_OS_MAC) && !defined(Q_OS_WINRT)
|
||||
maxSizeBits = 36; // 64 GiB
|
||||
#elif defined(Q_OS_MAC)
|
||||
// HFS+ does not support sparse files, so we limit file size for the test
|
||||
@ -135,6 +135,9 @@ private:
|
||||
|
||||
int fd_;
|
||||
FILE *stream_;
|
||||
|
||||
QSharedPointer<QTemporaryDir> m_tempDir;
|
||||
QString m_previousCurrent;
|
||||
};
|
||||
|
||||
/*
|
||||
@ -229,6 +232,11 @@ QByteArray const &tst_LargeFile::getDataBlock(int index, qint64 position)
|
||||
|
||||
void tst_LargeFile::initTestCase()
|
||||
{
|
||||
m_previousCurrent = QDir::currentPath();
|
||||
m_tempDir = QSharedPointer<QTemporaryDir>(new QTemporaryDir);
|
||||
QVERIFY2(!m_tempDir.isNull(), qPrintable("Could not create temporary directory."));
|
||||
QVERIFY2(QDir::setCurrent(m_tempDir->path()), qPrintable("Could not switch current directory"));
|
||||
|
||||
QFile file("qt_largefile.tmp");
|
||||
QVERIFY( !file.exists() || file.remove() );
|
||||
}
|
||||
@ -240,6 +248,8 @@ void tst_LargeFile::cleanupTestCase()
|
||||
|
||||
QFile file("qt_largefile.tmp");
|
||||
QVERIFY( !file.exists() || file.remove() );
|
||||
|
||||
QDir::setCurrent(m_previousCurrent);
|
||||
}
|
||||
|
||||
void tst_LargeFile::init()
|
||||
|
@ -52,6 +52,7 @@ class tst_QAbstractFileEngine
|
||||
{
|
||||
Q_OBJECT
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private slots:
|
||||
@ -64,6 +65,8 @@ private slots:
|
||||
void mounting();
|
||||
private:
|
||||
QStringList filesForRemoval;
|
||||
QSharedPointer<QTemporaryDir> m_currentDir;
|
||||
QString m_previousCurrent;
|
||||
};
|
||||
|
||||
class ReferenceFileEngine
|
||||
@ -563,6 +566,14 @@ class FileEngineHandler
|
||||
}
|
||||
};
|
||||
|
||||
void tst_QAbstractFileEngine::initTestCase()
|
||||
{
|
||||
m_previousCurrent = QDir::currentPath();
|
||||
m_currentDir = QSharedPointer<QTemporaryDir>(new QTemporaryDir());
|
||||
QVERIFY2(!m_currentDir.isNull(), qPrintable("Could not create current directory."));
|
||||
QDir::setCurrent(m_currentDir->path());
|
||||
}
|
||||
|
||||
void tst_QAbstractFileEngine::cleanupTestCase()
|
||||
{
|
||||
bool failed = false;
|
||||
@ -576,6 +587,8 @@ void tst_QAbstractFileEngine::cleanupTestCase()
|
||||
}
|
||||
|
||||
QVERIFY(!failed);
|
||||
|
||||
QDir::setCurrent(m_previousCurrent);
|
||||
}
|
||||
|
||||
void tst_QAbstractFileEngine::customHandler()
|
||||
|
@ -50,6 +50,7 @@ public:
|
||||
void stream_data(int noOfElements);
|
||||
|
||||
public slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
|
||||
private slots:
|
||||
@ -243,6 +244,10 @@ private:
|
||||
void readqint64(QDataStream *s);
|
||||
void readQIcon(QDataStream *s);
|
||||
void readQEasingCurve(QDataStream *s);
|
||||
|
||||
private:
|
||||
QSharedPointer<QTemporaryDir> m_tempDir;
|
||||
QString m_previousCurrent;
|
||||
};
|
||||
|
||||
static int NColorRoles[] = {
|
||||
@ -293,10 +298,20 @@ void tst_QDataStream::getSetCheck()
|
||||
QCOMPARE(QDataStream::ReadCorruptData, obj1.status());
|
||||
}
|
||||
|
||||
void tst_QDataStream::initTestCase()
|
||||
{
|
||||
m_previousCurrent = QDir::currentPath();
|
||||
m_tempDir = QSharedPointer<QTemporaryDir>(new QTemporaryDir);
|
||||
QVERIFY2(!m_tempDir.isNull(), qPrintable("Could not create temporary directory."));
|
||||
QVERIFY2(QDir::setCurrent(m_tempDir->path()), qPrintable("Could not switch current directory"));
|
||||
}
|
||||
|
||||
void tst_QDataStream::cleanupTestCase()
|
||||
{
|
||||
QFile::remove(QLatin1String("qdatastream.out"));
|
||||
QFile::remove(QLatin1String("datastream.tmp"));
|
||||
|
||||
QDir::setCurrent(m_previousCurrent);
|
||||
}
|
||||
|
||||
static int dataIndex(const QString &tag)
|
||||
|
@ -5,6 +5,9 @@ SOURCES = tst_qdir.cpp
|
||||
RESOURCES += qdir.qrc
|
||||
|
||||
TESTDATA += testdir testData searchdir resources entrylist types tst_qdir.cpp
|
||||
|
||||
contains(CONFIG, builtin_testdata): DEFINES += BUILTIN_TESTDATA
|
||||
|
||||
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
|
||||
|
||||
android:!android-no-sdk {
|
||||
|
@ -56,7 +56,7 @@
|
||||
# include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_VXWORKS)
|
||||
#if defined(Q_OS_VXWORKS) || defined(Q_OS_WINRT)
|
||||
#define Q_NO_SYMLINKS
|
||||
#endif
|
||||
|
||||
@ -216,7 +216,12 @@ private slots:
|
||||
void cdBelowRoot();
|
||||
|
||||
private:
|
||||
#ifdef BUILTIN_TESTDATA
|
||||
QString m_dataPath;
|
||||
QSharedPointer<QTemporaryDir> m_dataDir;
|
||||
#else
|
||||
const QString m_dataPath;
|
||||
#endif
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(tst_QDir::UncHandling)
|
||||
@ -224,7 +229,7 @@ Q_DECLARE_METATYPE(tst_QDir::UncHandling)
|
||||
tst_QDir::tst_QDir()
|
||||
#if defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
|
||||
: m_dataPath(QStandardPaths::writableLocation(QStandardPaths::CacheLocation))
|
||||
#else
|
||||
#elif !defined(BUILTIN_TESTDATA)
|
||||
: m_dataPath(QFileInfo(QFINDTESTDATA("testData")).absolutePath())
|
||||
#endif
|
||||
{
|
||||
@ -261,12 +266,23 @@ void tst_QDir::init()
|
||||
|
||||
void tst_QDir::initTestCase()
|
||||
{
|
||||
#ifdef BUILTIN_TESTDATA
|
||||
m_dataDir = QEXTRACTTESTDATA("/");
|
||||
QVERIFY2(!m_dataDir.isNull(), qPrintable("Did not find testdata. Is this builtin?"));
|
||||
m_dataPath = m_dataDir->path();
|
||||
#endif
|
||||
|
||||
QVERIFY2(!m_dataPath.isEmpty(), "test data not found");
|
||||
}
|
||||
|
||||
void tst_QDir::cleanupTestCase()
|
||||
{
|
||||
#ifdef BUILTIN_TESTDATA
|
||||
// We need to reset the current directory outside of QTemporaryDir for successful deletion
|
||||
QDir::setCurrent(QCoreApplication::applicationDirPath());
|
||||
#else
|
||||
QDir(QDir::currentPath() + "/tmpdir").removeRecursively();
|
||||
#endif
|
||||
}
|
||||
|
||||
// Testing get/set functions
|
||||
@ -532,7 +548,7 @@ void tst_QDir::exists_data()
|
||||
|
||||
QTest::newRow("simple dir") << (m_dataPath + "/resources") << true;
|
||||
QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << true;
|
||||
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
|
||||
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE)) && !defined(Q_OS_WINRT)
|
||||
const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
|
||||
QTest::newRow("unc 1") << uncRoot << true;
|
||||
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
|
||||
@ -544,7 +560,7 @@ void tst_QDir::exists_data()
|
||||
QTest::newRow("unc 8") << uncRoot + "/asharethatshouldnotexist" << false;
|
||||
QTest::newRow("unc 9") << "//ahostthatshouldnotexist" << false;
|
||||
#endif
|
||||
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
|
||||
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
|
||||
QTest::newRow("This drive should exist") << "C:/" << true;
|
||||
// find a non-existing drive and check if it does not exist
|
||||
#ifdef QT_BUILD_INTERNAL
|
||||
@ -897,7 +913,7 @@ void tst_QDir::entryListSimple_data()
|
||||
QTest::newRow("simple dir with slash") << (m_dataPath + "/resources/") << 2;
|
||||
#endif
|
||||
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
|
||||
const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
|
||||
QTest::newRow("unc 1") << uncRoot << 2;
|
||||
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << 2;
|
||||
@ -980,7 +996,6 @@ void tst_QDir::canonicalPath_data()
|
||||
|
||||
QTest::newRow("relative") << "." << m_dataPath;
|
||||
QTest::newRow("relativeSubDir") << "./testData/../testData" << m_dataPath + "/testData";
|
||||
|
||||
#ifndef Q_OS_WIN
|
||||
QTest::newRow("absPath") << m_dataPath + "/testData/../testData" << m_dataPath + "/testData";
|
||||
#else
|
||||
@ -1179,7 +1194,7 @@ tst_QDir::cleanPath_data()
|
||||
QTest::newRow("data10") << "/:/" << "/:";
|
||||
#endif
|
||||
#endif
|
||||
#ifdef Q_OS_WIN
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
|
||||
QTest::newRow("data11") << "//foo//bar" << "//foo/bar";
|
||||
#endif
|
||||
QTest::newRow("data12") << "ab/a/" << "ab/a"; // Path item with length of 2
|
||||
@ -1191,11 +1206,13 @@ tst_QDir::cleanPath_data()
|
||||
|
||||
QTest::newRow("data14") << "c://foo" << "c:/foo";
|
||||
// Drive letters and unc path in one string
|
||||
#ifndef Q_OS_WINRT
|
||||
#ifdef Q_OS_WIN
|
||||
QTest::newRow("data15") << "//c:/foo" << "//c:/foo";
|
||||
#else
|
||||
QTest::newRow("data15") << "//c:/foo" << "/c:/foo";
|
||||
#endif
|
||||
#endif // !Q_OS_WINRT
|
||||
|
||||
QTest::newRow("QTBUG-23892_0") << "foo/.." << ".";
|
||||
QTest::newRow("QTBUG-23892_1") << "foo/../" << ".";
|
||||
@ -1314,7 +1331,7 @@ void tst_QDir::absoluteFilePath_data()
|
||||
QTest::newRow("2") << "/" << "passwd" << "/passwd";
|
||||
QTest::newRow("3") << "relative" << "path" << QDir::currentPath() + "/relative/path";
|
||||
QTest::newRow("4") << "" << "" << QDir::currentPath();
|
||||
#ifdef Q_OS_WIN
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
|
||||
QTest::newRow("5") << "//machine" << "share" << "//machine/share";
|
||||
#endif
|
||||
|
||||
@ -1338,7 +1355,7 @@ void tst_QDir::absolutePath_data()
|
||||
QTest::addColumn<QString>("expectedPath");
|
||||
|
||||
QTest::newRow("0") << "/machine/share/dir1" << "/machine/share/dir1";
|
||||
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
|
||||
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
|
||||
QTest::newRow("1") << "\\machine\\share\\dir1" << "/machine/share/dir1";
|
||||
QTest::newRow("2") << "//machine/share/dir1" << "//machine/share/dir1";
|
||||
QTest::newRow("3") << "\\\\machine\\share\\dir1" << "//machine/share/dir1";
|
||||
@ -1406,10 +1423,12 @@ void tst_QDir::relativeFilePath_data()
|
||||
QTest::newRow("27") << "C:" << "D:/" << "D:/";
|
||||
QTest::newRow("28") << "C:/" << "D:" << "D:";
|
||||
QTest::newRow("29") << "C:/" << "D:/" << "D:/";
|
||||
#ifndef Q_OS_WINRT
|
||||
QTest::newRow("30") << "C:/foo/bar" << "//anotherHost/foo/bar" << "//anotherHost/foo/bar";
|
||||
QTest::newRow("31") << "//anotherHost/foo" << "//anotherHost/foo/bar" << "bar";
|
||||
QTest::newRow("32") << "//anotherHost/foo" << "bar" << "bar";
|
||||
QTest::newRow("33") << "//anotherHost/foo" << "C:/foo/bar" << "C:/foo/bar";
|
||||
#endif // !Q_OS_WINRT
|
||||
#endif
|
||||
|
||||
QTest::newRow("resource0") << ":/prefix" << "foo.bar" << "foo.bar";
|
||||
@ -1594,7 +1613,11 @@ void tst_QDir::homePath()
|
||||
qputenv("HOME", envHome);
|
||||
|
||||
#elif defined(Q_OS_WIN)
|
||||
if (strHome.length() > 3) // root dir = "c:/"; "//" is not really valid...
|
||||
if (strHome.length() > 3 // root dir = "c:/"; "//" is not really valid...
|
||||
#if defined(Q_OS_WINRT)
|
||||
&& strHome.length() > QDir::rootPath().length()
|
||||
#endif
|
||||
)
|
||||
QVERIFY(!strHome.endsWith('/'));
|
||||
#endif
|
||||
|
||||
@ -2059,6 +2082,9 @@ void tst_QDir::drives()
|
||||
QVERIFY(list.count() >= 1); //system
|
||||
QLatin1Char systemdrive('c');
|
||||
#endif
|
||||
#if defined(Q_OS_WINRT)
|
||||
QSKIP("WinRT has no concept of drives");
|
||||
#endif
|
||||
#if defined(Q_OS_WIN)
|
||||
QVERIFY(list.count() <= 26);
|
||||
bool foundsystem = false;
|
||||
@ -2115,7 +2141,9 @@ void tst_QDir::equalityOperator_data()
|
||||
<< true;
|
||||
|
||||
//need a path in the root directory that is unlikely to be a symbolic link.
|
||||
#if defined (Q_OS_WIN)
|
||||
#if defined (Q_OS_WINRT)
|
||||
QString pathinroot(QDir::rootPath() + QLatin1String("assets/.."));
|
||||
#elif defined (Q_OS_WIN)
|
||||
QString pathinroot("c:/windows/..");
|
||||
#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
|
||||
QString pathinroot("/system/..");
|
||||
@ -2246,6 +2274,10 @@ void tst_QDir::cdBelowRoot()
|
||||
#define ROOT QString("/")
|
||||
#define DIR QString("/tmp")
|
||||
#define CD_INTO "tmp"
|
||||
#elif defined (Q_OS_WINRT)
|
||||
#define ROOT QDir::rootPath()
|
||||
#define DIR QDir::rootPath()
|
||||
#define CD_INTO QDir::rootPath()
|
||||
#else
|
||||
#define ROOT QString::fromLocal8Bit(qgetenv("SystemDrive"))+"/"
|
||||
#define DIR QString::fromLocal8Bit(qgetenv("SystemRoot")).replace('\\', '/')
|
||||
@ -2260,6 +2292,9 @@ void tst_QDir::cdBelowRoot()
|
||||
#ifdef Q_OS_UNIX
|
||||
if (::getuid() == 0)
|
||||
QSKIP("Running this test as root doesn't make sense");
|
||||
#endif
|
||||
#ifdef Q_OS_WINRT
|
||||
QSKIP("WinRT has no concept of system root");
|
||||
#endif
|
||||
QDir dir(DIR);
|
||||
QVERIFY(!dir.cd("../.."));
|
||||
|
@ -5,6 +5,7 @@ SOURCES = tst_qdiriterator.cpp
|
||||
RESOURCES += qdiriterator.qrc
|
||||
|
||||
TESTDATA += entrylist
|
||||
contains(CONFIG, builtin_testdata): DEFINES += BUILTIN_TESTDATA
|
||||
|
||||
wince*mips*|wincewm50smart-msvc200*: DEFINES += WINCE_BROKEN_ITERATE=1
|
||||
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
|
||||
|
@ -42,7 +42,7 @@
|
||||
|
||||
#include <QtCore/private/qfsfileengine_p.h>
|
||||
|
||||
#if defined(Q_OS_VXWORKS)
|
||||
#if defined(Q_OS_VXWORKS) || defined(Q_OS_WINRT)
|
||||
#define Q_NO_SYMLINKS
|
||||
#endif
|
||||
|
||||
@ -115,6 +115,10 @@ private slots:
|
||||
#ifndef Q_OS_WIN
|
||||
void hiddenDirs_hiddenFiles();
|
||||
#endif
|
||||
#ifdef BUILTIN_TESTDATA
|
||||
private:
|
||||
QSharedPointer<QTemporaryDir> m_dataDir;
|
||||
#endif
|
||||
};
|
||||
|
||||
void tst_QDirIterator::initTestCase()
|
||||
@ -141,6 +145,10 @@ void tst_QDirIterator::initTestCase()
|
||||
}
|
||||
|
||||
testdata_dir += QStringLiteral("/entrylist");
|
||||
#elif defined(BUILTIN_TESTDATA)
|
||||
m_dataDir = QEXTRACTTESTDATA("/");
|
||||
QVERIFY2(!m_dataDir.isNull(), qPrintable("Could not extract test data"));
|
||||
QString testdata_dir = m_dataDir->path();
|
||||
#else
|
||||
|
||||
// chdir into testdata directory, then find testdata by relative paths.
|
||||
@ -217,6 +225,11 @@ void tst_QDirIterator::cleanupTestCase()
|
||||
|
||||
Q_FOREACH(QString dirName, createdDirectories)
|
||||
currentDir.rmdir(dirName);
|
||||
|
||||
#ifdef Q_OS_WINRT
|
||||
QDir::setCurrent(QCoreApplication::applicationDirPath());
|
||||
#endif // Q_OS_WINRT
|
||||
|
||||
}
|
||||
|
||||
void tst_QDirIterator::iterateRelativeDirectory_data()
|
||||
|
@ -66,7 +66,7 @@
|
||||
#include <private/qfileinfo_p.h>
|
||||
#include "../../../../shared/filesystem.h"
|
||||
|
||||
#if defined(Q_OS_VXWORKS)
|
||||
#if defined(Q_OS_VXWORKS) || defined(Q_OS_WINRT)
|
||||
#define Q_NO_SYMLINKS
|
||||
#endif
|
||||
|
||||
@ -427,12 +427,12 @@ void tst_QFileInfo::isDir_data()
|
||||
|
||||
QTest::newRow("broken link") << "brokenlink.lnk" << false;
|
||||
|
||||
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
|
||||
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
|
||||
QTest::newRow("drive 1") << "c:" << true;
|
||||
QTest::newRow("drive 2") << "c:/" << true;
|
||||
//QTest::newRow("drive 2") << "t:s" << false;
|
||||
#endif
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
|
||||
const QString uncRoot = QStringLiteral("//") + QtNetworkSettings::winServerName();
|
||||
QTest::newRow("unc 1") << uncRoot << true;
|
||||
QTest::newRow("unc 2") << uncRoot + QLatin1Char('/') << true;
|
||||
@ -469,7 +469,7 @@ void tst_QFileInfo::isRoot_data()
|
||||
|
||||
QTest::newRow("simple dir") << m_resourcesDir << false;
|
||||
QTest::newRow("simple dir with slash") << (m_resourcesDir + QLatin1Char('/')) << false;
|
||||
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
|
||||
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
|
||||
QTest::newRow("drive 1") << "c:" << false;
|
||||
QTest::newRow("drive 2") << "c:/" << true;
|
||||
QTest::newRow("drive 3") << "p:/" << false;
|
||||
@ -513,7 +513,12 @@ void tst_QFileInfo::exists_data()
|
||||
QTest::newRow("data8") << (m_resourcesDir + "/*.ext1") << false;
|
||||
QTest::newRow("data9") << (m_resourcesDir + "/file?.ext1") << false;
|
||||
QTest::newRow("data10") << "." << true;
|
||||
|
||||
// Skip for the WinRT case, as GetFileAttributesEx removes _any_
|
||||
// trailing whitespace and "." is a valid entry as seen in data10
|
||||
#ifndef Q_OS_WINRT
|
||||
QTest::newRow("data11") << ". " << false;
|
||||
#endif
|
||||
QTest::newRow("empty") << "" << false;
|
||||
|
||||
QTest::newRow("simple dir") << m_resourcesDir << true;
|
||||
@ -554,7 +559,7 @@ void tst_QFileInfo::absolutePath_data()
|
||||
QTest::addColumn<QString>("filename");
|
||||
|
||||
QString drivePrefix;
|
||||
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE))
|
||||
#if (defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT))
|
||||
drivePrefix = QDir::currentPath().left(2);
|
||||
QString nonCurrentDrivePrefix =
|
||||
drivePrefix.left(1).compare("X", Qt::CaseInsensitive) == 0 ? QString("Y:") : QString("X:");
|
||||
@ -564,6 +569,8 @@ void tst_QFileInfo::absolutePath_data()
|
||||
QTest::newRow("<not current drive>:my.dll") << nonCurrentDrivePrefix + "my.dll"
|
||||
<< nonCurrentDrivePrefix + "/"
|
||||
<< "my.dll";
|
||||
#elif defined(Q_OS_WINRT)
|
||||
drivePrefix = QDir::currentPath().left(2);
|
||||
#endif
|
||||
QTest::newRow("0") << "/machine/share/dir1/" << drivePrefix + "/machine/share/dir1" << "";
|
||||
QTest::newRow("1") << "/machine/share/dir1" << drivePrefix + "/machine/share" << "dir1";
|
||||
@ -571,7 +578,7 @@ void tst_QFileInfo::absolutePath_data()
|
||||
QTest::newRow("3") << "/usr/local/bin/" << drivePrefix + "/usr/local/bin" << "";
|
||||
QTest::newRow("/test") << "/test" << drivePrefix + "/" << "test";
|
||||
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
|
||||
QTest::newRow("c:\\autoexec.bat") << "c:\\autoexec.bat" << "C:/"
|
||||
<< "autoexec.bat";
|
||||
QTest::newRow("c:autoexec.bat") << QDir::currentPath().left(2) + "autoexec.bat" << QDir::currentPath()
|
||||
@ -735,7 +742,7 @@ void tst_QFileInfo::canonicalFilePath()
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
|
||||
typedef BOOL (WINAPI *PtrCreateSymbolicLink)(LPTSTR, LPTSTR, DWORD);
|
||||
PtrCreateSymbolicLink ptrCreateSymbolicLink =
|
||||
(PtrCreateSymbolicLink)QLibrary::resolve(QLatin1String("kernel32"), "CreateSymbolicLinkW");
|
||||
@ -831,7 +838,7 @@ void tst_QFileInfo::dir_data()
|
||||
QTest::newRow("absFilePath") << QDir::currentPath() + "/tmp.txt" << false << QDir::currentPath();
|
||||
QTest::newRow("absFilePathAbsPath") << QDir::currentPath() + "/tmp.txt" << true << QDir::currentPath();
|
||||
QTest::newRow("resource1") << ":/tst_qfileinfo/resources/file1.ext1" << true << ":/tst_qfileinfo/resources";
|
||||
#ifdef Q_OS_WIN
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
|
||||
QTest::newRow("driveWithSlash") << "C:/file1.ext1.ext2" << true << "C:/";
|
||||
QTest::newRow("driveWithoutSlash") << QDir::currentPath().left(2) + "file1.ext1.ext2" << false << QDir::currentPath().left(2);
|
||||
#endif
|
||||
@ -1022,7 +1029,7 @@ void tst_QFileInfo::size()
|
||||
|
||||
void tst_QFileInfo::systemFiles()
|
||||
{
|
||||
#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE)
|
||||
#if !defined(Q_OS_WIN) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
|
||||
QSKIP("This is a Windows only test");
|
||||
#endif
|
||||
QFileInfo fi("c:\\pagefile.sys");
|
||||
@ -1193,6 +1200,8 @@ void tst_QFileInfo::fileTimes()
|
||||
#endif
|
||||
#if defined(Q_OS_WINCE)
|
||||
QEXPECT_FAIL("simple", "WinCE only stores date of access data, not the time", Continue);
|
||||
#elif defined(Q_OS_WINRT)
|
||||
QEXPECT_FAIL("", "WinRT does not allow timestamp handling change in the filesystem due to sandboxing", Continue);
|
||||
#elif defined(Q_OS_QNX)
|
||||
QEXPECT_FAIL("", "QNX uses the noatime filesystem option", Continue);
|
||||
#elif defined(Q_OS_ANDROID) && !defined(Q_OS_ANDROID_NO_SDK)
|
||||
@ -1628,7 +1637,7 @@ void tst_QFileInfo::isWritable()
|
||||
QVERIFY(QFileInfo("tempfile.txt").isWritable());
|
||||
tempfile.remove();
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
|
||||
#ifdef Q_OS_WINCE
|
||||
QFileInfo fi("\\Windows\\wince.nls");
|
||||
#else
|
||||
|
@ -24,6 +24,7 @@
|
||||
<file>platforms/+unix/test</file>
|
||||
<file>platforms/+windows/+wince/test</file>
|
||||
<file>platforms/+windows/+winnt/test</file>
|
||||
<file>platforms/+windows/+winrt/test</file>
|
||||
<file>platforms/+windows/test</file>
|
||||
<file>platforms/+android/test</file>
|
||||
<file>platforms/+blackberry/test</file>
|
||||
@ -34,6 +35,7 @@
|
||||
<file>platforms/+haiku/test</file>
|
||||
<file>platforms/+linux/test</file>
|
||||
<file>platforms/+wince/test</file>
|
||||
<file>platforms/+winrt/test</file>
|
||||
|
||||
<!-- platforms/test2: shallow selection for the deepest selector -->
|
||||
<file>platforms/test2</file>
|
||||
@ -45,6 +47,7 @@
|
||||
<file>platforms/+linux/test2</file>
|
||||
<file>platforms/+wince/test2</file>
|
||||
<file>platforms/+winnt/test2</file>
|
||||
<file>platforms/+winrt/test2</file>
|
||||
|
||||
<!-- platforms/test3: selection for the family only -->
|
||||
<file>platforms/test3</file>
|
||||
|
@ -99,7 +99,7 @@ void tst_QFileSelector::basicTest_data()
|
||||
expectedPlatform2File = QString(":/platforms/test2");
|
||||
#else
|
||||
QString distributionName;
|
||||
# if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || defined(Q_OS_FREEBSD)
|
||||
# if (defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)) || defined(Q_OS_FREEBSD) || defined(Q_OS_WINRT)
|
||||
distributionName = QSysInfo::productType();
|
||||
# endif
|
||||
foreach (const QString &selector, QFileSelectorPrivate::platformSelectors()) {
|
||||
|
@ -43,6 +43,7 @@ class tst_QIODevice : public QObject
|
||||
|
||||
private slots:
|
||||
void initTestCase();
|
||||
void cleanupTestCase();
|
||||
void getSetCheck();
|
||||
void constructing_QTcpSocket();
|
||||
void constructing_QFile();
|
||||
@ -60,6 +61,10 @@ private slots:
|
||||
void peekBug();
|
||||
void readAllKeepPosition();
|
||||
void writeInTextMode();
|
||||
|
||||
private:
|
||||
QSharedPointer<QTemporaryDir> m_tempDir;
|
||||
QString m_previousCurrent;
|
||||
};
|
||||
|
||||
void tst_QIODevice::initTestCase()
|
||||
@ -68,6 +73,15 @@ void tst_QIODevice::initTestCase()
|
||||
QVERIFY(QFileInfo(QStringLiteral("./tst_qiodevice.cpp")).exists()
|
||||
|| QFile::copy(QStringLiteral(":/tst_qiodevice.cpp"), QStringLiteral("./tst_qiodevice.cpp")));
|
||||
#endif
|
||||
m_previousCurrent = QDir::currentPath();
|
||||
m_tempDir = QSharedPointer<QTemporaryDir>(new QTemporaryDir);
|
||||
QVERIFY2(!m_tempDir.isNull(), qPrintable("Could not create temporary directory."));
|
||||
QVERIFY2(QDir::setCurrent(m_tempDir->path()), qPrintable("Could not switch current directory"));
|
||||
}
|
||||
|
||||
void tst_QIODevice::cleanupTestCase()
|
||||
{
|
||||
QDir::setCurrent(m_previousCurrent);
|
||||
}
|
||||
|
||||
// Testing get/set functions
|
||||
|
@ -6,6 +6,7 @@ QT = core core-private testlib
|
||||
|
||||
SOURCES += tst_qloggingregistry.cpp
|
||||
OTHER_FILES += qtlogging.ini
|
||||
TESTDATA += qtlogging.ini
|
||||
|
||||
android:!android-no-sdk: {
|
||||
RESOURCES += \
|
||||
|
@ -429,6 +429,8 @@ void tst_qstandardpaths::testFindExecutable()
|
||||
|
||||
void tst_qstandardpaths::testFindExecutableLinkToDirectory()
|
||||
{
|
||||
// WinRT has no link support
|
||||
#ifndef Q_OS_WINRT
|
||||
// link to directory
|
||||
const QString target = QDir::tempPath() + QDir::separator() + QLatin1String("link.lnk");
|
||||
QFile::remove(target);
|
||||
@ -436,15 +438,16 @@ void tst_qstandardpaths::testFindExecutableLinkToDirectory()
|
||||
QVERIFY(appFile.link(target));
|
||||
QVERIFY(QStandardPaths::findExecutable(target).isEmpty());
|
||||
QFile::remove(target);
|
||||
#endif
|
||||
}
|
||||
|
||||
void tst_qstandardpaths::testRuntimeDirectory()
|
||||
{
|
||||
#ifdef Q_XDG_PLATFORM
|
||||
const QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation);
|
||||
QVERIFY(!runtimeDir.isEmpty());
|
||||
|
||||
// Check that it can automatically fix permissions
|
||||
#ifdef Q_XDG_PLATFORM
|
||||
QFile file(runtimeDir);
|
||||
const QFile::Permissions wantedPerms = QFile::ReadUser | QFile::WriteUser | QFile::ExeUser;
|
||||
const QFile::Permissions additionalPerms = QFile::ReadOwner | QFile::WriteOwner | QFile::ExeOwner;
|
||||
|
@ -72,11 +72,14 @@ private slots:
|
||||
|
||||
void QTBUG43352_failedSetPermissions();
|
||||
|
||||
public:
|
||||
private:
|
||||
QString m_previousCurrent;
|
||||
};
|
||||
|
||||
void tst_QTemporaryDir::initTestCase()
|
||||
{
|
||||
m_previousCurrent = QDir::currentPath();
|
||||
QDir::setCurrent(QDir::tempPath());
|
||||
QVERIFY(QDir("test-XXXXXX").exists() || QDir().mkdir("test-XXXXXX"));
|
||||
QCoreApplication::setApplicationName("tst_qtemporarydir");
|
||||
}
|
||||
@ -84,6 +87,8 @@ void tst_QTemporaryDir::initTestCase()
|
||||
void tst_QTemporaryDir::cleanupTestCase()
|
||||
{
|
||||
QVERIFY(QDir().rmdir("test-XXXXXX"));
|
||||
|
||||
QDir::setCurrent(m_previousCurrent);
|
||||
}
|
||||
|
||||
void tst_QTemporaryDir::construction()
|
||||
|
@ -85,10 +85,15 @@ private slots:
|
||||
void QTBUG_4796_data();
|
||||
void QTBUG_4796();
|
||||
void guaranteeUnique();
|
||||
private:
|
||||
QString m_previousCurrent;
|
||||
};
|
||||
|
||||
void tst_QTemporaryFile::initTestCase()
|
||||
{
|
||||
m_previousCurrent = QDir::currentPath();
|
||||
QDir::setCurrent(QDir::tempPath());
|
||||
|
||||
// For QTBUG_4796
|
||||
QVERIFY(QDir("test-XXXXXX").exists() || QDir().mkdir("test-XXXXXX"));
|
||||
QCoreApplication::setApplicationName("tst_qtemporaryfile");
|
||||
@ -116,6 +121,8 @@ void tst_QTemporaryFile::cleanupTestCase()
|
||||
{
|
||||
// From QTBUG_4796
|
||||
QVERIFY(QDir().rmdir("test-XXXXXX"));
|
||||
|
||||
QDir::setCurrent(m_previousCurrent);
|
||||
}
|
||||
|
||||
void tst_QTemporaryFile::construction()
|
||||
@ -678,8 +685,11 @@ void tst_QTemporaryFile::createNativeFile_data()
|
||||
const QString nativeFilePath = QFINDTESTDATA("resources/test.txt");
|
||||
#endif
|
||||
|
||||
QTest::newRow("nativeFile") << nativeFilePath << (qint64)-1 << false << QByteArray();
|
||||
QTest::newRow("nativeFileWithPos") << nativeFilePath << (qint64)5 << false << QByteArray();
|
||||
// File might not exist locally in case of sandboxing or remote testing
|
||||
if (!nativeFilePath.startsWith(QLatin1String(":/"))) {
|
||||
QTest::newRow("nativeFile") << nativeFilePath << (qint64)-1 << false << QByteArray();
|
||||
QTest::newRow("nativeFileWithPos") << nativeFilePath << (qint64)5 << false << QByteArray();
|
||||
}
|
||||
QTest::newRow("resourceFile") << ":/resources/test.txt" << (qint64)-1 << true << QByteArray("This is a test");
|
||||
QTest::newRow("resourceFileWithPos") << ":/resources/test.txt" << (qint64)5 << true << QByteArray("This is a test");
|
||||
}
|
||||
|
@ -3013,14 +3013,20 @@ void tst_QUrl::fromUserInputWithCwd_data()
|
||||
it.next();
|
||||
QUrl url = QUrl::fromLocalFile(it.filePath());
|
||||
if (it.fileName() == QLatin1String(".")) {
|
||||
url = QUrl::fromLocalFile(QDir::currentPath()); // fromUserInput cleans the path
|
||||
url = QUrl::fromLocalFile(QDir::currentPath()
|
||||
#ifdef Q_OS_WINRT
|
||||
+ QLatin1Char('/')
|
||||
#endif
|
||||
); // fromUserInput cleans the path
|
||||
}
|
||||
QTest::newRow(QString("file-%1").arg(c++).toLatin1()) << it.fileName() << QDir::currentPath() << url << url;
|
||||
}
|
||||
#ifndef Q_OS_WINRT // WinRT cannot cd outside current / sandbox
|
||||
QDir parent = QDir::current();
|
||||
QVERIFY(parent.cdUp());
|
||||
QUrl parentUrl = QUrl::fromLocalFile(parent.path());
|
||||
QTest::newRow("dotdot") << ".." << QDir::currentPath() << parentUrl << parentUrl;
|
||||
#endif
|
||||
|
||||
QTest::newRow("nonexisting") << "nonexisting" << QDir::currentPath() << QUrl("http://nonexisting") << QUrl::fromLocalFile(QDir::currentPath() + "/nonexisting");
|
||||
QTest::newRow("short-url") << "example.org" << QDir::currentPath() << QUrl("http://example.org") << QUrl::fromLocalFile(QDir::currentPath() + "/example.org");
|
||||
|
Loading…
x
Reference in New Issue
Block a user