Commit faae4147 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

Properly isolate tests and re-enable check for default collection

First make sure the test is not overwriting actual config files
when running locally. Then we can write fake values into the config
to make the check for default pre-selected collection work again.
parent ad9b2464
......@@ -47,6 +47,7 @@ EventEditTest::EventEditTest()
qRegisterMetaType<Akonadi::Collection>();
qRegisterMetaType<KMime::Message::Ptr>();
qRegisterMetaType<KCalCore::Event::Ptr>();
QStandardPaths::setTestModeEnabled(true);
QStandardItemModel *model = new QStandardItemModel;
for (int id = 42; id < 51; ++id) {
......@@ -64,12 +65,14 @@ EventEditTest::EventEditTest()
model->appendRow(item);
}
MessageViewer::_k_eventEditStubModel = model;
// Fake a default-selected collection for shouldHaveDefaultValuesOnCreation test
MessageViewer::MessageViewerSettingsBase::self()->setLastEventSelectedFolder(43);
}
void EventEditTest::shouldHaveDefaultValuesOnCreation()
{
MessageViewer::EventEdit edit;
//We can't test it. Collection value is stored in settings here, and not in jenkins so disable it
QVERIFY(edit.collection().isValid());
QVERIFY(!edit.message());
QLineEdit *eventedit = edit.findChild<QLineEdit *>(QStringLiteral("eventedit"));
......
......@@ -42,6 +42,7 @@ NoteEditTest::NoteEditTest()
{
qRegisterMetaType<Akonadi::Collection>();
qRegisterMetaType<KMime::Message::Ptr>();
QStandardPaths::setTestModeEnabled(true);
QStandardItemModel *model = new QStandardItemModel;
for (int id = 42; id < 51; ++id) {
......@@ -59,13 +60,16 @@ NoteEditTest::NoteEditTest()
model->appendRow(item);
}
MessageViewer::_k_noteEditStubModel = model;
// Fake a default-selected collection for shouldHaveDefaultValuesOnCreation test
MessageViewer::MessageViewerSettingsBase::self()->setLastEventSelectedFolder(43);
}
void NoteEditTest::shouldHaveDefaultValuesOnCreation()
{
MessageViewer::NoteEdit edit;
//We can't test if because it loads from settings and in Jenkins it doesn't exist but here it exists
//QVERIFY(edit.collection().isValid());
QVERIFY(edit.collection().isValid());
QVERIFY(!edit.message());
QLineEdit *noteedit = edit.findChild<QLineEdit *>(QStringLiteral("noteedit"));
QPushButton *save = edit.findChild<QPushButton *>(QStringLiteral("save-button"));
......
......@@ -44,6 +44,7 @@ TodoEditTest::TodoEditTest()
qRegisterMetaType<Akonadi::Collection>();
qRegisterMetaType<KMime::Message::Ptr>();
qRegisterMetaType<KCalCore::Todo::Ptr>();
QStandardPaths::setTestModeEnabled(true);
QStandardItemModel *model = new QStandardItemModel;
for (int id = 42; id < 51; ++id) {
......@@ -61,13 +62,15 @@ TodoEditTest::TodoEditTest()
model->appendRow(item);
}
MessageViewer::_k_todoEditStubModel = model;
// Fake a default-selected collection for shouldHaveDefaultValuesOnCreation test
MessageViewer::MessageViewerSettingsBase::self()->setLastEventSelectedFolder(43);
}
void TodoEditTest::shouldHaveDefaultValuesOnCreation()
{
MessageViewer::TodoEdit edit;
//We can't test if because it loads from settings and in Jenkins it doesn't exist but here it exists
//QVERIFY(edit.collection().isValid());
QVERIFY(edit.collection().isValid());
QVERIFY(!edit.message());
QLineEdit *noteedit = edit.findChild<QLineEdit *>(QStringLiteral("noteedit"));
QPushButton *openEditor = edit.findChild<QPushButton *>(QStringLiteral("open-editor-button"));
......
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