File indexing completed on 2025-01-05 04:58:20
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 "blacklistbalooemailutiltest.h" 0009 #include "../blacklistbalooemailutil.h" 0010 #include <QTest> 0011 BlackListBalooEmailUtilTest::BlackListBalooEmailUtilTest(QObject *parent) 0012 : QObject(parent) 0013 { 0014 } 0015 0016 BlackListBalooEmailUtilTest::~BlackListBalooEmailUtilTest() = default; 0017 0018 void BlackListBalooEmailUtilTest::shouldReturnEmptyResult() 0019 { 0020 PimCommon::BlackListBalooEmailUtil util; 0021 QVERIFY(util.createNewBlackList().isEmpty()); 0022 } 0023 0024 void BlackListBalooEmailUtilTest::shouldDontChangeWhenNotChanged() 0025 { 0026 PimCommon::BlackListBalooEmailUtil util; 0027 const QStringList lst = QStringList() << QStringLiteral("foo") << QStringLiteral("foo1") << QStringLiteral("foo2"); 0028 util.initialBlackList(lst); 0029 QCOMPARE(util.createNewBlackList(), lst); 0030 } 0031 0032 void BlackListBalooEmailUtilTest::shouldCreateNewList() 0033 { 0034 PimCommon::BlackListBalooEmailUtil util; 0035 const QStringList lst = QStringList() << QStringLiteral("foo") << QStringLiteral("foo1") << QStringLiteral("foo2"); 0036 util.initialBlackList(lst); 0037 QHash<QString, bool> newList; 0038 newList.insert(QStringLiteral("foo"), false); 0039 util.setNewBlackList(newList); 0040 QCOMPARE(util.createNewBlackList(), QStringList() << QStringLiteral("foo1") << QStringLiteral("foo2")); 0041 } 0042 0043 void BlackListBalooEmailUtilTest::shouldAddNewElements() 0044 { 0045 PimCommon::BlackListBalooEmailUtil util; 0046 QHash<QString, bool> newList; 0047 newList.insert(QStringLiteral("foo"), false); 0048 newList.insert(QStringLiteral("foo1"), false); 0049 newList.insert(QStringLiteral("foo2"), false); 0050 util.setNewBlackList(newList); 0051 QCOMPARE(util.createNewBlackList().count(), 0); 0052 0053 newList.clear(); 0054 newList.insert(QStringLiteral("foo"), true); 0055 newList.insert(QStringLiteral("foo1"), true); 0056 newList.insert(QStringLiteral("foo2"), true); 0057 util.setNewBlackList(newList); 0058 QCOMPARE(util.createNewBlackList().count(), 3); 0059 } 0060 0061 QTEST_MAIN(BlackListBalooEmailUtilTest) 0062 0063 #include "moc_blacklistbalooemailutiltest.cpp"