File indexing completed on 2025-02-16 04:55:55

0001 /*
0002    SPDX-FileCopyrightText: 2017-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "regexpeditorlineedittest.h"
0008 #include "autocreatescripts/sieveconditions/widgets/regexpeditorlineedit.h"
0009 #include <QHBoxLayout>
0010 #include <QLineEdit>
0011 #include <QTest>
0012 
0013 RegexpEditorLineEditTest::RegexpEditorLineEditTest(QObject *parent)
0014     : QObject(parent)
0015 {
0016 }
0017 
0018 void RegexpEditorLineEditTest::shouldHaveDefaultValue()
0019 {
0020     KSieveUi::RegexpEditorLineEdit w;
0021     auto mLineEdit = w.findChild<QLineEdit *>(QStringLiteral("lineedit"));
0022     QVERIFY(mLineEdit);
0023 
0024     auto mainLayout = w.findChild<QHBoxLayout *>(QStringLiteral("mainlayout"));
0025     QVERIFY(mainLayout);
0026     QCOMPARE(mainLayout->contentsMargins(), QMargins(0, 0, 0, 0));
0027 }
0028 
0029 void RegexpEditorLineEditTest::shouldChangeValue_data()
0030 {
0031     QTest::addColumn<QString>("input");
0032     QTest::newRow("empty") << QString();
0033     QTest::newRow("test1") << QStringLiteral("foo");
0034 }
0035 
0036 void RegexpEditorLineEditTest::shouldChangeValue()
0037 {
0038     QFETCH(QString, input);
0039     KSieveUi::RegexpEditorLineEdit w;
0040     w.setCode(input);
0041     QCOMPARE(w.code(), input);
0042 }
0043 
0044 QTEST_MAIN(RegexpEditorLineEditTest)
0045 
0046 #include "moc_regexpeditorlineedittest.cpp"