Commit 54778cce authored by Boudewijn Rempt's avatar Boudewijn Rempt

Add test for the tag iterator

parent abe0b038
......@@ -40,27 +40,30 @@ public:
QDirIterator::Subdirectories));
}
bool hasNext() const override { return m_dirIterator->hasNext(); }
bool hasNext() const override
{
return m_dirIterator->hasNext();
}
void next() const override
{
m_dirIterator->next();
load(const_cast<KisTag*>(&m_tag));
const_cast<FolderTagIterator*>(this)->m_tag.reset(new KisTag);
load(m_tag);
}
QString url() const override { return m_tag.url(); }
QString name() const override { return m_tag.name(); }
QString comment() const override {return m_tag.comment(); }
QString url() const override { return m_tag ? m_tag->url() : QString(); }
QString name() const override { return m_tag ? m_tag->name() : QString(); }
QString comment() const override {return m_tag ? m_tag->comment() : QString(); }
QSharedPointer<KisTag> tag() const
{
QSharedPointer<KisTag> t(new KisTag());
load(t.data());
return t;
return m_tag;
}
private:
bool load(KisTag *tag) const
bool load(QSharedPointer<KisTag> tag) const
{
QFile f(m_dirIterator->filePath());
if (f.exists()) {
......@@ -76,7 +79,7 @@ private:
QScopedPointer<QDirIterator> m_dirIterator;
QString m_location;
QString m_resourceType;
KisTag m_tag;
QSharedPointer<KisTag> m_tag;
};
......
......@@ -46,13 +46,25 @@ void TestFolderStorage ::testStorage()
QVERIFY(iter->hasNext());
int count = 0;
while (iter->hasNext()) {
qDebug() << iter->url() << iter->type() << iter->lastModified();
iter->next();
qDebug() << iter->url() << iter->type() << iter->lastModified();
count++;
}
QVERIFY(count == 1);
}
void TestFolderStorage::testTagIterator()
{
KisFolderStorage folderStorage(QString(FILES_DATA_DIR));
QSharedPointer<KisResourceStorage::TagIterator> iter = folderStorage.tags("paintoppresets");
QVERIFY(iter->hasNext());
int count = 0;
while (iter->hasNext()) {
iter->next();
qDebug() << iter->url() << iter->name() << iter->tag();
count++;
}
QVERIFY(count == 1);
}
QTEST_MAIN(TestFolderStorage)
......
......@@ -27,6 +27,7 @@ class TestFolderStorage : public QObject
Q_OBJECT
private Q_SLOTS:
void testStorage();
void testTagIterator();
private:
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment