From 6c683414225d28f93acf1b57acaa68e55a062164 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Mon, 24 Apr 2023 19:07:42 +0800 Subject: [PATCH] Add test for tags in filetagmodel Signed-off-by: Claudio Cambra --- test/testfiletagmodel.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/testfiletagmodel.cpp b/test/testfiletagmodel.cpp index 59cab8e87..5633b642c 100644 --- a/test/testfiletagmodel.cpp +++ b/test/testfiletagmodel.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #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)