From 477e19d22f7952c78df22416099a4f57f9e90684 Mon Sep 17 00:00:00 2001 From: Bjoern Michaelsen Date: Mon, 17 Sep 2012 18:54:04 +0100 Subject: targetted make reversion. --- writerfilter/CppunitTest_writerfilter_doctok.mk | 6 +- writerfilter/Module_writerfilter.mk | 5 +- writerfilter/qa/complex/ooxml/LoadDocuments.java | 79 +++--- writerfilter/qa/complex/ooxml/TestDocument.java | 31 --- writerfilter/qa/cppunittests/doctok/testdoctok.cxx | 271 ++++++++++++++------- 5 files changed, 213 insertions(+), 179 deletions(-) delete mode 100644 writerfilter/qa/complex/ooxml/TestDocument.java diff --git a/writerfilter/CppunitTest_writerfilter_doctok.mk b/writerfilter/CppunitTest_writerfilter_doctok.mk index ae2fb2c16144..fd2fe872b30f 100644 --- a/writerfilter/CppunitTest_writerfilter_doctok.mk +++ b/writerfilter/CppunitTest_writerfilter_doctok.mk @@ -45,9 +45,7 @@ $(eval $(call gb_CppunitTest_set_include,writerfilter_doctok,\ -I$(SRCDIR)/writerfilter/inc \ )) -$(eval $(call gb_CppunitTest_use_api,writerfilter_doctok,\ - offapi \ - udkapi \ -)) +$(eval $(call gb_CppunitTest_use_sdk_api,writerfilter_doctok)) +$(eval $(call gb_CppunitTest_use_udk_api,writerfilter_doctok)) # vim: set noet sw=4 ts=4: diff --git a/writerfilter/Module_writerfilter.mk b/writerfilter/Module_writerfilter.mk index 4daf029e4b2b..0b33587ba1b5 100644 --- a/writerfilter/Module_writerfilter.mk +++ b/writerfilter/Module_writerfilter.mk @@ -35,12 +35,9 @@ $(eval $(call gb_Module_add_targets,writerfilter,\ )) $(eval $(call gb_Module_add_check_targets,writerfilter,\ - CppunitTest_writerfilter_doctok \ CppunitTest_writerfilter_rtftok \ )) -$(eval $(call gb_Module_add_subsequentcheck_targets,writerfilter,\ - JunitTest_writerfilter_complex \ -)) +# CppunitTest_writerfilter_doctok \ # vim: set noet sw=4 ts=4: diff --git a/writerfilter/qa/complex/ooxml/LoadDocuments.java b/writerfilter/qa/complex/ooxml/LoadDocuments.java index 984ef76a10e1..acbbdb606ff3 100644 --- a/writerfilter/qa/complex/ooxml/LoadDocuments.java +++ b/writerfilter/qa/complex/ooxml/LoadDocuments.java @@ -17,17 +17,10 @@ */ 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.AfterClass; -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 @@ -38,54 +31,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 e29b7e76ab4a..000000000000 --- a/writerfilter/qa/complex/ooxml/TestDocument.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -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/cppunittests/doctok/testdoctok.cxx b/writerfilter/qa/cppunittests/doctok/testdoctok.cxx index b86fb925f67b..7fef9a63d886 100644 --- a/writerfilter/qa/cppunittests/doctok/testdoctok.cxx +++ b/writerfilter/qa/cppunittests/doctok/testdoctok.cxx @@ -17,141 +17,234 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include + #include +#include +#include #include #include "cppunit/TestAssert.h" #include "cppunit/TestFixture.h" #include "cppunit/extensions/HelperMacros.h" #include "cppunit/plugin/TestPlugIn.h" -#include #include +#include #include -#include +#include +#include +#include +#include #include +#include + +#include namespace testdoctok { -using namespace ::std; -using namespace ::com::sun::star; -using namespace ::writerfilter::doctok; + using namespace ::std; + using namespace ::writerfilter::doctok; + using namespace ::com::sun::star; -uno::Reference xStream; -uno::Reference xContext; -WW8Document::Pointer_t pDocument; -uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > xSimpleFileAccess; + uno::Reference xStream; + uno::Reference 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() + { + } - uno::Reference - xComponentContext - (::cppu::defaultBootstrap_InitialComponentContext()); - OSL_ASSERT( xComponentContext.is() ); + void testInitUno() + { + bool bResult = false; - xContext = xComponentContext; + // initialise UCB-Broker + uno::Reference + xComponentContext + (::cppu::defaultBootstrap_InitialComponentContext()); + OSL_ASSERT( xComponentContext.is() ); - uno::Reference - xFactory(xComponentContext->getServiceManager() ); - OSL_ASSERT(xFactory.is()); + xContext = xComponentContext; - uno::Reference - xServiceFactory(xFactory, uno::UNO_QUERY); - OSL_ASSERT( xServiceFactory.is() ); + uno::Reference + xFactory(xComponentContext->getServiceManager() ); + OSL_ASSERT(xFactory.is()); - if (xServiceFactory.is()) - { - uno::Reference< ::com::sun::star::ucb::XSimpleFileAccess > - xNameContainer(xFactory->createInstanceWithContext - ("com.sun.star.ucb.SimpleFileAccess", - xComponentContext), uno::UNO_QUERY ); + uno::Sequence aUcbInitSequence(2); + aUcbInitSequence[0] <<= + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local")); + aUcbInitSequence[1] <<= + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Office")); - if (xNameContainer.is()) - { - xSimpleFileAccess = xNameContainer; + uno::Reference + xServiceFactory(xFactory, uno::UNO_QUERY); + OSL_ASSERT( xServiceFactory.is() ); - bResult = true; + if (xServiceFactory.is()) + { + 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::createFromAscii + ("com.sun.star.ucb.SimpleFileAccess" ), + xComponentContext), uno::UNO_QUERY ); + + if (xNameContainer.is()) + { + xSimpleFileAccess = xNameContainer; + + bResult = true; + } + } } + + CPPUNIT_ASSERT_MESSAGE("UNO initialization failed", + bResult); } - CPPUNIT_ASSERT_MESSAGE("UNO initialization failed", - bResult); - } + // insert your test code here. + void testOpenFile() + { + try + { + rtl_uString *dir=NULL; + osl_getProcessWorkingDir(&dir); + rtl_uString *fname=NULL; + //rtl_uString_newFromAscii(&fname, "/OpenDocument-v1.doc"); + rtl_uString_newFromAscii(&fname, "/test.doc"); + //rtl_uString_newFromAscii(&fname, "/numbers.doc"); + rtl_uString *absfile=NULL; + rtl_uString_newConcat(&absfile, dir, fname); - // 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); + rtl::OUString sInputFileURL( absfile ); - OUString sInputFileURL( absfile ); + for (sal_uInt32 n = 0; n < sInputFileURL.getLength(); ++n) + { + sal_uChar nC = sInputFileURL[n]; - for (sal_Int32 n = 0; n < sInputFileURL.getLength(); ++n) - { - sal_uChar nC = sInputFileURL[n]; + if (nC < 0xff && isprint(nC)) + clog << static_cast(nC); + else + clog << "."; + } + + clog << endl; + + xStream = xSimpleFileAccess->openFileRead(sInputFileURL); + + WW8Stream::Pointer_t pStream = + WW8DocumentFactory::createStream(xContext, xStream); - if (nC < 0xff && isprint(nC)) - clog << static_cast(nC); - else - clog << "."; + pDocument = WW8DocumentFactory::createDocument(pStream); + } + catch (writerfilter::Exception e) + { + clog << "Exception!!" << endl; + } + + CPPUNIT_ASSERT_MESSAGE("creating document failed", + pDocument != NULL); + +#if 1 } - clog << endl; + void testTraversal() + { +#endif + sal_uInt32 nResult = 0; - xStream = xSimpleFileAccess->openFileRead(sInputFileURL); + try + { + WW8DocumentIterator::Pointer_t pIt = pDocument->begin(); + WW8DocumentIterator::Pointer_t pItEnd = pDocument->end(); - WW8Stream::Pointer_t pStream = - WW8DocumentFactory::createStream(xContext, xStream); + while (! pIt->equal(*pItEnd)) + { + pIt->dump(clog); - pDocument.reset(WW8DocumentFactory::createDocument(pStream)); + clog << endl; - CPPUNIT_ASSERT_MESSAGE("creating document failed", - pDocument != NULL); - } + WW8PropertySet::Pointer_t pAttrs = pIt->getProperties(); - void testEvents() - { - ::writerfilter::Stream::Pointer_t pStream = ::writerfilter::createStreamHandler(); + if (pAttrs != NULL) + { + pAttrs->dump(clog); + } - pDocument->resolve(*pStream); - } + pIt->getText().dump(clog); + ++(*pIt); + ++nResult; + } + } + catch (writerfilter::Exception e) + { + clog << "Exception!!" << endl; + } - // 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. + char sBuffer[256]; + snprintf(sBuffer, 255, "%d", nResult); + clog << "Iterator steps:" << sBuffer << endl; - CPPUNIT_TEST_SUITE(test); - CPPUNIT_TEST(testInitUno); - CPPUNIT_TEST(testOpenFile); - CPPUNIT_TEST(testEvents); - CPPUNIT_TEST_SUITE_END(); -}; // class test + CPPUNIT_ASSERT_MESSAGE("traversing document failed", + nResult > 0); + } -// ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(testdoctok::test, "doctok"); -} // namespace doctok + void testEvents() + { + try + { + Stream::Pointer_t pStream = doctok::createStreamHandler(); + + pDocument->resolve(*pStream); + } + catch (writerfilter::Exception e) + { + clog << "Exception!!" << endl; + } + } + + 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. + + CPPUNIT_TEST_SUITE(test); + CPPUNIT_TEST(testInitUno); + CPPUNIT_TEST(testOpenFile); + //CPPUNIT_TEST(testTraversal); + CPPUNIT_TEST(testEvents); + CPPUNIT_TEST(testEnd); + CPPUNIT_TEST_SUITE_END(); + }; // class test + + // ----------------------------------------------------------------------------- + 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: */ -- cgit v1.2.3