Kaydet (Commit) 6f223177 authored tarafından David Tardon's avatar David Tardon

convert pdfimport test

üst 19dd8658
# -*- 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.
#
# Major Contributor(s):
# Copyright (C) 2012 Red Hat, Inc., David Tardon <dtardon@redhat.com>
# (initial developer)
#
# All Rights Reserved.
#
# 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,sdext_pdfimport))
$(eval $(call gb_CppunitTest_add_defs,sdext_pdfimport,\
-DPDFIMPORT_EXECUTABLE_LOCATION=\"file://$(dir $(call gb_Executable_get_target,xpdfimport))\" \
))
$(eval $(call gb_CppunitTest_add_api,sdext_pdfimport,\
offapi \
udkapi \
))
$(eval $(call gb_CppunitTest_set_include,sdext_pdfimport,\
-I$(SRCDIR)/sdext/source/pdfimport/inc \
$$(INCLUDE) \
))
$(eval $(call gb_CppunitTest_use_externals,sdext_pdfimport,\
zlib \
))
$(eval $(call gb_CppunitTest_add_linked_libs,sdext_pdfimport,\
comphelper \
cppu \
cppuhelper \
sal \
test \
unotest \
$(gb_STDLIBS) \
))
$(eval $(call gb_CppunitTest_add_linked_static_libs,sdext_pdfimport,\
basegfx_s \
))
$(eval $(call gb_CppunitTest_add_library_objects,sdext_pdfimport,\
pdfimport \
))
$(eval $(call gb_CppunitTest_add_exception_objects,sdext_pdfimport,\
sdext/source/pdfimport/test/tests \
))
$(eval $(call gb_CppunitTest_uses_ure,sdext_pdfimport))
$(eval $(call gb_CppunitTest_add_type_rdbs,sdext_pdfimport,\
types \
))
$(eval $(call gb_CppunitTest_add_components,sdext_pdfimport,\
comphelper/util/comphelp \
configmgr/source/configmgr \
i18npool/util/i18npool \
ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \
))
$(eval $(call gb_CppunitTest_set_args,sdext_pdfimport,\
--headless \
--protector unoexceptionprotector$(gb_Library_DLLEXT) unoexceptionprotector \
"-env:CONFIGURATION_LAYERS=xcsxcu:$(call gb_CppunitTarget__make_url,$(OUTDIR)/xml/registry)" \
))
# vim:set shiftwidth=4 softtabstop=4 expandtab:
......@@ -45,6 +45,10 @@ $(eval $(call gb_Module_add_targets,sdext,\
Library_pdfimport \
Package_pdfimport_keywords \
))
$(eval $(call gb_Module_add_check_targets,sdext,\
CppunitTest_pdfimport \
))
endif
ifeq ($(ENABLE_PRESENTER_SCREEN),YES)
......
#*************************************************************************
#
# 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
......@@ -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;
}
};
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment