Kaydet (Commit) df8bb7b3 authored tarafından Miklos Vajna's avatar Miklos Vajna

svx: add XOutBitmap testcase

This fails with commit 7d76bb25 (vcl:
add graphic export-as-pdf filter, 2016-06-24) reverted.

Change-Id: Idea5c282d610d949958d757677ee642d97ca1c8e
Reviewed-on: https://gerrit.libreoffice.org/26747Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 1ce7176b
...@@ -19,11 +19,22 @@ $(eval $(call gb_CppunitTest_set_include,svx_unit,\ ...@@ -19,11 +19,22 @@ $(eval $(call gb_CppunitTest_set_include,svx_unit,\
$(eval $(call gb_CppunitTest_add_exception_objects,svx_unit, \ $(eval $(call gb_CppunitTest_add_exception_objects,svx_unit, \
svx/qa/unit/svdraw/test_SdrTextObject \ svx/qa/unit/svdraw/test_SdrTextObject \
svx/qa/unit/xoutdev \
)) ))
$(eval $(call gb_CppunitTest_use_libraries,svx_unit, \ $(eval $(call gb_CppunitTest_use_libraries,svx_unit, \
sal \ sal \
svxcore \ 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: # vim: set noet sw=4 ts=4:
/* -*- 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: */
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