diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /lib/kofficecore/tests/kooasissettingstest.cpp | |
download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip |
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
Diffstat (limited to 'lib/kofficecore/tests/kooasissettingstest.cpp')
-rw-r--r-- | lib/kofficecore/tests/kooasissettingstest.cpp | 106 |
1 files changed, 106 insertions, 0 deletions
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 <faure@kde.org> + + 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 <KoOasisSettings.h> +#include <KoDom.h> +#include <kdebug.h> +#include <assert.h> + +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 = "\ +<?xml version=\"1.0\" encoding=\"UTF-8\"?> \ +<office:document-settings xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\" xmlns:config=\"urn:oasis:names:tc:opendocument:xmlns:config:1.0\"> \ + <office:settings> \ + <config:config-item-set config:name=\"view-settings\"> \ + <config:config-item config:name=\"unit\" config:type=\"string\">mm</config:config-item> \ + <config:config-item-map-indexed config:name=\"Views\"> \ + <config:config-item-map-entry> \ + <config:config-item config:name=\"ZoomFactor\" config:type=\"short\">100</config:config-item> \ + </config:config-item-map-entry> \ + </config:config-item-map-indexed> \ + <config:config-item-map-named config:name=\"NamedMap\"> \ + <config:config-item-map-entry config:name=\"foo\"> \ + <config:config-item config:name=\"ZoomFactor\" config:type=\"int\">100</config:config-item> \ + </config:config-item-map-entry> \ + </config:config-item-map-named> \ + </config:config-item-set> \ + </office:settings> \ +</office:document-settings> \ +"; + + 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; +} |