QTest asynchronous signal interception
-
I am investigating "QTest":http://qt-project.org/doc/qt-5/qtest-overview.html for "GUI testing":http://en.wikipedia.org/wiki/Graphical_user_interface_testing. It appears that there is no mechanism in QTest to asynchronously test a "signal":http://qt-project.org/doc/qt-5/signalsandslots.html callback. Am I misunderstanding how to use QTest, or misunderstanding the intended functionality provided by QTest?
For example, I am attempting to test a signal which launches a modal "QMessageBox":http://qt-project.org/doc/qt-5/qmessagebox.html popup in response to clicking a "QPushButton":http://qt-project.org/doc/qt-5/QPushButton.html. I want to test events and state between the clicking of the button and clicking 'OK' on the QMessageBox. I have tried using "QSignalSpy.wait()":http://qt-project.org/doc/qt-5/qsignalspy.html#wait, "QTestEventList.simulate()":https://qt-project.org/doc/qt-5/qtesteventlist.html#simulate, "QTest::mouseClick()":http://qt-project.org/doc/qt-5/qtest.html#mouseClick-2, "QTest::mouseEvent()":http://qt-project.org/doc/qt-5/qtest.html#mouseEvent, and "QTRY_VERIFY()":http://qt-project.org/doc/qt-5/qtest.html#QTRY_VERIFY, all of which, when called from the testing code, do not return until after clicking 'OK' on the QMessageBox popup. Therefore, to test anything before all event handlers return, I would have to do something like install an event filter on the object under test, and write my own asynchronous testing code.
This is all the same code we would have to write if we weren't using a test library and we can do all of this without using QTest. For example, we can manually "get a handle":http://qt-project.org/doc/qt-5/qobject.html#findChild to the object under test, "connect signals":http://qt-project.org/doc/qt-5/qobject.html#connect-6 for testing, "invoke an event":http://qt-project.org/doc/qt-5/qabstractbutton.html#click to trigger the event handler or "invoke the signal manually":http://qt-project.org/doc/qt-5/qabstractbutton.html#clicked, and also write the installed test handlers that interact with the test environment before returning execution to the point at which the event was launched. What does QTest gain us here?
(This is a copy of my "post on SO":http://stackoverflow.com/questions/23139030/qtest-asynchronous-signal-interception)