Commit 472ed0f6 authored by Adrian Page's avatar Adrian Page

Add a configure check for kunittest and add a few basic tiled data manager tests.

Use 'make check' to run the tests.

svn path=/trunk/koffice/; revision=423210
parent 26100b8e
......@@ -78,3 +78,10 @@ if test "$magick_info_list" = 'yes'; then
else
AC_MSG_RESULT(no)
fi
# Check for kunittest
AC_MSG_CHECKING([for kunittest])
have_kunittest_header="no"
KDE_CHECK_HEADER(kunittest/tester.h, have_kunittest_header="yes", , )
AM_CONDITIONAL(include_kunittest_tests, test "$have_kunittest_header" = "yes")
if include_kunittest_tests
TESTSDIR = tests
endif
SUBDIRS = . $(TESTSDIR)
INCLUDES = -I$(srcdir)/../ \
-I$(interfacedir) \
$(KOFFICE_INCLUDES) \
......@@ -9,3 +15,4 @@ noinst_LTLIBRARIES = libkistile.la
libkistile_la_SOURCES = kis_tiledvlineiterator.cc kis_tiledhlineiterator.cc kis_tileddatamanager.cc kis_tile.cc kis_tilediterator.cc kis_tiledrectiterator.cc kis_memento.cc
libkistile_la_METASOURCES = AUTO
AM_CPPFLAGS = -I$(srcdir)/../ \
-I$(srcdir)/../.. \
$(all_includes)
# The check_ target makes sure we don't install the modules,
# $(KDE_CHECK_PLUGIN) assures a shared library is created.
check_LTLIBRARIES = kunittest_kis_tiled_data_tester.la
kunittest_kis_tiled_data_tester_la_SOURCES = kis_tiled_data_tester.cpp
kunittest_kis_tiled_data_tester_la_LIBADD = -lkunittest ../../../libkritacommon.la
kunittest_kis_tiled_data_tester_la_LDFLAGS = -module $(KDE_CHECK_PLUGIN) $(all_libraries)
check-local:
kunittestmodrunner
/*
* Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com>
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <kunittest/runner.h>
#include <kunittest/module.h>
#include "kis_tiled_data_tester.h"
#include "kis_datamanager.h"
using namespace KUnitTest;
KUNITTEST_MODULE( kunittest_kis_tiled_data_tester, "Tiled Data Tester" );
KUNITTEST_MODULE_REGISTER_TESTER( KisTiledDataTester );
#define TEST_PIXEL_SIZE 4
static Q_UINT8 defaultPixel[TEST_PIXEL_SIZE] = {0, 0, 0, OPACITY_TRANSPARENT};
void KisTiledDataTester::allTests()
{
KisDataManager *dm = new KisDataManager(TEST_PIXEL_SIZE, defaultPixel);
Q_INT32 extentX;
Q_INT32 extentY;
Q_INT32 extentWidth;
Q_INT32 extentHeight;
dm -> extent(extentX, extentY, extentWidth, extentHeight);
CHECK(extentWidth, 0);
CHECK(extentHeight, 0);
const Q_UINT8 *readOnlyPixel = dm -> pixel(KisTile::WIDTH/2, KisTile::HEIGHT/2);
dm -> extent(extentX, extentY, extentWidth, extentHeight);
CHECK(extentWidth, 0);
CHECK(extentHeight, 0);
Q_UINT8 *writablePixel = dm -> writablePixel(KisTile::WIDTH/2, KisTile::HEIGHT/2);
dm -> extent(extentX, extentY, extentWidth, extentHeight);
CHECK(extentX, 0);
CHECK(extentY, 0);
CHECK(extentWidth, KisTile::WIDTH);
CHECK(extentHeight, KisTile::HEIGHT);
writablePixel = dm -> writablePixel(-KisTile::WIDTH, -KisTile::HEIGHT);
dm -> extent(extentX, extentY, extentWidth, extentHeight);
CHECK(extentX, -KisTile::WIDTH);
CHECK(extentY, -KisTile::HEIGHT);
CHECK(extentWidth, 2*KisTile::WIDTH);
CHECK(extentHeight, 2*KisTile::HEIGHT);
dm -> clear();
dm -> extent(extentX, extentY, extentWidth, extentHeight);
CHECK(extentWidth, 0);
CHECK(extentHeight, 0);
delete dm;
}
/*
* Copyright (c) 2005 Adrian Page <adrian@pagenet.plus.com>
*
* 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef KIS_TILED_DATA_TESTER_H
#define KIS_TILED_DATA_TESTER_H
#include <kunittest/tester.h>
class KisTiledDataTester : public KUnitTest::Tester
{
public:
void allTests();
};
#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