summaryrefslogtreecommitdiff
path: root/writerfilter/qa
diff options
context:
space:
mode:
authorBjoern Michaelsen <bjoern.michaelsen@canonical.com>2011-07-23 03:12:47 +0200
committerBjoern Michaelsen <bjoern.michaelsen@canonical.com>2011-07-23 03:12:47 +0200
commit88efc04329da4914900ccbbe27050070eea14d08 (patch)
tree560591752e7b084fa23cb72ab6a2ed5bb7602789 /writerfilter/qa
parente0b4860fb10ecda319f2770de65c64b4284ec36b (diff)
revert to old writerfilter gbuilization
* gnumake4's writerfilter gbuildization got pushed in a seperate branch * it might or might not be merged to master later
Diffstat (limited to 'writerfilter/qa')
-rw-r--r--writerfilter/qa/complex/ooxml/LoadDocuments.java80
-rw-r--r--writerfilter/qa/complex/ooxml/TestDocument.java40
-rw-r--r--writerfilter/qa/complex/ooxml/makefile.mk86
-rw-r--r--writerfilter/qa/cppunittests/doctok/makefile.mk70
-rw-r--r--writerfilter/qa/cppunittests/doctok/testdoctok.cxx281
5 files changed, 349 insertions, 208 deletions
diff --git a/writerfilter/qa/complex/ooxml/LoadDocuments.java b/writerfilter/qa/complex/ooxml/LoadDocuments.java
index fe9f8f81afb7..6f05391b6d21 100644
--- a/writerfilter/qa/complex/ooxml/LoadDocuments.java
+++ b/writerfilter/qa/complex/ooxml/LoadDocuments.java
@@ -1,19 +1,9 @@
package complex.ooxml;
-
-import com.sun.star.lang.XComponent;
import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.uno.UnoRuntime;
import complexlib.ComplexTestCase;
import java.io.File;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.openoffice.test.Argument;
-import org.openoffice.test.OfficeConnection;
-import static org.junit.Assert.*;
+import com.sun.star.text.XTextDocument;
/*
* To change this template, choose Tools | Templates
@@ -24,54 +14,38 @@ import static org.junit.Assert.*;
*
* @author hb137859
*/
-public class LoadDocuments {
- @Test public void test1() {
- String testDocumentsPath = Argument.get("tdoc");
- System.out.println("Test documents in:" + testDocumentsPath);
+public class LoadDocuments extends ComplexTestCase {
+ private XMultiServiceFactory m_xMSF;
+
+ @Override
+ public String[] getTestMethodNames() {
+ return new String [] {
+ "test1"
+ };
+ }
+
+ public void before() throws Exception {
+ m_xMSF = (XMultiServiceFactory) param.getMSF();
+ }
+
+ public void test1() {
+ String testDocumentsPath = util.utils.getFullTestDocName("");
+ log.println("Test documents in:" + testDocumentsPath);
File dir = new File(testDocumentsPath);
String [] files = dir.list();
- try {
- if (files != null) {
- for (int i = 0; i < files.length; ++i) {
- System.out.println(files[i]);
- String url = TestDocument.getUrl(files[i]);
- System.out.println(url);
+ if (files != null) {
+ for (int i = 0; i < files.length; ++i) {
+ log.println(files[i]);
+ String url = util.utils.getFullTestURL(files[i]);
+ log.println(url);
- XComponent xDoc = util.DesktopTools.loadDoc(getMSF(), url, null);
- System.out.println("loaded.");
- util.DesktopTools.closeDoc(xDoc);
- System.out.println("done.");
- }
- } else {
- fail("Files not found");
+ XTextDocument xDoc = util.WriterTools.loadTextDoc(m_xMSF, url);
+ util.DesktopTools.closeDoc(xDoc);
}
+ } else {
+ failed();
}
- catch (Exception e) {
- System.out.println(e);
- fail("failed");
- }
- }
-
- private XMultiServiceFactory getMSF()
- {
- final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager());
- return xMSF1;
- }
-
- // setup and close connections
- @BeforeClass public static void setUpConnection() throws Exception
- {
- System.out.println("setUpConnection()");
- connection.setUp();
- }
-
- @AfterClass public static void tearDownConnection()
- throws InterruptedException, com.sun.star.uno.Exception
- {
- System.out.println("tearDownConnection()");
- connection.tearDown();
}
- private static final OfficeConnection connection = new OfficeConnection();
}
diff --git a/writerfilter/qa/complex/ooxml/TestDocument.java b/writerfilter/qa/complex/ooxml/TestDocument.java
deleted file mode 100644
index 95c5fe50b344..000000000000
--- a/writerfilter/qa/complex/ooxml/TestDocument.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*************************************************************************
-*
-* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-*
-* Copyright 2000, 2010 Oracle and/or its affiliates.
-*
-* OpenOffice.org - a multi-platform office productivity suite
-*
-* This file is part of OpenOffice.org.
-*
-* OpenOffice.org is free software: you can redistribute it and/or modify
-* it under the terms of the GNU Lesser General Public License version 3
-* only, as published by the Free Software Foundation.
-*
-* OpenOffice.org 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 version 3 for more details
-* (a copy is included in the LICENSE file that accompanied this code).
-*
-* You should have received a copy of the GNU Lesser General Public License
-* version 3 along with OpenOffice.org. If not, see
-* <http://www.openoffice.org/license.html>
-* for a copy of the LGPLv3 License.
-*
-************************************************************************/
-
-package complex.ooxml;
-
-import java.io.File;
-import org.openoffice.test.OfficeFileUrl;
-import org.openoffice.test.Argument;
-
-final class TestDocument {
- public static String getUrl(String name) {
- return OfficeFileUrl.getAbsolute(new File(Argument.get("tdoc"), name));
- }
-
- private TestDocument() {}
-}
diff --git a/writerfilter/qa/complex/ooxml/makefile.mk b/writerfilter/qa/complex/ooxml/makefile.mk
new file mode 100644
index 000000000000..77df9fe09dcd
--- /dev/null
+++ b/writerfilter/qa/complex/ooxml/makefile.mk
@@ -0,0 +1,86 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2008 by Sun Microsystems, Inc.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..
+TARGET = PropertyValues
+PRJNAME = $(TARGET)
+PACKAGE = complex$/ooxml
+
+# --- Settings -----------------------------------------------------
+.INCLUDE: settings.mk
+
+
+#----- compile .java files -----------------------------------------
+
+JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
+JAVAFILES = LoadDocuments.java
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+#----- make a jar from compiled files ------------------------------
+
+MAXLINELENGTH = 100000
+
+JARCLASSDIRS = $(PACKAGE)
+JARTARGET = $(TARGET).jar
+JARCOMPRESS = TRUE
+
+# --- Parameters for the test --------------------------------------
+
+# start an office if the parameter is set for the makefile
+.IF "$(OFFICE)" == ""
+CT_APPEXECCOMMAND =
+.ELSE
+CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;"
+.ENDIF
+
+# test base is java complex
+CT_TESTBASE = -TestBase java_complex
+
+# build package name with "." instead of $/
+CT_PACKAGE = -o $(PACKAGE:s\$/\.\)
+
+# start the runner application
+CT_APP = org.openoffice.Runner
+
+# --- Targets ------------------------------------------------------
+
+.IF "$(depend)" == ""
+ALL: ALLTAR
+.ELSE
+ALL: ALLDEP
+.ENDIF
+
+.INCLUDE : target.mk
+
+run: \
+ LoadDocuments
+
+RUN: run
+
+LoadDocuments:
+ +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) -tdoc $(PWD)$/testdocuments $(CT_PACKAGE).LoadDocuments
+
diff --git a/writerfilter/qa/cppunittests/doctok/makefile.mk b/writerfilter/qa/cppunittests/doctok/makefile.mk
new file mode 100644
index 000000000000..2896e297a43f
--- /dev/null
+++ b/writerfilter/qa/cppunittests/doctok/makefile.mk
@@ -0,0 +1,70 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org 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 version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ=..$/..$/..
+
+PRJNAME=writerfilter
+TARGET=test-doctok
+
+ENABLE_EXCEPTIONS=TRUE
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+CFLAGSCXX += $(CPPUNIT_CFLAGS)
+
+# BEGIN ----------------------------------------------------------------
+# auto generated Target:doctok by codegen.pl
+SHL1OBJS= \
+ $(SLO)$/testdoctok.obj
+
+SHL1TARGET= testdoctok
+SHL1STDLIBS=\
+ $(SALLIB) \
+ $(UCBHELPERLIB) \
+ $(CPPUHELPERLIB) \
+ $(CPPULIB) \
+ $(CPPUNITLIB)
+
+SHL1LIBS=\
+ $(SLB)$/doctok.lib
+SHL1DEPS= \
+ $(SHL1LIBS)
+
+SHL1IMPLIB= i$(SHL1TARGET)
+# SHL1DEF= $(MISC)$/$(SHL1TARGET).def
+
+DEF1NAME =$(SHL1TARGET)
+# DEF1EXPORTFILE= export.exp
+SHL1VERSIONMAP= export.map
+# auto generated Target:doctok
+# END ------------------------------------------------------------------
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+.INCLUDE : _cppunit.mk
diff --git a/writerfilter/qa/cppunittests/doctok/testdoctok.cxx b/writerfilter/qa/cppunittests/doctok/testdoctok.cxx
index 27b9feef32a5..250a7804d15e 100644
--- a/writerfilter/qa/cppunittests/doctok/testdoctok.cxx
+++ b/writerfilter/qa/cppunittests/doctok/testdoctok.cxx
@@ -1,176 +1,227 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
// autogenerated file with codegen.pl
-#include <sal/cppunit.h>
+#include <testshl/simpleheader.hxx>
+
#include <osl/process.h>
-#include <cppuhelper/bootstrap.hxx>
#include <ucbhelper/contentbroker.hxx>
-#include <com/sun/star/io/XInputStream.hpp>
+#include <cppuhelper/bootstrap.hxx>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <iostream>
+#include <com/sun/star/lang/XMultiComponentFactory.hpp>
+#include <com/sun/star/uno/Any.hxx>
+#include <com/sun/star/container/XNameContainer.hpp>
+#include <doctok/exceptions.hxx>
#include <doctok/WW8Document.hxx>
+#include <resourcemodel/WW8ResourceModel.hxx>
+
+#include <iostream>
namespace testdoctok
{
-using namespace ::std;
-using namespace ::com::sun::star;
-using namespace ::writerfilter::doctok;
+ using namespace ::std;
+ using namespace ::com::sun::star;
+ using namespace doctok;
-uno::Reference<io::XInputStream> xStream;
-uno::Reference<uno::XComponentContext> xContext;
-WW8Document::Pointer_t pDocument;
-uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleFileAccess;
+ uno::Reference<io::XInputStream> xStream;
+ uno::Reference<uno::XComponentContext> xContext;
+ WW8Document::Pointer_t pDocument;
+ uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleFileAccess;
-class test : public CppUnit::TestFixture
-{
-
-public:
- // initialise your test code values here.
- void setUp()
+ class test : public CppUnit::TestFixture
{
- }
- void tearDown()
- {
- }
+ public:
+ // initialise your test code values here.
+ void setUp()
+ {
+ }
- void testInitUno()
- {
- bool bResult = false;
+ void tearDown()
+ {
+ }
- // initialise UCB-Broker
- uno::Reference<uno::XComponentContext>
- xComponentContext
- (::cppu::defaultBootstrap_InitialComponentContext());
- OSL_ASSERT( xComponentContext.is() );
+ void testInitUno()
+ {
+ bool bResult = false;
- xContext = xComponentContext;
+ // initialise UCB-Broker
+ uno::Reference<uno::XComponentContext>
+ xComponentContext
+ (::cppu::defaultBootstrap_InitialComponentContext());
+ OSL_ASSERT( xComponentContext.is() );
- uno::Reference<lang::XMultiComponentFactory>
- xFactory(xComponentContext->getServiceManager() );
- OSL_ASSERT(xFactory.is());
+ xContext = xComponentContext;
- uno::Sequence<uno::Any> aUcbInitSequence(2);
- aUcbInitSequence[0] <<=
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
- aUcbInitSequence[1] <<=
- rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
+ uno::Reference<lang::XMultiComponentFactory>
+ xFactory(xComponentContext->getServiceManager() );
+ OSL_ASSERT(xFactory.is());
- uno::Reference<lang::XMultiServiceFactory>
- xServiceFactory(xFactory, uno::UNO_QUERY);
- OSL_ASSERT( xServiceFactory.is() );
+ uno::Sequence<uno::Any> aUcbInitSequence(2);
+ aUcbInitSequence[0] <<=
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local"));
+ aUcbInitSequence[1] <<=
+ rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office"));
- if (xServiceFactory.is())
- {
- sal_Bool bRet =
- ::ucbhelper::ContentBroker::initialize(xServiceFactory,
- aUcbInitSequence);
+ uno::Reference<lang::XMultiServiceFactory>
+ xServiceFactory(xFactory, uno::UNO_QUERY);
+ OSL_ASSERT( xServiceFactory.is() );
- OSL_ASSERT(bRet);
- if (bRet)
+ if (xServiceFactory.is())
{
- uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >
- xNameContainer(xFactory->createInstanceWithContext
+ sal_Bool bRet =
+ ::ucb::ContentBroker::initialize(xServiceFactory,
+ aUcbInitSequence);
+
+ OSL_ASSERT(bRet);
+ if (bRet)
+ {
+ uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess >
+ xNameContainer(xFactory->createInstanceWithContext
(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM
("com.sun.star.ucb.SimpleFileAccess" )),
- xComponentContext), uno::UNO_QUERY );
+ xComponentContext), uno::UNO_QUERY );
- if (xNameContainer.is())
- {
- xSimpleFileAccess = xNameContainer;
+ if (xNameContainer.is())
+ {
+ xSimpleFileAccess = xNameContainer;
- bResult = true;
+ bResult = true;
+ }
}
}
- }
- CPPUNIT_ASSERT_MESSAGE("UNO initialization failed",
- bResult);
- }
+ CPPUNIT_ASSERT_MESSAGE("UNO initialization failed",
+ bResult);
+ }
- // insert your test code here.
- void testOpenFile()
- {
- try
+ // insert your test code here.
+ void testOpenFile()
{
- rtl_uString *dir=NULL;
- osl_getProcessWorkingDir(&dir);
- rtl_uString *fname=NULL;
- rtl_uString_newFromAscii(&fname, "/test.doc");
- rtl_uString *absfile=NULL;
- rtl_uString_newConcat(&absfile, dir, fname);
+ try
+ {
+ rtl_uString *dir=NULL;
+ osl_getProcessWorkingDir(&dir);
+ rtl_uString *fname=NULL;
+ rtl_uString_newFromAscii(&fname, "/test.doc");
+ rtl_uString *absfile=NULL;
+ rtl_uString_newConcat(&absfile, dir, fname);
- rtl::OUString sInputFileURL( absfile );
+ rtl::OUString sInputFileURL( absfile );
- for (sal_Int32 n = 0; n < sInputFileURL.getLength(); ++n)
- {
- sal_uChar nC = sInputFileURL[n];
+ for (sal_uInt32 n = 0; n < sInputFileURL.getLength(); ++n)
+ {
+ sal_uChar nC = sInputFileURL[n];
- if (nC < 0xff && isprint(nC))
- clog << static_cast<char>(nC);
- else
- clog << ".";
- }
+ if (nC < 0xff && isprint(nC))
+ clog << static_cast<char>(nC);
+ else
+ clog << ".";
+ }
- clog << endl;
+ clog << endl;
- xStream = xSimpleFileAccess->openFileRead(sInputFileURL);
+ xStream = xSimpleFileAccess->openFileRead(sInputFileURL);
- WW8Stream::Pointer_t pStream =
- WW8DocumentFactory::createStream(xContext, xStream);
+ WW8Stream::Pointer_t pStream =
+ WW8DocumentFactory::createStream(xContext, xStream);
- pDocument.reset(WW8DocumentFactory::createDocument(pStream));
- }
+ pDocument = WW8DocumentFactory::createDocument(pStream);
+ }
catch (doctok::Exception)
- {
- clog << "Exception!!" << endl;
+ {
+ clog << "Exception!!" << endl;
+ }
+
+ CPPUNIT_ASSERT_MESSAGE("creating document failed",
+ pDocument != NULL);
+
+#if 1
}
- CPPUNIT_ASSERT_MESSAGE("creating document failed",
- pDocument != NULL);
+ void testTraversal()
+ {
+#endif
+ sal_uInt32 nResult = 0;
+
+ try
+ {
+ WW8DocumentIterator::Pointer_t pIt = pDocument->begin();
+ WW8DocumentIterator::Pointer_t pItEnd = pDocument->end();
+
+ while (! pIt->equal(*pItEnd))
+ {
+ pIt->dump(clog);
+
+ clog << endl;
+
+ WW8PropertySet::Pointer_t pAttrs = pIt->getProperties();
+
+ if (pAttrs != NULL)
+ {
+ pAttrs->dump(clog);
+ }
+
+ pIt->getText().dump(clog);
+ ++(*pIt);
+ ++nResult;
+ }
+ }
catch (doctok::Exception)
- }
+ {
+ clog << "Exception!!" << endl;
+ }
- void testEvents()
- {
- try
- {
- ::writerfilter::Stream::Pointer_t pStream = ::writerfilter::createStreamHandler();
+ char sBuffer[256];
+ snprintf(sBuffer, 255, "%d", nResult);
+ clog << "Iterator steps:" << sBuffer << endl;
- pDocument->resolve(*pStream);
+ CPPUNIT_ASSERT_MESSAGE("traversing document failed",
+ nResult > 0);
}
- catch (doctok::Exception)
+
+ void testEvents()
{
- clog << "Exception!!" << endl;
+ try
+ {
+ Stream::Pointer_t pStream = doctok::createStreamHandler();
+
+ pDocument->resolve(*pStream);
+ }
+ catch (doctok::Exception)
+ {
+ clog << "Exception!!" << endl;
+ }
}
- }
- void testEnd()
- {
- ::ucbhelper::ContentBroker::deinitialize();
- }
+ void testEnd()
+ {
+ ::ucb::ContentBroker::deinitialize();
+ }
- // Change the following lines only, if you add, remove or rename
- // member functions of the current class,
- // because these macros are need by auto register mechanism.
+ // Change the following lines only, if you add, remove or rename
+ // member functions of the current class,
+ // because these macros are need by auto register mechanism.
- CPPUNIT_TEST_SUITE(test);
- CPPUNIT_TEST(testInitUno);
- CPPUNIT_TEST(testOpenFile);
- CPPUNIT_TEST(testEvents);
- CPPUNIT_TEST(testEnd);
- CPPUNIT_TEST_SUITE_END();
-}; // class test
+ CPPUNIT_TEST_SUITE(test);
+ CPPUNIT_TEST(testInitUno);
+ CPPUNIT_TEST(testOpenFile);
+ CPPUNIT_TEST(testEvents);
+ CPPUNIT_TEST(testEnd);
+ CPPUNIT_TEST_SUITE_END();
+ }; // class test
-// -----------------------------------------------------------------------------
-CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(testdoctok::test, "doctok");
+ // -----------------------------------------------------------------------------
+ CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(testdoctok::test, "doctok");
} // namespace doctok
// -----------------------------------------------------------------------------
-CPPUNIT_PLUGIN_IMPLEMENT();
+// this macro creates an empty function, which will called by the RegisterAllFunctions()
+// to let the user the possibility to also register some functions by hand.
+NOADDITIONAL;
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */