Commit 4de3382b authored by Cyrille Berger's avatar Cyrille Berger

start working on a test for the CTL colorspace parser

(and fix the first bug found by the test : infinite loop)

svn path=/trunk/koffice/; revision=951710
parent 71d24a23
include_directories(${OPENCTL_INCLUDE_DIR})
include_directories(${OPENCTL_INCLUDE_DIR} )
add_definitions(${OPENCTL_DEFINITIONS})
......@@ -24,3 +24,5 @@ install(TARGETS krita_ctlcs_plugin DESTINATION ${PLUGIN_INSTALL_DIR})
install( FILES krita_ctlcs_plugin.desktop DESTINATION ${SERVICES_INSTALL_DIR})
add_subdirectory(tests)
\ No newline at end of file
......@@ -21,7 +21,7 @@
#include <QFile>
#include <QDomDocument>
#include <kis_debug.h>
#include <KoCtlParser.h>
#include "KoCtlParser.h"
struct KoCtlColorSpaceInfo::ChannelInfo::Private {
};
......@@ -78,7 +78,7 @@ bool KoCtlColorSpaceInfo::load()
return false;
}
QDomNode n = docElem.firstChild();
while(not n.isNull()) {
while(!n.isNull()) {
QDomElement e = n.toElement();
if(not e.isNull()) {
dbgPlugins << e.tagName();
......@@ -87,5 +87,12 @@ bool KoCtlColorSpaceInfo::load()
d->colorDepthID = KoCtlParser::generateDepthID(e.attribute("depth"), e.attribute("type"));
}
}
n = n.nextSibling();
}
return true;
}
const QString& KoCtlColorSpaceInfo::colorDepthId() const
{
return d->colorDepthID;
}
......@@ -37,6 +37,7 @@ class KoCtlColorSpaceInfo {
const QString& fileName() const;
bool load();
~KoCtlColorSpaceInfo();
const QString& colorDepthId() const;
private:
struct Private;
Private* const d;
......
set( EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR} )
add_definitions(-DFILES_DATA_DIR="\\"${CMAKE_CURRENT_SOURCE_DIR}/../ctlcolorspaces/\\"")
########### next target ###############
set(ko_ctl_color_space_info_test_SRCS KoCtlColorSpaceInfoTest.cpp ../KoCtlColorSpaceInfo.cpp ../KoCtlParser.cpp )
kde4_add_unit_test(ko_ctl_color_space_info_test TESTNAME krita-cs-ko_ctl_color_space_info_test ${ko_ctl_color_space_info_test_SRCS})
target_link_libraries(ko_ctl_color_space_info_test ${KDE4_KDEUI_LIBS} kritaui ${QT_QTTEST_LIBRARY})
/*
* Copyright (c) 2009 Cyrille Berger <cberger@cberger.net>
*
* 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; 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 "KoCtlColorSpaceInfoTest.h"
#include <qtest_kde.h>
#include "../KoCtlColorSpaceInfo.h"
void KoCtlColorSpaceInfoTest::testCreation()
{
KoCtlColorSpaceInfo info(FILES_DATA_DIR + QString("rgba32f.ctlcs"));
QVERIFY(info.load());
QCOMPARE(info.colorDepthId(), QString( "F32"));
}
QTEST_KDEMAIN(KoCtlColorSpaceInfoTest, NoGUI)
#include "KoCtlColorSpaceInfoTest.moc"
/*
* Copyright (c) 2009 Cyrille Berger <cberger@cberger.net>
*
* 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; 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser 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 _KOCTLCOLORSPACEINFOTEST_H_
#define _KOCTLCOLORSPACEINFOTEST_H_
#include <QtTest/QtTest>
class KoCtlColorSpaceInfoTest : public QObject
{
Q_OBJECT
private slots:
void testCreation();
};
#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