Commit afcb9243 authored by Kuntal  Majumder's avatar Kuntal Majumder 😟

Added initial structure for KisMagneticWorkerTest

Ref T10894
parent a3a4a7bf
if (NOT WIN32 AND NOT APPLE)
add_subdirectory(tests)
endif()
set(kritaselectiontools_SOURCES
selection_tools.cc
kis_tool_select_rectangular.cc
......@@ -8,12 +12,15 @@ set(kritaselectiontools_SOURCES
kis_tool_select_path.cc
kis_tool_select_similar.cc
kis_selection_modifier_mapper.cc
KisMagneticWorker.cc
)
qt5_add_resources(kritaselectiontools_SOURCES selectiontools.qrc)
add_library(kritaselectiontools MODULE ${kritaselectiontools_SOURCES})
generate_export_header(kritaselectiontools BASE_NAME kritaselectiontools)
target_link_libraries(kritaselectiontools kritaui kritabasicflakes)
install(TARGETS kritaselectiontools DESTINATION ${KRITA_PLUGIN_INSTALL_DIR})
......
/*
* Copyright (c) 2019 Kuntal Majumder <hellozee@disroot.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1 of the License.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "KisMagneticWorker.h"
#include "kis_gaussian_kernel.h"
#include <QtCore>
void KisMagneticWorker::run(KisPaintDeviceSP dev, const QRect &rect)
{
KisGaussianKernel::applyLoG(dev, rect, 2, -1.0, QBitArray(), 0);
}
/*
* Copyright (c) 2019 Kuntal Majumder <hellozee@disroot.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1 of the License.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KISMAGNETICWORKER_H
#define KISMAGNETICWORKER_H
#include <kis_paint_device.h>
#include <kritaselectiontools_export.h>
class KRITASELECTIONTOOLS_EXPORT KisMagneticWorker{
public:
void run(KisPaintDeviceSP dev, const QRect& rect);
};
#endif
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/..
${CMAKE_CURRENT_BINARY_DIR}/..
${CMAKE_SOURCE_DIR}/sdk/tests
)
macro_add_unittest_definitions()
########### next target ###############
ecm_add_test(KisMagneticWorkerTest.cc
NAME_PREFIX plugins-magneticselection-
LINK_LIBRARIES kritaselectiontools kritaimage Qt5::Test)
/*
* Copyright (c) 2019 Kuntal Majumder <hellozee@disroot.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1 of the License.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "KisMagneticWorkerTest.h"
#include <KisMagneticWorker.h>
#include <kis_paint_device.h>
#include <kis_painter.h>
#include <testutil.h>
#include <kis_paint_device_debug_utils.h>
inline KisPaintDeviceSP loadTestImage(const QString &name, bool convertToAlpha)
{
QImage image(TestUtil::fetchDataFileLazy(name));
KisPaintDeviceSP dev = new KisPaintDevice(KoColorSpaceRegistry::instance()->rgb8());
dev->convertFromQImage(image, 0);
if (convertToAlpha) {
dev = KisPainter::convertToAlphaAsAlpha(dev);
}
return dev;
}
void KisMagneticWorkerTest::testWorker()
{
KisPaintDeviceSP dev = loadTestImage("test_main.png", false);
const QRect rect = dev->exactBounds();
KisMagneticWorker worker;
worker.run(dev, rect);
KIS_DUMP_DEVICE_2(dev, rect, "main", "dd");
}
QTEST_MAIN(KisMagneticWorkerTest)
/*
* Copyright (c) 2019 Kuntal Majumder <hellozee@disroot.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 2.1 of the License.
*
* 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KISMAGNETICWORKERTEST_H
#define KISMAGNETICWORKERTEST_H
#include <QtTest>
class KisMagneticWorkerTest : public QObject
{
Q_OBJECT
private Q_SLOTS:
void testWorker();
};
#endif
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