Commit 6e64cee3 authored by Emanuele Tamponi's avatar Emanuele Tamponi

Tests skel added.

svn path=/trunk/koffice/; revision=752391
parent 67a463df
#add_subdirectory(tests)
add_subdirectory(tests)
#################################################
# Painterly Common Libraries
......@@ -6,7 +6,7 @@
set(kritapainterlycommon_PART_SRCS
kis_illuminant_profile.cpp
kis_ks3_colorspace.cpp
ks_reflectance_converter.cpp
channel_converter.cpp
# kis_rgbks_colorspace.cpp
# mathematics.cpp
)
......
......@@ -19,18 +19,18 @@
#include <cmath>
#include "ks_reflectance_converter.h"
#include "channel_converter.h"
KSReflectanceConverter::KSReflectanceConverter(float whiteS, float blackK)
ChannelConverter::ChannelConverter(float whiteS, float blackK)
: S_w(whiteS), K_b(blackK)
{
}
KSReflectanceConverter::~KSReflectanceConverter()
ChannelConverter::~ChannelConverter()
{
}
void KSReflectanceConverter::KSToReflectance(float K, float S, float &R) const
void ChannelConverter::KSToReflectance(float K, float S, float &R) const
{
if (S == 0.0) {
R = 0.0;
......@@ -46,7 +46,7 @@ void KSReflectanceConverter::KSToReflectance(float K, float S, float &R) const
R = 1.0 + Q - sqrt( Q*Q + 2.0*Q );
}
void KSReflectanceConverter::reflectanceToKS(float R, float &K, float &S) const
void ChannelConverter::reflectanceToKS(float R, float &K, float &S) const
{
if ( R == 0.0 ) {
K = 0.8 * K_b;
......
......@@ -17,22 +17,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#ifndef KS_REF_CONVERTER_H_
#define KS_REF_CONVERTER_H_
#ifndef CHANNEL_CONVERTER_H_
#define CHANNEL_CONVERTER_H_
class KSReflectanceConverter {
class ChannelConverter {
public:
KSReflectanceConverter() {}
KSReflectanceConverter(float whiteS, float blackK);
~KSReflectanceConverter();
ChannelConverter() {}
ChannelConverter(float whiteS, float blackK);
~ChannelConverter();
void KSToReflectance(float K, float S, float &R) const;
void reflectanceToKS(float R, float &K, float &S) const;
// TODO add normalized / gamma'ed sRGB conversions.
private:
float S_w, K_b;
};
#endif // KS_REF_CONVERTER_H_
#endif // CHANNEL_CONVERTER_H_
......@@ -19,7 +19,7 @@
#include "kis_ks3_colorspace.h"
#include "ks_reflectance_converter.h"
#include "channel_converter.h"
#include "kis_illuminant_profile.h"
#include <KoColorSpaceMaths.h>
#include <KoColorProfile.h>
......@@ -47,7 +47,7 @@ KisKS3ColorSpace::KisKS3ColorSpace(KoColorProfile *p)
return;
m_profile = dynamic_cast<KisIlluminantProfile *>(p);
m_converter = KSReflectanceConverter(m_profile->Swhite(), m_profile->Kblack());
m_converter = ChannelConverter(m_profile->Swhite(), m_profile->Kblack());
m_permutation = gsl_permutation_alloc(3);
gsl_linalg_LU_decomp(m_profile->T(), m_permutation, &m_s);
......
......@@ -21,7 +21,7 @@
#define KIS_KS3_COLORSPACE_H_
#include "kis_ks_colorspace_traits.h"
#include "ks_reflectance_converter.h"
#include "channel_converter.h"
#include <KoIncompleteColorSpace.h>
#include <gsl/gsl_linalg.h>
......@@ -53,7 +53,7 @@ class KisKS3ColorSpace : public KoIncompleteColorSpace<KisKS3ColorSpaceTrait>
private:
KisIlluminantProfile *m_profile;
KSReflectanceConverter m_converter;
ChannelConverter m_converter;
int m_s;
gsl_permutation *m_permutation;
......
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
include_directories( ${KOMAIN_INCLUDES} "../" )
########### KisIlluminantProfile Test ###############
set(kis_illuminant_profile_test_SRCS
kis_illuminant_profile_test.cpp
../kis_illuminant_profile.cpp)
kde4_add_unit_test(KisIlluminantProfileTest
TESTNAME krita-plugins-KisIlluminantProfileTest
${kis_illuminant_profile_test_SRCS})
target_link_libraries(KisIlluminantProfileTest
${KDE4_KDEUI_LIBS} komain kritaimage ${GSL_LIBRARIES} ${GSL_CBLAS_LIBRARIES} ${QT_QTTEST_LIBRARY})
########### ChannelConverter Test ###############
set(channel_converter_test_SRCS
channel_converter_test.cpp
../channel_converter.cpp)
kde4_add_unit_test(ChannelConverterTest
TESTNAME krita-plugins-ChannelConverterTest
${channel_converter_test_SRCS})
target_link_libraries(ChannelConverterTest
${KDE4_KDEUI_LIBS} ${QT_QTTEST_LIBRARY})
########### KisKS3ColorSpace Test ###############
set(kis_ks3_colorspace_test_SRCS
kis_ks3_colorspace_test.cpp
../kis_illuminant_profile.cpp
../channel_converter.cpp
../kis_ks3_colorspace.cpp)
kde4_add_unit_test(KisKS3ColorSpaceTest
TESTNAME krita-plugins-KisKS3ColorSpaceTest
${kis_ks3_colorspace_test_SRCS})
target_link_libraries(KisKS3ColorSpaceTest
${KDE4_KDEUI_LIBS} komain kritaimage ${GSL_LIBRARIES} ${GSL_CBLAS_LIBRARIES} ${QT_QTTEST_LIBRARY})
/*
* Copyright (c) 2007 Emanuele Tamponi <emanuele@valinor.it>
*
*
* 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 "channel_converter_test.h"
void ChannelConverterTest::testKSReflectance()
{
}
void ChannelConverterTest::testRGBsRGB()
{
}
QTEST_KDEMAIN(ChannelConverterTest, NoGUI)
#include "channel_converter_test.moc"
/*
* Copyright (c) 2007 Emanuele Tamponi <emanuele@valinor.it>
*
*
* 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 CHANNEL_CONVERTER_TEST_H_
#define CHANNEL_CONVERTER_TEST_H_
#include <QtTest/QtTest>
class ChannelConverterTest : public QObject
{
Q_OBJECT
private slots:
void testKSReflectance();
void testRGBsRGB();
};
#endif // CHANNEL_CONVERTER_TEST_H_
/*
* Copyright (c) 2007 Emanuele Tamponi <emanuele@valinor.it>
*
*
* 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_illuminant_profile_test.h"
void KisIlluminantProfileTest::testLoading()
{
}
void KisIlluminantProfileTest::testSaving()
{
}
QTEST_KDEMAIN(KisIlluminantProfileTest, NoGUI)
#include "kis_illuminant_profile_test.moc"
/*
* Copyright (c) 2007 Emanuele Tamponi <emanuele@valinor.it>
*
*
* 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_ILLUMINANT_PROFILE_TEST_H_
#define KIS_ILLUMINANT_PROFILE_TEST_H_
#include <QtTest/QtTest>
class KisIlluminantProfileTest : public QObject
{
Q_OBJECT
private slots:
void testLoading();
void testSaving();
};
#endif // KIS_ILLUMINANT_PROFILE_TEST_H_
/*
* Copyright (c) 2007 Emanuele Tamponi <emanuele@valinor.it>
*
*
* 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_ks3_colorspace_test.h"
void KisKS3ColorSpaceTest::testConstructor()
{
}
void KisKS3ColorSpaceTest::testFromRgbA16()
{
}
void KisKS3ColorSpaceTest::testToRgbA16()
{
}
QTEST_KDEMAIN(KisKS3ColorSpaceTest, NoGUI)
#include "kis_ks3_colorspace_test.moc"
/*
* Copyright (c) 2007 Emanuele Tamponi <emanuele@valinor.it>
*
*
* 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_KS3_COLORSPACE_TEST_H_
#define KIS_KS3_COLORSPACE_TEST_H_
#include <QtTest/QtTest>
class KisKS3ColorSpaceTest : public QObject
{
Q_OBJECT
private slots:
void testConstructor();
void testFromRgbA16();
void testToRgbA16();
};
#endif // KIS_KS3_COLORSPACE_TEST_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