File indexing completed on 2024-12-15 04:55:35

0001 /*
0002    SPDX-FileCopyrightText: 2016-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "importimapsettingsearchpagetest.h"
0008 #include "../importimapsettingsearchpage.h"
0009 #include <QLabel>
0010 #include <QListWidget>
0011 #include <QStandardPaths>
0012 #include <QTest>
0013 #include <QVBoxLayout>
0014 ImportImapSettingSearchPageTest::ImportImapSettingSearchPageTest(QObject *parent)
0015     : QObject(parent)
0016 {
0017     QStandardPaths::setTestModeEnabled(true);
0018 }
0019 
0020 ImportImapSettingSearchPageTest::~ImportImapSettingSearchPageTest() = default;
0021 
0022 void ImportImapSettingSearchPageTest::shouldHaveDefaultValue()
0023 {
0024     ImportImapSettingSearchPage w;
0025     auto label = w.findChild<QLabel *>(QStringLiteral("label"));
0026     QVERIFY(label);
0027     QVERIFY(!label->text().isEmpty());
0028 
0029     auto mFoundProgramList = w.findChild<QListWidget *>(QStringLiteral("foundprogramlist"));
0030     QVERIFY(mFoundProgramList);
0031     QCOMPARE(mFoundProgramList->count(), 0);
0032 
0033     auto mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainlayout"));
0034     QVERIFY(mainLayout);
0035 }
0036 
0037 void ImportImapSettingSearchPageTest::shouldAddCheckPrograms()
0038 {
0039     ImportImapSettingSearchPage w;
0040     const QStringList lst{QStringLiteral("foo"), QStringLiteral("bla"), QStringLiteral("do")};
0041 
0042     w.setProgramList(lst);
0043     auto mFoundProgramList = w.findChild<QListWidget *>(QStringLiteral("foundprogramlist"));
0044     QCOMPARE(mFoundProgramList->count(), lst.count());
0045     for (int i = 0; i < mFoundProgramList->count(); ++i) {
0046         QCOMPARE(mFoundProgramList->item(i)->checkState(), Qt::Unchecked);
0047     }
0048 }
0049 
0050 QTEST_MAIN(ImportImapSettingSearchPageTest)
0051 
0052 #include "moc_importimapsettingsearchpagetest.cpp"