Commit b5271566 authored by Glen Ditchfield's avatar Glen Ditchfield 🐛
Browse files

Fix autotest koeventpopupmenutest

 * Deleted createEventFromEvent() because the event-specific menu no
   longer has a menu item that creates another event.  Deleted
   createTodoFromTodo() for the same reason.

 * The other create* tests were failing because menu items no longer have
   object names.  Switched to C-locale item text; since it is key to
   i18n, it should be stable.

 * Deleted

 * Deleted defaultMenuEventVisible() because the "is visible" tests are
   covered by other tests, and the "not visible" test is an implementation
   detail.  Deleted defaultMenuTodoVisible() for the same reason.
parent 6e6f769c
Pipeline #20781 failed with stage
in 7 minutes and 38 seconds
......@@ -28,50 +28,23 @@
#include <QStandardPaths>
#include <QTest>
KoEventPopupMenuTest::KoEventPopupMenuTest(QObject *parent)
: QObject(parent)
{
QStandardPaths::setTestModeEnabled(true);
qputenv("LC_ALL", "C");
}
void KoEventPopupMenuTest::createEventFromEvent()
static QAction *itemWithText(KOEventPopupMenu *m, const char *t)
{
Akonadi::ETMCalendar::Ptr calendar(new Akonadi::ETMCalendar());
KOEventPopupMenu menu(nullptr);
KCalendarCore::Event::Ptr event(new KCalendarCore::Event());
Akonadi::Item item;
item.setMimeType(KCalendarCore::Event::eventMimeType());
item.setPayload<KCalendarCore::Event::Ptr>(event);
menu.setCalendar(calendar);
menu.showIncidencePopup(item, QDate());
QAction *createevent = menu.findChild<QAction *>(QStringLiteral("createevent"));
createevent->trigger();
IncidenceEditorNG::IncidenceDialog *dlg
= menu.findChild<IncidenceEditorNG::IncidenceDialog *>(QStringLiteral("incidencedialog"));
QVERIFY(!dlg);
}
void KoEventPopupMenuTest::createTodoFromTodo()
{
Akonadi::ETMCalendar::Ptr calendar(new Akonadi::ETMCalendar());
KOEventPopupMenu menu(nullptr);
KCalendarCore::Todo::Ptr todo(new KCalendarCore::Todo());
Akonadi::Item item;
item.setMimeType(KCalendarCore::Todo::todoMimeType());
item.setPayload<KCalendarCore::Todo::Ptr>(todo);
menu.setCalendar(calendar);
menu.showIncidencePopup(item, QDate());
QAction *createtodo = menu.findChild<QAction *>(QStringLiteral("createtodo"));
createtodo->trigger();
IncidenceEditorNG::IncidenceDialog *dlg
= menu.findChild<IncidenceEditorNG::IncidenceDialog *>(QStringLiteral("incidencedialog"));
QVERIFY(!dlg);
auto text = QString::fromLatin1(t);
for (auto item : m->findChildren<QAction *>()) {
if (item->text() == text && item->isVisible() && item->isEnabled()) {
return item;
}
}
return nullptr;
}
void KoEventPopupMenuTest::createEventFromTodo()
......@@ -94,7 +67,8 @@ void KoEventPopupMenuTest::createEventFromTodo()
menu.setCalendar(calendar);
menu.showIncidencePopup(item, QDate());
QAction *createevent = menu.findChild<QAction *>(QStringLiteral("createevent"));
QAction *createevent = itemWithText(&menu, "Create Event from To-do");
QVERIFY2(createevent, "menu item missing, invisible, or disabled");
createevent->trigger();
IncidenceEditorNG::IncidenceDialog *dlg
= menu.findChild<IncidenceEditorNG::IncidenceDialog *>();
......@@ -130,7 +104,8 @@ void KoEventPopupMenuTest::createTodoFromEvent()
menu.setCalendar(calendar);
menu.showIncidencePopup(item, QDate());
QAction *createtodo = menu.findChild<QAction *>(QStringLiteral("createtodo"));
QAction *createtodo = itemWithText(&menu, "Create To-do from Event");
QVERIFY2(createtodo, "menu item missing, invisible, or disabled");
createtodo->trigger();
IncidenceEditorNG::IncidenceDialog *dlg
= menu.findChild<IncidenceEditorNG::IncidenceDialog *>();
......@@ -168,7 +143,8 @@ void KoEventPopupMenuTest::createNoteFromEvent()
menu.setCalendar(calendar);
menu.showIncidencePopup(item, QDate());
QAction *createnote = menu.findChild<QAction *>(QStringLiteral("createnote"));
QAction *createnote = itemWithText(&menu, "Create Note for Event");
QVERIFY2(createnote, "menu item missing, invisible, or disabled");
CalendarSupport::NoteEditDialog *noteedit = menu.findChild<CalendarSupport::NoteEditDialog *>();
QVERIFY(!noteedit);
createnote->trigger();
......@@ -206,7 +182,8 @@ void KoEventPopupMenuTest::createNoteFromTodo()
menu.setCalendar(calendar);
menu.showIncidencePopup(item, QDate());
QAction *createnote = menu.findChild<QAction *>(QStringLiteral("createnote"));
QAction *createnote = itemWithText(&menu, "Create Note for To-do");
QVERIFY2(createnote, "menu item missing, invisible, or disabled");
CalendarSupport::NoteEditDialog *noteedit = menu.findChild<CalendarSupport::NoteEditDialog *>();
QVERIFY(!noteedit);
......@@ -222,45 +199,4 @@ void KoEventPopupMenuTest::createNoteFromTodo()
QCOMPARE(note.attachments().at(0).data(), QByteArray());
}
void KoEventPopupMenuTest::defaultMenuEventVisible()
{
Akonadi::ETMCalendar::Ptr calendar(new Akonadi::ETMCalendar());
KOEventPopupMenu menu(nullptr);
KCalendarCore::Event::Ptr event(new KCalendarCore::Event());
Akonadi::Item item;
item.setMimeType(KCalendarCore::Event::eventMimeType());
item.setPayload<KCalendarCore::Event::Ptr>(event);
menu.setCalendar(calendar);
menu.showIncidencePopup(item, QDate());
QAction *createevent = menu.findChild<QAction *>(QStringLiteral("createevent"));
QAction *createnote = menu.findChild<QAction *>(QStringLiteral("createnote"));
QAction *createtodo = menu.findChild<QAction *>(QStringLiteral("createtodo"));
QVERIFY(!createevent->isVisible());
QVERIFY(createnote->isVisible());
QVERIFY(createtodo->isVisible());
}
void KoEventPopupMenuTest::defaultMenuTodoVisible()
{
Akonadi::ETMCalendar::Ptr calendar(new Akonadi::ETMCalendar());
KOEventPopupMenu menu(nullptr);
KCalendarCore::Todo::Ptr todo(new KCalendarCore::Todo());
Akonadi::Item item;
item.setMimeType(KCalendarCore::Todo::todoMimeType());
item.setPayload<KCalendarCore::Todo::Ptr>(todo);
menu.setCalendar(calendar);
menu.showIncidencePopup(item, QDate());
QAction *createevent = menu.findChild<QAction *>(QStringLiteral("createevent"));
QAction *createnote = menu.findChild<QAction *>(QStringLiteral("createnote"));
QAction *createtodo = menu.findChild<QAction *>(QStringLiteral("createtodo"));
QVERIFY(createevent->isVisible());
QVERIFY(createnote->isVisible());
QVERIFY(!createtodo->isVisible());
}
QTEST_MAIN(KoEventPopupMenuTest)
......@@ -34,12 +34,8 @@ public:
private Q_SLOTS:
void createEventFromTodo();
void createTodoFromEvent();
void createEventFromEvent();
void createTodoFromTodo();
void createNoteFromEvent();
void createNoteFromTodo();
void defaultMenuEventVisible();
void defaultMenuTodoVisible();
};
#endif // KOEVENTPOPUPMENUTESTTEST_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment