It is now time to see how you can test your GUI using the Qt Test API. The QTest class offers several functions to simulate keys and mouse events.
To demonstrate it, we will stay with the notion of testing a Track state, but on an upper level. Rather than testing the Track state itself, we will check that the UI state of the drum-machine application is properly updated when the Track state is changed. Namely, the control buttons (play, stop, record) should be in a specific state when a recording is started.
Start by creating a TestGui class in the drum-machine-test project. Don't forget to add the TestGui class in the tests map of main.cpp. As usual, make it inherit QObject and update TestGui.h like so:
#include <QTest> #include "MainWindow.h" class TestGui : public QObject { Q_OBJECT public: TestGui(QObject* parent = 0)...