From 2228e670ca89d3292452673f2630aa2f88e1873b Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Thu, 6 Aug 2009 14:29:54 +0200 Subject: Fixes autotests in QFileSystemWatcher: watchFileAndItsDirectory dnotify is something from older linux kernels and cannot be trusted, therefore we skip some tests. Also we cannot guarantee that 1 operation on the file give only 1 notification in general, so we relaxed the conditions. Reviewed-by: paul --- .../qfilesystemwatcher/tst_qfilesystemwatcher.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index c883c63..b89890e 100644 --- a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -399,6 +399,15 @@ void tst_QFileSystemWatcher::removePaths() watcher.removePaths(paths); } +#if 0 +class SignalTest : public QObject { + Q_OBJECT; + public slots: + void fileSlot(const QString &file) { qDebug() << "file " << file;} + void dirSlot(const QString &dir) { qDebug() << "dir" << dir;} +}; +#endif + void tst_QFileSystemWatcher::watchFileAndItsDirectory() { QFETCH(QString, backend); @@ -423,6 +432,12 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() watcher.addPath(testDir.dirName()); watcher.addPath(testFileName); + /* + SignalTest signalTest; + QObject::connect(&watcher, SIGNAL(fileChanged(const QString &)), &signalTest, SLOT(fileSlot(const QString &))); + QObject::connect(&watcher, SIGNAL(directoryChanged(const QString &)), &signalTest, SLOT(dirSlot(const QString &))); + */ + QSignalSpy fileChangedSpy(&watcher, SIGNAL(fileChanged(const QString &))); QSignalSpy dirChangedSpy(&watcher, SIGNAL(directoryChanged(const QString &))); QEventLoop eventLoop; @@ -440,9 +455,12 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() timer.start(3000); eventLoop.exec(); - QCOMPARE(fileChangedSpy.count(), 1); + QVERIFY(fileChangedSpy.count() > 0); QCOMPARE(dirChangedSpy.count(), 0); + if (backend == "dnotify") + QSKIP("dnotify is broken, skipping the rest of the test.", SkipSingle); + fileChangedSpy.clear(); QFile secondFile(secondFileName); secondFile.open(QIODevice::WriteOnly | QIODevice::Truncate); @@ -460,7 +478,7 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() timer.start(3000); eventLoop.exec(); - QCOMPARE(fileChangedSpy.count(), 1); + QVERIFY(fileChangedSpy.count() > 0); QCOMPARE(dirChangedSpy.count(), 1); fileChangedSpy.clear(); -- cgit v0.12