[Libreoffice-commits] .: sd/CppunitTest_sd_filters_test.mk sd/Module_sd.mk sd/qa sd/RdbTarget_sd_filters_test.mk svx/inc

Michael Meeks michael at kemper.freedesktop.org
Thu Nov 10 14:33:32 PST 2011


 sd/CppunitTest_sd_filters_test.mk |  102 +++++++++++++++++++++
 sd/Module_sd.mk                   |    5 -
 sd/RdbTarget_sd_filters_test.mk   |   66 ++++++++++++++
 sd/qa/unit/data/a.pptx            |binary
 sd/qa/unit/filters-test.cxx       |  179 ++++++++++++++++++++++++++++++++++++++
 svx/inc/svx/svdtext.hxx           |    1 
 6 files changed, 352 insertions(+), 1 deletion(-)

New commits:
commit 83ea2162b80b4d03e4cca90d354b5d56ea3f5898
Author: Michael Meeks <michael.meeks at suse.com>
Date:   Thu Nov 10 16:51:58 2011 +0000

    Initial sd filters unit tests

diff --git a/sd/CppunitTest_sd_filters_test.mk b/sd/CppunitTest_sd_filters_test.mk
new file mode 100644
index 0000000..193ef5c
--- /dev/null
+++ b/sd/CppunitTest_sd_filters_test.mk
@@ -0,0 +1,102 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+# 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. <caolanm at redhat.com>
+# 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,sd_filters_test))
+
+$(eval $(call gb_CppunitTest_add_exception_objects,sd_filters_test, \
+    sd/qa/unit/filters-test \
+))
+
+$(eval $(call gb_CppunitTest_add_linked_libs,sd_filters_test, \
+    avmedia \
+    basegfx \
+    comphelper \
+    cppu \
+    cppuhelper \
+    drawinglayer \
+    editeng \
+    fileacc \
+    for \
+    forui \
+    i18nisolang1 \
+    msfilter \
+    oox \
+    sal \
+    salhelper \
+    sax \
+    sd \
+    sfx \
+    sot \
+    svl \
+    svt \
+    svx \
+    svxcore \
+	test \
+    tl \
+    tk \
+    ucbhelper \
+	unotest \
+    utl \
+    vcl \
+    xo \
+	$(gb_STDLIBS) \
+))
+
+$(eval $(call gb_CppunitTest_set_include,sd_filters_test,\
+    -I$(realpath $(SRCDIR)/sd/inc/pch) \
+    -I$(realpath $(SRCDIR)/sd/source/ui/inc) \
+    -I$(realpath $(SRCDIR)/sd/inc) \
+    $$(INCLUDE) \
+    -I$(OUTDIR)/inc \
+))
+
+$(eval $(call gb_CppunitTest_add_api,sd_filters_test,\
+    offapi \
+    udkapi \
+))
+
+$(eval $(call gb_CppunitTest_uses_ure,sd_filters_test))
+
+$(eval $(call gb_CppunitTest_add_type_rdbs,sd_filters_test,\
+    types \
+))
+
+$(eval $(call gb_CppunitTest_add_service_rdbs,sd_filters_test,\
+    sd_filters_test \
+))
+
+$(eval $(call gb_CppunitTest_set_args,sd_filters_test,\
+    --headless \
+    --protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \
+    "-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry) module:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry/spool)" \
+))
+    # .../spool is required for the (somewhat strange) filter configuration
+
+# vim: set noet sw=4 ts=4:
diff --git a/sd/Module_sd.mk b/sd/Module_sd.mk
index 933dc70..eef68f8 100644
--- a/sd/Module_sd.mk
+++ b/sd/Module_sd.mk
@@ -42,11 +42,14 @@ $(eval $(call gb_Module_add_targets,sd,\
 
 ifneq ($(OS),DRAGONFLY)
 $(eval $(call gb_Module_add_check_targets,sd,\
-    CppunitTest_sd_uimpress \
+    CppunitTest_sd_filters_test \
     RdbTarget_sd_uimpress \
+	RdbTarget_sd_filters_test \
 ))
 endif
 
+#    CppunitTest_sd_uimpress \
+
 $(eval $(call gb_Module_add_subsequentcheck_targets,sd,\
     JunitTest_sd_unoapi \
 ))
diff --git a/sd/RdbTarget_sd_filters_test.mk b/sd/RdbTarget_sd_filters_test.mk
new file mode 100644
index 0000000..d3a15d8
--- /dev/null
+++ b/sd/RdbTarget_sd_filters_test.mk
@@ -0,0 +1,66 @@
+# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
+#*************************************************************************
+# 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. <caolanm at redhat.com>
+# 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_RdbTarget_RdbTarget,sd_filters_test))
+
+$(eval $(call gb_RdbTarget_add_components,sd_filters_test,\
+    basic/util/sb \
+    comphelper/util/comphelp \
+    dbaccess/util/dba \
+    fileaccess/source/fileacc \
+    filter/source/config/cache/filterconfig1 \
+    forms/util/frm \
+    framework/util/fwk \
+    i18npool/util/i18npool \
+    oox/util/oox \
+    package/source/xstor/xstor \
+    package/util/package2 \
+    sax/source/expatwrap/expwrap \
+    sax/source/fastparser/fastsax \
+    sd/util/sd \
+    sd/util/sdfilt \
+    sfx2/util/sfx \
+    sot/util/sot \
+    toolkit/util/tk \
+    unotools/util/utl \
+    unoxml/source/rdf/unordf \
+    unoxml/source/service/unoxml \
+    xmlsecurity/util/xsec_fw \
+    xmlsecurity/util/xmlsecurity \
+))
+
+$(eval $(call gb_RdbTarget_add_old_components,sd_filters_test,\
+    configmgr \
+    ucb1 \
+    ucpfile1 \
+    ucptdoc1 \
+))
+
+# vim: set noet sw=4 ts=4:
diff --git a/sd/qa/unit/data/a.pptx b/sd/qa/unit/data/a.pptx
new file mode 100644
index 0000000..e0cfe49
Binary files /dev/null and b/sd/qa/unit/data/a.pptx differ
diff --git a/sd/qa/unit/filters-test.cxx b/sd/qa/unit/filters-test.cxx
new file mode 100644
index 0000000..62006c4
--- /dev/null
+++ b/sd/qa/unit/filters-test.cxx
@@ -0,0 +1,179 @@
+/* -*- 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
+ *       Michael Meeks <michael.meeks at suse.com>
+ * Portions created by the Initial Developer are Copyright (C) 2011 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Caolán McNamara <caolanm at 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 <sal/config.h>
+#include <unotest/filters-test.hxx>
+#include <test/bootstrapfixture.hxx>
+#include <rtl/strbuf.hxx>
+#include <osl/file.hxx>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/document/XFilter.hpp>
+
+#include <sfx2/app.hxx>
+#include <sfx2/docfilt.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/sfxmodelfactory.hxx>
+#include <svl/stritem.hxx>
+
+#include <svx/svdtext.hxx>
+#include <svx/svdotext.hxx>
+
+#include "drawdoc.hxx"
+#include "../source/ui/inc/DrawDocShell.hxx"
+
+#include <osl/process.h>
+#include <osl/thread.h>
+
+/* Implementation of Filters test */
+
+using namespace ::com::sun::star;
+
+class SdFiltersTest
+    : public test::FiltersTest
+    , public test::BootstrapFixture
+{
+public:
+    SdFiltersTest();
+
+    ::sd::DrawDocShellRef loadURL( const rtl::OUString &rURL );
+    virtual bool load(const rtl::OUString &, const rtl::OUString &, const rtl::OUString &) { return false; }
+    virtual void setUp();
+    virtual void tearDown();
+
+    // FIXME: we should add some CVE tests ...
+    void test();
+
+    CPPUNIT_TEST_SUITE(SdFiltersTest);
+    CPPUNIT_TEST(test);
+    CPPUNIT_TEST_SUITE_END();
+
+private:
+    uno::Reference<document::XFilter> m_xFilter;
+    uno::Reference<uno::XInterface> m_xDrawComponent;
+};
+
+#define PPTX_FORMAT_TYPE 268959811
+
+struct FileFormat {
+    const char* pName; const char* pFilterName; const char* pTypeName; sal_uLong nFormatType;
+};
+
+// cf. sc/qa/unit/filters-test.cxx and filters/...*.xcu to fill out.
+FileFormat aFileFormats[] = {
+    { "pptx" , "Impress MS PowerPoint 2007 XML", "MS PowerPoint 2007 XML", PPTX_FORMAT_TYPE },
+    { 0, 0, 0, 0 }
+};
+
+::sd::DrawDocShellRef SdFiltersTest::loadURL( const rtl::OUString &rURL )
+{
+    FileFormat *pFmt;
+
+    for (size_t i = 0; i < SAL_N_ELEMENTS (aFileFormats); i++)
+    {
+        pFmt = aFileFormats + i;
+        if (pFmt->pName &&  rURL.endsWithIgnoreAsciiCaseAsciiL (pFmt->pName, strlen (pFmt->pName)))
+            break;
+    }
+    CPPUNIT_ASSERT_MESSAGE( "missing filter info", pFmt->pName != NULL );
+
+    sal_uInt32 nFormat = 0;
+    if (pFmt->nFormatType)
+        nFormat = SFX_FILTER_IMPORT | SFX_FILTER_USESOPTIONS;
+    SfxFilter* aFilter = new SfxFilter(
+        rtl::OUString::createFromAscii( pFmt->pFilterName ),
+        rtl::OUString(), pFmt->nFormatType, nFormat,
+        rtl::OUString::createFromAscii( pFmt->pTypeName ),
+        0, rtl::OUString(), rtl::OUString(), /* userdata */
+        rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("private:factory/scalc*")) );
+    aFilter->SetVersion(SOFFICE_FILEFORMAT_CURRENT);
+
+    ::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell();
+    SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READWRITE, true);
+    pSrcMed->SetFilter(aFilter);
+    CPPUNIT_ASSERT_MESSAGE( "load failed", xDocShRef->DoLoad(pSrcMed) );
+
+    return xDocShRef;
+}
+
+void SdFiltersTest::test()
+{
+    ::sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/a.pptx"));
+    CPPUNIT_ASSERT_MESSAGE( "failed to load", xDocShRef.Is() );
+    CPPUNIT_ASSERT_MESSAGE( "not in destruction", !xDocShRef->IsInDestruction() );
+
+    SdDrawDocument *pDoc = xDocShRef->GetDoc();
+    CPPUNIT_ASSERT_MESSAGE( "no document", pDoc != NULL );
+
+    // cf. SdrModel svx/svdmodel.hxx ...
+
+    CPPUNIT_ASSERT_MESSAGE( "wrong page count", pDoc->GetPageCount() == 3);
+
+    const SdrPage *pPage = pDoc->GetPage (1);
+    CPPUNIT_ASSERT_MESSAGE( "no page", pPage != NULL );
+
+    sal_uIntPtr nObjs = pPage->GetObjCount();
+    for (sal_uIntPtr i = 0; i < nObjs; i++)
+    {
+        SdrObject *pObj = pPage->GetObj(i);
+        SdrObjKind eKind = (SdrObjKind) pObj->GetObjIdentifier();
+        SdrTextObj *pTxt = dynamic_cast<SdrTextObj *>( pObj );
+        (void)pTxt; (void)eKind;
+    }
+
+    CPPUNIT_ASSERT_MESSAGE( "changed", !pDoc->IsChanged() );
+    xDocShRef->DoClose();
+}
+
+SdFiltersTest::SdFiltersTest()
+{
+}
+
+void SdFiltersTest::setUp()
+{
+    test::BootstrapFixture::setUp();
+
+    // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
+    // which is a private symbol to us, gets called
+    m_xDrawComponent =
+        getMultiServiceFactory()->createInstance(rtl::OUString(
+        RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.Draw.PresentationDocument")));
+    CPPUNIT_ASSERT_MESSAGE("no impress component!", m_xDrawComponent.is());
+}
+
+void SdFiltersTest::tearDown()
+{
+    uno::Reference< lang::XComponent >( m_xDrawComponent, uno::UNO_QUERY_THROW )->dispose();
+    test::BootstrapFixture::tearDown();
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svx/inc/svx/svdtext.hxx b/svx/inc/svx/svdtext.hxx
index ca44bed..35d74ac 100644
--- a/svx/inc/svx/svdtext.hxx
+++ b/svx/inc/svx/svdtext.hxx
@@ -48,6 +48,7 @@ namespace sdr { namespace properties {
 /** This class stores information about one text inside a shape.
 */
 
+class SfxStyleSheet;
 class SVX_DLLPUBLIC SdrText : public tools::WeakBase< SdrText >
 {
 public:


More information about the Libreoffice-commits mailing list