File indexing completed on 2024-11-10 04:50:01

0001 /*
0002   SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>
0003 
0004   SPDX-License-Identifier: GPL-2.0-only
0005 */
0006 
0007 #include "filterconverttosieveresultdialogtest.h"
0008 #include "../filterconverter/filterconverttosieveresultdialog.h"
0009 #include <QDialogButtonBox>
0010 #include <QPushButton>
0011 #include <QStandardPaths>
0012 #include <QTest>
0013 #include <TextCustomEditor/PlainTextEditorWidget>
0014 FilterConvertToSieveResultDialogTest::FilterConvertToSieveResultDialogTest(QObject *parent)
0015     : QObject(parent)
0016 {
0017     QStandardPaths::setTestModeEnabled(true);
0018 }
0019 
0020 FilterConvertToSieveResultDialogTest::~FilterConvertToSieveResultDialogTest() = default;
0021 
0022 void FilterConvertToSieveResultDialogTest::shouldHaveDefaultValue()
0023 {
0024     MailCommon::FilterConvertToSieveResultDialog dlg;
0025     auto buttonBox = dlg.findChild<QDialogButtonBox *>(QStringLiteral("buttonbox"));
0026     QVERIFY(buttonBox);
0027 
0028     auto saveButton = dlg.findChild<QPushButton *>(QStringLiteral("savebutton"));
0029     QVERIFY(saveButton);
0030 
0031     auto editor = dlg.findChild<TextCustomEditor::PlainTextEditorWidget *>(QStringLiteral("editor"));
0032     QVERIFY(editor);
0033     QVERIFY(editor->toPlainText().isEmpty());
0034 }
0035 
0036 void FilterConvertToSieveResultDialogTest::shouldAddCode()
0037 {
0038     MailCommon::FilterConvertToSieveResultDialog dlg;
0039 
0040     auto editor = dlg.findChild<TextCustomEditor::PlainTextEditorWidget *>(QStringLiteral("editor"));
0041     QVERIFY(editor->toPlainText().isEmpty());
0042     const QString code = QStringLiteral("foo");
0043     dlg.setCode(code);
0044     QCOMPARE(editor->toPlainText(), code);
0045 }
0046 
0047 QTEST_MAIN(FilterConvertToSieveResultDialogTest)
0048 
0049 #include "moc_filterconverttosieveresultdialogtest.cpp"