File indexing completed on 2024-12-01 04:35:28

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 "systemmessagesmodeltest.h"
0008 #include "model/systemmessagesmodel.h"
0009 #include <QTest>
0010 QTEST_MAIN(SystemMessagesModelTest)
0011 SystemMessagesModelTest::SystemMessagesModelTest(QObject *parent)
0012     : QObject(parent)
0013 {
0014 }
0015 
0016 void SystemMessagesModelTest::shouldHaveDefaultValues()
0017 {
0018     SystemMessagesModel w;
0019     QCOMPARE(w.rowCount(), 34);
0020     QVERIFY(w.systemMessagesSelected().isEmpty());
0021     QStringList lst;
0022     const int rowCountNb = w.rowCount();
0023     // First one is not a message type
0024     for (int i = 1; i < rowCountNb; i++) {
0025         QStandardItem *itemModel = w.item(i);
0026         if (itemModel) {
0027             lst.append(itemModel->data(SystemMessagesModel::SystemMessages).toString());
0028         }
0029     }
0030     QStringList lstRoles{
0031         QStringLiteral("au"),
0032         QStringLiteral("wm"),
0033         QStringLiteral("ut"),
0034         QStringLiteral("ul"),
0035         QStringLiteral("ult"),
0036         QStringLiteral("uj"),
0037         QStringLiteral("subscription-role-removed"),
0038         QStringLiteral("subscription-role-added"),
0039         QStringLiteral("ru"),
0040         QStringLiteral("room-unarchived"),
0041         QStringLiteral("room_disabled_encryption"),
0042         QStringLiteral("enabled_encryption"),
0043         QStringLiteral("room_changed_privacy"),
0044         QStringLiteral("room_changed_avatar"),
0045         QStringLiteral("mute_unmute"),
0046         QStringLiteral("r"),
0047         QStringLiteral("rm"),
0048         QStringLiteral("room-archived"),
0049         QStringLiteral("room_e2e_enabled"),
0050         QStringLiteral("room_e2e_disabled"),
0051         QStringLiteral("room-removed-read-only"),
0052         QStringLiteral("room-set-read-only"),
0053         QStringLiteral("room-disallowed-reacting"),
0054         QStringLiteral("room-allowed-reacting"),
0055         QStringLiteral("user-added-room-to-team"),
0056         QStringLiteral("user-converted-to-channel"),
0057         QStringLiteral("user-converted-to-team"),
0058         QStringLiteral("user-removed-room-from-team"),
0059         QStringLiteral("user-deleted-room-from-team"),
0060         QStringLiteral("ujt"),
0061         QStringLiteral("removed-user-from-team"),
0062         QStringLiteral("added-user-to-team"),
0063         QStringLiteral("room_changed_topic"),
0064     };
0065 
0066     for (const QString &r : std::as_const(lst)) {
0067         QVERIFY(lstRoles.contains(r));
0068         lstRoles.removeAll(r);
0069     }
0070     QVERIFY(lstRoles.isEmpty());
0071 }
0072 
0073 #include "moc_systemmessagesmodeltest.cpp"