File indexing completed on 2024-12-01 04:35:24
0001 /* 0002 SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #include "filesforroomfilterproxymodeltest.h" 0008 #include "model/filesforroomfilterproxymodel.h" 0009 #include "model/filesforroommodel.h" 0010 #include <QTest> 0011 QTEST_GUILESS_MAIN(FilesForRoomFilterProxyModelTest) 0012 0013 FilesForRoomFilterProxyModelTest::FilesForRoomFilterProxyModelTest(QObject *parent) 0014 : QObject(parent) 0015 { 0016 } 0017 0018 void FilesForRoomFilterProxyModelTest::shouldHaveDefaultValue() 0019 { 0020 } 0021 0022 void FilesForRoomFilterProxyModelTest::shouldHaveDefaultValues() 0023 { 0024 FilesForRoomModel model; 0025 FilesForRoomFilterProxyModel proxy(&model); 0026 QCOMPARE(proxy.rowCount(), 0); 0027 QCOMPARE(proxy.filterCaseSensitivity(), Qt::CaseInsensitive); 0028 QCOMPARE(proxy.filterRole(), FilesForRoomModel::FileName); 0029 QCOMPARE(proxy.sortRole(), FilesForRoomModel::SortByTimeStamp); 0030 } 0031 0032 void FilesForRoomFilterProxyModelTest::shouldAssignValue() 0033 { 0034 FilesForRoomFilterProxyModel proxy; 0035 FilesForRoomModel model; 0036 proxy.setSourceModel(&model); 0037 QVector<File> mFiles; 0038 for (int i = 0; i < 10; ++i) { 0039 File f; 0040 f.setFileName(QStringLiteral("name%1").arg(i)); 0041 f.setDescription(QStringLiteral("description%1").arg(i)); 0042 f.setUserId(QStringLiteral("userid%1").arg(i)); 0043 mFiles.append(std::move(f)); 0044 } 0045 model.setFiles(mFiles); 0046 QCOMPARE(model.rowCount(), 10); 0047 QCOMPARE(proxy.rowCount(), 10); 0048 0049 mFiles.clear(); 0050 for (int i = 0; i < 3; ++i) { 0051 File f; 0052 f.setFileName(QStringLiteral("name%1").arg(i)); 0053 f.setDescription(QStringLiteral("description%1").arg(i)); 0054 f.setUserId(QStringLiteral("userid%1").arg(i)); 0055 mFiles.append(std::move(f)); 0056 } 0057 model.setFiles(mFiles); 0058 QCOMPARE(model.rowCount(), 3); 0059 QCOMPARE(proxy.rowCount(), 3); 0060 } 0061 0062 #include "moc_filesforroomfilterproxymodeltest.cpp"