Add test for maxTags in FileTagModel

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-04-25 11:45:08 +08:00
parent 1bab57b176
commit 73b94bcf2f

View file

@ -121,6 +121,23 @@ private slots:
QCOMPARE(tag.toString(), _expectedTags[i]);
}
}
void testModelMaxTags()
{
auto fileTagModel = FileTagModel(testFilePath, _account);
const auto fileTagModelTester = QAbstractItemModelTester(&fileTagModel);
QSignalSpy fileTagsChanged(&fileTagModel, &FileTagModel::totalTagsChanged);
fileTagsChanged.wait(1000);
constexpr auto testMaxTags = 3;
Q_ASSERT(testMaxTags < testNumTags);
QSignalSpy maxTagsChangedSpy(&fileTagModel, &FileTagModel::maxTagsChanged);
fileTagModel.setMaxTags(testMaxTags);
QCOMPARE(maxTagsChangedSpy.count(), 1);
QCOMPARE(fileTagModel.maxTags(), testMaxTags);
QCOMPARE(fileTagModel.rowCount(), testMaxTags);
}
};
QTEST_MAIN(TestFileTagModel)