File indexing completed on 2025-03-09 04:54:37
0001 /* 0002 SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "remotecontentmanagertest.h" 0008 #include "remote-content/remotecontentinfo.h" 0009 #include <QStandardPaths> 0010 #include <QTest> 0011 QTEST_MAIN(RemoteContentManagerTest) 0012 RemoteContentManagerTest::RemoteContentManagerTest(QObject *parent) 0013 : QObject(parent) 0014 { 0015 QStandardPaths::setTestModeEnabled(true); 0016 } 0017 0018 RemoteContentManagerTest::~RemoteContentManagerTest() 0019 { 0020 mRemoveContentManager.clear(); 0021 } 0022 0023 void RemoteContentManagerTest::shouldHaveDefaultValues() 0024 { 0025 QVERIFY(mRemoveContentManager.removeContentInfo().isEmpty()); 0026 } 0027 0028 void RemoteContentManagerTest::shouldIsBlocked_data() 0029 { 0030 QTest::addColumn<QUrl>("url"); 0031 QTest::addColumn<bool>("blocked"); 0032 QTest::addColumn<bool>("contains"); 0033 QTest::newRow("empty") << QUrl() << false << false; 0034 MessageViewer::RemoteContentInfo info; 0035 info.setUrl(QStringLiteral("http://www.kde.org")); 0036 info.setStatus(MessageViewer::RemoteContentInfo::RemoteContentInfoStatus::Blocked); 0037 0038 mRemoveContentManager.addRemoteContent(info); 0039 QTest::newRow("kde-blocked") << QUrl(QStringLiteral("http://www.kde.org")) << false << true; 0040 MessageViewer::RemoteContentInfo info2; 0041 info2.setUrl(QStringLiteral("http://www.kde2.org")); 0042 info2.setStatus(MessageViewer::RemoteContentInfo::RemoteContentInfoStatus::Authorized); 0043 mRemoveContentManager.addRemoteContent(info2); 0044 0045 QTest::newRow("kde-authorized") << QUrl(QStringLiteral("http://www.kde2.org")) << true << true; 0046 } 0047 0048 void RemoteContentManagerTest::shouldIsBlocked() 0049 { 0050 QFETCH(QUrl, url); 0051 QFETCH(bool, blocked); 0052 QFETCH(bool, contains); 0053 bool isInList = false; 0054 const bool result = mRemoveContentManager.isAutorized(url, isInList); 0055 QCOMPARE(isInList, contains); 0056 QCOMPARE(blocked, result); 0057 } 0058 0059 #include "moc_remotecontentmanagertest.cpp"