Tests: check the output of QFile::open
Wrap the call in QVERIFY. tst_QTextStream::read0d0d0a was also faulty as it *never* opened the file because of a broken path. Fix it with QFINDTESTDATA. Change-Id: I61a8f83beddf098d37fda13cb3bfb4aaa4913fc5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
cccda0e62d
commit
8414a0aa2c
@ -520,7 +520,7 @@ void tst_QDir::makedirReturnCode()
|
|||||||
// Remove the directory and create a file with the same path
|
// Remove the directory and create a file with the same path
|
||||||
QDir::current().rmdir(dirName);
|
QDir::current().rmdir(dirName);
|
||||||
QVERIFY(!f.exists());
|
QVERIFY(!f.exists());
|
||||||
f.open(QIODevice::WriteOnly);
|
QVERIFY(f.open(QIODevice::WriteOnly));
|
||||||
f.write("test");
|
f.write("test");
|
||||||
f.close();
|
f.close();
|
||||||
QVERIFY2(f.exists(), msgDoesNotExist(f.fileName()).constData());
|
QVERIFY2(f.exists(), msgDoesNotExist(f.fileName()).constData());
|
||||||
@ -614,7 +614,7 @@ void tst_QDir::removeRecursivelySymlink()
|
|||||||
QDir().mkpath(tmpdir);
|
QDir().mkpath(tmpdir);
|
||||||
QDir currentDir;
|
QDir currentDir;
|
||||||
currentDir.mkdir("myDir");
|
currentDir.mkdir("myDir");
|
||||||
QFile("testfile").open(QIODevice::WriteOnly);
|
QVERIFY(QFile("testfile").open(QIODevice::WriteOnly));
|
||||||
const QString link = tmpdir + "linkToDir.lnk";
|
const QString link = tmpdir + "linkToDir.lnk";
|
||||||
const QString linkToFile = tmpdir + "linkToFile.lnk";
|
const QString linkToFile = tmpdir + "linkToFile.lnk";
|
||||||
#ifndef Q_NO_SYMLINKS_TO_DIRS
|
#ifndef Q_NO_SYMLINKS_TO_DIRS
|
||||||
@ -1081,7 +1081,7 @@ void tst_QDir::entryListWithSymLinks()
|
|||||||
QFile::remove("testfile.cpp");
|
QFile::remove("testfile.cpp");
|
||||||
QDir dir;
|
QDir dir;
|
||||||
dir.mkdir("myDir");
|
dir.mkdir("myDir");
|
||||||
QFile("testfile.cpp").open(QIODevice::WriteOnly);
|
QVERIFY(QFile("testfile.cpp").open(QIODevice::WriteOnly));
|
||||||
# ifndef Q_NO_SYMLINKS_TO_DIRS
|
# ifndef Q_NO_SYMLINKS_TO_DIRS
|
||||||
QVERIFY(QFile::link("myDir", "myLinkToDir.lnk"));
|
QVERIFY(QFile::link("myDir", "myLinkToDir.lnk"));
|
||||||
# endif
|
# endif
|
||||||
@ -1623,7 +1623,7 @@ void tst_QDir::filePath()
|
|||||||
void tst_QDir::remove()
|
void tst_QDir::remove()
|
||||||
{
|
{
|
||||||
QFile f("remove-test");
|
QFile f("remove-test");
|
||||||
f.open(QIODevice::WriteOnly);
|
QVERIFY(f.open(QIODevice::WriteOnly));
|
||||||
f.close();
|
f.close();
|
||||||
QDir dir;
|
QDir dir;
|
||||||
QVERIFY(dir.remove("remove-test"));
|
QVERIFY(dir.remove("remove-test"));
|
||||||
@ -1636,7 +1636,7 @@ void tst_QDir::remove()
|
|||||||
void tst_QDir::rename()
|
void tst_QDir::rename()
|
||||||
{
|
{
|
||||||
QFile f("rename-test");
|
QFile f("rename-test");
|
||||||
f.open(QIODevice::WriteOnly);
|
QVERIFY(f.open(QIODevice::WriteOnly));
|
||||||
f.close();
|
f.close();
|
||||||
QDir dir;
|
QDir dir;
|
||||||
QVERIFY(dir.rename("rename-test", "rename-test-renamed"));
|
QVERIFY(dir.rename("rename-test", "rename-test-renamed"));
|
||||||
|
@ -1117,7 +1117,7 @@ void tst_QFile::missingEndOfLine()
|
|||||||
void tst_QFile::readBlock()
|
void tst_QFile::readBlock()
|
||||||
{
|
{
|
||||||
QFile f( m_testFile );
|
QFile f( m_testFile );
|
||||||
f.open( QIODevice::ReadOnly );
|
QVERIFY( f.open( QIODevice::ReadOnly ) );
|
||||||
|
|
||||||
int length = 0;
|
int length = 0;
|
||||||
char p[256];
|
char p[256];
|
||||||
@ -1132,7 +1132,7 @@ void tst_QFile::readBlock()
|
|||||||
void tst_QFile::getch()
|
void tst_QFile::getch()
|
||||||
{
|
{
|
||||||
QFile f( m_testFile );
|
QFile f( m_testFile );
|
||||||
f.open( QIODevice::ReadOnly );
|
QVERIFY( f.open( QIODevice::ReadOnly ) );
|
||||||
|
|
||||||
char c;
|
char c;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@ -1670,7 +1670,7 @@ void tst_QFile::absolutePathLinkToRelativePath()
|
|||||||
QFile::remove("myDir/myLink.lnk");
|
QFile::remove("myDir/myLink.lnk");
|
||||||
QDir dir;
|
QDir dir;
|
||||||
dir.mkdir("myDir");
|
dir.mkdir("myDir");
|
||||||
QFile("myDir/test.txt").open(QFile::WriteOnly);
|
QVERIFY(QFile("myDir/test.txt").open(QFile::WriteOnly));
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QVERIFY(QFile::link("test.txt", "myDir/myLink.lnk"));
|
QVERIFY(QFile::link("test.txt", "myDir/myLink.lnk"));
|
||||||
@ -1774,7 +1774,7 @@ void tst_QFile::writeTextFile()
|
|||||||
QCOMPARE(file.write(in), qlonglong(in.size()));
|
QCOMPARE(file.write(in), qlonglong(in.size()));
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
file.open(QFile::ReadOnly);
|
QVERIFY(file.open(QFile::ReadOnly));
|
||||||
QCOMPARE(file.readAll(), out);
|
QCOMPARE(file.readAll(), out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2399,7 +2399,7 @@ void tst_QFile::useQFileInAFileHandler()
|
|||||||
void tst_QFile::getCharFF()
|
void tst_QFile::getCharFF()
|
||||||
{
|
{
|
||||||
QFile file("file.txt");
|
QFile file("file.txt");
|
||||||
file.open(QFile::ReadWrite);
|
QVERIFY(file.open(QFile::ReadWrite));
|
||||||
file.write("\xff\xff\xff");
|
file.write("\xff\xff\xff");
|
||||||
file.flush();
|
file.flush();
|
||||||
file.seek(0);
|
file.seek(0);
|
||||||
@ -2502,7 +2502,7 @@ void tst_QFile::fullDisk()
|
|||||||
QVERIFY(!file.isOpen());
|
QVERIFY(!file.isOpen());
|
||||||
QCOMPARE(file.error(), QFile::ResourceError);
|
QCOMPARE(file.error(), QFile::ResourceError);
|
||||||
|
|
||||||
file.open(QIODevice::WriteOnly);
|
QVERIFY2(file.open(QIODevice::WriteOnly), msgOpenFailed(file).constData());
|
||||||
QCOMPARE(file.error(), QFile::NoError);
|
QCOMPARE(file.error(), QFile::NoError);
|
||||||
QVERIFY(file.flush()); // Shouldn't inherit write buffer
|
QVERIFY(file.flush()); // Shouldn't inherit write buffer
|
||||||
file.close();
|
file.close();
|
||||||
@ -3114,7 +3114,7 @@ void tst_QFile::handle()
|
|||||||
QFile file2;
|
QFile file2;
|
||||||
StdioFileGuard fp(fopen(qPrintable(m_testSourceFile), "r"));
|
StdioFileGuard fp(fopen(qPrintable(m_testSourceFile), "r"));
|
||||||
QVERIFY(fp);
|
QVERIFY(fp);
|
||||||
file2.open(fp, QIODevice::ReadOnly);
|
QVERIFY(file2.open(fp, QIODevice::ReadOnly));
|
||||||
QCOMPARE(int(file2.handle()), int(QT_FILENO(fp)));
|
QCOMPARE(int(file2.handle()), int(QT_FILENO(fp)));
|
||||||
QCOMPARE(int(file2.handle()), int(QT_FILENO(fp)));
|
QCOMPARE(int(file2.handle()), int(QT_FILENO(fp)));
|
||||||
fp.close();
|
fp.close();
|
||||||
@ -3123,7 +3123,7 @@ void tst_QFile::handle()
|
|||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
QFile file3;
|
QFile file3;
|
||||||
fd = QT_OPEN(qPrintable(m_testSourceFile), QT_OPEN_RDONLY);
|
fd = QT_OPEN(qPrintable(m_testSourceFile), QT_OPEN_RDONLY);
|
||||||
file3.open(fd, QIODevice::ReadOnly);
|
QVERIFY(file3.open(fd, QIODevice::ReadOnly));
|
||||||
QCOMPARE(int(file3.handle()), fd);
|
QCOMPARE(int(file3.handle()), fd);
|
||||||
QT_CLOSE(fd);
|
QT_CLOSE(fd);
|
||||||
#endif
|
#endif
|
||||||
@ -3514,7 +3514,7 @@ void tst_QFile::mapOpenMode()
|
|||||||
*memory = 'a';
|
*memory = 'a';
|
||||||
file.unmap(memory);
|
file.unmap(memory);
|
||||||
file.close();
|
file.close();
|
||||||
file.open(QIODevice::OpenMode(openMode));
|
QVERIFY(file.open(QIODevice::OpenMode(openMode)));
|
||||||
file.seek(0);
|
file.seek(0);
|
||||||
char c;
|
char c;
|
||||||
QVERIFY(file.getChar(&c));
|
QVERIFY(file.getChar(&c));
|
||||||
@ -3661,7 +3661,7 @@ void tst_QFile::openStandardStreamsFileDescriptors()
|
|||||||
|
|
||||||
{
|
{
|
||||||
QFile in;
|
QFile in;
|
||||||
in.open(STDIN_FILENO, QIODevice::ReadOnly);
|
QVERIFY(in.open(STDIN_FILENO, QIODevice::ReadOnly));
|
||||||
QCOMPARE( in.pos(), streamCurrentPosition(STDIN_FILENO) );
|
QCOMPARE( in.pos(), streamCurrentPosition(STDIN_FILENO) );
|
||||||
QCOMPARE( in.size(), streamExpectedSize(STDIN_FILENO) );
|
QCOMPARE( in.size(), streamExpectedSize(STDIN_FILENO) );
|
||||||
}
|
}
|
||||||
@ -3675,7 +3675,7 @@ void tst_QFile::openStandardStreamsFileDescriptors()
|
|||||||
|
|
||||||
{
|
{
|
||||||
QFile err;
|
QFile err;
|
||||||
err.open(STDERR_FILENO, QIODevice::WriteOnly);
|
QVERIFY(err.open(STDERR_FILENO, QIODevice::WriteOnly));
|
||||||
QCOMPARE( err.pos(), streamCurrentPosition(STDERR_FILENO) );
|
QCOMPARE( err.pos(), streamCurrentPosition(STDERR_FILENO) );
|
||||||
QCOMPARE( err.size(), streamExpectedSize(STDERR_FILENO) );
|
QCOMPARE( err.size(), streamExpectedSize(STDERR_FILENO) );
|
||||||
}
|
}
|
||||||
@ -3691,21 +3691,21 @@ void tst_QFile::openStandardStreamsBufferedStreams()
|
|||||||
// Using streams
|
// Using streams
|
||||||
{
|
{
|
||||||
QFile in;
|
QFile in;
|
||||||
in.open(stdin, QIODevice::ReadOnly);
|
QVERIFY(in.open(stdin, QIODevice::ReadOnly));
|
||||||
QCOMPARE( in.pos(), streamCurrentPosition(stdin) );
|
QCOMPARE( in.pos(), streamCurrentPosition(stdin) );
|
||||||
QCOMPARE( in.size(), streamExpectedSize(QT_FILENO(stdin)) );
|
QCOMPARE( in.size(), streamExpectedSize(QT_FILENO(stdin)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
QFile out;
|
QFile out;
|
||||||
out.open(stdout, QIODevice::WriteOnly);
|
QVERIFY(out.open(stdout, QIODevice::WriteOnly));
|
||||||
QCOMPARE( out.pos(), streamCurrentPosition(stdout) );
|
QCOMPARE( out.pos(), streamCurrentPosition(stdout) );
|
||||||
QCOMPARE( out.size(), streamExpectedSize(QT_FILENO(stdout)) );
|
QCOMPARE( out.size(), streamExpectedSize(QT_FILENO(stdout)) );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
QFile err;
|
QFile err;
|
||||||
err.open(stderr, QIODevice::WriteOnly);
|
QVERIFY(err.open(stderr, QIODevice::WriteOnly));
|
||||||
QCOMPARE( err.pos(), streamCurrentPosition(stderr) );
|
QCOMPARE( err.pos(), streamCurrentPosition(stderr) );
|
||||||
QCOMPARE( err.size(), streamExpectedSize(QT_FILENO(stderr)) );
|
QCOMPARE( err.size(), streamExpectedSize(QT_FILENO(stderr)) );
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ void tst_QFileInfo::isDir_data()
|
|||||||
QFile::remove("brokenlink.lnk");
|
QFile::remove("brokenlink.lnk");
|
||||||
QFile::remove("dummyfile");
|
QFile::remove("dummyfile");
|
||||||
QFile file3("dummyfile");
|
QFile file3("dummyfile");
|
||||||
file3.open(QIODevice::WriteOnly);
|
QVERIFY(file3.open(QIODevice::WriteOnly));
|
||||||
if (file3.link("brokenlink.lnk")) {
|
if (file3.link("brokenlink.lnk")) {
|
||||||
file3.remove();
|
file3.remove();
|
||||||
QFileInfo info3("brokenlink.lnk");
|
QFileInfo info3("brokenlink.lnk");
|
||||||
@ -658,7 +658,7 @@ void tst_QFileInfo::canonicalFilePath()
|
|||||||
QFile file(QDir::currentPath());
|
QFile file(QDir::currentPath());
|
||||||
if (file.link(link)) {
|
if (file.link(link)) {
|
||||||
QFile tempfile("tempfile.txt");
|
QFile tempfile("tempfile.txt");
|
||||||
tempfile.open(QIODevice::ReadWrite);
|
QVERIFY(tempfile.open(QIODevice::ReadWrite));
|
||||||
tempfile.write("This file is generated by the QFileInfo autotest.");
|
tempfile.write("This file is generated by the QFileInfo autotest.");
|
||||||
QVERIFY(tempfile.flush());
|
QVERIFY(tempfile.flush());
|
||||||
tempfile.close();
|
tempfile.close();
|
||||||
@ -1240,7 +1240,7 @@ void tst_QFileInfo::fakeFileTimes()
|
|||||||
QFETCH(QDateTime, when);
|
QFETCH(QDateTime, when);
|
||||||
|
|
||||||
QFile file("faketimefile.txt");
|
QFile file("faketimefile.txt");
|
||||||
file.open(QIODevice::WriteOnly);
|
QVERIFY(file.open(QIODevice::WriteOnly));
|
||||||
file.write("\n", 1);
|
file.write("\n", 1);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
@ -1249,7 +1249,7 @@ void tst_QFileInfo::fakeFileTimes()
|
|||||||
the file is open at the time. Of course, when writing, close() changes
|
the file is open at the time. Of course, when writing, close() changes
|
||||||
modification time, so need to re-open for read in order to setFileTime().
|
modification time, so need to re-open for read in order to setFileTime().
|
||||||
*/
|
*/
|
||||||
file.open(QIODevice::ReadOnly);
|
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||||
bool ok = file.setFileTime(when, QFileDevice::FileModificationTime);
|
bool ok = file.setFileTime(when, QFileDevice::FileModificationTime);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
@ -1271,7 +1271,7 @@ void tst_QFileInfo::isSymLink_data()
|
|||||||
QVERIFY(file1.link("link.lnk"));
|
QVERIFY(file1.link("link.lnk"));
|
||||||
|
|
||||||
QFile file2("dummyfile");
|
QFile file2("dummyfile");
|
||||||
file2.open(QIODevice::WriteOnly);
|
QVERIFY(file2.open(QIODevice::WriteOnly));
|
||||||
QVERIFY(file2.link("brokenlink.lnk"));
|
QVERIFY(file2.link("brokenlink.lnk"));
|
||||||
file2.remove();
|
file2.remove();
|
||||||
|
|
||||||
@ -1457,7 +1457,7 @@ void tst_QFileInfo::link_data()
|
|||||||
|
|
||||||
QFile file1(m_sourceFile);
|
QFile file1(m_sourceFile);
|
||||||
QFile file2("dummyfile");
|
QFile file2("dummyfile");
|
||||||
file2.open(QIODevice::WriteOnly);
|
QVERIFY(file2.open(QIODevice::WriteOnly));
|
||||||
|
|
||||||
QTest::newRow("existent file") << m_sourceFile << false << false << "";
|
QTest::newRow("existent file") << m_sourceFile << false << false << "";
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
@ -1894,7 +1894,7 @@ void tst_QFileInfo::brokenShortcut()
|
|||||||
void tst_QFileInfo::isWritable()
|
void tst_QFileInfo::isWritable()
|
||||||
{
|
{
|
||||||
QFile tempfile("tempfile.txt");
|
QFile tempfile("tempfile.txt");
|
||||||
tempfile.open(QIODevice::WriteOnly);
|
QVERIFY(tempfile.open(QIODevice::WriteOnly));
|
||||||
tempfile.write("This file is generated by the QFileInfo autotest.");
|
tempfile.write("This file is generated by the QFileInfo autotest.");
|
||||||
tempfile.close();
|
tempfile.close();
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ void tst_QFileSystemWatcher::basicTest()
|
|||||||
if (isPollerBackend || isQNX)
|
if (isPollerBackend || isQNX)
|
||||||
QTest::qWait(pollingEngineTimeout);
|
QTest::qWait(pollingEngineTimeout);
|
||||||
|
|
||||||
testFile.open(QIODevice::WriteOnly | QIODevice::Append);
|
QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Append));
|
||||||
testFile.write(QByteArray("world"));
|
testFile.write(QByteArray("world"));
|
||||||
testFile.close();
|
testFile.close();
|
||||||
|
|
||||||
@ -172,7 +172,7 @@ void tst_QFileSystemWatcher::basicTest()
|
|||||||
|
|
||||||
// remove the watch and modify the file, should not get a signal from the watcher
|
// remove the watch and modify the file, should not get a signal from the watcher
|
||||||
QVERIFY(watcher.removePath(testFile.fileName()));
|
QVERIFY(watcher.removePath(testFile.fileName()));
|
||||||
testFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Truncate));
|
||||||
testFile.write(QByteArray("hello universe!"));
|
testFile.write(QByteArray("hello universe!"));
|
||||||
testFile.close();
|
testFile.close();
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ void tst_QFileSystemWatcher::basicTest()
|
|||||||
const QString relativeTestFileName = QDir::current().relativeFilePath(testFile.fileName());
|
const QString relativeTestFileName = QDir::current().relativeFilePath(testFile.fileName());
|
||||||
QVERIFY(!relativeTestFileName.isEmpty());
|
QVERIFY(!relativeTestFileName.isEmpty());
|
||||||
QVERIFY(watcher.addPath(relativeTestFileName));
|
QVERIFY(watcher.addPath(relativeTestFileName));
|
||||||
testFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
QVERIFY(testFile.open(QIODevice::WriteOnly | QIODevice::Truncate));
|
||||||
testFile.write(QByteArray("hello multiverse!"));
|
testFile.write(QByteArray("hello multiverse!"));
|
||||||
testFile.close();
|
testFile.close();
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ void tst_QIODevice::constructing_QFile()
|
|||||||
void tst_QIODevice::read_QByteArray()
|
void tst_QIODevice::read_QByteArray()
|
||||||
{
|
{
|
||||||
QFile f(QFINDTESTDATA("tst_qiodevice.cpp"));
|
QFile f(QFINDTESTDATA("tst_qiodevice.cpp"));
|
||||||
f.open(QIODevice::ReadOnly);
|
QVERIFY(f.open(QIODevice::ReadOnly));
|
||||||
|
|
||||||
QByteArray b = f.read(10);
|
QByteArray b = f.read(10);
|
||||||
QCOMPARE(b.size(), 10);
|
QCOMPARE(b.size(), 10);
|
||||||
|
@ -382,7 +382,7 @@ void tst_QResourceEngine::checkStructure_data()
|
|||||||
<< qlonglong(info.size());
|
<< qlonglong(info.size());
|
||||||
|
|
||||||
QFile file(QFINDTESTDATA("testqrc/aliasdir/compressme.txt"));
|
QFile file(QFINDTESTDATA("testqrc/aliasdir/compressme.txt"));
|
||||||
file.open(QFile::ReadOnly);
|
QVERIFY(file.open(QFile::ReadOnly));
|
||||||
info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/compressme.txt"));
|
info = QFileInfo(QFINDTESTDATA("testqrc/aliasdir/compressme.txt"));
|
||||||
QTest::addRow("%s compressed text", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt")
|
QTest::addRow("%s compressed text", qPrintable(root)) << QString(root + "aliasdir/aliasdir.txt")
|
||||||
<< file.readAll()
|
<< file.readAll()
|
||||||
|
@ -105,7 +105,7 @@ void tst_QSaveFile::transactionalWrite()
|
|||||||
const QString otherFile = dir.path() + QString::fromLatin1("/otherfile");
|
const QString otherFile = dir.path() + QString::fromLatin1("/otherfile");
|
||||||
QFile::remove(otherFile);
|
QFile::remove(otherFile);
|
||||||
QFile other(otherFile);
|
QFile other(otherFile);
|
||||||
other.open(QIODevice::WriteOnly);
|
QVERIFY(other.open(QIODevice::WriteOnly));
|
||||||
other.close();
|
other.close();
|
||||||
QCOMPARE(QFile::permissions(targetFile), QFile::permissions(otherFile));
|
QCOMPARE(QFile::permissions(targetFile), QFile::permissions(otherFile));
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ void tst_QTemporaryFile::fileName()
|
|||||||
QString absoluteTempPath = QDir(tempPath).absolutePath();
|
QString absoluteTempPath = QDir(tempPath).absolutePath();
|
||||||
QTemporaryFile file;
|
QTemporaryFile file;
|
||||||
file.setAutoRemove(true);
|
file.setAutoRemove(true);
|
||||||
file.open();
|
QVERIFY(file.open());
|
||||||
QString fileName = file.fileName();
|
QString fileName = file.fileName();
|
||||||
QVERIFY2(fileName.contains("/tst_qtemporaryfile."), qPrintable(fileName));
|
QVERIFY2(fileName.contains("/tst_qtemporaryfile."), qPrintable(fileName));
|
||||||
QVERIFY(QFile::exists(fileName));
|
QVERIFY(QFile::exists(fileName));
|
||||||
@ -426,7 +426,7 @@ void tst_QTemporaryFile::io()
|
|||||||
|
|
||||||
file.reset();
|
file.reset();
|
||||||
QFile compare(file.fileName());
|
QFile compare(file.fileName());
|
||||||
compare.open(QIODevice::ReadOnly);
|
QVERIFY(compare.open(QIODevice::ReadOnly));
|
||||||
QCOMPARE(compare.readAll() , data);
|
QCOMPARE(compare.readAll() , data);
|
||||||
QCOMPARE(compare.fileTime(QFile::FileModificationTime), mtime);
|
QCOMPARE(compare.fileTime(QFile::FileModificationTime), mtime);
|
||||||
}
|
}
|
||||||
@ -460,7 +460,7 @@ void tst_QTemporaryFile::removeAndReOpen()
|
|||||||
QString fileName;
|
QString fileName;
|
||||||
{
|
{
|
||||||
QTemporaryFile file;
|
QTemporaryFile file;
|
||||||
file.open();
|
QVERIFY(file.open());
|
||||||
fileName = file.fileName(); // materializes any unnamed file
|
fileName = file.fileName(); // materializes any unnamed file
|
||||||
QVERIFY(QFile::exists(fileName));
|
QVERIFY(QFile::exists(fileName));
|
||||||
|
|
||||||
@ -480,7 +480,7 @@ void tst_QTemporaryFile::removeAndReOpen()
|
|||||||
void tst_QTemporaryFile::removeUnnamed()
|
void tst_QTemporaryFile::removeUnnamed()
|
||||||
{
|
{
|
||||||
QTemporaryFile file;
|
QTemporaryFile file;
|
||||||
file.open();
|
QVERIFY(file.open());
|
||||||
|
|
||||||
// we did not call fileName(), so the file name may not have a name
|
// we did not call fileName(), so the file name may not have a name
|
||||||
QVERIFY(file.remove());
|
QVERIFY(file.remove());
|
||||||
@ -870,7 +870,7 @@ void tst_QTemporaryFile::createNativeFile()
|
|||||||
|
|
||||||
QFile f(filePath);
|
QFile f(filePath);
|
||||||
if (currentPos != -1) {
|
if (currentPos != -1) {
|
||||||
f.open(QIODevice::ReadOnly);
|
QVERIFY(f.open(QIODevice::ReadOnly));
|
||||||
f.seek(currentPos);
|
f.seek(currentPos);
|
||||||
}
|
}
|
||||||
QTemporaryFile *tempFile = QTemporaryFile::createNativeFile(f);
|
QTemporaryFile *tempFile = QTemporaryFile::createNativeFile(f);
|
||||||
@ -1015,7 +1015,7 @@ void tst_QTemporaryFile::guaranteeUnique()
|
|||||||
// First pass. See which filename QTemporaryFile will try first.
|
// First pass. See which filename QTemporaryFile will try first.
|
||||||
{
|
{
|
||||||
QTemporaryFile tmpFile("testFile1.XXXXXX");
|
QTemporaryFile tmpFile("testFile1.XXXXXX");
|
||||||
tmpFile.open();
|
QVERIFY(tmpFile.open());
|
||||||
takenFileName = tmpFile.fileName();
|
takenFileName = tmpFile.fileName();
|
||||||
QVERIFY(QFile::exists(takenFileName));
|
QVERIFY(QFile::exists(takenFileName));
|
||||||
}
|
}
|
||||||
|
@ -1220,7 +1220,7 @@ void tst_QMetaType::flagsBinaryCompatibility6_0_data()
|
|||||||
QTest::addColumn<quint32>("flags");
|
QTest::addColumn<quint32>("flags");
|
||||||
|
|
||||||
QFile file(QFINDTESTDATA("typeFlags.bin"));
|
QFile file(QFINDTESTDATA("typeFlags.bin"));
|
||||||
file.open(QIODevice::ReadOnly);
|
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||||
QList<quint32> buffer;
|
QList<quint32> buffer;
|
||||||
QDataStream ds(&file);
|
QDataStream ds(&file);
|
||||||
ds >> buffer;
|
ds >> buffer;
|
||||||
|
@ -95,7 +95,7 @@ void tst_QTranslator::load()
|
|||||||
|
|
||||||
{
|
{
|
||||||
QFile file(filepath);
|
QFile file(filepath);
|
||||||
file.open(QFile::ReadOnly);
|
QVERIFY(file.open(QFile::ReadOnly));
|
||||||
QByteArray data = file.readAll();
|
QByteArray data = file.readAll();
|
||||||
QTranslator tor;
|
QTranslator tor;
|
||||||
QVERIFY(tor.load((const uchar *)data.constData(), data.length()));
|
QVERIFY(tor.load((const uchar *)data.constData(), data.length()));
|
||||||
@ -329,7 +329,7 @@ void tst_QTranslator::dependencies()
|
|||||||
{
|
{
|
||||||
QTranslator tor( 0 );
|
QTranslator tor( 0 );
|
||||||
QFile file("dependencies_la.qm");
|
QFile file("dependencies_la.qm");
|
||||||
file.open(QFile::ReadOnly);
|
QVERIFY(file.open(QFile::ReadOnly));
|
||||||
QByteArray data = file.readAll();
|
QByteArray data = file.readAll();
|
||||||
QVERIFY(tor.load((const uchar *)data.constData(), data.length()));
|
QVERIFY(tor.load((const uchar *)data.constData(), data.length()));
|
||||||
QVERIFY(!tor.isEmpty());
|
QVERIFY(!tor.isEmpty());
|
||||||
|
@ -2551,7 +2551,7 @@ void tst_QtJson::parseDuplicateKeys()
|
|||||||
void tst_QtJson::testParser()
|
void tst_QtJson::testParser()
|
||||||
{
|
{
|
||||||
QFile file(testDataDir + "/test.json");
|
QFile file(testDataDir + "/test.json");
|
||||||
file.open(QFile::ReadOnly);
|
QVERIFY(file.open(QFile::ReadOnly));
|
||||||
QByteArray testJson = file.readAll();
|
QByteArray testJson = file.readAll();
|
||||||
|
|
||||||
QJsonDocument doc = QJsonDocument::fromJson(testJson);
|
QJsonDocument doc = QJsonDocument::fromJson(testJson);
|
||||||
@ -3136,7 +3136,7 @@ void tst_QtJson::documentEquals()
|
|||||||
void tst_QtJson::bom()
|
void tst_QtJson::bom()
|
||||||
{
|
{
|
||||||
QFile file(testDataDir + "/bom.json");
|
QFile file(testDataDir + "/bom.json");
|
||||||
file.open(QFile::ReadOnly);
|
QVERIFY(file.open(QFile::ReadOnly));
|
||||||
QByteArray json = file.readAll();
|
QByteArray json = file.readAll();
|
||||||
|
|
||||||
// Import json document into a QJsonDocument
|
// Import json document into a QJsonDocument
|
||||||
|
@ -3936,13 +3936,13 @@ void tst_QDataStream::typedefQt5Compat()
|
|||||||
QTemporaryDir dir;
|
QTemporaryDir dir;
|
||||||
QVERIFY(dir.isValid());
|
QVERIFY(dir.isValid());
|
||||||
QFile file(dir.filePath(u"typedef.q6"_s));
|
QFile file(dir.filePath(u"typedef.q6"_s));
|
||||||
file.open(QIODevice::WriteOnly);
|
QVERIFY(file.open(QIODevice::WriteOnly));
|
||||||
QDataStream stream(&file);
|
QDataStream stream(&file);
|
||||||
stream.setVersion(QDataStream::Qt_5_15);
|
stream.setVersion(QDataStream::Qt_5_15);
|
||||||
CustomPair p {42, 100};
|
CustomPair p {42, 100};
|
||||||
stream << QVariant::fromValue(p);
|
stream << QVariant::fromValue(p);
|
||||||
file.close();
|
file.close();
|
||||||
file.open(QIODevice::ReadOnly);
|
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||||
QCOMPARE(file.readAll(), qt5Data);
|
QCOMPARE(file.readAll(), qt5Data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -550,7 +550,7 @@ void tst_QTextStream::readLineMaxlen()
|
|||||||
QFile::remove("testfile");
|
QFile::remove("testfile");
|
||||||
QFile file("testfile");
|
QFile file("testfile");
|
||||||
if (useDevice) {
|
if (useDevice) {
|
||||||
file.open(QIODevice::ReadWrite);
|
QVERIFY(file.open(QIODevice::ReadWrite));
|
||||||
file.write(input.toUtf8());
|
file.write(input.toUtf8());
|
||||||
file.seek(0);
|
file.seek(0);
|
||||||
stream.setDevice(&file);
|
stream.setDevice(&file);
|
||||||
@ -935,7 +935,8 @@ void tst_QTextStream::lineCount_data()
|
|||||||
QTest::newRow("buffersize+1 line") << QByteArray(16384, '\n') << 16384;
|
QTest::newRow("buffersize+1 line") << QByteArray(16384, '\n') << 16384;
|
||||||
QTest::newRow("buffersize+2 line") << QByteArray(16385, '\n') << 16385;
|
QTest::newRow("buffersize+2 line") << QByteArray(16385, '\n') << 16385;
|
||||||
|
|
||||||
QFile file(m_rfc3261FilePath); file.open(QFile::ReadOnly);
|
QFile file(m_rfc3261FilePath);
|
||||||
|
QVERIFY(file.open(QFile::ReadOnly));
|
||||||
QTest::newRow("rfc3261") << file.readAll() << 15067;
|
QTest::newRow("rfc3261") << file.readAll() << 15067;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -946,7 +947,7 @@ void tst_QTextStream::lineCount()
|
|||||||
QFETCH(int, lineCount);
|
QFETCH(int, lineCount);
|
||||||
|
|
||||||
QFile out("out.txt");
|
QFile out("out.txt");
|
||||||
out.open(QFile::WriteOnly);
|
QVERIFY(out.open(QFile::WriteOnly));
|
||||||
|
|
||||||
QTextStream lineReader(data);
|
QTextStream lineReader(data);
|
||||||
int lines = 0;
|
int lines = 0;
|
||||||
@ -1408,7 +1409,7 @@ void tst_QTextStream::pos3LargeFile()
|
|||||||
|
|
||||||
{
|
{
|
||||||
QFile file(testFileName);
|
QFile file(testFileName);
|
||||||
file.open(QIODevice::WriteOnly | QIODevice::Text);
|
QVERIFY(file.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||||
QTextStream out( &file );
|
QTextStream out( &file );
|
||||||
// NOTE: The unusual spacing is to ensure non-1-character whitespace.
|
// NOTE: The unusual spacing is to ensure non-1-character whitespace.
|
||||||
QString lineString = " 0 1 2\t3 4\t \t5 6 7 8 9 \n";
|
QString lineString = " 0 1 2\t3 4\t \t5 6 7 8 9 \n";
|
||||||
@ -1419,7 +1420,7 @@ void tst_QTextStream::pos3LargeFile()
|
|||||||
// File is automatically flushed and closed on destruction.
|
// File is automatically flushed and closed on destruction.
|
||||||
}
|
}
|
||||||
QFile file(testFileName);
|
QFile file(testFileName);
|
||||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
|
||||||
QTextStream in( &file );
|
QTextStream in( &file );
|
||||||
const int testValues[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
const int testValues[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
|
||||||
int value;
|
int value;
|
||||||
@ -1516,7 +1517,7 @@ void tst_QTextStream::read()
|
|||||||
{
|
{
|
||||||
QFile::remove("testfile");
|
QFile::remove("testfile");
|
||||||
QFile file("testfile");
|
QFile file("testfile");
|
||||||
file.open(QFile::WriteOnly);
|
QVERIFY(file.open(QFile::WriteOnly));
|
||||||
file.write("4.15 abc ole");
|
file.write("4.15 abc ole");
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
@ -1538,7 +1539,7 @@ void tst_QTextStream::read()
|
|||||||
// File larger than QTEXTSTREAM_BUFFERSIZE
|
// File larger than QTEXTSTREAM_BUFFERSIZE
|
||||||
QFile::remove("testfile");
|
QFile::remove("testfile");
|
||||||
QFile file("testfile");
|
QFile file("testfile");
|
||||||
file.open(QFile::WriteOnly);
|
QVERIFY(file.open(QFile::WriteOnly));
|
||||||
for (int i = 0; i < 16384 / 8; ++i)
|
for (int i = 0; i < 16384 / 8; ++i)
|
||||||
file.write("01234567");
|
file.write("01234567");
|
||||||
file.write("0");
|
file.write("0");
|
||||||
@ -1594,8 +1595,8 @@ void tst_QTextStream::forceSign()
|
|||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
void tst_QTextStream::read0d0d0a()
|
void tst_QTextStream::read0d0d0a()
|
||||||
{
|
{
|
||||||
QFile file("task113817.txt");
|
QFile file(QFINDTESTDATA("task113817.txt"));
|
||||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Text));
|
||||||
|
|
||||||
QTextStream stream(&file);
|
QTextStream stream(&file);
|
||||||
while (!stream.atEnd())
|
while (!stream.atEnd())
|
||||||
@ -1759,7 +1760,7 @@ void tst_QTextStream::utf8IncompleteAtBufferBoundary()
|
|||||||
"\342\200\223"
|
"\342\200\223"
|
||||||
"\342\200\223");
|
"\342\200\223");
|
||||||
|
|
||||||
data.open(QFile::WriteOnly | QFile::Truncate);
|
QVERIFY(data.open(QFile::WriteOnly | QFile::Truncate));
|
||||||
{
|
{
|
||||||
QTextStream out(&data);
|
QTextStream out(&data);
|
||||||
out.setEncoding(QStringConverter::Utf8);
|
out.setEncoding(QStringConverter::Utf8);
|
||||||
@ -1771,7 +1772,7 @@ void tst_QTextStream::utf8IncompleteAtBufferBoundary()
|
|||||||
}
|
}
|
||||||
data.close();
|
data.close();
|
||||||
|
|
||||||
data.open(QFile::ReadOnly);
|
QVERIFY(data.open(QFile::ReadOnly));
|
||||||
QTextStream in(&data);
|
QTextStream in(&data);
|
||||||
|
|
||||||
QFETCH(bool, useLocale);
|
QFETCH(bool, useLocale);
|
||||||
|
@ -1943,7 +1943,7 @@ void tst_QXmlStream::tokenErrorHandling() const
|
|||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
QSKIP(QObject::tr("Testfile %1 not found.").arg(fileName).toUtf8().constData());
|
QSKIP(QObject::tr("Testfile %1 not found.").arg(fileName).toUtf8().constData());
|
||||||
|
|
||||||
file.open(QIODevice::ReadOnly);
|
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||||
QXmlStreamReader reader(&file);
|
QXmlStreamReader reader(&file);
|
||||||
while (!reader.atEnd())
|
while (!reader.atEnd())
|
||||||
reader.readNext();
|
reader.readNext();
|
||||||
@ -1960,7 +1960,7 @@ void tst_QXmlStream::checkStreamNotationDeclarations() const
|
|||||||
QFile file(dir.absoluteFilePath(fileName));
|
QFile file(dir.absoluteFilePath(fileName));
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
QSKIP(QObject::tr("Testfile %1 not found.").arg(fileName).toUtf8().constData());
|
QSKIP(QObject::tr("Testfile %1 not found.").arg(fileName).toUtf8().constData());
|
||||||
file.open(QIODevice::ReadOnly);
|
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||||
QXmlStreamReader reader(&file);
|
QXmlStreamReader reader(&file);
|
||||||
while (!reader.atEnd())
|
while (!reader.atEnd())
|
||||||
reader.readNext();
|
reader.readNext();
|
||||||
@ -1985,7 +1985,7 @@ void tst_QXmlStream::checkStreamEntityDeclarations() const
|
|||||||
QFile file(dir.absoluteFilePath(fileName));
|
QFile file(dir.absoluteFilePath(fileName));
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
QSKIP(QObject::tr("Testfile %1 not found.").arg(fileName).toUtf8().constData());
|
QSKIP(QObject::tr("Testfile %1 not found.").arg(fileName).toUtf8().constData());
|
||||||
file.open(QIODevice::ReadOnly);
|
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||||
QXmlStreamReader reader(&file);
|
QXmlStreamReader reader(&file);
|
||||||
while (!reader.atEnd())
|
while (!reader.atEnd())
|
||||||
reader.readNext();
|
reader.readNext();
|
||||||
|
@ -806,9 +806,7 @@ void tst_QChar::normalization_data()
|
|||||||
QString testFile = QFINDTESTDATA("data/NormalizationTest.txt");
|
QString testFile = QFINDTESTDATA("data/NormalizationTest.txt");
|
||||||
QVERIFY2(!testFile.isEmpty(), "data/NormalizationTest.txt not found!");
|
QVERIFY2(!testFile.isEmpty(), "data/NormalizationTest.txt not found!");
|
||||||
QFile f(testFile);
|
QFile f(testFile);
|
||||||
QVERIFY(f.exists());
|
QVERIFY(f.open(QIODevice::ReadOnly));
|
||||||
|
|
||||||
f.open(QIODevice::ReadOnly);
|
|
||||||
|
|
||||||
while (!f.atEnd()) {
|
while (!f.atEnd()) {
|
||||||
linenum++;
|
linenum++;
|
||||||
|
@ -82,9 +82,7 @@ static void generateDataFromFile(const QString &fname, const QSet<QString> &skip
|
|||||||
QString testFile = QFINDTESTDATA(fname);
|
QString testFile = QFINDTESTDATA(fname);
|
||||||
QVERIFY2(!testFile.isEmpty(), (fname.toLatin1() + QByteArray(" not found!")));
|
QVERIFY2(!testFile.isEmpty(), (fname.toLatin1() + QByteArray(" not found!")));
|
||||||
QFile f(testFile);
|
QFile f(testFile);
|
||||||
QVERIFY(f.exists());
|
QVERIFY(f.open(QIODevice::ReadOnly));
|
||||||
|
|
||||||
f.open(QIODevice::ReadOnly);
|
|
||||||
|
|
||||||
int linenum = 0;
|
int linenum = 0;
|
||||||
while (!f.atEnd()) {
|
while (!f.atEnd()) {
|
||||||
|
@ -1423,7 +1423,7 @@ void tst_QPixmap::loadFromDataImage()
|
|||||||
QPixmap pixmapWithCopy = QPixmap::fromImage(imageRef);
|
QPixmap pixmapWithCopy = QPixmap::fromImage(imageRef);
|
||||||
|
|
||||||
QFile file(imagePath);
|
QFile file(imagePath);
|
||||||
file.open(QIODevice::ReadOnly);
|
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||||
QByteArray rawData = file.readAll();
|
QByteArray rawData = file.readAll();
|
||||||
|
|
||||||
QPixmap directLoadingPixmap;
|
QPixmap directLoadingPixmap;
|
||||||
|
@ -877,13 +877,13 @@ void tst_QFileSystemModel::sort()
|
|||||||
//Create a file that will be at the end when sorting by name (For Mac, the default)
|
//Create a file that will be at the end when sorting by name (For Mac, the default)
|
||||||
//but if we sort by size descending it will be the first
|
//but if we sort by size descending it will be the first
|
||||||
QFile tempFile(dirPath + "/plop2.txt");
|
QFile tempFile(dirPath + "/plop2.txt");
|
||||||
tempFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
QVERIFY(tempFile.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||||
QTextStream out(&tempFile);
|
QTextStream out(&tempFile);
|
||||||
out << "The magic number is: " << 49 << "\n";
|
out << "The magic number is: " << 49 << "\n";
|
||||||
tempFile.close();
|
tempFile.close();
|
||||||
|
|
||||||
QFile tempFile2(dirPath + "/plop.txt");
|
QFile tempFile2(dirPath + "/plop.txt");
|
||||||
tempFile2.open(QIODevice::WriteOnly | QIODevice::Text);
|
QVERIFY(tempFile2.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||||
QTextStream out2(&tempFile2);
|
QTextStream out2(&tempFile2);
|
||||||
out2 << "The magic number is : " << 49 << " but i write some stuff in the file \n";
|
out2 << "The magic number is : " << 49 << " but i write some stuff in the file \n";
|
||||||
tempFile2.close();
|
tempFile2.close();
|
||||||
|
@ -54,7 +54,7 @@ void tst_qfileopenevent::cleanupTestCase()
|
|||||||
void tst_qfileopenevent::createFile(const QString &filename, const QByteArray &content)
|
void tst_qfileopenevent::createFile(const QString &filename, const QByteArray &content)
|
||||||
{
|
{
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
file.open(QFile::WriteOnly);
|
QVERIFY(file.open(QFile::WriteOnly));
|
||||||
file.write(content);
|
file.write(content);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
@ -138,7 +138,7 @@ void tst_qfileopenevent::handleLifetime()
|
|||||||
|
|
||||||
// check the content
|
// check the content
|
||||||
QFile checkContent("testHandleLifetime");
|
QFile checkContent("testHandleLifetime");
|
||||||
checkContent.open(QFile::ReadOnly);
|
QVERIFY(checkContent.open(QFile::ReadOnly));
|
||||||
QString content(checkContent.readAll());
|
QString content(checkContent.readAll());
|
||||||
QCOMPARE(content, QLatin1String("test content+closed original handles"));
|
QCOMPARE(content, QLatin1String("test content+closed original handles"));
|
||||||
checkContent.close();
|
checkContent.close();
|
||||||
|
@ -205,7 +205,7 @@ void tst_QColorSpace::fromIccProfile()
|
|||||||
QFETCH(QString, description);
|
QFETCH(QString, description);
|
||||||
|
|
||||||
QFile file(testProfile);
|
QFile file(testProfile);
|
||||||
file.open(QIODevice::ReadOnly);
|
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||||
QByteArray iccProfile = file.readAll();
|
QByteArray iccProfile = file.readAll();
|
||||||
QColorSpace fileColorSpace = QColorSpace::fromIccProfile(iccProfile);
|
QColorSpace fileColorSpace = QColorSpace::fromIccProfile(iccProfile);
|
||||||
QVERIFY(fileColorSpace.isValid());
|
QVERIFY(fileColorSpace.isValid());
|
||||||
@ -538,8 +538,8 @@ void tst_QColorSpace::imageConversionOverNonThreeComponentMatrix_data()
|
|||||||
QString prefix = QFINDTESTDATA("resources/");
|
QString prefix = QFINDTESTDATA("resources/");
|
||||||
QFile file1(prefix + "VideoHD.icc");
|
QFile file1(prefix + "VideoHD.icc");
|
||||||
QFile file2(prefix + "sRGB_ICC_v4_Appearance.icc");
|
QFile file2(prefix + "sRGB_ICC_v4_Appearance.icc");
|
||||||
file1.open(QFile::ReadOnly);
|
QVERIFY(file1.open(QFile::ReadOnly));
|
||||||
file2.open(QFile::ReadOnly);
|
QVERIFY(file2.open(QFile::ReadOnly));
|
||||||
QByteArray iccProfile1 = file1.readAll();
|
QByteArray iccProfile1 = file1.readAll();
|
||||||
QByteArray iccProfile2 = file2.readAll();
|
QByteArray iccProfile2 = file2.readAll();
|
||||||
QColorSpace hdtvColorSpace = QColorSpace::fromIccProfile(iccProfile1);
|
QColorSpace hdtvColorSpace = QColorSpace::fromIccProfile(iccProfile1);
|
||||||
@ -772,7 +772,7 @@ void tst_QColorSpace::changePrimaries()
|
|||||||
|
|
||||||
|
|
||||||
QFile iccFile(QFINDTESTDATA("resources/") + "VideoHD.icc");
|
QFile iccFile(QFINDTESTDATA("resources/") + "VideoHD.icc");
|
||||||
iccFile.open(QFile::ReadOnly);
|
QVERIFY(iccFile.open(QFile::ReadOnly));
|
||||||
QByteArray iccData = iccFile.readAll();
|
QByteArray iccData = iccFile.readAll();
|
||||||
QColorSpace hdtvColorSpace = QColorSpace::fromIccProfile(iccData);
|
QColorSpace hdtvColorSpace = QColorSpace::fromIccProfile(iccData);
|
||||||
QVERIFY(hdtvColorSpace.isValid());
|
QVERIFY(hdtvColorSpace.isValid());
|
||||||
|
@ -231,7 +231,7 @@ void tst_QFontDatabase::addAppFont()
|
|||||||
int id;
|
int id;
|
||||||
if (useMemoryFont) {
|
if (useMemoryFont) {
|
||||||
QFile fontfile(m_ledFont);
|
QFile fontfile(m_ledFont);
|
||||||
fontfile.open(QIODevice::ReadOnly);
|
QVERIFY(fontfile.open(QIODevice::ReadOnly));
|
||||||
QByteArray fontdata = fontfile.readAll();
|
QByteArray fontdata = fontfile.readAll();
|
||||||
QVERIFY(!fontdata.isEmpty());
|
QVERIFY(!fontdata.isEmpty());
|
||||||
id = QFontDatabase::addApplicationFontFromData(fontdata);
|
id = QFontDatabase::addApplicationFontFromData(fontdata);
|
||||||
|
@ -1054,7 +1054,7 @@ void tst_QRawFont::qtbug65923_partal_clone_data()
|
|||||||
void tst_QRawFont::qtbug65923_partal_clone()
|
void tst_QRawFont::qtbug65923_partal_clone()
|
||||||
{
|
{
|
||||||
QFile file(testFont);
|
QFile file(testFont);
|
||||||
file.open(QIODevice::ReadOnly);
|
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||||
QByteArray fontData = file.readAll();
|
QByteArray fontData = file.readAll();
|
||||||
|
|
||||||
QRawFont outerFont;
|
QRawFont outerFont;
|
||||||
|
@ -3775,7 +3775,7 @@ void tst_QNetworkReply::ioGetFromFtpWithReuse()
|
|||||||
QSKIP("FTP is not supported");
|
QSKIP("FTP is not supported");
|
||||||
QString fileName = testDataDir + "/rfc3252.txt";
|
QString fileName = testDataDir + "/rfc3252.txt";
|
||||||
QFile reference(fileName);
|
QFile reference(fileName);
|
||||||
reference.open(QIODevice::ReadOnly);
|
QVERIFY(reference.open(QIODevice::ReadOnly));
|
||||||
|
|
||||||
QNetworkRequest request(QUrl("ftp://" + QtNetworkSettings::ftpServerName() + "/qtest/rfc3252.txt"));
|
QNetworkRequest request(QUrl("ftp://" + QtNetworkSettings::ftpServerName() + "/qtest/rfc3252.txt"));
|
||||||
|
|
||||||
@ -3905,7 +3905,7 @@ void tst_QNetworkReply::ioGetFromHttpWithAuth_data()
|
|||||||
QTest::addColumn<int>("expectedAuth");
|
QTest::addColumn<int>("expectedAuth");
|
||||||
|
|
||||||
QFile reference(testDataDir + "/rfc3252.txt");
|
QFile reference(testDataDir + "/rfc3252.txt");
|
||||||
reference.open(QIODevice::ReadOnly);
|
QVERIFY(reference.open(QIODevice::ReadOnly));
|
||||||
QByteArray referenceData = reference.readAll();
|
QByteArray referenceData = reference.readAll();
|
||||||
QString httpServer = QtNetworkSettings::httpServerName();
|
QString httpServer = QtNetworkSettings::httpServerName();
|
||||||
QTest::newRow("basic")
|
QTest::newRow("basic")
|
||||||
@ -8279,7 +8279,7 @@ void tst_QNetworkReply::synchronousRequest()
|
|||||||
if (expected.startsWith("file:")) {
|
if (expected.startsWith("file:")) {
|
||||||
QString path = expected.mid(5);
|
QString path = expected.mid(5);
|
||||||
QFile file(path);
|
QFile file(path);
|
||||||
file.open(QIODevice::ReadOnly);
|
QVERIFY(file.open(QIODevice::ReadOnly));
|
||||||
expectedContent = file.readAll();
|
expectedContent = file.readAll();
|
||||||
} else if (expected.startsWith("data:")) {
|
} else if (expected.startsWith("data:")) {
|
||||||
expectedContent = expected.mid(5).toUtf8();
|
expectedContent = expected.mid(5).toUtf8();
|
||||||
@ -8903,7 +8903,7 @@ protected slots:
|
|||||||
void tst_QNetworkReply::putWithRateLimiting()
|
void tst_QNetworkReply::putWithRateLimiting()
|
||||||
{
|
{
|
||||||
QFile reference(testDataDir + "/rfc3252.txt");
|
QFile reference(testDataDir + "/rfc3252.txt");
|
||||||
reference.open(QIODevice::ReadOnly);
|
QVERIFY(reference.open(QIODevice::ReadOnly));
|
||||||
QByteArray data = reference.readAll();
|
QByteArray data = reference.readAll();
|
||||||
QVERIFY(data.size() > 0);
|
QVERIFY(data.size() > 0);
|
||||||
|
|
||||||
|
@ -580,7 +580,7 @@ void tst_QSslKey::passphraseChecks()
|
|||||||
QVERIFY(keyFile.exists());
|
QVERIFY(keyFile.exists());
|
||||||
{
|
{
|
||||||
if (!keyFile.isOpen())
|
if (!keyFile.isOpen())
|
||||||
keyFile.open(QIODevice::ReadOnly);
|
QVERIFY(keyFile.open(QIODevice::ReadOnly));
|
||||||
else
|
else
|
||||||
keyFile.reset();
|
keyFile.reset();
|
||||||
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey);
|
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey);
|
||||||
@ -588,7 +588,7 @@ void tst_QSslKey::passphraseChecks()
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
if (!keyFile.isOpen())
|
if (!keyFile.isOpen())
|
||||||
keyFile.open(QIODevice::ReadOnly);
|
QVERIFY(keyFile.open(QIODevice::ReadOnly));
|
||||||
else
|
else
|
||||||
keyFile.reset();
|
keyFile.reset();
|
||||||
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "");
|
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "");
|
||||||
@ -596,7 +596,7 @@ void tst_QSslKey::passphraseChecks()
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
if (!keyFile.isOpen())
|
if (!keyFile.isOpen())
|
||||||
keyFile.open(QIODevice::ReadOnly);
|
QVERIFY(keyFile.open(QIODevice::ReadOnly));
|
||||||
else
|
else
|
||||||
keyFile.reset();
|
keyFile.reset();
|
||||||
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "WRONG!");
|
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "WRONG!");
|
||||||
@ -604,7 +604,7 @@ void tst_QSslKey::passphraseChecks()
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
if (!keyFile.isOpen())
|
if (!keyFile.isOpen())
|
||||||
keyFile.open(QIODevice::ReadOnly);
|
QVERIFY(keyFile.open(QIODevice::ReadOnly));
|
||||||
else
|
else
|
||||||
keyFile.reset();
|
keyFile.reset();
|
||||||
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, passphrase);
|
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, passphrase);
|
||||||
@ -622,7 +622,7 @@ void tst_QSslKey::noPassphraseChecks()
|
|||||||
QFile keyFile(fileName);
|
QFile keyFile(fileName);
|
||||||
{
|
{
|
||||||
if (!keyFile.isOpen())
|
if (!keyFile.isOpen())
|
||||||
keyFile.open(QIODevice::ReadOnly);
|
QVERIFY(keyFile.open(QIODevice::ReadOnly));
|
||||||
else
|
else
|
||||||
keyFile.reset();
|
keyFile.reset();
|
||||||
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey);
|
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey);
|
||||||
@ -630,7 +630,7 @@ void tst_QSslKey::noPassphraseChecks()
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
if (!keyFile.isOpen())
|
if (!keyFile.isOpen())
|
||||||
keyFile.open(QIODevice::ReadOnly);
|
QVERIFY(keyFile.open(QIODevice::ReadOnly));
|
||||||
else
|
else
|
||||||
keyFile.reset();
|
keyFile.reset();
|
||||||
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "");
|
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "");
|
||||||
@ -638,7 +638,7 @@ void tst_QSslKey::noPassphraseChecks()
|
|||||||
}
|
}
|
||||||
{
|
{
|
||||||
if (!keyFile.isOpen())
|
if (!keyFile.isOpen())
|
||||||
keyFile.open(QIODevice::ReadOnly);
|
QVERIFY(keyFile.open(QIODevice::ReadOnly));
|
||||||
else
|
else
|
||||||
keyFile.reset();
|
keyFile.reset();
|
||||||
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "xxx");
|
QSslKey key(&keyFile,QSsl::Rsa,QSsl::Pem, QSsl::PrivateKey, "xxx");
|
||||||
|
@ -347,9 +347,7 @@ void tst_QComplexText::bidiCharacterTest()
|
|||||||
{
|
{
|
||||||
QString testFile = QFINDTESTDATA("data/BidiCharacterTest.txt");
|
QString testFile = QFINDTESTDATA("data/BidiCharacterTest.txt");
|
||||||
QFile f(testFile);
|
QFile f(testFile);
|
||||||
QVERIFY(f.exists());
|
QVERIFY(f.open(QIODevice::ReadOnly));
|
||||||
|
|
||||||
f.open(QIODevice::ReadOnly);
|
|
||||||
|
|
||||||
int linenum = 0;
|
int linenum = 0;
|
||||||
while (!f.atEnd()) {
|
while (!f.atEnd()) {
|
||||||
@ -441,9 +439,7 @@ void tst_QComplexText::bidiTest()
|
|||||||
{
|
{
|
||||||
QString testFile = QFINDTESTDATA("data/BidiTest.txt");
|
QString testFile = QFINDTESTDATA("data/BidiTest.txt");
|
||||||
QFile f(testFile);
|
QFile f(testFile);
|
||||||
QVERIFY(f.exists());
|
QVERIFY(f.open(QIODevice::ReadOnly));
|
||||||
|
|
||||||
f.open(QIODevice::ReadOnly);
|
|
||||||
|
|
||||||
int linenum = 0;
|
int linenum = 0;
|
||||||
QList<int> resolvedLevels;
|
QList<int> resolvedLevels;
|
||||||
|
@ -925,7 +925,7 @@ void tst_QFiledialog::selectFiles()
|
|||||||
QString filesPath = fd.directory().absolutePath();
|
QString filesPath = fd.directory().absolutePath();
|
||||||
for (int i=0; i < 5; ++i) {
|
for (int i=0; i < 5; ++i) {
|
||||||
QFile file(filesPath + QLatin1String("/qfiledialog_auto_test_not_pres_") + QString::number(i));
|
QFile file(filesPath + QLatin1String("/qfiledialog_auto_test_not_pres_") + QString::number(i));
|
||||||
file.open(QIODevice::WriteOnly);
|
QVERIFY(file.open(QIODevice::WriteOnly));
|
||||||
file.resize(1024);
|
file.resize(1024);
|
||||||
file.flush();
|
file.flush();
|
||||||
file.close();
|
file.close();
|
||||||
|
@ -1252,7 +1252,7 @@ void tst_QFileDialog2::QTBUG6558_showDirsOnly()
|
|||||||
|
|
||||||
//Create a file
|
//Create a file
|
||||||
QFile tempFile(dirPath + "/plop.txt");
|
QFile tempFile(dirPath + "/plop.txt");
|
||||||
tempFile.open(QIODevice::WriteOnly | QIODevice::Text);
|
QVERIFY(tempFile.open(QIODevice::WriteOnly | QIODevice::Text));
|
||||||
QTextStream out(&tempFile);
|
QTextStream out(&tempFile);
|
||||||
out << "The magic number is: " << 49 << "\n";
|
out << "The magic number is: " << 49 << "\n";
|
||||||
tempFile.close();
|
tempFile.close();
|
||||||
|
@ -4523,8 +4523,7 @@ void tst_QWidget::restoreVersion1Geometry()
|
|||||||
const Qt::WindowStates WindowStateMask = Qt::WindowFullScreen | Qt::WindowMaximized | Qt::WindowMinimized;
|
const Qt::WindowStates WindowStateMask = Qt::WindowFullScreen | Qt::WindowMaximized | Qt::WindowMinimized;
|
||||||
|
|
||||||
QFile f(fileName);
|
QFile f(fileName);
|
||||||
QVERIFY(f.exists());
|
QVERIFY(f.open(QIODevice::ReadOnly));
|
||||||
f.open(QIODevice::ReadOnly);
|
|
||||||
const QByteArray savedGeometry = f.readAll();
|
const QByteArray savedGeometry = f.readAll();
|
||||||
QCOMPARE(savedGeometry.size(), 46);
|
QCOMPARE(savedGeometry.size(), 46);
|
||||||
f.close();
|
f.close();
|
||||||
|
@ -122,7 +122,7 @@ void tst_Lancelot::initTestCase()
|
|||||||
std::sort(qpsFiles.begin(), qpsFiles.end());
|
std::sort(qpsFiles.begin(), qpsFiles.end());
|
||||||
foreach (const QString& fileName, qpsFiles) {
|
foreach (const QString& fileName, qpsFiles) {
|
||||||
QFile file(scriptsDir + fileName);
|
QFile file(scriptsDir + fileName);
|
||||||
file.open(QFile::ReadOnly);
|
QVERIFY(file.open(QFile::ReadOnly));
|
||||||
QByteArray cont = file.readAll();
|
QByteArray cont = file.readAll();
|
||||||
scripts.insert(fileName, QString::fromUtf8(cont).split(QLatin1Char('\n'), Qt::SkipEmptyParts));
|
scripts.insert(fileName, QString::fromUtf8(cont).split(QLatin1Char('\n'), Qt::SkipEmptyParts));
|
||||||
scriptChecksums.insert(fileName, qChecksum(cont));
|
scriptChecksums.insert(fileName, qChecksum(cont));
|
||||||
@ -423,7 +423,7 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
|
|||||||
QString tempStem(QDir::tempPath() + QLatin1String("/lancelot_XXXXXX_") + qpsFile.chopped(4));
|
QString tempStem(QDir::tempPath() + QLatin1String("/lancelot_XXXXXX_") + qpsFile.chopped(4));
|
||||||
|
|
||||||
QTemporaryFile pdfFile(tempStem + QLatin1String(".pdf"));
|
QTemporaryFile pdfFile(tempStem + QLatin1String(".pdf"));
|
||||||
pdfFile.open();
|
QVERIFY(pdfFile.open());
|
||||||
QPdfWriter writer(&pdfFile);
|
QPdfWriter writer(&pdfFile);
|
||||||
writer.setPdfVersion(QPdfWriter::PdfVersion_1_6);
|
writer.setPdfVersion(QPdfWriter::PdfVersion_1_6);
|
||||||
QPageSize pageSize(QSize(800, 800), QStringLiteral("LancePage"), QPageSize::ExactMatch);
|
QPageSize pageSize(QSize(800, 800), QStringLiteral("LancePage"), QPageSize::ExactMatch);
|
||||||
@ -435,7 +435,7 @@ void tst_Lancelot::runTestSuite(GraphicsEngine engine, QImage::Format format, co
|
|||||||
|
|
||||||
// Convert pdf to something we can read into a QImage, using macOS' sips utility
|
// Convert pdf to something we can read into a QImage, using macOS' sips utility
|
||||||
QTemporaryFile pngFile(tempStem + QLatin1String(".png"));
|
QTemporaryFile pngFile(tempStem + QLatin1String(".png"));
|
||||||
pngFile.open(); // Just create the file name
|
QVERIFY(pngFile.open()); // Just create the file name
|
||||||
pngFile.close();
|
pngFile.close();
|
||||||
QProcess proc;
|
QProcess proc;
|
||||||
const char *rawArgs = "-s format png -o";
|
const char *rawArgs = "-s format png -o";
|
||||||
|
@ -63,7 +63,7 @@ void tst_Stylesheet::loadTestFiles()
|
|||||||
for (const auto &qssFile : qssFiles) {
|
for (const auto &qssFile : qssFiles) {
|
||||||
QFileInfo fileInfo(qssFile);
|
QFileInfo fileInfo(qssFile);
|
||||||
QFile file(qssFile);
|
QFile file(qssFile);
|
||||||
file.open(QFile::ReadOnly);
|
QVERIFY(file.open(QFile::ReadOnly));
|
||||||
QString styleSheet = QString::fromUtf8(file.readAll());
|
QString styleSheet = QString::fromUtf8(file.readAll());
|
||||||
QBaselineTest::newRow(fileInfo.baseName().toUtf8()) << styleSheet;
|
QBaselineTest::newRow(fileInfo.baseName().toUtf8()) << styleSheet;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ void tst_Text::loadTestFiles()
|
|||||||
for (const auto &htmlFile : htmlFiles) {
|
for (const auto &htmlFile : htmlFiles) {
|
||||||
QFileInfo fileInfo(htmlFile);
|
QFileInfo fileInfo(htmlFile);
|
||||||
QFile file(htmlFile);
|
QFile file(htmlFile);
|
||||||
file.open(QFile::ReadOnly);
|
QVERIFY(file.open(QFile::ReadOnly));
|
||||||
QString html = QString::fromUtf8(file.readAll());
|
QString html = QString::fromUtf8(file.readAll());
|
||||||
QBaselineTest::newRow(fileInfo.baseName().toUtf8()) << html;
|
QBaselineTest::newRow(fileInfo.baseName().toUtf8()) << html;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user