File indexing completed on 2024-04-28 16:49:47

0001 /*
0002     SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl>
0003 
0004     SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
0005 */
0006 
0007 #include <QAbstractItemModelTester>
0008 #include <QTest>
0009 
0010 #include <QDBusInterface>
0011 
0012 #include "SensorTreeModel.h"
0013 
0014 class SensorTreeModelTest : public QObject
0015 {
0016     Q_OBJECT
0017 private Q_SLOTS:
0018     void initTestCase()
0019     {
0020         QDBusInterface interface{QStringLiteral("org.kde.ksystemstats"), QStringLiteral("/")};
0021         if (!interface.isValid()) {
0022             QSKIP("KSystemStats Daemon is not running");
0023         }
0024     }
0025 
0026     void testModel()
0027     {
0028         KSysGuard::SensorTreeModel model;
0029         QAbstractItemModelTester tester(&model);
0030         Q_UNUSED(tester)
0031 
0032         QVERIFY(model.rowCount() == 0);
0033 
0034         QTRY_VERIFY(model.rowCount() > 0);
0035     }
0036 };
0037 
0038 QTEST_MAIN(SensorTreeModelTest);
0039 
0040 #include "sensortreemodeltest.moc"