Kaydet (Commit) 71457cb2 authored tarafından Jan Holesovsky's avatar Jan Holesovsky

pct import: Unit test for the clipping import fix.

Change-Id: I8f9df1d92c86c087e37f77209f413ff8c1c6358f
üst ce90fa30
......@@ -10,12 +10,17 @@
#include <unotest/filters-test.hxx>
#include <test/bootstrapfixture.hxx>
#include <vcl/FilterConfigItem.hxx>
#include <test/mtfxmldump.hxx>
#include <test/xmltesttools.hxx>
#include <tools/stream.hxx>
#include <vcl/graph.hxx>
#include <vcl/metaactiontypes.hxx>
#include <osl/file.hxx>
#include <osl/process.h>
#include "../../source/graphicfilter/ipict/ipict.hxx"
extern "C"
{
SAL_DLLPUBLIC_EXPORT bool SAL_CALL
......@@ -30,6 +35,7 @@ using namespace ::com::sun::star;
class PictFilterTest
: public test::FiltersTest
, public test::BootstrapFixture
, public XmlTestTools
{
public:
PictFilterTest() : BootstrapFixture(true, false) {}
......@@ -38,13 +44,21 @@ public:
const OUString &rURL, const OUString &,
unsigned int, unsigned int, unsigned int) SAL_OVERRIDE;
OUString pictURL()
{
return getURLFromSrc("/filter/qa/cppunit/data/pict/");
}
/**
* Ensure CVEs remain unbroken
*/
void testCVEs();
void testDontClipTooMuch();
CPPUNIT_TEST_SUITE(PictFilterTest);
CPPUNIT_TEST(testCVEs);
CPPUNIT_TEST(testDontClipTooMuch);
CPPUNIT_TEST_SUITE_END();
};
......@@ -60,10 +74,29 @@ bool PictFilterTest::load(const OUString &,
void PictFilterTest::testCVEs()
{
testDir(OUString(),
getURLFromSrc("/filter/qa/cppunit/data/pict/"),
pictURL(),
OUString());
}
void PictFilterTest::testDontClipTooMuch()
{
SvFileStream aFileStream(pictURL() + "clipping-problem.pct", STREAM_READ);
GDIMetaFile aGDIMetaFile;
pict::ReadPictFile(aFileStream, aGDIMetaFile);
MetafileXmlDump dumper;
dumper.filterAllActionTypes();
dumper.filterActionType(META_CLIPREGION_ACTION, false);
xmlDocPtr pDoc = dumper.dumpAndParse(aGDIMetaFile);
CPPUNIT_ASSERT (pDoc);
assertXPath(pDoc, "/metafile/clipregion[5]", "top", "0");
assertXPath(pDoc, "/metafile/clipregion[5]", "left", "0");
assertXPath(pDoc, "/metafile/clipregion[5]", "bottom", "-32767");
assertXPath(pDoc, "/metafile/clipregion[5]", "right", "-32767");
}
CPPUNIT_TEST_SUITE_REGISTRATION(PictFilterTest);
CPPUNIT_PLUGIN_IMPLEMENT();
......
......@@ -17,7 +17,6 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <string.h>
#include <osl/thread.h>
#include <vcl/bmpacc.hxx>
......@@ -26,6 +25,7 @@
#include <vcl/virdev.hxx>
#include <math.h>
#include "ipict.hxx"
#include "shape.hxx"
#include <boost/scoped_array.hpp>
......@@ -1940,5 +1940,14 @@ GraphicImport( SvStream& rIStm, Graphic & rGraphic, FilterConfigItem* )
return bRet;
}
namespace pict {
SAL_DLLPUBLIC_EXPORT void ReadPictFile(SvStream &rStreamPict, GDIMetaFile& rGDIMetaFile)
{
PictReader aPictReader;
aPictReader.ReadPict(rStreamPict, rGDIMetaFile);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- 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/.
*/
#ifndef INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX
#define INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX
class GDIMetaFile;
class SvStream;
namespace pict {
/// Function to access PictReader::ReadPict for unit testing.
void ReadPictFile(SvStream &rStreamPict, GDIMetaFile& rGDIMetaFile);
}
#endif // INCLUDED_FILTER_SOURCE_GRAPHICFILTER_IPICT_HXX
/* 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