diff options
author | Jason McDonald <jason.mcdonald@nokia.com> | 2011-12-22 17:16:48 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-12-28 04:48:11 +0100 |
commit | ea415e20607016651f3cef02dff109235d84eb4d (patch) | |
tree | 8c954afe7d078b0ca742a1f2249ccc5a9ddf1b82 /tests/auto/corelib/io/qfilesystemwatcher | |
parent | 1e7296f3f2e7346f52e8f70d4e531405a248aa8b (diff) |
Cleanup corelib autotests.
When using QSignalSpy, always verify that the signal spy is valid. This
will cause the test to give a meaningful failure when spying on a
non-existant signal. Without this change, tests that spy on a signal to
ensure that it is not emitted (i.e. by comparing the spy count to zero)
could pass erroneously if something went wrong when creating the signal
spy, as an invalid QSignalSpy will always return a count of zero.
Change-Id: I41f4a63d9f0de9190a86de237662dc96be802446
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
Diffstat (limited to 'tests/auto/corelib/io/qfilesystemwatcher')
-rw-r--r-- | tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index b9840bdb75..0f2c163e24 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -138,6 +138,7 @@ void tst_QFileSystemWatcher::basicTest() watcher.addPath(testFile.fileName()); QSignalSpy changedSpy(&watcher, SIGNAL(fileChanged(const QString &))); + QVERIFY(changedSpy.isValid()); QEventLoop eventLoop; QTimer timer; connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit())); @@ -273,6 +274,7 @@ void tst_QFileSystemWatcher::watchDirectory() watcher.addPath(testDir.dirName()); QSignalSpy changedSpy(&watcher, SIGNAL(directoryChanged(const QString &))); + QVERIFY(changedSpy.isValid()); QEventLoop eventLoop; QTimer timer; connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit())); @@ -423,6 +425,8 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() QSignalSpy fileChangedSpy(&watcher, SIGNAL(fileChanged(const QString &))); QSignalSpy dirChangedSpy(&watcher, SIGNAL(directoryChanged(const QString &))); + QVERIFY(fileChangedSpy.isValid()); + QVERIFY(dirChangedSpy.isValid()); QEventLoop eventLoop; QTimer timer; connect(&timer, SIGNAL(timeout()), &eventLoop, SLOT(quit())); |