File indexing completed on 2024-05-12 15:51:08
0001 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-License-Identifier: LGPL-3.0-or-later 0003 0004 #include <QAbstractItemModelTester> 0005 #include <QtTest/QtTest> 0006 #include <tableofcontentmodel.h> 0007 0008 class TableOfContentTest : public QObject 0009 { 0010 Q_OBJECT 0011 0012 private Q_SLOTS: 0013 void initTestCase() 0014 { 0015 } 0016 0017 void testModel() 0018 { 0019 TableOfContentModel tocModel; 0020 QAbstractItemModelTester tester(&tocModel); 0021 QFile json; 0022 json.setFileName(QLatin1String(DATA_DIR) + QLatin1String("/mobidick-toc.json")); 0023 json.open(QIODevice::ReadOnly); 0024 0025 tocModel.importFromJson(json.readAll()); 0026 0027 QCOMPARE(tocModel.rowCount(), 142); 0028 QCOMPARE(tocModel.rowCount(tocModel.index(4, 0)), 1); 0029 QVERIFY(tocModel.hasChildren(tocModel.index(4, 0))); 0030 } 0031 }; 0032 0033 QTEST_MAIN(TableOfContentTest) 0034 #include "tableofcontenttest.moc"