From ca72c1cea799c7fa4ed5e84261c40a73e3b3a273 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Tue, 7 Jun 2011 23:07:05 +0100 Subject: restore filters qa test --- sw/CppunitTest_sw_test_filters.mk | 95 +++++++++++++++++++++++++++++++++++++++ sw/Module_sw.mk | 4 ++ sw/qa/core/filters-test.cxx | 82 +++++++++++++++++++-------------- 3 files changed, 148 insertions(+), 33 deletions(-) create mode 100644 sw/CppunitTest_sw_test_filters.mk diff --git a/sw/CppunitTest_sw_test_filters.mk b/sw/CppunitTest_sw_test_filters.mk new file mode 100644 index 000000000000..307986b89d57 --- /dev/null +++ b/sw/CppunitTest_sw_test_filters.mk @@ -0,0 +1,95 @@ +#************************************************************************* +# 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 or as specified alternatively below. 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, Red Hat, Inc. +# Portions created by the Initial Developer are Copyright (C) 2011 the +# Initial Developer. All Rights Reserved. +# +# Major Contributor(s): +# +# For minor contributions see the git repository. +# +# 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. +#************************************************************************* + +$(eval $(call gb_CppunitTest_CppunitTest,sw_filters_test)) + +$(eval $(call gb_CppunitTest_add_exception_objects,sw_filters_test, \ + sw/qa/core/filters-test \ +)) + +$(eval $(call gb_CppunitTest_add_linked_libs,sw_filters_test, \ + sw \ + sfx \ + svl \ + svt \ + vcl \ + tl \ + ucbhelper \ + utl \ + i18nisolang1 \ + comphelper \ + cppu \ + cppuhelper \ + sal \ + $(gb_STDLIBS) \ +)) + +$(eval $(call gb_CppunitTest_set_include,sw_filters_test,\ + -I$(realpath $(SRCDIR)/sw/inc/pch) \ + -I$(realpath $(SRCDIR)/sw/source/ui/inc) \ + -I$(realpath $(SRCDIR)/sw/inc) \ + $$(INCLUDE) \ + -I$(OUTDIR)/inc/offuh \ + -I$(OUTDIR)/inc \ +)) + +$(eval $(call gb_CppunitTest_uses_ure,sw_filters_test)) + +$(eval $(call gb_CppunitTest_add_type_rdbs,sw_filters_test,\ + types \ +)) + +$(eval $(call gb_CppunitTest_add_service_rdbs,sw_filters_test,\ + sw_filters_test \ +)) + +$(eval $(call gb_CppunitTest_set_args,sw_filters_test,\ + --headless \ + --invisible \ +)) + +$(eval $(call gb_RdbTarget_RdbTarget,sw_filters_test)) + +$(eval $(call gb_RdbTarget_add_components,sw_filters_test,\ + sw/util/sw \ + sw/util/msword \ + sfx2/util/sfx \ + framework/util/fwk \ + unoxml/source/service/unoxml \ + fileaccess/source/fileacc \ + comphelper/util/comphelp \ +)) + +$(eval $(call gb_RdbTarget_add_old_components,sw_filters_test,\ + i18npool \ + ucb1 \ + ucpfile1 \ +)) + +# vim: set noet sw=4: diff --git a/sw/Module_sw.mk b/sw/Module_sw.mk index c6257e22fc93..0394f37ea321 100644 --- a/sw/Module_sw.mk +++ b/sw/Module_sw.mk @@ -39,6 +39,10 @@ $(eval $(call gb_Module_add_targets,sw,\ Package_xml \ )) +$(eval $(call gb_Module_add_check_targets,sw,\ + CppunitTest_sw_test_filters \ +)) + $(eval $(call gb_Module_add_subsequentcheck_targets,sw,\ JunitTest_sw_complex \ JunitTest_sw_unoapi \ diff --git a/sw/qa/core/filters-test.cxx b/sw/qa/core/filters-test.cxx index 253e666be5d6..19a4f71283a5 100644 --- a/sw/qa/core/filters-test.cxx +++ b/sw/qa/core/filters-test.cxx @@ -26,31 +26,35 @@ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable * instead of those above. */ -#include "precompiled_sw.hxx" -#include -#include -#include -#include -#include +#include +#include #include #include + #include #include #include + #include + +#include + +#include + +#include +#include + #include +#include + #include #include #include #include -#include -#include -#include - #include "init.hxx" #include "swtypes.hxx" #include "doc.hxx" @@ -63,11 +67,6 @@ SO2_IMPL_REF(SwDocShell) using namespace ::com::sun::star; -static sal_uInt16 aWndFunc(Window *, sal_uInt16, const String &, const String &) -{ - return ERRCODE_BUTTON_OK; -} - /* Implementation of Filters test */ class FiltersTest : public CppUnit::TestFixture @@ -96,7 +95,7 @@ private: uno::Reference m_xContext; uno::Reference m_xFactory; uno::Reference m_xWriterComponent; - ::rtl::OUString m_aPWDURL; + ::rtl::OUString m_aSrcRoot; }; bool FiltersTest::testLoad(const rtl::OUString &rFilter, @@ -123,62 +122,63 @@ void FiltersTest::testCVEs() bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("StarOffice XML (Writer)")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CXML")), - m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2006-3117-1.sxw"))); + m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/clone/writer/sw/qa/core/CVE/CVE-2006-3117-1.sxw"))); CPPUNIT_ASSERT_MESSAGE("CVE-2006-3117 regression", bResult == false); bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Rich Text Format")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RTF")), - m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2007-0245-1.rtf"))); + m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/clone/writer/sw/qa/core/CVE/CVE-2007-0245-1.rtf"))); CPPUNIT_ASSERT_MESSAGE("CVE-2007-0245 regression", bResult == true); bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), - m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2009-0200-1.doc"))); + m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/clone/writer/sw/qa/core/CVE/CVE-2009-0200-1.doc"))); CPPUNIT_ASSERT_MESSAGE("CVE-2009-0200 regression", bResult == true); bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), - m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2009-0201-1.doc"))); + m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/clone/writer/sw/qa/core/CVE/CVE-2009-0201-1.doc"))); CPPUNIT_ASSERT_MESSAGE("CVE-2009-0201 regression", bResult == true); bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), - m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2009-3301-1.doc"))); + m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/clone/writer/sw/qa/core/CVE/CVE-2009-3301-1.doc"))); CPPUNIT_ASSERT_MESSAGE("CVE-2009-3301 regression", bResult == true); bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), - m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2009-3302-1.doc"))); + m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/clone/writer/sw/qa/core/CVE/CVE-2009-3302-1.doc"))); CPPUNIT_ASSERT_MESSAGE("CVE-2009-3302 regression", bResult == true); bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), - m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2009-3302-2.doc"))); + m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/clone/writer/sw/qa/core/CVE/CVE-2009-3302-2.doc"))); CPPUNIT_ASSERT_MESSAGE("CVE-2009-3302 regression", bResult == true); bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Rich Text Format")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RTF")), - m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2010-3451-1.rtf"))); + m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/clone/writer/sw/qa/core/CVE/CVE-2010-3451-1.rtf"))); CPPUNIT_ASSERT_MESSAGE("CVE-2010-3451 regression", bResult == false); bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Rich Text Format")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RTF")), - m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2010-3452-1.rtf"))); + m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/clone/writer/sw/qa/core/CVE/CVE-2010-3452-1.rtf"))); CPPUNIT_ASSERT_MESSAGE("CVE-2010-3452 regression", bResult == true); bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), - m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2010-3453-1.doc"))); + m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/clone/writer/sw/qa/core/CVE/CVE-2010-3453-1.doc"))); CPPUNIT_ASSERT_MESSAGE("CVE-2010-3453 regression", bResult == true); bResult = testLoad(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MS Word 97")), rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CWW8")), - m_aPWDURL + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/CVE/CVE-2010-3454-1.doc"))); + m_aSrcRoot + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/clone/writer/sw/qa/core/CVE/CVE-2010-3454-1.doc"))); CPPUNIT_ASSERT_MESSAGE("CVE-2010-3454 regression", bResult == true); #endif } FiltersTest::FiltersTest() + : m_aSrcRoot(RTL_CONSTASCII_USTRINGPARAM("file://")) { m_xContext = cppu::defaultBootstrap_InitialComponentContext(); m_xFactory = m_xContext->getServiceManager(); @@ -203,20 +203,35 @@ FiltersTest::FiltersTest() rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.ucb.FileContentProvider"))), uno::UNO_QUERY); xUcb->registerContentProvider(xFileProvider, rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("file")), sal_True); + // force locale (and resource files loaded) to en-US + const LanguageType eLang=LANGUAGE_ENGLISH_US; + + rtl::OUString aLang, aCountry; + MsLangId::convertLanguageToIsoNames(eLang, aLang, aCountry); + lang::Locale aLocale(aLang, aCountry, rtl::OUString()); + ResMgr::SetDefaultLocale( aLocale ); + + SvtSysLocaleOptions aLocalOptions; + aLocalOptions.SetUILocaleConfigString( + MsLangId::convertLanguageToIsoString( eLang ) ); InitVCL(xSM); - //This is a bit of a fudge, we do this to ensure that SwGlobals::ensure, which is - //a private symbol to us, gets called + //This is a bit of a fudge, we do this to ensure that SwGlobals::ensure, + //which is a private symbol to us, gets called m_xWriterComponent = xSM->createInstance(rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Writer.TextDocument"))); - CPPUNIT_ASSERT_MESSAGE("no PWD!", m_xWriterComponent.is()); + CPPUNIT_ASSERT_MESSAGE("no writer component!", m_xWriterComponent.is()); - ErrorHandler::RegisterDisplay(&aWndFunc); + const char* pSrcRoot = getenv( "SRC_ROOT" ); + CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot != NULL && pSrcRoot[0] != 0); - oslProcessError err = osl_getProcessWorkingDir(&m_aPWDURL.pData); - CPPUNIT_ASSERT_MESSAGE("no PWD!", err == osl_Process_E_None); +#ifdef WNT + if (pSrcRoot[1] == ':') + m_aSrcRoot += rtl::OUString::createFromAscii( "/" ); +#endif + m_aSrcRoot += rtl::OUString::createFromAscii( pSrcRoot ); } void FiltersTest::setUp() @@ -225,6 +240,7 @@ void FiltersTest::setUp() FiltersTest::~FiltersTest() { + uno::Reference< lang::XComponent >(m_xContext, uno::UNO_QUERY_THROW)->dispose(); } void FiltersTest::tearDown() -- cgit