From ca7dd36dd46f2338dd685533cad69ca7a229a001 Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Sun, 22 Feb 2015 07:46:00 +0100 Subject: [PATCH] Fix unittest --- autotests/followupreminderselectdatedialogtest.cpp | 10 ++++++++-- followupreminder/followupreminderselectdatedialog.cpp | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/autotests/followupreminderselectdatedialogtest.cpp b/autotests/followupreminderselectdatedialogtest.cpp index 934d1624d..ad3d11ad3 100644 --- a/autotests/followupreminderselectdatedialogtest.cpp +++ b/autotests/followupreminderselectdatedialogtest.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include FollowupReminderSelectDateDialogTest::FollowupReminderSelectDateDialogTest(QObject *parent) : QObject(parent) @@ -45,6 +45,10 @@ void FollowupReminderSelectDateDialogTest::shouldHaveDefaultValue() QVERIFY(combobox); QDate currentDate = QDate::currentDate(); QCOMPARE(datecombobox->date(), currentDate.addDays(1)); + + QPushButton *okButton = dlg.findChild(QLatin1String("ok_button")); + QVERIFY(okButton); + QVERIFY(okButton->isEnabled()); } void FollowupReminderSelectDateDialogTest::shouldDisableOkButtonIfDateIsEmpty() @@ -52,8 +56,10 @@ void FollowupReminderSelectDateDialogTest::shouldDisableOkButtonIfDateIsEmpty() FollowUpReminderSelectDateDialog dlg; KDateComboBox *datecombobox = qFindChild(&dlg, QLatin1String("datecombobox")); QVERIFY(datecombobox); + QPushButton *okButton = dlg.findChild(QLatin1String("ok_button")); + QVERIFY(okButton->isEnabled()); datecombobox->lineEdit()->clear(); - //FIXME QT5 QVERIFY(!dlg.button(KDialog::Ok)->isEnabled()); + QVERIFY(!okButton->isEnabled()); } QTEST_MAIN(FollowupReminderSelectDateDialogTest) diff --git a/followupreminder/followupreminderselectdatedialog.cpp b/followupreminder/followupreminderselectdatedialog.cpp index a13e30748..c6a27183f 100644 --- a/followupreminder/followupreminderselectdatedialog.cpp +++ b/followupreminder/followupreminderselectdatedialog.cpp @@ -43,6 +43,7 @@ FollowUpReminderSelectDateDialog::FollowUpReminderSelectDateDialog(QWidget *pare QVBoxLayout *topLayout = new QVBoxLayout; setLayout(topLayout); mOkButton = buttonBox->button(QDialogButtonBox::Ok); + mOkButton->setObjectName(QLatin1Literal("ok_button")); mOkButton->setDefault(true); mOkButton->setShortcut(Qt::CTRL | Qt::Key_Return); connect(buttonBox, &QDialogButtonBox::accepted, this, &FollowUpReminderSelectDateDialog::accept);