Commit 2d41e617 authored by Laurent Montel's avatar Laurent Montel 😁

Add autotest

parent 1ca13620
include_directories(${kdebugsettings_BINARY_DIR}/src)
add_definitions( -DKDEBUGSETTINGS_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data" )
set(full_source_file
../src/kdebugsettingsdialog.cpp
../src/customdebugsettingspage.cpp
../src/kdeapplicationdebugsettingpage.cpp
../src/kdebugsettingsutil.cpp
../src/configurecustomsettingdialog.cpp
../src/configurecustomsettingwidget.cpp
../src/environmentsettingsrulespage.cpp
../src/environmentplaintextedit.cpp
../src/categorytypecombobox.cpp
../src/kdeapplicationtreelistwidget.cpp
../src/categorywarning.cpp
../src/loggingcategory.cpp
../src/kdeloggingcategory.cpp
${CMAKE_BINARY_DIR}/src/kdebugsettings_debug.cpp
)
../src/kdebugsettingsdialog.cpp
../src/customdebugsettingspage.cpp
../src/kdeapplicationdebugsettingpage.cpp
../src/kdebugsettingsutil.cpp
../src/configurecustomsettingdialog.cpp
../src/configurecustomsettingwidget.cpp
../src/environmentsettingsrulespage.cpp
../src/environmentplaintextedit.cpp
../src/categorytypecombobox.cpp
../src/kdeapplicationtreelistwidget.cpp
../src/categorywarning.cpp
../src/loggingcategory.cpp
../src/kdeloggingcategory.cpp
../src/loadcategoriesjob.cpp
${CMAKE_BINARY_DIR}/src/kdebugsettings_debug.cpp
)
# convenience macro to add qtest unit tests
macro(add_unittest _source _additionalsource)
set(_test ${_source} ${_additionalsource})
get_filename_component(_name ${_source} NAME_WE)
add_executable( ${_name} ${_test} )
add_test( ${_name} ${_name} )
ecm_mark_as_test(kdebugsettings-${_name})
target_link_libraries( ${_name}
Qt5::Test
KF5::I18n
Qt5::Widgets
KF5::ConfigCore
KF5::WidgetsAddons
KF5::ItemViews
KF5::Completion
)
set(_test ${_source} ${_additionalsource})
get_filename_component(_name ${_source} NAME_WE)
add_executable( ${_name} ${_test} )
add_test( ${_name} ${_name} )
ecm_mark_as_test(kdebugsettings-${_name})
target_link_libraries( ${_name}
Qt5::Test
KF5::I18n
Qt5::Widgets
KF5::ConfigCore
KF5::WidgetsAddons
KF5::ItemViews
KF5::Completion
)
endmacro ()
add_unittest( kdebugsettingsdialogtest.cpp "${full_source_file}")
......@@ -47,3 +49,4 @@ add_unittest( categorytypecomboboxtest.cpp "../src/loggingcategory.cpp;../src/ca
add_unittest( kdeapplicationtreelistwidgettest.cpp "../src/loggingcategory.cpp;../src/kdeapplicationtreelistwidget.cpp;../src/categorytypecombobox.cpp")
add_unittest( categorywarningtest.cpp "../src/categorywarning.cpp")
add_unittest( loggingcategorytest.cpp "../src/loggingcategory.cpp")
add_unittest( loadcategoriesjobtest.cpp "../src/loadcategoriesjob.cpp;../src/loggingcategory.cpp;../src/kdeloggingcategory.cpp;../src/kdebugsettings_debug.cpp;../src/kdebugsettingsutil.cpp")
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#include "loadcategoriesjobtest.h"
#include "../src/loadcategoriesjob.h"
#include <QTest>
#include <QFile>
#include <QDebug>
LoadCategoriesJobTest::LoadCategoriesJobTest(QObject *parent)
: QObject(parent)
{
}
LoadCategoriesJobTest::~LoadCategoriesJobTest()
{
}
void LoadCategoriesJobTest::shouldHaveDefaultValue()
{
LoadCategoriesJob job;
QVERIFY(job.customCategories().isEmpty());
QVERIFY(!job.foundOverrideRule());
QVERIFY(job.qtKdeCategories().isEmpty());
}
void LoadCategoriesJobTest::shouldReadRules_data()
{
QTest::addColumn<QString>("filename");
QTest::addColumn<KdeLoggingCategory::List>("listKdeLoggingCategories");
QTest::addColumn<bool>("foundoverriderules");
QTest::newRow("empty") << QString(QLatin1String(KDEBUGSETTINGS_DATA_DIR) + QLatin1Char('/') + QStringLiteral("emptyrulefiles.ini")) << KdeLoggingCategory::List() << false;
}
void LoadCategoriesJobTest::shouldReadRules()
{
QFETCH(QString, filename);
QFETCH(KdeLoggingCategory::List, listKdeLoggingCategories);
QFETCH(bool, foundoverriderules);
QFile file(filename);
QVERIFY(file.exists());
LoadCategoriesJob job;
job.setFileName(filename);
QVERIFY(job.customCategories().isEmpty());
QCOMPARE(job.foundOverrideRule(), foundoverriderules);
QVERIFY(job.qtKdeCategories().isEmpty());
}
QTEST_MAIN(LoadCategoriesJobTest)
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
This library is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to the
Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.
*/
#ifndef LOADCATEGORIESJOBTEST_H
#define LOADCATEGORIESJOBTEST_H
#include <QObject>
class LoadCategoriesJobTest : public QObject
{
Q_OBJECT
public:
explicit LoadCategoriesJobTest(QObject *parent = Q_NULLPTR);
~LoadCategoriesJobTest();
private Q_SLOTS:
void shouldHaveDefaultValue();
void shouldReadRules_data();
void shouldReadRules();
};
#endif // LOADCATEGORIESJOBTEST_H
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