summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/io')
-rw-r--r--tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp4
-rw-r--r--tests/auto/corelib/io/qdebug/tst_qdebug.cpp16
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp12
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp56
-rw-r--r--tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp139
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp20
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp48
-rw-r--r--tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp40
8 files changed, 288 insertions, 47 deletions
diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
index a6d76ea7b6..a477d6bc6c 100644
--- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
+++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp
@@ -270,7 +270,9 @@ static int NColorRoles[] = {
QPalette::ToolTipText + 1, // Qt_5_0
QPalette::ToolTipText + 1, // Qt_5_1
QPalette::ToolTipText + 1, // Qt_5_2
- 0 // add the correct value for Qt_5_3 here later
+ QPalette::ToolTipText + 1, // Qt_5_3
+ QPalette::ToolTipText + 1, // Qt_5_4
+ 0 // add the correct value for Qt_5_5 here later
};
// Testing get/set functions
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
index 80144dba20..07e011f449 100644
--- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
+++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
@@ -163,7 +163,8 @@ public:
QDebug operator<< (QDebug s, const MyPoint& point)
{
const QDebugStateSaver saver(s);
- return s.nospace() << "MyPoint(" << point.v1 << ", " << point.v2 << ")";
+ s.nospace() << "MyPoint(" << point.v1 << ", " << point.v2 << ")";
+ return s;
}
class MyLine
@@ -199,10 +200,19 @@ void tst_QDebug::debugSpaceHandling() const
d << 1 << 2;
MyLine line(MyPoint(10, 11), MyPoint (12, 13));
d << line;
+ d << "bar";
// With the old implementation of MyPoint doing dbg.nospace() << ...; dbg.space() we ended up with
// MyLine(MyPoint(10, 11) , MyPoint(12, 13) )
}
- QCOMPARE(s_msg, QString::fromLatin1(" foo key=value 1 2 MyLine(MyPoint(10, 11), MyPoint(12, 13))"));
+ QCOMPARE(s_msg, QString::fromLatin1(" foo key=value 1 2 MyLine(MyPoint(10, 11), MyPoint(12, 13)) bar"));
+
+ QVERIFY(qDebug().autoInsertSpaces());
+ qDebug() << QPoint(21, 22) << QRect(23, 24, 25, 26) << QLine(27, 28, 29, 30);
+ QCOMPARE(s_msg, QString::fromLatin1("QPoint(21,22) QRect(23,24 25x26) QLine(QPoint(27,28),QPoint(29,30))"));
+ qDebug() << QPointF(21, 22) << QRectF(23, 24, 25, 26) << QLineF(27, 28, 29, 30);
+ QCOMPARE(s_msg, QString::fromLatin1("QPointF(21,22) QRectF(23,24 25x26) QLineF(QPointF(27,28),QPointF(29,30))"));
+ qDebug() << QMimeType() << QMimeDatabase().mimeTypeForName("application/pdf") << "foo";
+ QCOMPARE(s_msg, QString::fromLatin1("QMimeType(invalid) QMimeType(\"application/pdf\") foo"));
}
void tst_QDebug::stateSaver() const
@@ -214,7 +224,7 @@ void tst_QDebug::stateSaver() const
QDebugStateSaver saver(d);
d.nospace() << hex << right << qSetFieldWidth(3) << qSetPadChar('0') << 42;
}
- d.space() << 42;
+ d << 42;
}
QCOMPARE(s_msg, QString::fromLatin1("02a 42"));
}
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
index e06af5a799..7e04fa5957 100644
--- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
+++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
@@ -140,7 +140,7 @@ void tst_QFileSystemWatcher::basicTest()
watcher.setObjectName(QLatin1String("_qt_autotest_force_engine_") + backend);
QVERIFY(watcher.addPath(testFile.fileName()));
- QSignalSpy changedSpy(&watcher, SIGNAL(fileChanged(QString)));
+ QSignalSpy changedSpy(&watcher, &QFileSystemWatcher::fileChanged);
QVERIFY(changedSpy.isValid());
QEventLoop eventLoop;
QTimer timer;
@@ -278,7 +278,7 @@ void tst_QFileSystemWatcher::watchDirectory()
watcher.setObjectName(QLatin1String("_qt_autotest_force_engine_") + backend);
QVERIFY(watcher.addPath(testDir.absolutePath()));
- QSignalSpy changedSpy(&watcher, SIGNAL(directoryChanged(QString)));
+ QSignalSpy changedSpy(&watcher, &QFileSystemWatcher::directoryChanged);
QVERIFY(changedSpy.isValid());
QEventLoop eventLoop;
QTimer timer;
@@ -441,8 +441,8 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory()
QVERIFY(watcher.addPath(testDir.absolutePath()));
QVERIFY(watcher.addPath(testFileName));
- QSignalSpy fileChangedSpy(&watcher, SIGNAL(fileChanged(QString)));
- QSignalSpy dirChangedSpy(&watcher, SIGNAL(directoryChanged(QString)));
+ QSignalSpy fileChangedSpy(&watcher, &QFileSystemWatcher::fileChanged);
+ QSignalSpy dirChangedSpy(&watcher, &QFileSystemWatcher::directoryChanged);
QVERIFY(fileChangedSpy.isValid());
QVERIFY(dirChangedSpy.isValid());
QEventLoop eventLoop;
@@ -601,7 +601,7 @@ void tst_QFileSystemWatcher::QTBUG2331()
QVERIFY(watcher.addPath(temporaryDirectory.path()));
// watch signal
- QSignalSpy changedSpy(&watcher, SIGNAL(directoryChanged(QString)));
+ QSignalSpy changedSpy(&watcher, &QFileSystemWatcher::directoryChanged);
QVERIFY(changedSpy.isValid());
// remove directory, we should get one change signal, and we should no longer
@@ -680,7 +680,7 @@ void tst_QFileSystemWatcher::signalsEmittedAfterFileMoved()
connect(&watcher, SIGNAL(fileChanged(QString)), &signalReceiver, SLOT(fileChanged(QString)));
// watch signals
- QSignalSpy changedSpy(&watcher, SIGNAL(fileChanged(QString)));
+ QSignalSpy changedSpy(&watcher, &QFileSystemWatcher::fileChanged);
QVERIFY(changedSpy.isValid());
// move files to second directory
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index b67166272b..67cf954f98 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -259,7 +259,7 @@ void tst_QProcess::simpleStart()
qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState");
process = new QProcess;
- QSignalSpy spy(process, SIGNAL(stateChanged(QProcess::ProcessState)));
+ QSignalSpy spy(process, &QProcess::stateChanged);
QVERIFY(spy.isValid());
connect(process, SIGNAL(readyRead()), this, SLOT(readFromProcess()));
@@ -351,7 +351,7 @@ void tst_QProcess::crashTest()
{
qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState");
process = new QProcess;
- QSignalSpy stateSpy(process, SIGNAL(stateChanged(QProcess::ProcessState)));
+ QSignalSpy stateSpy(process, &QProcess::stateChanged);
QVERIFY(stateSpy.isValid());
process->start("testProcessCrash/testProcessCrash");
QVERIFY(process->waitForStarted(5000));
@@ -359,8 +359,8 @@ void tst_QProcess::crashTest()
qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
- QSignalSpy spy(process, SIGNAL(error(QProcess::ProcessError)));
- QSignalSpy spy2(process, SIGNAL(finished(int,QProcess::ExitStatus)));
+ QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
+ QSignalSpy spy2(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
QVERIFY(spy.isValid());
QVERIFY(spy2.isValid());
@@ -394,8 +394,8 @@ void tst_QProcess::crashTest2()
qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
- QSignalSpy spy(process, SIGNAL(error(QProcess::ProcessError)));
- QSignalSpy spy2(process, SIGNAL(finished(int,QProcess::ExitStatus)));
+ QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
+ QSignalSpy spy2(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
QVERIFY(spy.isValid());
QVERIFY(spy2.isValid());
@@ -503,8 +503,8 @@ void tst_QProcess::echoTest2()
QCOMPARE(process->error(), QProcess::Timedout);
process->write("Hello");
- QSignalSpy spy1(process, SIGNAL(readyReadStandardOutput()));
- QSignalSpy spy2(process, SIGNAL(readyReadStandardError()));
+ QSignalSpy spy1(process, &QProcess::readyReadStandardOutput);
+ QSignalSpy spy2(process, &QProcess::readyReadStandardError);
QVERIFY(spy1.isValid());
QVERIFY(spy2.isValid());
@@ -685,7 +685,7 @@ void tst_QProcess::readTimeoutAndThenCrash()
QCOMPARE(process->error(), QProcess::Timedout);
qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
- QSignalSpy spy(process, SIGNAL(error(QProcess::ProcessError)));
+ QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
QVERIFY(spy.isValid());
process->kill();
@@ -887,7 +887,7 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives()
QProcess proc;
connect(&proc, SIGNAL(readyRead()), this, SLOT(exitLoopSlot()));
- QSignalSpy spy(&proc, SIGNAL(readyRead()));
+ QSignalSpy spy(&proc, &QProcess::readyRead);
QVERIFY(spy.isValid());
proc.start("testProcessEcho/testProcessEcho");
@@ -1283,7 +1283,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot()
process->start("testProcessEcho/testProcessEcho");
QVERIFY(process->waitForStarted(5000));
- QSignalSpy spy(process, SIGNAL(readyRead()));
+ QSignalSpy spy(process, &QProcess::readyRead);
QVERIFY(spy.isValid());
process->write("foo");
QTestEventLoop::instance().enterLoop(30);
@@ -1323,7 +1323,7 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
process->start("testProcessEcho/testProcessEcho");
QVERIFY(process->waitForStarted(5000));
- QSignalSpy spy(process, SIGNAL(bytesWritten(qint64)));
+ QSignalSpy spy(process, &QProcess::bytesWritten);
QVERIFY(spy.isValid());
process->write("f");
QTestEventLoop::instance().enterLoop(30);
@@ -1538,10 +1538,10 @@ void tst_QProcess::failToStart()
qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState");
QProcess process;
- QSignalSpy stateSpy(&process, SIGNAL(stateChanged(QProcess::ProcessState)));
- QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError)));
- QSignalSpy finishedSpy(&process, SIGNAL(finished(int)));
- QSignalSpy finishedSpy2(&process, SIGNAL(finished(int,QProcess::ExitStatus)));
+ QSignalSpy stateSpy(&process, &QProcess::stateChanged);
+ QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
+ QSignalSpy finishedSpy(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished));
+ QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
QVERIFY(stateSpy.isValid());
QVERIFY(errorSpy.isValid());
@@ -1605,9 +1605,9 @@ void tst_QProcess::failToStartWithWait()
QProcess process;
QEventLoop loop;
- QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError)));
- QSignalSpy finishedSpy(&process, SIGNAL(finished(int)));
- QSignalSpy finishedSpy2(&process, SIGNAL(finished(int,QProcess::ExitStatus)));
+ QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
+ QSignalSpy finishedSpy(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished));
+ QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
QVERIFY(errorSpy.isValid());
QVERIFY(finishedSpy.isValid());
@@ -1632,9 +1632,9 @@ void tst_QProcess::failToStartWithEventLoop()
QProcess process;
QEventLoop loop;
- QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError)));
- QSignalSpy finishedSpy(&process, SIGNAL(finished(int)));
- QSignalSpy finishedSpy2(&process, SIGNAL(finished(int,QProcess::ExitStatus)));
+ QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
+ QSignalSpy finishedSpy(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished));
+ QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
QVERIFY(errorSpy.isValid());
QVERIFY(finishedSpy.isValid());
@@ -1864,9 +1864,9 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess()
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
QProcess process;
- QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError)));
- QSignalSpy finishedSpy1(&process, SIGNAL(finished(int)));
- QSignalSpy finishedSpy2(&process, SIGNAL(finished(int,QProcess::ExitStatus)));
+ QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
+ QSignalSpy finishedSpy1(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished));
+ QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
QVERIFY(errorSpy.isValid());
QVERIFY(finishedSpy1.isValid());
@@ -2202,7 +2202,7 @@ void tst_QProcess::invalidProgramString()
QProcess process;
qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError");
- QSignalSpy spy(&process, SIGNAL(error(QProcess::ProcessError)));
+ QSignalSpy spy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error));
QVERIFY(spy.isValid());
process.start(programString);
@@ -2218,8 +2218,8 @@ void tst_QProcess::onlyOneStartedSignal()
qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus");
QProcess process;
- QSignalSpy spyStarted(&process, SIGNAL(started()));
- QSignalSpy spyFinished(&process, SIGNAL(finished(int,QProcess::ExitStatus)));
+ QSignalSpy spyStarted(&process, &QProcess::started);
+ QSignalSpy spyFinished(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished));
QVERIFY(spyStarted.isValid());
QVERIFY(spyFinished.isValid());
diff --git a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
index 87bcfe572d..08b943ba72 100644
--- a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
+++ b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp
@@ -93,6 +93,8 @@ private slots:
void transactionalWriteNoPermissionsOnFile();
void transactionalWriteCanceled();
void transactionalWriteErrorRenaming();
+ void symlink();
+ void directory();
};
static inline QByteArray msgCannotOpen(const QFileDevice &f)
@@ -340,5 +342,142 @@ void tst_QSaveFile::transactionalWriteErrorRenaming()
QCOMPARE(file.error(), QFile::RenameError);
}
+void tst_QSaveFile::symlink()
+{
+#ifdef Q_OS_UNIX
+ QByteArray someData = "some data";
+ QTemporaryDir dir;
+ QVERIFY(dir.isValid());
+
+ const QString targetFile = dir.path() + QLatin1String("/outfile");
+ const QString linkFile = dir.path() + QLatin1String("/linkfile");
+ {
+ QFile file(targetFile);
+ QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData());
+ QCOMPARE(file.write("Hello"), Q_INT64_C(5));
+ file.close();
+ }
+
+ QVERIFY(QFile::link(targetFile, linkFile));
+
+ QString canonical = QFileInfo(linkFile).canonicalFilePath();
+ QCOMPARE(canonical, QFileInfo(targetFile).canonicalFilePath());
+
+ // Try saving into it
+ {
+ QSaveFile saveFile(linkFile);
+ QVERIFY(saveFile.open(QIODevice::WriteOnly));
+ QCOMPARE(saveFile.write(someData), someData.size());
+ saveFile.commit();
+
+ //Check that the linkFile is still a link and still has the same canonical path
+ QFileInfo info(linkFile);
+ QVERIFY(info.isSymLink());
+ QCOMPARE(QFileInfo(linkFile).canonicalFilePath(), canonical);
+
+ QFile file(targetFile);
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData());
+ QCOMPARE(file.readAll(), someData);
+ file.remove();
+ }
+
+ // Save into a symbolic link that point to a removed file
+ someData = "more stuff";
+ {
+ QSaveFile saveFile(linkFile);
+ QVERIFY(saveFile.open(QIODevice::WriteOnly));
+ QCOMPARE(saveFile.write(someData), someData.size());
+ saveFile.commit();
+
+ QFileInfo info(linkFile);
+ QVERIFY(info.isSymLink());
+ QCOMPARE(QFileInfo(linkFile).canonicalFilePath(), canonical);
+
+ QFile file(targetFile);
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData());
+ QCOMPARE(file.readAll(), someData);
+ }
+
+ // link to a link in another directory
+ QTemporaryDir dir2;
+ QVERIFY(dir2.isValid());
+
+ const QString linkFile2 = dir2.path() + QLatin1String("/linkfile");
+ QVERIFY(QFile::link(linkFile, linkFile2));
+ QCOMPARE(QFileInfo(linkFile2).canonicalFilePath(), canonical);
+
+
+ someData = "hello everyone";
+
+ {
+ QSaveFile saveFile(linkFile2);
+ QVERIFY(saveFile.open(QIODevice::WriteOnly));
+ QCOMPARE(saveFile.write(someData), someData.size());
+ saveFile.commit();
+
+ QFile file(targetFile);
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData());
+ QCOMPARE(file.readAll(), someData);
+ }
+
+ //cyclic link
+ const QString cyclicLink = dir.path() + QLatin1String("/cyclic");
+ QVERIFY(QFile::link(cyclicLink, cyclicLink));
+ {
+ QSaveFile saveFile(cyclicLink);
+ QVERIFY(saveFile.open(QIODevice::WriteOnly));
+ QCOMPARE(saveFile.write(someData), someData.size());
+ saveFile.commit();
+
+ QFile file(cyclicLink);
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData());
+ QCOMPARE(file.readAll(), someData);
+ }
+
+ //cyclic link2
+ QVERIFY(QFile::link(cyclicLink + QLatin1Char('1'), cyclicLink + QLatin1Char('2')));
+ QVERIFY(QFile::link(cyclicLink + QLatin1Char('2'), cyclicLink + QLatin1Char('1')));
+
+ {
+ QSaveFile saveFile(cyclicLink + QLatin1Char('1'));
+ QVERIFY(saveFile.open(QIODevice::WriteOnly));
+ QCOMPARE(saveFile.write(someData), someData.size());
+ saveFile.commit();
+
+ // the explicit file becomes a file instead of a link
+ QVERIFY(!QFileInfo(cyclicLink + QLatin1Char('1')).isSymLink());
+ QVERIFY(QFileInfo(cyclicLink + QLatin1Char('2')).isSymLink());
+
+ QFile file(cyclicLink + QLatin1Char('1'));
+ QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData());
+ QCOMPARE(file.readAll(), someData);
+ }
+#endif
+}
+
+void tst_QSaveFile::directory()
+{
+ QTemporaryDir dir;
+ QVERIFY(dir.isValid());
+
+ const QString subdir = dir.path() + QLatin1String("/subdir");
+ QVERIFY(QDir(dir.path()).mkdir(QStringLiteral("subdir")));
+ {
+ QFile sf(subdir);
+ QVERIFY(!sf.open(QIODevice::WriteOnly));
+ }
+
+#ifdef Q_OS_UNIX
+ //link to a directory
+ const QString linkToDir = dir.path() + QLatin1String("/linkToDir");
+ QVERIFY(QFile::link(subdir, linkToDir));
+
+ {
+ QFile sf(linkToDir);
+ QVERIFY(!sf.open(QIODevice::WriteOnly));
+ }
+#endif
+}
+
QTEST_MAIN(tst_QSaveFile)
#include "tst_qsavefile.moc"
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index 7247b02498..c373e80408 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -56,7 +56,7 @@
#define Q_XDG_PLATFORM
#endif
-static const int MaxStandardLocation = QStandardPaths::GenericConfigLocation;
+static const int MaxStandardLocation = QStandardPaths::AppDataLocation;
class tst_qstandardpaths : public QObject
{
@@ -129,7 +129,8 @@ static const char * const enumNames[MaxStandardLocation + 1 - int(QStandardPaths
"ConfigLocation",
"DownloadLocation",
"GenericCacheLocation",
- "GenericConfigLocation"
+ "GenericConfigLocation",
+ "AppDataLocation"
};
void tst_qstandardpaths::dump()
@@ -238,7 +239,8 @@ void tst_qstandardpaths::enableTestMode()
// Check this for locations where test programs typically write. Not desktop, download, music etc...
typedef QHash<QStandardPaths::StandardLocation, QString> LocationHash;
LocationHash testLocations;
- testLocations.insert(QStandardPaths::DataLocation, QStandardPaths::writableLocation(QStandardPaths::DataLocation));
+ testLocations.insert(QStandardPaths::AppDataLocation, QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
+ testLocations.insert(QStandardPaths::AppLocalDataLocation, QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation));
testLocations.insert(QStandardPaths::GenericDataLocation, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation));
testLocations.insert(QStandardPaths::ConfigLocation, QStandardPaths::writableLocation(QStandardPaths::ConfigLocation));
testLocations.insert(QStandardPaths::GenericConfigLocation, QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation));
@@ -294,18 +296,18 @@ void tst_qstandardpaths::testDataLocation()
// applications are sandboxed.
#if !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_ANDROID) && !defined(Q_OS_WINRT)
const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation);
- QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/tst_qstandardpaths");
+ QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), base + "/tst_qstandardpaths");
QCoreApplication::instance()->setOrganizationName("Qt");
- QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/Qt/tst_qstandardpaths");
+ QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), base + "/Qt/tst_qstandardpaths");
QCoreApplication::instance()->setApplicationName("QtTest");
- QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/Qt/QtTest");
+ QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), base + "/Qt/QtTest");
#endif
#ifdef Q_XDG_PLATFORM
setDefaultLocations();
const QString expectedAppDataDir = QDir::homePath() + QString::fromLatin1("/.local/share/Qt/QtTest");
- QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), expectedAppDataDir);
- const QStringList appDataDirs = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
+ QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), expectedAppDataDir);
+ const QStringList appDataDirs = QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation);
QCOMPARE(appDataDirs.count(), 3);
QCOMPARE(appDataDirs.at(0), expectedAppDataDir);
QCOMPARE(appDataDirs.at(1), QString::fromLatin1("/usr/local/share/Qt/QtTest"));
@@ -463,7 +465,7 @@ void tst_qstandardpaths::testAllWritableLocations_data()
QTest::newRow("PicturesLocation") << QStandardPaths::PicturesLocation;
QTest::newRow("TempLocation") << QStandardPaths::TempLocation;
QTest::newRow("HomeLocation") << QStandardPaths::HomeLocation;
- QTest::newRow("DataLocation") << QStandardPaths::DataLocation;
+ QTest::newRow("AppLocalDataLocation") << QStandardPaths::AppLocalDataLocation;
QTest::newRow("DownloadLocation") << QStandardPaths::DownloadLocation;
}
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index 92dbb96817..df090c3de9 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -165,6 +165,8 @@ private slots:
void binaryData();
void fromUserInput_data();
void fromUserInput();
+ void fromUserInputWithCwd_data();
+ void fromUserInputWithCwd();
void fileName_data();
void fileName();
void isEmptyForEncodedUrl();
@@ -2913,6 +2915,52 @@ void tst_QUrl::fromUserInput()
QCOMPARE(url, guessUrlFromString);
}
+void tst_QUrl::fromUserInputWithCwd_data()
+{
+ QTest::addColumn<QString>("string");
+ QTest::addColumn<QString>("directory");
+ QTest::addColumn<QUrl>("guessedUrlDefault");
+ QTest::addColumn<QUrl>("guessedUrlAssumeLocalFile");
+
+ // Null
+ QTest::newRow("null") << QString() << QString() << QUrl() << QUrl();
+
+ // Existing file
+ QDirIterator it(QDir::currentPath(), QDir::NoDotDot | QDir::AllEntries);
+ int c = 0;
+ while (it.hasNext()) {
+ it.next();
+ QUrl url = QUrl::fromLocalFile(it.filePath());
+ QTest::newRow(QString("file-%1").arg(c++).toLatin1()) << it.fileName() << QDir::currentPath() << url << url;
+ }
+ QDir parent = QDir::current();
+ QVERIFY(parent.cdUp());
+ QUrl parentUrl = QUrl::fromLocalFile(parent.path());
+ QTest::newRow("dotdot") << ".." << QDir::currentPath() << parentUrl << parentUrl;
+
+ 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");
+ QTest::newRow("full-url") << "http://example.org" << QDir::currentPath() << QUrl("http://example.org") << QUrl("http://example.org");
+ QTest::newRow("absolute") << "/doesnotexist.txt" << QDir::currentPath() << QUrl("file:///doesnotexist.txt") << QUrl("file:///doesnotexist.txt");
+#ifdef Q_OS_WIN
+ QTest::newRow("windows-absolute") << "c:/doesnotexist.txt" << QDir::currentPath() << QUrl("file:///c:/doesnotexist.txt") << QUrl("file:///c:/doesnotexist.txt");
+#endif
+}
+
+void tst_QUrl::fromUserInputWithCwd()
+{
+ QFETCH(QString, string);
+ QFETCH(QString, directory);
+ QFETCH(QUrl, guessedUrlDefault);
+ QFETCH(QUrl, guessedUrlAssumeLocalFile);
+
+ QUrl url = QUrl::fromUserInput(string, directory);
+ QCOMPARE(url, guessedUrlDefault);
+
+ url = QUrl::fromUserInput(string, directory, QUrl::AssumeLocalFile);
+ QCOMPARE(url, guessedUrlAssumeLocalFile);
+}
+
void tst_QUrl::fileName_data()
{
QTest::addColumn<QString>("urlStr");
diff --git a/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp b/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp
index 8321f76bec..16f94e7c5d 100644
--- a/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp
+++ b/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp
@@ -58,6 +58,7 @@ private slots:
void readFile();
void waitForNotified_data();
void waitForNotified();
+ void waitForAnyNotified();
void brokenPipe();
void multipleOperations();
@@ -195,6 +196,45 @@ void tst_QWinOverlappedIoNotifier::waitForNotified()
QCOMPARE(notifier.waitForNotified(100, &overlapped), false);
}
+void tst_QWinOverlappedIoNotifier::waitForAnyNotified()
+{
+ const QString fileName = QDir::toNativeSeparators(sourceFileInfo.absoluteFilePath());
+ const int readBufferSize = sourceFileInfo.size();
+
+ QWinOverlappedIoNotifier notifier;
+ HANDLE hFile = CreateFile(reinterpret_cast<const wchar_t*>(fileName.utf16()),
+ GENERIC_READ, FILE_SHARE_READ,
+ NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
+ notifier.setHandle(hFile);
+ notifier.setEnabled(true);
+ QVERIFY(notifier.waitForAnyNotified(100) == 0);
+
+ OVERLAPPED overlapped1;
+ ZeroMemory(&overlapped1, sizeof(OVERLAPPED));
+ QByteArray buffer1(readBufferSize, 0);
+ BOOL readSuccess = ReadFile(hFile, buffer1.data(), buffer1.size(), NULL, &overlapped1);
+ QVERIFY(readSuccess || GetLastError() == ERROR_IO_PENDING);
+
+ OVERLAPPED overlapped2;
+ ZeroMemory(&overlapped2, sizeof(OVERLAPPED));
+ QByteArray buffer2(readBufferSize, 0);
+ readSuccess = ReadFile(hFile, buffer2.data(), buffer2.size(), NULL, &overlapped2);
+ QVERIFY(readSuccess || GetLastError() == ERROR_IO_PENDING);
+
+ QSet<OVERLAPPED *> overlappedObjects;
+ overlappedObjects << &overlapped1 << &overlapped2;
+
+ for (int i = 1; i <= 2; ++i) {
+ OVERLAPPED *notifiedOverlapped = notifier.waitForAnyNotified(3000);
+ QVERIFY(overlappedObjects.contains(notifiedOverlapped));
+ overlappedObjects.remove(notifiedOverlapped);
+ }
+
+ CloseHandle(hFile);
+ QVERIFY(overlappedObjects.isEmpty());
+ QVERIFY(notifier.waitForAnyNotified(100) == 0);
+}
+
void tst_QWinOverlappedIoNotifier::brokenPipe()
{
QWinOverlappedIoNotifier notifier;