Windows: Fix qabstractfilenengine-test.

The test fails if the repository is checked out with
Windows line endings. Try to work around.

Basically, ensure that common developers can conveniently
run the test.

Change-Id: I91f31b830ba7ba305deea782737d4e07a89420eb
Reviewed-by: Sergio Ahumada <sergio.ahumada@nokia.com>
bb10
Friedemann Kleint 2011-12-01 12:34:10 +01:00 committed by Qt by Nokia
parent 9e09b8dc48
commit f0942bd8cb
1 changed files with 16 additions and 2 deletions

View File

@ -598,11 +598,25 @@ void tst_QAbstractFileEngine::fileIO()
{
// Reading
QFile file(fileName);
QVERIFY(!file.isOpen());
QVERIFY(file.open(QIODevice::ReadOnly | QIODevice::Unbuffered));
/* For an exact match, this test requires the repository to
* be checked out with UNIX-style line endings on Windows.
* Try to succeed also for the common case of checking out with autocrlf
* by reading the file as text and checking if the size matches
* the original size + the '\r' characters added by autocrlf. */
QFile::OpenMode openMode = QIODevice::ReadOnly | QIODevice::Unbuffered;
#ifdef Q_OS_WIN
openMode |= QIODevice::Text;
#endif
QVERIFY(file.open(openMode));
QVERIFY(file.isOpen());
#ifdef Q_OS_WIN
const qint64 convertedSize = fileSize + readContent.count('\n');
if (file.size() == convertedSize)
fileSize = convertedSize;
#endif
QCOMPARE(file.size(), fileSize);
QCOMPARE(file.pos(), qint64(0));