File indexing completed on 2024-12-29 04:48:25
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "newmailnotificationhistorymanagertest.h" 0008 #include "newmailnotificationhistorymanager.h" 0009 #include <QTest> 0010 QTEST_MAIN(NewMailNotificationHistoryManagerTest) 0011 NewMailNotificationHistoryManagerTest::NewMailNotificationHistoryManagerTest(QObject *parent) 0012 : QObject{parent} 0013 { 0014 } 0015 0016 void NewMailNotificationHistoryManagerTest::shouldHaveDefaultValues() 0017 { 0018 NewMailNotificationHistoryManager w; 0019 QVERIFY(w.history().isEmpty()); 0020 QVERIFY(w.joinHistory().isEmpty()); 0021 } 0022 0023 void NewMailNotificationHistoryManagerTest::generateHtmlFromUniqueEmail() 0024 { 0025 NewMailNotificationHistoryManager w; 0026 w.setTestModeEnabled(true); 0027 NewMailNotificationHistoryManager::HistoryMailInfo info; 0028 info.message = QStringLiteral("Foo bla"); 0029 info.identifier = 45; 0030 w.addEmailInfoNotificationHistory(info); 0031 QString reference = QStringLiteral("<b> %1 </b><br>%2 <a href=\"openmail:%3\">[Show Mail]</a><br>") 0032 .arg(QDate::currentDate().toString()) 0033 .arg(info.message) 0034 .arg(QString::number(info.identifier)); 0035 QCOMPARE(w.joinHistory(), reference); 0036 0037 info.message = QStringLiteral("Mail 2"); 0038 info.identifier = 55; 0039 w.addEmailInfoNotificationHistory(info); 0040 0041 const QString betweenTwoMail = QStringLiteral("<br>"); 0042 reference += betweenTwoMail; 0043 reference += QStringLiteral("<b> %1 </b><br>%2 <a href=\"openmail:%3\">[Show Mail]</a><br>") 0044 .arg(QDate::currentDate().toString()) 0045 .arg(info.message) 0046 .arg(QString::number(info.identifier)); 0047 QCOMPARE(w.joinHistory(), reference); 0048 } 0049 0050 void NewMailNotificationHistoryManagerTest::generateHtmlFromFolders() 0051 { 0052 NewMailNotificationHistoryManager w; 0053 w.setTestModeEnabled(true); 0054 0055 NewMailNotificationHistoryManager::HistoryFolderInfo info; 0056 info.message = QStringLiteral("Foo bla"); 0057 info.identifier = 45; 0058 w.addFoldersInfoNotificationHistory({info}); 0059 0060 QString reference = QStringLiteral("<b> %1 </b><br>%2 <a href=\"openfolder:%3\">[Open Folder]</a><br>") 0061 .arg(QDate::currentDate().toString()) 0062 .arg(info.message) 0063 .arg(QString::number(info.identifier)); 0064 QCOMPARE(w.joinHistory(), reference); 0065 } 0066 0067 #include "moc_newmailnotificationhistorymanagertest.cpp"