File indexing completed on 2024-10-27 04:50:59
0001 /* 0002 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 0006 */ 0007 0008 #include "potentialphishingdetailwidgettest.h" 0009 #include "../potentialphishingdetailwidget.h" 0010 #include <QLabel> 0011 #include <QListWidget> 0012 #include <QTest> 0013 0014 PotentialPhishingDetailWidgetTest::PotentialPhishingDetailWidgetTest(QObject *parent) 0015 : QObject(parent) 0016 { 0017 } 0018 0019 PotentialPhishingDetailWidgetTest::~PotentialPhishingDetailWidgetTest() = default; 0020 0021 void PotentialPhishingDetailWidgetTest::shouldHaveDefaultValue() 0022 { 0023 PotentialPhishingDetailWidget dlg; 0024 auto searchLabel = dlg.findChild<QLabel *>(QStringLiteral("label")); 0025 QVERIFY(searchLabel); 0026 0027 auto listWidget = dlg.findChild<QListWidget *>(QStringLiteral("list_widget")); 0028 QVERIFY(listWidget); 0029 QCOMPARE(listWidget->count(), 0); 0030 } 0031 0032 void PotentialPhishingDetailWidgetTest::shouldFillList() 0033 { 0034 PotentialPhishingDetailWidget dlg; 0035 auto listWidget = dlg.findChild<QListWidget *>(QStringLiteral("list_widget")); 0036 QStringList lst; 0037 lst << QStringLiteral("bla"); 0038 lst << QStringLiteral("bli"); 0039 lst << QStringLiteral("blo"); 0040 dlg.fillList(lst); 0041 QCOMPARE(listWidget->count(), lst.count()); 0042 } 0043 0044 void PotentialPhishingDetailWidgetTest::shouldClearListBeforeToAddNew() 0045 { 0046 PotentialPhishingDetailWidget dlg; 0047 auto listWidget = dlg.findChild<QListWidget *>(QStringLiteral("list_widget")); 0048 QStringList lst; 0049 lst << QStringLiteral("bla"); 0050 lst << QStringLiteral("bli"); 0051 lst << QStringLiteral("blo"); 0052 dlg.fillList(lst); 0053 QCOMPARE(listWidget->count(), lst.count()); 0054 lst.clear(); 0055 lst << QStringLiteral("bla"); 0056 lst << QStringLiteral("bli"); 0057 dlg.fillList(lst); 0058 QCOMPARE(listWidget->count(), lst.count()); 0059 } 0060 0061 void PotentialPhishingDetailWidgetTest::shouldNotAddDuplicateEntries() 0062 { 0063 PotentialPhishingDetailWidget dlg; 0064 auto listWidget = dlg.findChild<QListWidget *>(QStringLiteral("list_widget")); 0065 QStringList lst; 0066 lst << QStringLiteral("bla"); 0067 lst << QStringLiteral("blo"); 0068 lst << QStringLiteral("blo"); 0069 dlg.fillList(lst); 0070 QCOMPARE(listWidget->count(), (lst.count() - 1)); 0071 } 0072 0073 QTEST_MAIN(PotentialPhishingDetailWidgetTest) 0074 0075 #include "moc_potentialphishingdetailwidgettest.cpp"