Commit c2fda11d authored by Boudewijn Rempt's avatar Boudewijn Rempt

Add a semi-interesting test for the KisFilterMask and an outline for the

KisGroupLayer test. Make hakonepa a png so we can do pixel-for-pixel
checking between image states.  Get rid of an obsolete api in
KisGroupLayer and add myself to the copyright lines. Next: fix the failure
in the KisFilterMask test.

svn path=/trunk/koffice/; revision=720807
parent fcbbfffd
......@@ -21,7 +21,7 @@
#include "kis_filter_configuration.h"
#include "kis_filter_registry.h"
class KisFilterMask::Private {
class KRITAIMAGE_EXPORT KisFilterMask::Private {
public:
KisFilterConfiguration * filterConfig;
......
/*
* Copyright (c) 2005 Casper Boemann <cbr@boemann.dk>
* Copyright (c) 2007 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -39,7 +40,6 @@ class KisGroupLayer::Private
public:
Private()
: projection( 0 )
// , projectionManager( 0 )
, cacheProjection( true )
, x( 0 )
, y( 0 )
......@@ -48,7 +48,6 @@ public:
KisPaintDeviceSP projection; // The cached composition of all
// layers in this group
// KisProjectionSP projectionManager; // owned by KisImage
bool cacheProjection;
qint32 x;
qint32 y;
......@@ -97,8 +96,7 @@ void KisGroupLayer::setDirty()
{
KisLayer::setDirty();
emit rectDirtied( extent() );
// if ( m_d->projectionManager )
// m_d->projectionManager->addDirtyRect( extent() );
}
......@@ -106,8 +104,6 @@ void KisGroupLayer::setDirty(const QRect & rect)
{
KisLayer::setDirty( rect );
emit rectDirtied( rect );
// if ( m_d->projectionManager )
// m_d->projectionManager->addDirtyRect( rect );
}
......@@ -115,9 +111,6 @@ void KisGroupLayer::setDirty( const QRegion & region)
{
KisLayer::setDirty( region );
emit regionDirtied( region );
// if ( m_d->projectionManager )
// m_d->projectionManager->addDirtyRegion( region );
}
......@@ -126,15 +119,8 @@ void KisGroupLayer::updateSettings()
KConfigGroup cfg = KGlobal::config()->group("");
m_d->cacheProjection = cfg.readEntry( "useProjections", true );
emit settingsUpdated();
// if ( m_d->projectionManager )
// m_d->projectionManager->updateSettings();
}
// void KisGroupLayer::setProjectionManager( KisProjectionSP projectionManager )
// {
// m_d->projectionManager = projectionManager;
// }
void KisGroupLayer::resetProjection(KisPaintDeviceSP to)
{
if (to)
......
/*
* Copyright (c) 2005 Casper Boemann <cbr@boemann.dk>
*
* Copyright (c) 2007 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -59,12 +59,6 @@ public:
/// override from KisNode
void setDirty( const QRegion & region);
// /**
// * Set a projection manager on this group layer. The group layer
// * will inform the projection manager of new
// */
// void setProjectionManager( KisProjectionSP projectionManager );
/**
* XXX: make the colorspace of a layergroup user-settable: we want
* to be able to have, for instance, a group of grayscale layers
......
......@@ -162,3 +162,18 @@ kde4_add_unit_test(KisPixelSelectionTest TESTNAME krita-image-KisPixelSelectionT
target_link_libraries(KisPixelSelectionTest ${KDE4_KDEUI_LIBS} komain kritaimage ${QT_QTTEST_LIBRARY})
########### next target ###############
set(kis_group_layer_test_SRCS kis_group_layer_test.cpp )
kde4_add_unit_test(KisGroupLayerTest TESTNAME krita-image-KisGroupLayerTest ${kis_group_layer_test_SRCS})
target_link_libraries(KisGroupLayerTest ${KDE4_KDEUI_LIBS} komain kritaimage ${QT_QTTEST_LIBRARY})
########### next target ###############
set(kis_filter_mask_test_SRCS kis_filter_mask_test.cpp )
kde4_add_unit_test(KisFilterMaskTest TESTNAME krita-image-KisFilterMaskTest ${kis_filter_mask_test_SRCS})
target_link_libraries(KisFilterMaskTest ${KDE4_KDEUI_LIBS} komain kritaimage ${QT_QTTEST_LIBRARY})
/*
* Copyright (c) 2007 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 <qtest_kde.h>
#include <KoColorSpaceRegistry.h>
#include "kis_filter.h"
#include "kis_filter_configuration.h"
#include "kis_filter_mask.h"
#include "kis_filter_registry.h"
#include "kis_group_layer.h"
#include "kis_paint_device.h"
#include "kis_paint_layer.h"
#include "kis_types.h"
#include "kis_filter_mask_test.h"
#include "testutil.h"
void KisFilterMaskTest::testProjection()
{
KoColorSpace * cs = KoColorSpaceRegistry::instance()->colorSpace("RGBA", 0);
QImage qimg( QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.png");
QImage inverted( QString(FILES_DATA_DIR) + QDir::separator() + "inverted_hakonepa.png" );
KisFilterSP f = KisFilterRegistry::instance()->value("invert");
Q_ASSERT( f );
KisFilterConfiguration * kfc = f->defaultConfiguration(0);
Q_ASSERT( kfc );
// Without a selection
KisFilterMaskSP mask = new KisFilterMask();
mask->setFilter( kfc );
// Check basic apply()
KisPaintDeviceSP projection = new KisPaintDevice( cs );
projection->convertFromQImage( qimg, 0, 0, 0 );
mask->apply( projection, QRect( 0, 0, qimg.width(), qimg.height() ) );
QPoint errpoint;
if ( !TestUtil::compareQImages( errpoint, inverted, projection->convertToQImage(0, 0, 0, qimg.width(), qimg.height() ) ) ) {
QFAIL( QString( "Failed to create identical image, first different pixel: %1,%2 " ).arg( errpoint.x() ).arg( errpoint.y() ).toAscii() );
}
// Check in image stack
KisImageSP image = new KisImage(0, qimg.width(), qimg.height(), cs, "merge test");
KisPaintLayerSP layer = new KisPaintLayer(image, "test", OPACITY_OPAQUE);
layer->paintDevice()->convertFromQImage( qimg, 0, 0, 0 );
image->addNode( layer.data() );
image->addNode(mask.data(), layer.data());
KisGroupLayerSP root = image->rootLayer();
root->updateProjection( QRect( 0, 0, qimg.width(), qimg.height() ) );
if ( !TestUtil::compareQImages( errpoint, inverted, root->projection()->convertToQImage(0, 0, 0, qimg.width(), qimg.height() ) ) ) {
QFAIL( QString( "Failed to create identical image, first different pixel: %1,%2 " ).arg( errpoint.x() ).arg( errpoint.y() ).toAscii() );
}
}
QTEST_KDEMAIN(KisFilterMaskTest, GUI)
#include "kis_filter_mask_test.moc"
/*
* Copyright (c) 2007 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 KIS_FILTER_MASK_TEST_H
#define KIS_FILTER_MASK_TEST_H
#include <QtTest/QtTest>
class KisFilterMaskTest : public QObject
{
Q_OBJECT
private slots:
void testProjection();
};
#endif
/*
* Copyright (c) 2007 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 <qtest_kde.h>
#include "kis_group_layer_test.h"
#include "kis_group_layer.h"
#include "kis_types.h"
#include "KoColorSpaceRegistry.h"
#include "kis_image.h"
void KisGroupLayerTest::testProjection()
{
KoColorSpace * colorSpace = KoColorSpaceRegistry::instance()->colorSpace("RGBA", 0);
KisImageSP image = new KisImage(0, 512, 512, colorSpace, "merge test");
}
QTEST_KDEMAIN(KisGroupLayerTest, GUI)
#include "kis_group_layer_test.moc"
/*
* Copyright (c) 2007 Boudewijn Rempt <boud@valdyas.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU 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 KIS_GROUP_LAYER_TEST_H
#define KIS_GROUP_LAYER_TEST_H
#include <QtTest/QtTest>
class KisGroupLayerTest : public QObject
{
Q_OBJECT
private slots:
void testProjection();
};
#endif
......@@ -142,7 +142,7 @@ void KisPaintDeviceTest::testPaintEngine()
{
QRectF target(100.0, 200.0, 80.0, 60.0);
QRectF source(0.0, 0.0, 70.0, 40.0);
QImage image(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.jpg");
QImage image(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.png");
gc.drawImage(target, image, source);
gc2.drawImage(target, image, source );
......@@ -182,7 +182,7 @@ void KisPaintDeviceTest::testPaintEngine()
{
QRectF target(200.0, 200.0, 80.0, 60.0);
QRectF source(0.0, 0.0, 70.0, 40.0);
QPixmap pixmap(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.jpg");
QPixmap pixmap(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.png");
gc.drawPixmap(target, pixmap, source);
gc2.drawPixmap(target, pixmap, source);
......@@ -498,7 +498,7 @@ void KisPaintDeviceTest::testColorSpaceConversion()
void KisPaintDeviceTest::testRoundtripConversion()
{
QImage image(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.jpg");
QImage image(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.png");
KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisPaintDeviceSP dev = new KisPaintDevice(cs);
dev->convertFromQImage( image, "" );
......@@ -515,7 +515,7 @@ void KisPaintDeviceTest::testRoundtripConversion()
void KisPaintDeviceTest::testThumbnail()
{
QImage image(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.jpg");
QImage image(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.png");
KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();
KisPaintDeviceSP dev = new KisPaintDevice(cs);
dev->convertFromQImage( image, "" );
......
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