summaryrefslogtreecommitdiff
path: root/sdext/source
diff options
context:
space:
mode:
authorDavid Tardon <dtardon@redhat.com>2012-02-25 13:43:14 +0100
committerDavid Tardon <dtardon@redhat.com>2012-03-06 10:32:05 +0100
commit6f223177f995d3c9347226356e96c67a62a7ec51 (patch)
tree5e088299f6c63a28baf8218aabee98874164f8c8 /sdext/source
parent19dd86582b4fa55e9e22d1e92d27ee15c44960d9 (diff)
convert pdfimport test
Diffstat (limited to 'sdext/source')
-rwxr-xr-xsdext/source/pdfimport/test/makefile.mk141
-rw-r--r--sdext/source/pdfimport/test/tests.cxx101
2 files changed, 98 insertions, 144 deletions
diff --git a/sdext/source/pdfimport/test/makefile.mk b/sdext/source/pdfimport/test/makefile.mk
deleted file mode 100755
index fdc3966c702f..000000000000
--- a/sdext/source/pdfimport/test/makefile.mk
+++ /dev/null
@@ -1,141 +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.
-#
-#*************************************************************************
-
-PRJ=..$/..$/..
-PRJNAME=sdext
-TARGET=tests
-TARGETTYPE=CUI
-ENABLE_EXCEPTIONS=TRUE
-
-# --- Settings -----------------------------------------------------
-
-.INCLUDE: settings.mk
-
-# --- test lib ------------------------------------------------------
-
-.IF "$(ENABLE_PDFIMPORT)" == "NO"
-@all:
- @echo "PDF Import extension disabled."
-.ENDIF
-
-CFLAGSCXX += $(CPPUNIT_CFLAGS)
-
-.IF "$(SYSTEM_ZLIB)" == "YES"
-CFLAGS+=-DSYSTEM_ZLIB
-.ENDIF
-
-SHL1OBJS= \
- $(SLO)$/tests.obj
-
-SHL1LIBS=\
- $(SLB)$/pdfmisc.lib \
- $(SLB)$/pdfparse.lib \
- $(SLB)$/pdfsax.lib \
- $(SLB)$/pdfparsetree.lib \
- $(SLB)$/pdfodf.lib \
- $(SLB)$/xpdfwrapper.lib \
- $(SLB)$/pdfimport.lib
-
-SHL1TARGET=$(TARGET)
-SHL1STDLIBS=\
- $(BASEGFXLIB) \
- $(UNOTOOLSLIB) \
- $(CANVASTOOLSLIB) \
- $(COMPHELPERLIB) \
- $(CPPUHELPERLIB) \
- $(CPPUNITLIB) \
- $(ZLIB3RDLIB) \
- $(CPPULIB) \
- $(UNOTESTLIB) \
- $(TESTLIB) \
- $(SALLIB)
-
-
-SHL1IMPLIB= i$(SHL1TARGET)
-DEF1NAME =$(SHL1TARGET)
-SHL1VERSIONMAP = export.map
-
-# --- pdf2xml binary ------------------------------------------------------
-
-TARGET2=pdf2xml
-
-APP1TARGET=$(TARGET2)
-APP1LIBSALCPPRT=
-APP1OBJS=$(SLO)$/pdf2xml.obj
-
-APP1LIBS=\
- $(SLB)$/pdfmisc.lib \
- $(SLB)$/pdfparse.lib \
- $(SLB)$/pdfsax.lib \
- $(SLB)$/pdfparsetree.lib \
- $(SLB)$/pdfodf.lib \
- $(SLB)$/xpdfwrapper.lib \
- $(SLB)$/pdfimport.lib
-
-APP1STDLIBS=\
- $(BASEGFXLIB) \
- $(UNOTOOLSLIB) \
- $(CANVASTOOLSLIB) \
- $(COMPHELPERLIB) \
- $(CPPUHELPERLIB) \
- $(CPPUNITLIB) \
- $(ZLIB3RDLIB) \
- $(CPPULIB) \
- $(SALLIB)
-
-# --- pdfunzip binary ------------------------------------------------------
-
-TARGET3=pdfunzip
-
-APP2TARGET=$(TARGET3)
-APP2LIBSALCPPRT=
-APP2OBJS=$(SLO)$/pdfunzip.obj
-
-APP2LIBS=\
- $(SLB)$/pdfmisc.lib \
- $(SLB)$/pdfparse.lib \
- $(SLB)$/pdfsax.lib \
- $(SLB)$/pdfparsetree.lib \
- $(SLB)$/pdfodf.lib \
- $(SLB)$/xpdfwrapper.lib \
- $(SLB)$/pdfimport.lib
-
-APP2STDLIBS=\
- $(BASEGFXLIB) \
- $(UNOTOOLSLIB) \
- $(CANVASTOOLSLIB) \
- $(COMPHELPERLIB) \
- $(CPPUHELPERLIB) \
- $(CPPUNITLIB) \
- $(ZLIB3RDLIB) \
- $(CPPULIB) \
- $(SALLIB)
-
-# --- Targets ------------------------------------------------------
-
-.INCLUDE : target.mk
-.INCLUDE : _cppunit.mk
diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx
index 0fd470e26c44..78d0a5ea8026 100644
--- a/sdext/source/pdfimport/test/tests.cxx
+++ b/sdext/source/pdfimport/test/tests.cxx
@@ -60,6 +60,7 @@
#include "cppunit/plugin/TestPlugIn.h"
#include <test/bootstrapfixture.hxx>
+#include <com/sun/star/deployment/XPackageInformationProvider.hpp>
#include <com/sun/star/rendering/XCanvas.hpp>
#include <com/sun/star/rendering/XColorSpace.hpp>
#include <com/sun/star/rendering/PathJoinType.hpp>
@@ -79,6 +80,7 @@
#include <vector>
#include <boost/unordered_map.hpp>
+#include <cassert>
using namespace ::pdfparse;
using namespace ::pdfi;
@@ -477,6 +479,92 @@ namespace
bool m_bDashedLineSeen;
};
+ /*
+ This is a (hackish) way to set correct path to the xpdfimport executable
+ during build. Because $OUTDIR/bin is not in $PATH, it will not be found
+ directly. We also know that xpdf_ImportFromFile() tries to get the path
+ through the extension mechanism, but there are no registered extensions
+ available when this test is run. So we create a phony
+ PackageInformationProvider that pretends such extension exists and passes
+ out the path we need .-)
+ */
+
+ typedef cppu::WeakComponentImplHelper1<deployment::XPackageInformationProvider> PackageInformationProvider_Base;
+
+ class PackageInformationProvider
+ : private cppu::BaseMutex
+ , public PackageInformationProvider_Base
+ {
+ public:
+ PackageInformationProvider()
+ : PackageInformationProvider_Base(m_aMutex)
+ {
+ }
+
+ private:
+ virtual rtl::OUString SAL_CALL getPackageLocation(rtl::OUString const&)
+ throw()
+ {
+ rtl::OUString const aLocation(RTL_CONSTASCII_USTRINGPARAM(PDFIMPORT_EXECUTABLE_LOCATION));
+ return aLocation;
+ }
+
+ virtual uno::Sequence<uno::Sequence<rtl::OUString> > SAL_CALL isUpdateAvailable(rtl::OUString const&)
+ throw()
+ {
+ // dummy impl.
+ uno::Sequence<uno::Sequence<rtl::OUString> > const aSeq;
+ return aSeq;
+ }
+
+ virtual uno::Sequence<uno::Sequence<rtl::OUString> > SAL_CALL getExtensionList()
+ throw()
+ {
+ // dummy impl.
+ uno::Sequence<uno::Sequence<rtl::OUString> > const aSeq;
+ return aSeq;
+ }
+ };
+
+ typedef cppu::WeakComponentImplHelper1<uno::XComponentContext> ComponentContext_Base;
+
+ class ComponentContext
+ : private cppu::BaseMutex
+ , public ComponentContext_Base
+ {
+ public:
+ explicit ComponentContext(uno::Reference<uno::XComponentContext> const& xParent)
+ : ComponentContext_Base(m_aMutex)
+ , m_xParent(xParent)
+ {
+ assert(m_xParent.is());
+ }
+
+ private:
+ virtual uno::Any SAL_CALL getValueByName(rtl::OUString const& rName)
+ throw()
+ {
+ if (rName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("/singletons/com.sun.star.deployment.PackageInformationProvider")))
+ {
+ uno::Reference<deployment::XPackageInformationProvider> const xProvider(new PackageInformationProvider());
+ uno::Any aComponent;
+ aComponent <<= xProvider;
+ return aComponent;
+ }
+
+ return m_xParent->getValueByName(rName);
+ }
+
+ virtual uno::Reference<lang::XMultiComponentFactory> SAL_CALL getServiceManager()
+ throw()
+ {
+ return m_xParent->getServiceManager();
+ }
+
+ private:
+ uno::Reference<uno::XComponentContext> m_xParent;
+ };
+
class PDFITest : public test::BootstrapFixture
{
public:
@@ -487,7 +575,7 @@ namespace
pSink,
uno::Reference< task::XInteractionHandler >(),
rtl::OUString(),
- getComponentContext() );
+ impl_getComponentContext() );
// make destruction explicit, a bunch of things are
// checked in the destructor
@@ -496,7 +584,7 @@ namespace
void testOdfDrawExport()
{
- pdfi::PDFIRawAdaptor aAdaptor( getComponentContext() );
+ pdfi::PDFIRawAdaptor aAdaptor( impl_getComponentContext() );
aAdaptor.setTreeVisitorFactory( createDrawTreeVisitorFactory() );
::rtl::OUString aURL, aAbsURL, aBaseURL;
@@ -512,7 +600,7 @@ namespace
void testOdfWriterExport()
{
- pdfi::PDFIRawAdaptor aAdaptor( getComponentContext() );
+ pdfi::PDFIRawAdaptor aAdaptor( impl_getComponentContext() );
aAdaptor.setTreeVisitorFactory( createWriterTreeVisitorFactory() );
::rtl::OUString aURL, aAbsURL, aBaseURL;
@@ -531,6 +619,13 @@ namespace
CPPUNIT_TEST(testOdfWriterExport);
CPPUNIT_TEST(testOdfDrawExport);
CPPUNIT_TEST_SUITE_END();
+
+ private:
+ uno::Reference<uno::XComponentContext> impl_getComponentContext()
+ {
+ uno::Reference<uno::XComponentContext> const xCtxt(new ComponentContext(getComponentContext()));
+ return xCtxt;
+ }
};
}