From: Claudio Cambra Date: Tue, 25 Apr 2023 03:45:08 +0000 (+0800) Subject: Add test for maxTags in FileTagModel X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~10^2~49^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=73b94bcf2fc8094fb5bd9a6f308bdfbb7e91e213;p=nextcloud-desktop.git Add test for maxTags in FileTagModel Signed-off-by: Claudio Cambra --- 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)