Commit 616ba5e7 authored by Boudewijn Rempt's avatar Boudewijn Rempt

Add basic unittests for the krita/image classes & fix some problems the unittests

showed up

svn path=/trunk/koffice/; revision=738782
parent 2a213f60
......@@ -7,7 +7,7 @@
Krita is built around two core libraries: pigment and kritaimage.
The pigment library abstracts colorspaces and color
transformations. Colorspaces provide functions to manipulate pixels. The
transformations. ColorSpaces provide functions to manipulate pixels. The
kritcolor library loads colorspace plugins to extend the range of
available colorspaces. Pigment is part of the KOffice libraries.
......
......@@ -64,7 +64,7 @@ set(kritaimage_LIB_SRCS
kis_macro.cc
kis_group_layer.cc
kis_paint_layer.cc
kis_nameserver.cc
kis_name_server.cpp
kis_paint_device.cc
kis_painter.cc
kis_paintop.cc
......
......@@ -111,10 +111,10 @@ namespace {
#endif
class KoColorSpaceConvertVisitor :public KisNodeVisitor {
class KisColorSpaceConvertVisitor :public KisNodeVisitor {
public:
KoColorSpaceConvertVisitor(const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent);
virtual ~KoColorSpaceConvertVisitor();
KisColorSpaceConvertVisitor(const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent);
virtual ~KisColorSpaceConvertVisitor();
public:
......@@ -133,18 +133,18 @@ private:
QBitArray m_emptyChannelFlags;
};
KoColorSpaceConvertVisitor::KoColorSpaceConvertVisitor(const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent) :
KisColorSpaceConvertVisitor::KisColorSpaceConvertVisitor(const KoColorSpace *dstColorSpace, KoColorConversionTransformation::Intent renderingIntent) :
KisNodeVisitor(),
m_dstColorSpace(dstColorSpace),
m_renderingIntent(renderingIntent)
{
}
KoColorSpaceConvertVisitor::~KoColorSpaceConvertVisitor()
KisColorSpaceConvertVisitor::~KisColorSpaceConvertVisitor()
{
}
bool KoColorSpaceConvertVisitor::visit(KisGroupLayer * layer)
bool KisColorSpaceConvertVisitor::visit(KisGroupLayer * layer)
{
// Clear the projection, we will have to re-render everything.
// The image is already set to the new colorspace, so this'll work.
......@@ -160,7 +160,7 @@ bool KoColorSpaceConvertVisitor::visit(KisGroupLayer * layer)
return true;
}
bool KoColorSpaceConvertVisitor::visit(KisPaintLayer *layer)
bool KisColorSpaceConvertVisitor::visit(KisPaintLayer *layer)
{
layer->paintDevice()->convertTo(m_dstColorSpace, m_renderingIntent);
layer->setChannelFlags( m_emptyChannelFlags );
......@@ -170,7 +170,7 @@ bool KoColorSpaceConvertVisitor::visit(KisPaintLayer *layer)
}
bool KoColorSpaceConvertVisitor::visit(KisAdjustmentLayer * layer)
bool KisColorSpaceConvertVisitor::visit(KisAdjustmentLayer * layer)
{
if (layer->filter()->name() == "perchannel") {
// Per-channel filters need to be reset because of different number
......
......@@ -24,7 +24,7 @@
#include <qimage.h>
/**
* KisGenericColorspace is a colorspace you use if you want to store some values
* KisGenericColorSpace is a colorspace you use if you want to store some values
* in a KisPaintDevice which are not colors. For instance the results of the
* computation of a wavelets.
*
......@@ -32,12 +32,12 @@
* memory, because it will benefit from Krita's memory management.
*/
template<typename _type, int _nbchannels>
class KisGenericColorspace : public KoColorSpace {
class KisGenericColorSpace : public KoColorSpace {
class KisGenericColorspaceConvolutionOpImpl : public KoConvolutionOp{
class KisGenericColorSpaceConvolutionOpImpl : public KoConvolutionOp{
public:
KisGenericColorspaceConvolutionOpImpl() { }
virtual ~KisGenericColorspaceConvolutionOpImpl() { }
KisGenericColorSpaceConvolutionOpImpl() { }
virtual ~KisGenericColorSpaceConvolutionOpImpl() { }
virtual void convolveColors(const quint8* const* colors, const qint32* kernelValues, quint8 *dst, qint32 factor, qint32 offset, qint32 nColors, const QBitArray & channelFlags) const
{
_type totals[ _nbchannels ];
......@@ -72,10 +72,10 @@ class KisGenericColorspace : public KoColorSpace {
public:
KisGenericColorspace() :
KoColorSpace("genericcolorspace", "genericcolorspace",0, 0, new KisGenericColorspaceConvolutionOpImpl)
KisGenericColorSpace() :
KoColorSpace("genericcolorspace", "genericcolorspace",0, 0, new KisGenericColorSpaceConvolutionOpImpl)
{ }
virtual ~KisGenericColorspace() { }
virtual ~KisGenericColorSpace() { }
public:
virtual KoID colorModelId() const { return KoID("",""); }
......
......@@ -45,13 +45,6 @@ enum enumCursorStyle {
CURSOR_STYLE_OUTLINE = 3
};
enum enumResourceTypes {
RESOURCE_PAINTOP,
RESOURCE_FILTER,
RESOURCE_TOOL,
RESOURCE_COLORSPACE
};
/*
* Most wacom pads have 512 levels of pressure; Qt only supports 256, and even
* this is downscaled to 127 levels because the line would be too jittery, and
......
......@@ -54,7 +54,7 @@
#include "kis_layer.h"
#include "kis_merge_visitor.h"
#include "kis_nameserver.h"
#include "kis_name_server.h"
#include "kis_paint_device.h"
#include "kis_paint_device_action.h"
#include "kis_paint_layer.h"
......@@ -580,7 +580,7 @@ void KisImage::convertTo(const KoColorSpace * dstColorSpace, KoColorConversionTr
setColorSpace(dstColorSpace);
KoColorSpaceConvertVisitor visitor(dstColorSpace, renderingIntent);
KisColorSpaceConvertVisitor visitor(dstColorSpace, renderingIntent);
m_d->rootLayer->accept(visitor);
unlock();
......
......@@ -38,6 +38,11 @@ KisImageCommand::KisImageCommand(const QString& name, KisImageSP image)
{
}
KisImageCommand::~KisImageCommand()
{
}
void KisImageCommand::setUndo(bool undo)
{
if (m_image->undoAdapter()) {
......@@ -251,6 +256,10 @@ KisImageLayerPropsCommand::KisImageLayerPropsCommand(KisImageSP image, KisLayerS
m_channelFlags = channelFlags;
}
KisImageLayerPropsCommand::~KisImageLayerPropsCommand()
{
}
void KisImageLayerPropsCommand::redo()
{
QString name = m_layer->name();
......
......@@ -28,6 +28,8 @@
#include "kis_types.h"
class KoCompositeOp;
class KoColorSpace;
class KoColorProfile;
/// the base command for commands altering a KisImage
class KisImageCommand : public QUndoCommand {
......@@ -40,7 +42,7 @@ public:
* @param image The image the command will be working on.
*/
KisImageCommand(const QString& name, KisImageSP image);
virtual ~KisImageCommand() {}
virtual ~KisImageCommand();
protected:
/**
......@@ -69,7 +71,6 @@ public:
* @param lockImage Locking state of the image, while redo.
*/
KisImageLockCommand(KisImageSP image, bool lockImage);
virtual ~KisImageLockCommand() {}
virtual void redo();
virtual void undo();
......@@ -83,7 +84,6 @@ class KisImageResizeCommand : public KisImageCommand {
public:
KisImageResizeCommand(KisImageSP image, qint32 width, qint32 height, qint32 oldWidth, qint32 oldHeight);
virtual ~KisImageResizeCommand() {}
virtual void redo();
virtual void undo();
......@@ -98,7 +98,6 @@ class KisImageConvertTypeCommand : public KisImageCommand {
public:
KisImageConvertTypeCommand(KisImageSP image, const KoColorSpace * beforeColorSpace, const KoColorSpace * afterColorSpace);
virtual ~KisImageConvertTypeCommand() {}
virtual void redo();
virtual void undo();
......@@ -124,7 +123,6 @@ public:
* @param newResolution the new image resolution which will be used for xRes and yRes
*/
KisImagePropsCommand(KisImageSP image, const KoColorSpace* newColorSpace, const KoColorProfile* newProfile);
virtual ~KisImagePropsCommand() {}
virtual void redo();
virtual void undo();
......@@ -141,7 +139,6 @@ class KisImageChangeLayersCommand : public KisImageCommand {
public:
KisImageChangeLayersCommand(KisImageSP image, KisNodeSP oldRootLayer, KisNodeSP newRootLayer, const QString& name);
virtual ~KisImageChangeLayersCommand() {}
virtual void redo();
virtual void undo();
......@@ -161,7 +158,6 @@ public:
* @param layer the layer to add
*/
KisImageLayerAddCommand(KisImageSP image, KisNodeSP layer);
virtual ~KisImageLayerAddCommand() {}
virtual void redo();
virtual void undo();
......@@ -186,7 +182,6 @@ public:
* @param wasAbove the layer above the layer
*/
KisImageLayerRemoveCommand(KisImageSP image, KisNodeSP layer, KisNodeSP wasParent, KisNodeSP wasAbove);
virtual ~KisImageLayerRemoveCommand() {}
virtual void redo();
virtual void undo();
......@@ -211,7 +206,6 @@ public:
* @param wasAbove the layer that was above the layer before the move
*/
KisImageLayerMoveCommand(KisImageSP image, KisNodeSP layer, KisNodeSP wasParent, KisNodeSP wasAbove);
virtual ~KisImageLayerMoveCommand() {}
virtual void redo();
virtual void undo();
......@@ -241,8 +235,7 @@ public:
* @param name the new layer name
*/
KisImageLayerPropsCommand(KisImageSP image, KisLayerSP layer, qint32 opacity, const KoCompositeOp* compositeOp, const QString& name, QBitArray channelFlags);
virtual ~KisImageLayerPropsCommand() {}
virtual ~KisImageLayerPropsCommand();
virtual void redo();
virtual void undo();
......
......@@ -20,7 +20,7 @@
#define KIS_ITERATORS_PIXEL_H_
#include "kis_iterator.h"
#include "kis_iteratorpixeltrait.h"
#include "kis_iterator_pixel_trait.h"
template<class T, typename TSelect>
......
......@@ -28,6 +28,11 @@ KisLayerCommand::KisLayerCommand(const QString& name, KisLayerSP layer) :
{
}
KisLayerCommand::~KisLayerCommand()
{
}
KisLayerOpacityCommand::KisLayerOpacityCommand(KisLayerSP layer, quint8 oldOpacity, quint8 newOpacity) :
KisLayerCommand(i18n("Layer Opacity"), layer)
{
......
......@@ -38,7 +38,7 @@ public:
* @param layer The layer the command will be working on.
*/
KisLayerCommand(const QString& name, KisLayerSP layer);
virtual ~KisLayerCommand() {}
virtual ~KisLayerCommand();
protected:
KisLayerSP m_layer;
......
......@@ -15,7 +15,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "kis_nameserver.h"
#include "kis_name_server.h"
KisNameServer::KisNameServer(qint32 seed)
{
......
......@@ -21,8 +21,7 @@
#include <krita_export.h>
#include <QUndoCommand>
#include "kis_types.h"
class KisFilterConfiguration;
#include "kis_filter_configuration.h"
template <typename T>
class KisChangeFilterCmd : public QUndoCommand {
......
......@@ -18,6 +18,8 @@
#ifndef KIS_NODE_GRAPH_LISTENER_H_
#define KIS_NODE_GRAPH_LISTENER_H_
class KisNode;
/**
* Implementations of this class are called by nodes whenever the node
* graph changes. These implementations can then emit the right
......
......@@ -46,7 +46,7 @@
#include "kis_filter.h"
#include "kis_iterator.h"
#include "kis_iterators_pixel.h"
#include "kis_iteratorpixeltrait.h"
#include "kis_iterator_pixel_trait.h"
#include "kis_random_accessor.h"
#include "kis_random_sub_accessor.h"
#include "kis_selection.h"
......
......@@ -161,7 +161,7 @@ QIcon KisPaintLayer::icon() const
KoDocumentSectionModel::PropertyList KisPaintLayer::sectionModelProperties() const
{
KoDocumentSectionModel::PropertyList l = KisLayer::sectionModelProperties();
l << KoDocumentSectionModel::Property(i18n("Colorspace"), m_d->paintDevice->colorSpace()->name());
l << KoDocumentSectionModel::Property(i18n("ColorSpace"), m_d->paintDevice->colorSpace()->name());
if( const KoColorProfile *profile = m_d->paintDevice->colorSpace()->profile() )
l << KoDocumentSectionModel::Property(i18n("Profile"), profile->name());
return l;
......
......@@ -47,12 +47,12 @@ KisRecordedAction::~KisRecordedAction()
delete d;
}
QString KisRecordedAction::id()
QString KisRecordedAction::id() const
{
return d->id;
}
QString KisRecordedAction::name()
QString KisRecordedAction::name() const
{
return d->name;
}
......@@ -90,12 +90,12 @@ KisRecordedActionFactory::~KisRecordedActionFactory()
delete d;
}
QString KisRecordedActionFactory::id()
QString KisRecordedActionFactory::id() const
{
return d->id;
}
QString KisRecordedActionFactory::name()
QString KisRecordedActionFactory::name() const
{
return QString();
}
......
......@@ -35,8 +35,8 @@ class KRITAIMAGE_EXPORT KisRecordedAction {
virtual KisRecordedAction* clone() const = 0;
virtual void toXML(QDomDocument& doc, QDomElement& elt);
public:
QString id();
QString name();
QString id() const;
QString name() const;
protected:
static QString layerToIndexPath(KisLayerSP);
private:
......@@ -49,8 +49,8 @@ class KRITAIMAGE_EXPORT KisRecordedActionFactory {
KisRecordedActionFactory(QString id);
virtual ~KisRecordedActionFactory();
virtual KisRecordedAction* fromXML(KisImageSP img, const QDomElement& elt) =0;
QString id();
QString name();
QString id() const;
QString name() const;
protected:
static KisLayerSP indexPathToLayer(KisImageSP img, QString);
private:
......
......@@ -428,3 +428,19 @@ void KisRotateVisitor::setProgressDone()
}
KisRotateVisitor::KisRotateVisitor( KoUpdater * progressUpdater )
: m_progressUpdater(progressUpdater)
{
}
KisRotateVisitor::~KisRotateVisitor()
{
}
void KisRotateVisitor::visitKisPaintDevice(KisPaintDevice* dev)
{
m_dev = dev;
}
......@@ -18,7 +18,7 @@
#ifndef KIS_ROTATE_VISITOR_H_
#define KIS_ROTATE_VISITOR_H_
#include "krita_export.h"
#include "kis_types.h"
class KisPaintDevice;
......@@ -73,17 +73,4 @@ private:
};
inline KisRotateVisitor::KisRotateVisitor( KoUpdater * progressUpdater )
: m_progressUpdater(progressUpdater)
{
}
inline KisRotateVisitor::~KisRotateVisitor()
{
}
inline void KisRotateVisitor::visitKisPaintDevice(KisPaintDevice* dev)
{
m_dev = dev;
}
#endif // KIS_ROTATE_VISITOR_H_
......@@ -25,12 +25,15 @@ class QDomDocument;
class KRITAIMAGE_EXPORT KisSerializableConfiguration {
public:
virtual ~KisSerializableConfiguration() {};
/**
* Fill the object from the XML encoded representation in s.
* This function use the "OpenRaster" style XML.
*/
virtual void fromXML(const QString&);
/**
* Fill the object from the XML encoded representation in s.
* This function use the "OpenRaster" style XML.
......@@ -42,6 +45,7 @@ class KRITAIMAGE_EXPORT KisSerializableConfiguration {
* This function use the "OpenRaster" style XML.
*/
virtual void toXML(QDomDocument&, QDomElement&) const = 0;
/**
* Create a serialized version of this object
* This function use the "OpenRaster" style XML.
......
......@@ -20,7 +20,6 @@
#define _KIS_SHARED_DATA_H_
#include <qatomic.h>
#include <kis_shared_ptr.h>
/**
* XXX: Add documentation!
......
......@@ -51,6 +51,12 @@ KisTransformWorker::KisTransformWorker(KisPaintDeviceSP dev,
m_fixBorderAlpha = fixBorderAlpha;
}
KisTransformWorker::~KisTransformWorker()
{
}
void KisTransformWorker::rotateNone(KisPaintDeviceSP src, KisPaintDeviceSP dst)
{
#if 0 // XXX_SELECTION
......
......@@ -21,6 +21,7 @@
#define KIS_TRANSFORM_WORKER_H_
#include "kis_types.h"
#include "krita_export.h"
class KisPaintDevice;
class KoUpdater;
......@@ -66,9 +67,4 @@ private:
bool m_fixBorderAlpha;
};
inline KisTransformWorker::~KisTransformWorker()
{
}
#endif // KIS_TRANSFORM_VISITOR_H_
This diff is collapsed.
/*
* 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_action_recorder_test.h"
#include "kis_action_recorder.h"
void KisActionRecorderTest::testCreation()
{
KisActionRecorder test();
}
QTEST_KDEMAIN(KisActionRecorderTest, GUI)
#include "kis_action_recorder_test.moc"
/*
* Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com>
* 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
......@@ -16,21 +16,18 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KIS_INTEGER_MATHS_TESTER_H
#define KIS_INTEGER_MATHS_TESTER_H
#ifndef KIS_ACTION_RECORDER_TEST_H
#define KIS_ACTION_RECORDER_TEST_H
#include <QtTest/QtTest>
class KisIntegerMathsTester : public QObject
class KisActionRecorderTest : public QObject
{
Q_OBJECT
private slots:
void UINT8Tests();
void UINT16Tests();
void conversionTests();
void testCreation();
};
#endif
/*
* Copyright (c) 2007 Boudewijn Rempt boud@valdyas.org
*