From 7f585fc4b95997018babe68d2e19c1bad172373e Mon Sep 17 00:00:00 2001 From: Alex Richardson Date: Wed, 7 May 2014 21:02:31 +0200 Subject: Apparently calling readAll() on the temporary file doesn't work Open a new QFile for reading after calling close() on the temp file --- autotests/kconfigtest.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'autotests/kconfigtest.cpp') diff --git a/autotests/kconfigtest.cpp b/autotests/kconfigtest.cpp index 4f29ea87..d82d8ca4 100644 --- a/autotests/kconfigtest.cpp +++ b/autotests/kconfigtest.cpp @@ -1630,16 +1630,21 @@ void KConfigTest::testNewlines() { // test that kconfig always uses the native line endings QTemporaryFile file; - file.open(); + QVERIFY(file.open()); + qWarning() << file.fileName(); KConfig anonConfig(file.fileName(), KConfig::SimpleConfig); KConfigGroup general(&anonConfig, "General"); general.writeEntry("Foo", "Bar"); general.writeEntry("Bar", "Foo"); anonConfig.sync(); + file.flush(); + file.close(); + QFile readFile(file.fileName()); + QVERIFY(readFile.open(QFile::ReadOnly)); #ifndef Q_OS_WIN - QCOMPARE(file.readAll(), QByteArrayLiteral("[General]\nBar=Foo\nFoo=Bar\n")); + QCOMPARE(readFile.readAll(), QByteArrayLiteral("[General]\nBar=Foo\nFoo=Bar\n")); #else - QCOMPARE(file.readAll(), QByteArrayLiteral("[General]\r\nBar=Foo\r\nFoo=Bar\r\n")); + QCOMPARE(readFile.readAll(), QByteArrayLiteral("[General]\r\nBar=Foo\r\nFoo=Bar\r\n")); #endif } -- cgit v1.2.1