diff --git a/addons/externaltools/autotests/CMakeLists.txt b/addons/externaltools/autotests/CMakeLists.txt index 87666f4a2..bf1eda847 100644 --- a/addons/externaltools/autotests/CMakeLists.txt +++ b/addons/externaltools/autotests/CMakeLists.txt @@ -1,11 +1,10 @@ include(ECMMarkAsTest) -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/.. -) - # Project Plugin -add_executable(externaltools_test externaltooltest.cpp) +add_executable(externaltools_test + externaltooltest.cpp + ../kateexternaltool.cpp +) add_test(plugin-externaltools_test externaltools_test) target_link_libraries(externaltools_test kdeinit_kate Qt5::Test) ecm_mark_as_test(externaltools_test) diff --git a/addons/externaltools/autotests/externaltooltest.cpp b/addons/externaltools/autotests/externaltooltest.cpp index a0dc6af8a..55afda896 100644 --- a/addons/externaltools/autotests/externaltooltest.cpp +++ b/addons/externaltools/autotests/externaltooltest.cpp @@ -1,43 +1,69 @@ /* This file is part of the KDE project * * Copyright 2019 Dominik Haumann * * 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 "externaltooltest.h" #include "../kateexternaltool.h" #include - #include -QTEST_MAIN(ToolRunnerTest) +#include +#include + +QTEST_MAIN(ExternalToolTest) + +void ExternalToolTest::initTestCase() +{ +} -void ToolRunnerTest::initTestCase() +void ExternalToolTest::cleanupTestCase() { } -void ToolRunnerTest::cleanupTestCase() +void ExternalToolTest::testLoadSave() { + KConfig config; + KConfigGroup cg(&config, "tool"); + + KateExternalTool tool; + tool.name = QStringLiteral("git cola"); + tool.icon = QStringLiteral("git-cola"); + tool.executable = QStringLiteral("git-cola"); + tool.arguments = QStringLiteral("none"); + tool.command = QStringLiteral("git-cola"); + tool.mimetypes = QStringList{ QStringLiteral("everything") }; + tool.hasexec = true; + tool.actionName = QStringLiteral("asdf"); + tool.cmdname = QStringLiteral("git-cola"); + tool.saveMode = KateExternalTool::SaveMode::None; + + tool.save(cg); + + KateExternalTool copiedTool; + copiedTool.load(cg); + QCOMPARE(tool.name, copiedTool.name); } -void ToolRunnerTest::testToolRunner() +void ExternalToolTest::testToolRunner() { // QCOMPARE(FileUtil::commonParent(QLatin1String("~/dev/proj1"), QLatin1String("~/dev/proj222")), QLatin1String("~/dev/")); } // kate: space-indent on; indent-width 4; replace-tabs on; diff --git a/addons/externaltools/autotests/externaltooltest.h b/addons/externaltools/autotests/externaltooltest.h index 7172bdaa7..910f4938d 100644 --- a/addons/externaltools/autotests/externaltooltest.h +++ b/addons/externaltools/autotests/externaltooltest.h @@ -1,40 +1,41 @@ /* This file is part of the KDE project * * Copyright 2019 Dominik Haumann * * 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 KATE_TOOLRUNNER_TEST_H #define KATE_TOOLRUNNER_TEST_H #include -class ToolRunnerTest : public QObject +class ExternalToolTest : public QObject { Q_OBJECT public Q_SLOTS: void initTestCase(); void cleanupTestCase(); private Q_SLOTS: + void testLoadSave(); void testToolRunner(); }; #endif // kate: space-indent on; indent-width 4; replace-tabs on;