From 75016a4a3bb2ae536a3a813f0ef410b1a0c83742 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 11 Oct 2010 16:35:58 +0200 Subject: Add test to test QDir caching behavior. Also fix the qfileenginemodel test to be less fragile Reviewed-by: Prasanth Ullattil --- tests/auto/qdir/tst_qdir.cpp | 13 +++++++++++++ tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/auto/qdir/tst_qdir.cpp b/tests/auto/qdir/tst_qdir.cpp index 2bb0a3e..d540f29 100644 --- a/tests/auto/qdir/tst_qdir.cpp +++ b/tests/auto/qdir/tst_qdir.cpp @@ -175,6 +175,8 @@ private slots: void detachingOperations(); + void testCaching(); + #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) void isRoot_data(); void isRoot(); @@ -1663,6 +1665,17 @@ void tst_QDir::detachingOperations() QCOMPARE(dir1.sorting(), sorting); } +void tst_QDir::testCaching() +{ + QString dirName = QString::fromLatin1("testCaching"); + QDir::current().rmdir(dirName); // cleanup a previous run. + QDir dir(dirName); + QVERIFY(!dir.exists()); + QDir::current().mkdir(dirName); + QVERIFY(QDir(dirName).exists()); // dir exists + QVERIFY(dir.exists()); // QDir doesn't cache the 'exist' between calls. +} + #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) void tst_QDir::isRoot_data() { diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index a391eb9..6b63691 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -997,8 +997,8 @@ void tst_QFileSystemModel::dirsBeforeFiles() } dir.rmdir(dirPath); } - dir.mkpath(dirPath); - QVERIFY(dir.exists()); + QVERIFY(dir.mkpath(dirPath)); + QVERIFY(QDir(dirPath).exists()); for (int i = 0; i < 3; ++i) { QLatin1Char c('a' + i); -- cgit v0.12