Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit e17919e7 authored by Boudewijn Rempt's avatar Boudewijn Rempt

The tests fail, but new argument order for thorsten & the right

tests are compiled now

svn path=/trunk/koffice/; revision=664189
parent dc83cc01
......@@ -26,8 +26,8 @@
#include "KoXmlReader.h"
/// Factory for path shapes
class KoPathShapeFactory : public KoShapeFactory
/// Factory for path shapes.
class FLAKE_EXPORT KoPathShapeFactory : public KoShapeFactory
{
public:
/// constructor
......
......@@ -19,11 +19,11 @@
#ifndef KOSHAPELOADINGCONTEXT_H
#define KOSHAPELOADINGCONTEXT_H
#include <flake_export.h>
/**
* Context passed to shapes during loading
*/
class KoShapeLoadingContext
class FLAKE_EXPORT KoShapeLoadingContext
{
public:
KoShapeLoadingContext();
......
......@@ -67,7 +67,7 @@ KoShapeRegistry* KoShapeRegistry::instance()
return KoShapeRegistry::m_singleton;
}
KoShape * KoShapeRegistry::createShapeFromOdf(KoShapeLoadingContext *context, const KoXmlElement & e) const
KoShape * KoShapeRegistry::createShapeFromOdf(const KoXmlElement & e, KoShapeLoadingContext *context) const
{
Q_UNUSED( context );
Q_UNUSED( e );
......
......@@ -60,7 +60,7 @@ public:
*
* @returns the shape or 0 if no shape could be created
*/
KoShape * createShapeFromOdf(KoShapeLoadingContext *context, const KoXmlElement & e) const;
KoShape * createShapeFromOdf(const KoXmlElement & e, KoShapeLoadingContext *context) const;
private:
KoShapeRegistry();
......
......@@ -125,7 +125,7 @@ add_test(libs-flake-TestShapePainting ${EXECUTABLE_OUTPUT_PATH}/TestShapePaintin
########### next target ###############
set(TestKoShapeFactory_test_SRCS TestShapePainting.cpp )
set(TestKoShapeFactory_test_SRCS TestKoShapeFactory.cpp )
kde4_automoc(${TestKoShapeFactory_test_SRCS})
......@@ -137,15 +137,15 @@ add_test(libs-flake-TestKoShapeFactory ${EXECUTABLE_OUTPUT_PATH}/TestKoShapeFact
########### next target ###############
set(TestKoShapeFactory_test_SRCS TestShapePainting.cpp )
set(TestKoShapeRegistry_test_SRCS TestKoShapeRegistry.cpp )
kde4_automoc(${TestKoShapeFactory_test_SRCS})
kde4_automoc(${TestKoShapeRegistry_test_SRCS})
kde4_add_executable(TestKoShapeFactory RUN_UNINSTALLED ${TestKoShapeFactory_test_SRCS})
kde4_add_executable(TestKoShapeRegistry RUN_UNINSTALLED ${TestKoShapeRegistry_test_SRCS})
target_link_libraries(TestKoShapeFactory ${KDE4_KDECORE_LIBS} flake ${QT_QTTEST_LIBRARY})
target_link_libraries(TestKoShapeRegistry ${KDE4_KDECORE_LIBS} flake ${QT_QTTEST_LIBRARY})
add_test(libs-flake-TestKoShapeFactory ${EXECUTABLE_OUTPUT_PATH}/TestKoShapeFactory)
add_test(libs-flake-TestKoShapeRegistry ${EXECUTABLE_OUTPUT_PATH}/TestKoShapeRegistry)
########### next target ###############
......
/* This file is part of the KDE project
* Copyright (c) 2007 Boudewijn Rempt (boud@valdyas.org)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* 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 "TestKoShapeFactory.h"
#include <QBuffer>
#include <QFile>
#include <QDateTime>
#include <QProcess>
#include <QString>
#include <QTextStream>
#include <QtXml>
#include <QStringList>
#include "KoShapeRegistry.h"
#include "KoPathShapeFactory.h"
#include "KoShape.h"
#include "KoShapeFactory.h"
#include "KoShapeLoadingContext.h"
#include "KoPathShape.h"
#include <KoXmlReader.h>
#include <KoXmlNS.h>
#include <kdebug.h>
void TestKoShapeFactory::testCreateFactory()
{
KoShapeFactory * factory = new KoPathShapeFactory(0, QStringList());
QVERIFY( factory != 0 );
}
void TestKoShapeFactory::testSupportsKoXmlElement()
{
}
void TestKoShapeFactory::testPriority()
{
KoShapeFactory * factory = new KoPathShapeFactory(0, QStringList());
QVERIFY( factory->loadingPriority() == 0 );
}
void TestKoShapeFactory::testCreateDefaultShape()
{
KoShapeFactory * factory = new KoPathShapeFactory(0, QStringList());
KoShape * shape = factory->createDefaultShape();
QVERIFY( shape != 0 );
QVERIFY( shape->shapeId() == KoPathShapeId );
}
void TestKoShapeFactory::testCreateShape()
{
KoShapeFactory * factory = new KoPathShapeFactory(0, QStringList());
KoShape * shape = factory->createShape( 0 );
QVERIFY( shape != 0 );
QVERIFY( shape->shapeId() == KoPathShapeId );
}
void TestKoShapeFactory::testOdfElement()
{
KoShapeFactory * factory = new KoPathShapeFactory(0, QStringList());
QVERIFY( factory->odfElementName() == "path" );
QVERIFY( factory->odfNameSpace() == KoXmlNS::draw );
QBuffer xmldevice;
xmldevice.open( QIODevice::WriteOnly );
QTextStream xmlstream( &xmldevice );
xmlstream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
xmlstream << "<office:document-content xmlns:office=\"urn:oasis:names:tc:opendocument:xmlns:office:1.0\" xmlns:meta=\"urn:oasis:names:tc:opendocument:xmlns:meta:1.0\" xmlns:config=\"urn:oasis:names:tc:opendocument:xmlns:config:1.0\" xmlns:text=\"urn:oasis:names:tc:opendocument:xmlns:text:1.0\" xmlns:table=\"urn:oasis:names:tc:opendocument:xmlns:table:1.0\" xmlns:draw=\"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0\" xmlns:presentation=\"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0\" xmlns:dr3d=\"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0\" xmlns:chart=\"urn:oasis:names:tc:opendocument:xmlns:chart:1.0\" xmlns:form=\"urn:oasis:names:tc:opendocument:xmlns:form:1.0\" xmlns:script=\"urn:oasis:names:tc:opendocument:xmlns:script:1.0\" xmlns:style=\"urn:oasis:names:tc:opendocument:xmlns:style:1.0\" xmlns:number=\"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0\" xmlns:math=\"http://www.w3.org/1998/Math/MathML\" xmlns:svg=\"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0\" xmlns:fo=\"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0\" xmlns:koffice=\"http://www.koffice.org/2005/\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">";
xmlstream << "<office:font-face-decls>";
xmlstream << "<style:font-face style:name=\"Georgia\" svg:font-family=\"Georgia\"/>";
xmlstream << "</office:font-face-decls>";
xmlstream << "<office:automatic-styles>";
xmlstream << "<style:style style:name=\"P1\" style:parent-style-name=\"Standard\" style:family=\"paragraph\" style:master-page-name=\"Standard\">";
xmlstream << "<style:paragraph-properties style:page-number=\"1\" style:writing-mode=\"lr-tb\"/>";
xmlstream << "<style:text-properties/>";
xmlstream << "</style:style>";
xmlstream << "</office:automatic-styles>";
xmlstream << "<office:body>";
xmlstream << "<office:text>";
xmlstream << "<text:p text:style-name=\"P1\"><?opendocument cursor-position?></text:p>";
xmlstream << "<draw:path svg:d=\"M0,0L100,100\"></draw:path>";
xmlstream << "</office:text>";
xmlstream << "</office:body>";
xmlstream << "</office:document-content>";
xmldevice.close();
KoXmlDocument doc;
QString errorMsg;
int errorLine = 0;
int errorColumn = 0;
QCOMPARE( doc.setContent( &xmldevice, true, &errorMsg, &errorLine, &errorColumn ), true );
QCOMPARE( errorMsg.isEmpty(), true );
QCOMPARE( errorLine, 0 );
QCOMPARE( errorColumn, 0 );
KoXmlElement contentElement = doc.documentElement();
KoXmlElement bodyElement = contentElement.firstChild().toElement();
QTEST( factory->supports( bodyElement ), false );
KoXmlElement textElement = bodyElement.firstChild().toElement();
QTEST( factory->supports( textElement ), false );
KoXmlElement pathElement = bodyElement.firstChild().nextSibling().toElement();
QCOMPARE( factory->supports( pathElement ), true );
}
QTEST_MAIN(TestKoShapeFactory)
#include "TestKoShapeFactory.moc"
/* This file is part of the KDE project
* Copyright (c) 2007 Boudewijn Rempt (boud@valdyas.org)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* 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.
*/
#ifndef TestKoShapeFactory_H
#define TestKoShapeFactory_H
#include <QtTest/QtTest>
class TestKoShapeFactory : public QObject
{
Q_OBJECT
private slots:
// tests
void testCreateFactory();
void testSupportsKoXmlElement();
void testPriority();
void testCreateDefaultShape();
void testCreateShape();
void testOdfElement();
};
#endif
......@@ -37,7 +37,7 @@
void TestKoShapeRegistry::testGetKoShapeRegistryInstance()
{
KoShapeRegistry * registry = KoShapeRegistry::instance();
QCOMPARE( registry, 0 );
QVERIFY( registry != 0 );
}
void TestKoShapeRegistry::testCreateEmptyShape()
......@@ -81,8 +81,8 @@ void TestKoShapeRegistry::testCreateEmptyShape()
KoShapeRegistry * registry = KoShapeRegistry::instance();
KoShapeLoadingContext * context = new KoShapeLoadingContext();
KoShape * shape = registry->createShapeFromOdf(context, bodyElement);
QCOMPARE( shape, 0 );
KoShape * shape = registry->createShapeFromOdf(bodyElement, context);
QVERIFY( shape == 0 );
}
......
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