Commit abdcc06b authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Add test for filter



Signed-off-by: Claudio Cambra's avatarClaudio Cambra <claudio.cambra@kde.org>
parent c8527c16
Pipeline #248926 passed with stage
in 3 minutes and 55 seconds
......@@ -25,6 +25,11 @@ set (commonAkonadiTest_LIBS
KF5::EventViews
)
set(filterTest_SRCS
filtertest.cpp
../src/filter.cpp
)
set(incidenceOccurrenceModelTest_SRCS
incidenceoccurrencemodeltest.cpp
../src/models/incidenceoccurrencemodel.cpp
......@@ -39,6 +44,11 @@ set(todoSortFilterProxyModelTest_SRCS
ecm_qt_declare_logging_category(incidenceOccurrenceModelTest_SRCS HEADER kalendar_debug.h IDENTIFIER KALENDAR_LOG CATEGORY_NAME org.kde.kalendar DESCRIPTION "kalendar" EXPORT KALENDAR)
add_executable(filtertest ${filterTest_SRCS})
add_test(NAME filtertest COMMAND filtertest)
ecm_mark_as_test(filtertest)
target_link_libraries(filtertest ${commonAkonadiTest_LIBS})
# the tests need the ical resource, which we might not have at this point (e.g. on the CI)
find_program(AKONADI_ICAL_RESOURCE NAMES akonadi_ical_resource)
if (UNIX)
......
// SPDX-FileCopyrightText: 2022 Claudio Cambra <claudio.cambra@gmail.com>
// SPDX-License-Identifier: LGPL-2.0-or-later
#include "../src/filter.h"
#include <QTest>
#include <QSignalSpy>
class FilterTest : public QObject
{
Q_OBJECT
public:
FilterTest() = default;
~FilterTest() override = default;
private:
static constexpr qint64 m_testCollectionId = 1;
const QString m_testName = QStringLiteral("name");
const QStringList m_testTags {QStringLiteral("tag-1"),
QStringLiteral("tag-2"),
QStringLiteral("tag-3")};
private Q_SLOTS:
void initTestCase()
{
}
void testProperties()
{
Filter filter;
QSignalSpy collectionIdChanged(&filter, &Filter::collectionIdChanged);
QSignalSpy tagsChanged(&filter, &Filter::tagsChanged);
QSignalSpy nameChanged(&filter, &Filter::nameChanged);
filter.setCollectionId(m_testCollectionId);
QCOMPARE(collectionIdChanged.count(), 1);
QCOMPARE(filter.collectionId(), m_testCollectionId);
filter.setTags(m_testTags);
QCOMPARE(tagsChanged.count(), 1);
QCOMPARE(filter.tags(), m_testTags);
filter.setName(m_testName);
QCOMPARE(nameChanged.count(), 1);
QCOMPARE(filter.name(), m_testName);
}
};
QTEST_MAIN(FilterTest)
#include "filtertest.moc"
Supports Markdown
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