From 73b94bcf2fc8094fb5bd9a6f308bdfbb7e91e213 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 25 Apr 2023 11:45:08 +0800 Subject: [PATCH] Add test for maxTags in FileTagModel Signed-off-by: Claudio Cambra --- test/testfiletagmodel.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/testfiletagmodel.cpp b/test/testfiletagmodel.cpp index 5633b642c..2cc7f28eb 100644 --- a/test/testfiletagmodel.cpp +++ b/test/testfiletagmodel.cpp @@ -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) -- 2.30.2