File indexing completed on 2024-05-12 05:46:53

0001 /*
0002     Copyright (C) 2019 David Edmundson <davidedmundson@kde.org>
0003 
0004     This library is free software; you can redistribute it and/or modify it
0005     under the terms of the GNU Lesser General Public License as published by
0006     the Free Software Foundation; either version 2.1 of the License, or (at your
0007     option) any later version.
0008 
0009     This library is distributed in the hope that it will be useful, but WITHOUT
0010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
0012     License for more details.
0013 
0014     You should have received a copy of the GNU Library General Public License
0015     along with this library; see the file COPYING.LIB.  If not, write to the
0016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
0017     02110-1301, USA.
0018 */
0019 
0020 #include <QObject>
0021 
0022 #include <QTest>
0023 #include <QSignalSpy>
0024 
0025 #include <QQmlApplicationEngine>
0026 
0027 #include <KConcatenateRowsProxyModel>
0028 
0029 class tst_KConcatenateRowsQml : public QObject
0030 {
0031     Q_OBJECT
0032 private Q_SLOTS:
0033     void testQmlLoad();
0034 };
0035 
0036 void tst_KConcatenateRowsQml::testQmlLoad()
0037 {
0038     QQmlApplicationEngine app;
0039     app.load(QFINDTESTDATA("concatenaterowstest.qml"));
0040 
0041     QCOMPARE(app.rootObjects().count(), 1);
0042 
0043     auto concatModel = qobject_cast<KConcatenateRowsProxyModel*>(app.rootObjects().first());
0044     QVERIFY(concatModel);
0045 
0046     QCOMPARE(concatModel->rowCount(), 4);
0047 
0048     QCOMPARE(concatModel->data(concatModel->index(0, 0)).toString(), "a");
0049     QCOMPARE(concatModel->data(concatModel->index(1, 0)).toString(), "b");
0050     QCOMPARE(concatModel->data(concatModel->index(2, 0)).toString(), "c");
0051     QCOMPARE(concatModel->data(concatModel->index(3, 0)).toString(), "d");
0052 }
0053 
0054 QTEST_MAIN(tst_KConcatenateRowsQml)
0055 
0056 #include "kconcatenaterows_qml.moc"