Add test for tags in filetagmodel

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2023-04-24 19:07:42 +08:00
parent ccb07af56a
commit 6c68341422

View 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)