svx/CppunitTest_svx_unit.mk | 11 +++++++ svx/qa/unit/data/graphic.pdf |binary svx/qa/unit/xoutdev.cxx | 65 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+)
New commits: commit df8bb7b32161ede37a0a82b421046435ad586f5c Author: Miklos Vajna <[email protected]> Date: Tue Jun 28 17:50:40 2016 +0200 svx: add XOutBitmap testcase This fails with commit 7d76bb251e0c88ff17282a33b801a5d17a434af5 (vcl: add graphic export-as-pdf filter, 2016-06-24) reverted. Change-Id: Idea5c282d610d949958d757677ee642d97ca1c8e Reviewed-on: https://gerrit.libreoffice.org/26747 Reviewed-by: Miklos Vajna <[email protected]> Tested-by: Jenkins <[email protected]> diff --git a/svx/CppunitTest_svx_unit.mk b/svx/CppunitTest_svx_unit.mk index 0e9fea3..765f385 100644 --- a/svx/CppunitTest_svx_unit.mk +++ b/svx/CppunitTest_svx_unit.mk @@ -19,11 +19,22 @@ $(eval $(call gb_CppunitTest_set_include,svx_unit,\ $(eval $(call gb_CppunitTest_add_exception_objects,svx_unit, \ svx/qa/unit/svdraw/test_SdrTextObject \ + svx/qa/unit/xoutdev \ )) $(eval $(call gb_CppunitTest_use_libraries,svx_unit, \ sal \ svxcore \ + tl \ + unotest \ + vcl \ + utl \ )) +$(eval $(call gb_CppunitTest_use_sdk_api,svx_unit)) +$(eval $(call gb_CppunitTest_use_ure,svx_unit)) +$(eval $(call gb_CppunitTest_use_vcl,svx_unit)) +$(eval $(call gb_CppunitTest_use_rdb,svx_unit,services)) +$(eval $(call gb_CppunitTest_use_configuration,svx_unit)) + # vim: set noet sw=4 ts=4: diff --git a/svx/qa/unit/data/graphic.pdf b/svx/qa/unit/data/graphic.pdf new file mode 100644 index 0000000..4b53d20 Binary files /dev/null and b/svx/qa/unit/data/graphic.pdf differ diff --git a/svx/qa/unit/xoutdev.cxx b/svx/qa/unit/xoutdev.cxx new file mode 100644 index 0000000..468d7ae --- /dev/null +++ b/svx/qa/unit/xoutdev.cxx @@ -0,0 +1,65 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <cppunit/TestAssert.h> +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> + +#include <sal/types.h> +#include <tools/stream.hxx> +#include <unotest/directories.hxx> +#include <unotools/tempfile.hxx> +#include <vcl/graph.hxx> +#include <vcl/graphicfilter.hxx> +#include <svx/xoutbmp.hxx> + +class XOutdevTest : public CppUnit::TestFixture +{ +public: + void testPdfGraphicExport(); + + CPPUNIT_TEST_SUITE(XOutdevTest); + CPPUNIT_TEST(testPdfGraphicExport); + CPPUNIT_TEST_SUITE_END(); +}; + +void XOutdevTest::testPdfGraphicExport() +{ + // Import the graphic. + Graphic aGraphic; + test::Directories aDirectories; + OUString aURL = aDirectories.getURLFromSrc("svx/qa/unit/data/graphic.pdf"); + SvFileStream aStream(aURL, StreamMode::READ); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt16>(GRFILTER_OK), GraphicFilter::GetGraphicFilter().ImportGraphic(aGraphic, aURL, aStream)); + + // Export it. + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(true); + XOutFlags eFlags = XOutFlags::DontExpandFilename | XOutFlags::DontAddExtension | XOutFlags::UseNativeIfPossible; + OUString aTempURL = aTempFile.GetURL(); + XOutBitmap::WriteGraphic(aGraphic, aTempURL, "pdf", eFlags); + + // Assert that the output looks like a PDF. + SvStream* pStream = aTempFile.GetStream(StreamMode::READ); + pStream->Seek(STREAM_SEEK_TO_END); + CPPUNIT_ASSERT(pStream->Tell() > 5); + pStream->Seek(STREAM_SEEK_TO_BEGIN); + sal_uInt8 sFirstBytes[5]; + pStream->ReadBytes(sFirstBytes, 5); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>('%'), sFirstBytes[0]); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>('P'), sFirstBytes[1]); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>('D'), sFirstBytes[2]); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>('F'), sFirstBytes[3]); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_uInt8>('-'), sFirstBytes[4]); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(XOutdevTest); + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
