File indexing completed on 2024-05-19 04:39:50
0001 /* 0002 SPDX-FileCopyrightText: 2007 Alexander Dymo <adymo@kdevelop.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "test_aggregatemodel.h" 0008 0009 // KDevPlatform 0010 #include <sublime/aggregatemodel.h> 0011 // Qt 0012 #include <QAbstractItemModelTester> 0013 #include <QTest> 0014 #include <QStandardItem> 0015 #include <QStandardItemModel> 0016 #include <QStandardPaths> 0017 0018 using namespace Sublime; 0019 0020 void TestAggregateModel::initTestCase() 0021 { 0022 QStandardPaths::setTestModeEnabled(true); 0023 } 0024 0025 void TestAggregateModel::modelAggregationInASingleView() 0026 { 0027 auto *model = new AggregateModel(this); 0028 model->addModel(QStringLiteral("First Model"), newModel()); 0029 model->addModel(QStringLiteral("Second Model"), newModel()); 0030 0031 new QAbstractItemModelTester(model, this); 0032 } 0033 0034 QStandardItemModel * TestAggregateModel::newModel() 0035 { 0036 /* 0037 construct the simple model like: 0038 cool item 0039 item 0 0040 item 1 0041 item 2 0042 item 3 0043 */ 0044 0045 auto *model = new QStandardItemModel(this); 0046 QStandardItem *parentItem = model->invisibleRootItem(); 0047 0048 auto* item = new QStandardItem(QStringLiteral("cool item")); 0049 parentItem->appendRow(item); 0050 0051 for (int i = 0; i < 4; ++i) { 0052 auto* item = new QStandardItem(QStringLiteral("item %0").arg(i)); 0053 parentItem->appendRow(item); 0054 parentItem = item; 0055 } 0056 0057 return model; 0058 } 0059 0060 0061 QTEST_MAIN(TestAggregateModel) 0062 0063 #include "moc_test_aggregatemodel.cpp"