summaryrefslogtreecommitdiff
path: root/sdext/source/pdfimport/test/tests.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sdext/source/pdfimport/test/tests.cxx')
-rw-r--r--sdext/source/pdfimport/test/tests.cxx101
1 files changed, 98 insertions, 3 deletions
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;
+ }
};
}