From 8362bf63dea22bbf6736609b0f49c152f975eb63 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 20 Jan 2010 01:29:50 +0000 Subject: Added old abandoned KDE3 version of koffice git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- lib/kofficecore/tests/kooasissettingstest.cpp | 106 ++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 lib/kofficecore/tests/kooasissettingstest.cpp (limited to 'lib/kofficecore/tests/kooasissettingstest.cpp') diff --git a/lib/kofficecore/tests/kooasissettingstest.cpp b/lib/kofficecore/tests/kooasissettingstest.cpp new file mode 100644 index 00000000..ef29536d --- /dev/null +++ b/lib/kofficecore/tests/kooasissettingstest.cpp @@ -0,0 +1,106 @@ +/* This file is part of the KDE project + Copyright (C) 2004 David Faure + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License version 2 as published by the Free Software Foundation. + + 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library 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 +#include +#include +#include + +void testSelectItemSet( KoOasisSettings& settings ) +{ + KoOasisSettings::Items items = settings.itemSet( "notexist" ); + assert( items.isNull() ); + items = settings.itemSet( "view-settings" ); + assert( !items.isNull() ); + kdDebug() << "testSelectItemSet OK" << endl; +} + +void testParseConfigItemString( KoOasisSettings& settings ) +{ + KoOasisSettings::Items viewSettings = settings.itemSet( "view-settings" ); + const QString unit = viewSettings.parseConfigItemString( "unit" ); + qDebug( "%s", unit.latin1() ); + assert( unit == "mm" ); + kdDebug() << "testParseConfigItemString OK" << endl; +} + +void testIndexedMap( KoOasisSettings& settings ) +{ + KoOasisSettings::Items viewSettings = settings.itemSet( "view-settings" ); + assert( !viewSettings.isNull() ); + KoOasisSettings::IndexedMap viewMap = viewSettings.indexedMap( "Views" ); + assert( !viewMap.isNull() ); + KoOasisSettings::Items firstView = viewMap.entry( 0 ); + assert( !firstView.isNull() ); + const short zoomFactor = firstView.parseConfigItemShort( "ZoomFactor" ); + assert( zoomFactor == 100 ); + KoOasisSettings::Items secondView = viewMap.entry( 1 ); + assert( secondView.isNull() ); + kdDebug() << "testIndexedMap OK" << endl; +} + +void testNamedMap( KoOasisSettings& settings ) +{ + KoOasisSettings::Items viewSettings = settings.itemSet( "view-settings" ); + assert( !viewSettings.isNull() ); + KoOasisSettings::NamedMap viewMap = viewSettings.namedMap( "NamedMap" ); + assert( !viewMap.isNull() ); + KoOasisSettings::Items foo = viewMap.entry( "foo" ); + assert( !foo.isNull() ); + const int zoomFactor = foo.parseConfigItemShort( "ZoomFactor" ); + assert( zoomFactor == 100 ); + KoOasisSettings::Items secondView = viewMap.entry( "foobar" ); + assert( secondView.isNull() ); + kdDebug() << "testNamedMap OK" << endl; +} + +int main( int, char** ) { + + const QCString xml = "\ + \ + \ + \ + \ + mm \ + \ + \ + 100 \ + \ + \ + \ + \ + 100 \ + \ + \ + \ + \ + \ +"; + + QDomDocument doc; + bool ok = doc.setContent( xml, true /* namespace processing */ ); + assert( ok ); + + KoOasisSettings settings( doc ); + + testSelectItemSet( settings ); + testParseConfigItemString( settings ); + testIndexedMap( settings ); + testNamedMap( settings ); + return 0; +} -- cgit v1.2.1