diff options
author | Shane Kearns <shane.kearns@sosco.com> | 2009-08-18 08:28:26 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@sosco.com> | 2009-08-18 08:28:26 (GMT) |
commit | 1428cc6d71a65c1ac7123c9c4cc3cfaf225cceed (patch) | |
tree | f9b0263c7f6a2dd782be20fc15763e0c752e043a /tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp | |
parent | 188c14c1fd66cc2bddcf19d753caeaac0241940c (diff) | |
download | Qt-1428cc6d71a65c1ac7123c9c4cc3cfaf225cceed.zip Qt-1428cc6d71a65c1ac7123c9c4cc3cfaf225cceed.tar.gz Qt-1428cc6d71a65c1ac7123c9c4cc3cfaf225cceed.tar.bz2 |
Fix autotest to accept Symbian OS behaviour as a pass.
Symbian generates a directory change event when a file is overwritten in
that directory.
Autotest was asserting that no change event is generated in this
situation (documentation allows it in the signal description)
So the test now allows 0 or 1 dir changed events, to allow existing
platforms and symbian to both pass.
Reviewed-by: brad
Diffstat (limited to 'tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp')
-rw-r--r-- | tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index 907b13e..a3dab07 100644 --- a/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -73,9 +73,11 @@ private slots: void removePath(); void addPaths(); void removePaths(); - void watchFileAndItsDirectory(); + void watchFileAndItsDirectory_data() { basicTest_data(); } + void watchFileAndItsDirectory(); + void cleanup(); private: QStringList do_force_engines; bool do_force_native; @@ -459,12 +461,22 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() timer.start(3000); eventLoop.exec(); QVERIFY(fileChangedSpy.count() > 0); - QCOMPARE(dirChangedSpy.count(), 0); + //according to Qt 4 documentation: + //void QFileSystemWatcher::directoryChanged ( const QString & path ) [signal] + //This signal is emitted when the directory at a specified path, is modified + //(e.g., when a file is added, -->modified<-- or deleted) or removed from disk. + //Note that if there are several changes during a short period of time, some + //of the changes might not emit this signal. However, the last change in the + //sequence of changes will always generate this signal. + //Symbian behaves as documented (and can't be filtered), but the other platforms don't + //so test should not assert this + QVERIFY(dirChangedSpy.count() < 2); if (backend == "dnotify") QSKIP("dnotify is broken, skipping the rest of the test.", SkipSingle); fileChangedSpy.clear(); + dirChangedSpy.clear(); QFile secondFile(secondFileName); secondFile.open(QIODevice::WriteOnly | QIODevice::Truncate); secondFile.write("Foo"); @@ -473,6 +485,11 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() timer.start(3000); eventLoop.exec(); QCOMPARE(fileChangedSpy.count(), 0); +#if defined(Q_OS_SYMBIAN) && defined(Q_CC_RVCT) + // Since native watcher is always used in real devices, this poller issue is irrelevant + // Symbian file system does not change modification time on a directory when a file inside is changed + QEXPECT_FAIL("poller", "Poller doesn't detect directory changes in RVCT builds", Abort); +#endif QCOMPARE(dirChangedSpy.count(), 1); dirChangedSpy.clear(); @@ -498,5 +515,15 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() QVERIFY(QDir().rmdir("testDir")); } +void tst_QFileSystemWatcher::cleanup() +{ + QDir testDir("testDir"); + QString testFileName = testDir.filePath("testFile.txt"); + QString secondFileName = testDir.filePath("testFile2.txt"); + QFile::remove(testFileName); + QFile::remove(secondFileName); + QDir().rmdir("testDir"); +} + QTEST_MAIN(tst_QFileSystemWatcher) #include "tst_qfilesystemwatcher.moc" |