I am writing unit test cases for my QT application which contains a QWizard. I am using QtTest framework. But I am not able to get the Next button clicked on my wizard page.
welcomePage->m_installedVersion->lineEdit()->setText("1102");
welcomePage->m_upgradeVersion->lineEdit()->setText("12");
welcomePage->completeChanged(); //Only the above two text fields are mandatory so Next button should be enabled here, but it is not. So I have manually enabled it below.
myWizard.getNextButton()->setEnabled(true);
while( !myWizard.getNextButton()->isEnabled())
{
}
//Trying different ways to click on Next
QTest::mouseClick(myWizard.getNextButton(), Qt::RightButton, Qt::NoModifier, QPoint(), 5000);
QSignalSpy(myWizard.getNextButton(), &QPushButton::clicked);
myWizard.getNextButton()->click();
The initializePage for the second page does not get called, so I don't think Next button has been clicked. How can I go to the Next page while unit testing?
I would try clicking it with left mouse button.
and also make sure in your test that the button is visible and enabled, like:
Invisible and disabled buttons do nothing when clicked. And Next-Buttons in wizards are often disabled until the required fields in the wizard page are filled.