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

0001 /*
0002    SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "usersmodeltest.h"
0008 #include "model/usersmodel.h"
0009 #include <QSignalSpy>
0010 #include <QTest>
0011 
0012 QTEST_GUILESS_MAIN(UsersModelTest)
0013 
0014 UsersModelTest::UsersModelTest(QObject *parent)
0015     : QObject(parent)
0016 {
0017 }
0018 
0019 void UsersModelTest::shouldHaveDefaultValue()
0020 {
0021     UsersModel w;
0022     QSignalSpy rowInsertedSpy(&w, &UsersModel::rowsInserted);
0023     QSignalSpy rowABTInserted(&w, &UsersModel::rowsAboutToBeInserted);
0024     QSignalSpy rowRemovedSpy(&w, &UsersModel::rowsRemoved);
0025     QSignalSpy rowABTRemoved(&w, &UsersModel::rowsAboutToBeRemoved);
0026     QSignalSpy userStatusChangedSpy(&w, &UsersModel::userStatusChanged);
0027     QCOMPARE(w.rowCount(), 0);
0028     QCOMPARE(rowInsertedSpy.count(), 0);
0029     QCOMPARE(rowABTInserted.count(), 0);
0030     QCOMPARE(userStatusChangedSpy.count(), 0);
0031     QCOMPARE(rowRemovedSpy.count(), 0);
0032     QCOMPARE(rowABTRemoved.count(), 0);
0033 }
0034 
0035 void UsersModelTest::shouldRemoveUser()
0036 {
0037     UsersModel w;
0038     QSignalSpy rowInsertedSpy(&w, &UsersModel::rowsInserted);
0039     QSignalSpy rowABTInserted(&w, &UsersModel::rowsAboutToBeInserted);
0040     QSignalSpy rowRemovedSpy(&w, &UsersModel::rowsRemoved);
0041     QSignalSpy rowABTRemoved(&w, &UsersModel::rowsAboutToBeRemoved);
0042     QSignalSpy userStatusChangedSpy(&w, &UsersModel::userStatusChanged);
0043     QCOMPARE(w.rowCount(), 0);
0044     QCOMPARE(rowInsertedSpy.count(), 0);
0045     QCOMPARE(rowABTInserted.count(), 0);
0046     QCOMPARE(userStatusChangedSpy.count(), 0);
0047     QCOMPARE(rowRemovedSpy.count(), 0);
0048     QCOMPARE(rowABTRemoved.count(), 0);
0049 }
0050 
0051 #include "moc_usersmodeltest.cpp"