diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-04-11 21:35:58 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-04-11 21:41:58 +0100 |
commit | 6a52e0ced42ac6d92bea1cb1dbdaf442d34a908f (patch) | |
tree | c33a28a2915ae3cd80bc54868afd6040e639764a /lotuswordpro/qa | |
parent | d2a1c2d4cfa51b6ee8a7f38baa258633fae9ec6d (diff) |
add a test harness and samples
Diffstat (limited to 'lotuswordpro/qa')
-rw-r--r-- | lotuswordpro/qa/cppunit/data/fail/A14.lwp | bin | 0 -> 82280 bytes | |||
-rw-r--r-- | lotuswordpro/qa/cppunit/data/fail/IntPres11-2004.lwp | bin | 0 -> 5417924 bytes | |||
-rw-r--r-- | lotuswordpro/qa/cppunit/data/pass/A14.lwp | bin | 0 -> 82280 bytes | |||
-rw-r--r-- | lotuswordpro/qa/cppunit/data/pass/IntPres11-2004.lwp | bin | 0 -> 5417924 bytes | |||
-rw-r--r-- | lotuswordpro/qa/cppunit/makefile.mk | 108 | ||||
-rw-r--r-- | lotuswordpro/qa/cppunit/test_lotuswordpro.cxx | 152 | ||||
-rw-r--r-- | lotuswordpro/qa/cppunit/version.map | 34 |
7 files changed, 294 insertions, 0 deletions
diff --git a/lotuswordpro/qa/cppunit/data/fail/A14.lwp b/lotuswordpro/qa/cppunit/data/fail/A14.lwp Binary files differnew file mode 100644 index 000000000000..9dd36f626456 --- /dev/null +++ b/lotuswordpro/qa/cppunit/data/fail/A14.lwp diff --git a/lotuswordpro/qa/cppunit/data/fail/IntPres11-2004.lwp b/lotuswordpro/qa/cppunit/data/fail/IntPres11-2004.lwp Binary files differnew file mode 100644 index 000000000000..7672793e7d5b --- /dev/null +++ b/lotuswordpro/qa/cppunit/data/fail/IntPres11-2004.lwp diff --git a/lotuswordpro/qa/cppunit/data/pass/A14.lwp b/lotuswordpro/qa/cppunit/data/pass/A14.lwp Binary files differnew file mode 100644 index 000000000000..7cc05cebc036 --- /dev/null +++ b/lotuswordpro/qa/cppunit/data/pass/A14.lwp diff --git a/lotuswordpro/qa/cppunit/data/pass/IntPres11-2004.lwp b/lotuswordpro/qa/cppunit/data/pass/IntPres11-2004.lwp Binary files differnew file mode 100644 index 000000000000..786164ea46b4 --- /dev/null +++ b/lotuswordpro/qa/cppunit/data/pass/IntPres11-2004.lwp diff --git a/lotuswordpro/qa/cppunit/makefile.mk b/lotuswordpro/qa/cppunit/makefile.mk new file mode 100644 index 000000000000..a7a863efe49d --- /dev/null +++ b/lotuswordpro/qa/cppunit/makefile.mk @@ -0,0 +1,108 @@ +#************************************************************************* +# +# 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=lotuswordpro +TARGET=qa_lotuswordpro + +ENABLE_EXCEPTIONS=TRUE + +my_components = qa_lwpfilter + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +CFLAGSCXX += $(CPPUNIT_CFLAGS) +DLLPRE = # no leading "lib" on .so files + +# --- Libs --------------------------------------------------------- + +SHL1OBJS= \ + $(SLO)/test_lotuswordpro.obj + +SHL1STDLIBS= \ + $(VCLLIB) \ + $(COMPHELPERLIB) \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(SALLIB) \ + $(CPPUNITLIB) + +SHL1TARGET= test_lotuswordpro +SHL1RPATH = NONE +SHL1IMPLIB= i$(SHL1TARGET) +DEF1NAME=$(SHL1TARGET) +SHL1VERSIONMAP= version.map + +# --- All object files --------------------------------------------- + +SLOFILES= \ + $(SHL1OBJS) + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +.IF "$(OS)" == "WNT" +my_file = file:/// +.ELSE +my_file = file:// +.END + +ALLTAR: test + +$(MISC)$/$(TARGET)$/types.rdb .ERRREMOVE : $(SOLARBINDIR)$/types.rdb + $(MKDIRHIER) $(@:d) + $(GNUCOPY) $? $@ + +$(MISC)/$(TARGET)/udkapi.rdb .ERRREMOVE : $(SOLARBINDIR)$/udkapi.rdb + $(MKDIRHIER) $(@:d) + $(GNUCOPY) $? $@ + +#Make a services.rdb with the services we know we need to get up and running +$(MISC)/$(TARGET)/services.rdb .ERRREMOVE: $(SOLARENV)/bin/packcomponents.xslt \ + $(MISC)/$(TARGET)/services.input \ + $(my_components:^"$(MISC)/":+".component") + $(XSLTPROC) --nonet --stringparam prefix $(PWD)/$(MISC)/ -o $@ \ + $(SOLARENV)/bin/packcomponents.xslt $(MISC)/$(TARGET)/services.input + +$(MISC)/$(TARGET)/services.input: + $(MKDIRHIER) $(@:d) + echo \ + '<list>$(my_components:^"<filename>":+".component</filename>")</list>' \ + > $@ + +test .PHONY: $(SHL1TARGETN) $(MISC)/$(TARGET)/services.rdb $(MISC)$/$(TARGET)$/types.rdb $(MISC)/$(TARGET)/udkapi.rdb + @echo ---------------------------------------------------------- + @echo - start unit test \#1 on library $(SHL1TARGETN) + @echo ---------------------------------------------------------- + $(CPPUNITTESTER) $(SHL1TARGETN) --headless --invisible \ + -env:UNO_SERVICES=$(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb \ + -env:UNO_TYPES="$(my_file)$(PWD)/$(MISC)/$(TARGET)/types.rdb $(my_file)$(PWD)/$(MISC)/$(TARGET)/udkapi.rdb" \ + -env:OOO_INBUILD_SHAREDLIB_DIR="$(my_file)$(PWD)/$(DLLDEST)" diff --git a/lotuswordpro/qa/cppunit/test_lotuswordpro.cxx b/lotuswordpro/qa/cppunit/test_lotuswordpro.cxx new file mode 100644 index 000000000000..c721fa1bb1ce --- /dev/null +++ b/lotuswordpro/qa/cppunit/test_lotuswordpro.cxx @@ -0,0 +1,152 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * Version: MPL 1.1 / GPLv3+ / LGPLv3+ + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (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.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Initial Developer of the Original Code is + * Caolán McNamara <caolanm@redhat.com> (Red Hat, Inc.) + * Portions created by the Initial Developer are Copyright (C) 2011 the + * Initial Developer. All Rights Reserved. + * + * Contributor(s): Caolán McNamara <caolanm@redhat.com> + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 3 or later (the "GPLv3+"), or + * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"), + * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable + * instead of those above. + */ + +#include <cppunit/TestAssert.h> +#include <cppunit/TestFixture.h> +#include <cppunit/plugin/TestPlugIn.h> +#include <cppunit/extensions/HelperMacros.h> + +#include <cppuhelper/bootstrap.hxx> +#include <comphelper/processfactory.hxx> + +#include <com/sun/star/lang/XMultiComponentFactory.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/document/XFilter.hpp> + +#include <osl/file.hxx> +#include <osl/process.h> + +#include <vcl/svapp.hxx> + +using namespace ::com::sun::star; + +namespace +{ + class LotusWordProTest : public ::CppUnit::TestFixture + { + public: + LotusWordProTest(); + + virtual void setUp(); + virtual void tearDown(); + + void recursiveScan(const rtl::OUString &rURL, bool bExpected); + bool load(const rtl::OUString &rURL); + void test(); + + CPPUNIT_TEST_SUITE(LotusWordProTest); + CPPUNIT_TEST(test); + CPPUNIT_TEST_SUITE_END(); + private: + uno::Reference<uno::XComponentContext> m_xContext; + uno::Reference<lang::XMultiComponentFactory> m_xFactory; + uno::Reference<lang::XMultiServiceFactory> m_xMSF; + uno::Reference<document::XFilter> m_xFilter; + + ::rtl::OUString m_aPWDURL; + int m_nLoadedDocs; + }; + + LotusWordProTest::LotusWordProTest() : m_nLoadedDocs(0) + { + m_xContext = cppu::defaultBootstrap_InitialComponentContext(); + m_xFactory = m_xContext->getServiceManager(); + m_xMSF = uno::Reference<lang::XMultiServiceFactory>(m_xFactory, uno::UNO_QUERY_THROW); + m_xFilter = uno::Reference< document::XFilter >(m_xMSF->createInstance( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Writer.LotusWordProImportFilter"))), + uno::UNO_QUERY_THROW); + + oslProcessError err = osl_getProcessWorkingDir(&m_aPWDURL.pData); + CPPUNIT_ASSERT_MESSAGE("no PWD!", err == osl_Process_E_None); + + //Without this we're crashing because callees are using + //getProcessServiceFactory. In general those should be removed in favour + //of retaining references to the root ServiceFactory as its passed around + comphelper::setProcessServiceFactory(m_xMSF); + + //Lotus Import filter pokes at printers :-( + InitVCL(m_xMSF); + } + + void LotusWordProTest::setUp() + { + } + + void LotusWordProTest::tearDown() + { + } + + bool LotusWordProTest::load(const rtl::OUString &rURL) + { + uno::Sequence< beans::PropertyValue > aDescriptor(1); + aDescriptor[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URL")); + aDescriptor[0].Value <<= rURL; + sal_Bool bRet = m_xFilter->filter(aDescriptor); + + ++m_nLoadedDocs; + + return bRet; + } + + void LotusWordProTest::recursiveScan(const rtl::OUString &rURL, bool bExpected) + { + osl::Directory aDir(rURL); + + CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.open()); + osl::DirectoryItem aItem; + osl::FileStatus aFileStatus(FileStatusMask_FileURL|FileStatusMask_Type); + while (aDir.getNextItem(aItem) == osl::FileBase::E_None) + { + aItem.getFileStatus(aFileStatus); + rtl::OUString sURL = aFileStatus.getFileURL(); + if (aFileStatus.getFileType() == osl::FileStatus::Directory) + recursiveScan(sURL, bExpected); + else + { + bool bRes = load(sURL); + rtl::OString aRes(rtl::OUStringToOString(sURL, osl_getThreadTextEncoding())); + CPPUNIT_ASSERT_MESSAGE(aRes.getStr(), bRes == bExpected); + } + } + CPPUNIT_ASSERT(osl::FileBase::E_None == aDir.close()); + } + + void LotusWordProTest::test() + { + recursiveScan(m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/data/pass/")), true); + recursiveScan(m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/data/fail/")), false); + + printf("LotusWordPro: tested %d files\n", m_nLoadedDocs); + } + + CPPUNIT_TEST_SUITE_REGISTRATION(LotusWordProTest); +} + +CPPUNIT_PLUGIN_IMPLEMENT(); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/lotuswordpro/qa/cppunit/version.map b/lotuswordpro/qa/cppunit/version.map new file mode 100644 index 000000000000..3308588ef6f8 --- /dev/null +++ b/lotuswordpro/qa/cppunit/version.map @@ -0,0 +1,34 @@ +#************************************************************************* +# +# 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. +# +#************************************************************************* + +UDK_3_0_0 { + global: + cppunitTestPlugIn; + + local: + *; +}; |