Details
-
Suggestion
-
Resolution: Done
-
Not Evaluated
-
4.7.3
-
None
Description
qtest-qml and has pretty good documentation http://qt.gitorious.net/qt-labs/qtest-qml
Its SignalSpy is a good tool for verifying that the signal is emitted. It took me however quite some time to realize that it can also be used for verifying that signal is not emitted within the given time.
SignalSpy's wait() method fails if signal is not emitted, but TestCase's wait() method provides an alternative for waiting and SignalSpy continues to listen to signal without any extra activation needed. It would be cool to document the following:
1) SignalSpy is listening all the time, not only when its wait() is called
2) Show an example of a test that confirms that signal is not emitted within a given time. Something like the following:
import QtQuick 1.0 import QtQuickTest 1.0 Rectangle{ id: main width: 400 height: 300 color: "lightblue" MouseArea { id: testArea anchors.fill: parent } SignalSpy { id: clickSpy target: testArea signalName: "clicked" } TestCase { id: mainCase name: "SignalSpy tests" /** mouse signals cannot be simulated until window is shown */ when: windowShown function test_canCaptureClickSignal() { clickSpy.clear() mouseClick(testArea, 5, 5) clickSpy.wait() compare(clickSpy.count, 1) } function test_canConfirmThatSignalIsNotEmittedWithin600Ms() { clickSpy.clear() // if the following line is uncommented, test will fail // mouseClick(testArea, 5, 5) wait(600) compare(clickSpy.count, 0) } } }