10#include <config_validation.h>
17#include <com/sun/star/lang/XMultiServiceFactory.hpp>
18#include <com/sun/star/ucb/XContentProvider.hpp>
19#include <com/sun/star/ucb/XUniversalContentBroker.hpp>
25#include <osl/file.hxx>
26#include <osl/process.h>
43 OString aErr =
"Unexpected dialog: " +
47 CPPUNIT_ASSERT_MESSAGE( aErr.getStr(),
false);
55 : m_bNeedUCB( bNeedUCB )
56 , m_bAssertOnDialog( bAssertOnDialog )
64 lang::XMultiServiceFactory * pSFactory)
76 uno::Reference<ucb::XUniversalContentBroker> xUcb(pSFactory->createInstance(
"com.sun.star.ucb.UniversalContentBroker"), uno::UNO_QUERY_THROW);
77 uno::Reference<ucb::XContentProvider> xFileProvider(pSFactory->createInstance(
"com.sun.star.ucb.FileContentProvider"), uno::UNO_QUERY_THROW);
78 xUcb->registerContentProvider(xFileProvider,
"file",
true);
79 uno::Reference<ucb::XContentProvider> xTdocProvider(pSFactory->createInstance(
"com.sun.star.ucb.TransientDocumentsContentProvider"), uno::UNO_QUERY);
80 if (xTdocProvider.is())
82 xUcb->registerContentProvider(xTdocProvider,
"vnd.sun.star.tdoc",
true);
88SAL_DLLPUBLIC_EXPORT
void test_init(lang::XMultiServiceFactory *pFactory)
92 ::comphelper::setProcessServiceFactory(pFactory);
96 catch (...) { abort(); }
113#if OSL_DEBUG_LEVEL > 0
124#if HAVE_EXPORT_VALIDATION
127OString loadFile(
const OUString& rURL)
129 osl::File aFile(rURL);
130 osl::FileBase::RC eStatus = aFile.open(osl_File_OpenFlag_Read);
131 CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, eStatus);
133 aFile.getSize(nSize);
134 std::unique_ptr<char[]> aBytes(
new char[nSize]);
135 sal_uInt64 nBytesRead;
136 aFile.read(aBytes.get(), nSize, nBytesRead);
137 CPPUNIT_ASSERT_EQUAL(nSize, nBytesRead);
138 OString aContent(aBytes.get(), nBytesRead);
148#if HAVE_EXPORT_VALIDATION
156 var =
"ODFVALIDATOR";
161 var =
"BFFVALIDATOR";
168 oslProcessError e = osl_getEnvironment(var.pData, &aValidator.pData);
169 CPPUNIT_ASSERT_EQUAL_MESSAGE(
170 OUString(
"cannot get env var " + var).toUtf8().getStr(),
171 osl_Process_E_None, e);
172 CPPUNIT_ASSERT_MESSAGE(
173 OUString(
"empty get env var " + var).toUtf8().getStr(),
174 !aValidator.isEmpty());
181 + m_directories.getPathFromSrc(
u"/schema/libreoffice/OpenDocument-v1.3+libreoffice-manifest-schema.rng")
183 + m_directories.getPathFromSrc(
u"/schema/libreoffice/OpenDocument-v1.3+libreoffice-dsig-schema.rng")
185 + m_directories.getPathFromSrc(
u"/schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng")
187 + m_directories.getPathFromSrc(
u"/schema/mathml2/mathml2.xsd");
193 OUString
aCommand = aValidator +
" " + rPath +
" > " + aOutputFile +
" 2>&1";
201 auto const n =
env.indexOf(
'=');
210 SAL_INFO(
"test",
"BootstrapFixture::validate: executing '" <<
aCommand <<
"'");
213 OString aContentString = loadFile(aOutput.
GetURL());
214 OUString aContentOUString = OStringToOUString(aContentString, RTL_TEXTENCODING_UTF8);
216 if( eFormat ==
test::OOXML && !aContentOUString.isEmpty() )
219 sal_Int32
nIndex = aContentOUString.lastIndexOf(
"Grand total of errors in submitted package: ");
222 SAL_WARN(
"test",
"no summary line");
226 sal_Int32 nStartOfNumber =
nIndex + std::strlen(
"Grand total of errors in submitted package: ");
227 std::u16string_view aNumber = aContentOUString.subView(nStartOfNumber);
229 OString aMsg =
"validation error in OOXML export: Errors: " + OString::number(nErrors);
234 CPPUNIT_ASSERT_EQUAL_MESSAGE(aMsg.getStr(), sal_Int32(0), nErrors);
237 else if( eFormat ==
test::ODF && !aContentOUString.isEmpty() )
239 if( aContentOUString.indexOf(
"Error") != -1 )
242 CPPUNIT_FAIL(aContentString.getStr());
245 CPPUNIT_ASSERT_EQUAL_MESSAGE(
278 return device->GetBitCount();
css::uno::Reference< css::uno::XComponentContext > mxComponentContext
IMPL_STATIC_LINK(test::BootstrapFixture, ImplInitFilterHdl, ConvertData &, rData, bool)
static void test_init_impl(bool bAssertOnDialog, bool bNeedUCB, lang::XMultiServiceFactory *pSFactory)
static void aBasicErrorFunc(const OUString &rErr, const OUString &rAction)
SAL_DLLPUBLIC_EXPORT void test_init(lang::XMultiServiceFactory *pFactory)
SAL_DLLPUBLIC_EXPORT void test_deinit()
static OutputDevice * GetDefaultDevice()
static void SetFilterHdl(const Link< ConvertData &, bool > &rLink)
static void RegisterDisplay(BasicDisplayErrorFunc *)
static GraphicFilter & GetGraphicFilter()
Link< ConvertData &, bool > GetFilterCallback() const
SAL_DLLPRIVATE sal_Int32 GetDPIX() const
SAL_DLLPRIVATE sal_Int32 GetDPIY() const
static void ProcessEventsToIdle()
static VclPtr< reference_type > Create(Arg &&... arg)
virtual void setUp() override
static bool IsDefaultDPI()
static std::pair< double, double > getDPIScaling()
virtual void setUp() override
static sal_uInt16 getDefaultDeviceBitCount()
virtual ~BootstrapFixture() override
void validate(const OUString &rURL, ValidationFormat) const
BootstrapFixture(bool bAssertOnDialog=true, bool bNeedUCB=true)
void EnableKillingFile(bool bEnable=true)
OUString const & GetURL() const
OUString GetFileName() const
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
#define SAL_INFO(area, stream)
const css::uno::Reference< css::xml::crypto::XSecurityEnvironment > & env
Reference< XComponentContext > getComponentContext(Reference< XMultiServiceFactory > const &factory)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
bool getArgument(std::u16string_view name, OUString *value)
OOO_DLLPUBLIC_TEST_SETUPVCL void setUpVcl(bool forceHeadless=false)
VCL_DLLPUBLIC void DeInitVCL()