File indexing completed on 2025-03-23 09:55:59
0001 /* 0002 SPDX-FileCopyrightText: 2019 David Edmundson <davidedmundson@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #include <QObject> 0008 0009 #include <QSignalSpy> 0010 #include <QTest> 0011 0012 #include <QLoggingCategory> 0013 #include <QQmlApplicationEngine> 0014 0015 #include <KConcatenateRowsProxyModel> 0016 0017 #ifdef IMPORT_ITEMMODELSPLUGIN 0018 #include <QPluginLoader> 0019 Q_IMPORT_PLUGIN(Plugin) 0020 #endif 0021 class tst_KConcatenateRowsQml : public QObject 0022 { 0023 Q_OBJECT 0024 private Q_SLOTS: 0025 void initTestCase() 0026 { 0027 // avoid deprecation warning 0028 QLoggingCategory::setFilterRules(QStringLiteral("kf.itemmodels.quick.deprecations.*=false")); 0029 } 0030 void testQmlLoad(); 0031 }; 0032 0033 void tst_KConcatenateRowsQml::testQmlLoad() 0034 { 0035 QQmlApplicationEngine app; 0036 app.load(QFINDTESTDATA("concatenaterowstest.qml")); 0037 0038 QCOMPARE(app.rootObjects().count(), 1); 0039 0040 auto concatModel = qobject_cast<KConcatenateRowsProxyModel *>(app.rootObjects().first()); 0041 QVERIFY(concatModel); 0042 0043 QCOMPARE(concatModel->rowCount(), 4); 0044 0045 QCOMPARE(concatModel->data(concatModel->index(0, 0)).toString(), "a"); 0046 QCOMPARE(concatModel->data(concatModel->index(1, 0)).toString(), "b"); 0047 QCOMPARE(concatModel->data(concatModel->index(2, 0)).toString(), "c"); 0048 QCOMPARE(concatModel->data(concatModel->index(3, 0)).toString(), "d"); 0049 } 0050 0051 QTEST_MAIN(tst_KConcatenateRowsQml) 0052 0053 #include "kconcatenaterows_qml.moc"