Add test for tags in filetagmodel
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 24 Apr 2023 11:07:42 +0000 (19:07 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 16 May 2023 10:23:33 +0000 (18:23 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
test/testfiletagmodel.cpp

index 59cab8e870886d4bba61bf182ada01ccae022a98..5633b642cb66ab674d1805384cf394b507e16202 100644 (file)
@@ -17,6 +17,7 @@
 #include <QTest>
 #include <QSignalSpy>
 #include <QDomDocument>
+#include <QAbstractItemModelTester>
 
 #include "accountmanager.h"
 #include "syncenginetestutils.h"
@@ -102,6 +103,24 @@ private slots:
             "two"
         };
     }
+
+    void testModelTagFetch()
+    {
+        auto fileTagModel = FileTagModel(testFilePath, _account);
+        const auto fileTagModelTester = QAbstractItemModelTester(&fileTagModel);
+        QSignalSpy fileTagsChanged(&fileTagModel, &FileTagModel::totalTagsChanged);
+        fileTagsChanged.wait(1000);
+
+        const auto modelTotalTags = fileTagModel.totalTags();
+        QCOMPARE(modelTotalTags, testNumTags);
+
+        for (auto i = 0; i < modelTotalTags; ++i) {
+            const auto index = fileTagModel.index(i);
+            const auto tag = index.data();
+
+            QCOMPARE(tag.toString(), _expectedTags[i]);
+        }
+    }
 };
 
 QTEST_MAIN(TestFileTagModel)