Kaydet (Commit) a2e25af0 authored tarafından Armin Le Grand's avatar Armin Le Grand Kaydeden (comit) Thorsten Behrens

emfplus: corrections for UnitTest in vcl

The CppunitTest_vcl_filters_test was not working due
to a wmf file now being loadable. This leaded to better
check errors on stream and react on it in test code.
Hrad to find since that test - for whatever reason - is
not executed on win. Also need to check result of
EmfReader. Added emfio to test's module list

Change-Id: Iea2b835408e919a8456e8f178cbfc782885ffebb
üst 208e6618
......@@ -83,7 +83,7 @@ void Test::checkRectPrimitive(Primitive2DSequence& rPrimitive)
void Test::testWorking()
{
Primitive2DSequence aSequenceRect = parseEmf("/emfio/qa/cppunit/data/fdo79679-2.emf");
Primitive2DSequence aSequenceRect = parseEmf("/emfio/qa/cppunit/emf/data/fdo79679-2.emf");
CPPUNIT_ASSERT_EQUAL(1, (int) aSequenceRect.getLength());
checkRectPrimitive(aSequenceRect);
}
......
......@@ -136,16 +136,29 @@ namespace emfio
pStream->ReadUInt32(nMetaType);
pStream->Seek(nOrgPos);
bool bReadError(false);
if (nMetaType == 0x464d4520)
{
emfio::EmfReader(*pStream, aMtf).ReadEnhWMF();
// read and get possible failure/error, ReadEnhWMF returns success
bReadError = !emfio::EmfReader(*pStream, aMtf).ReadEnhWMF();
}
else
{
emfio::WmfReader(*pStream, aMtf, bExternalHeaderUsed ? &aExternalHeader : nullptr).ReadWMF();
// Need to check for ErrCode at stream to not lose former work.
// This may contain important information and will behave the
// same as before. When we have an error, do not create content
ErrCode aErrCode(pStream->GetError());
bReadError = aErrCode.IsError();
}
pStream->SetEndian(nOrigNumberFormat);
if (!bReadError)
{
Size aSize(aMtf.GetPrefSize());
if (aMtf.GetPrefMapMode().GetMapUnit() == MapUnit::MapPixel)
......@@ -189,9 +202,7 @@ namespace emfio
//
// aRetval.push_back(new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(basegfx::B2DPolyPolygon(aOutline), aColor));
// }
}
}
else
{
......
......@@ -31,6 +31,7 @@ $(eval $(call gb_CppunitTest_use_libraries,vcl_filters_test, \
tl \
unotest \
vcl \
emfio \
))
$(eval $(call gb_CppunitTest_use_sdk_api,vcl_filters_test))
......@@ -44,6 +45,7 @@ $(eval $(call gb_CppunitTest_use_components,vcl_filters_test,\
ucb/source/core/ucb1 \
ucb/source/ucp/file/ucpfile1 \
uui/util/uui \
emfio/emfio \
))
$(eval $(call gb_CppunitTest_use_configuration,vcl_filters_test))
......
......@@ -57,7 +57,30 @@ bool VclFiltersTest::load(const OUString &,
{
SvFileStream aFileStream(rURL, StreamMode::READ);
Graphic aGraphic;
return mGraphicFilter.ImportGraphic(aGraphic, rURL, aFileStream) == ERRCODE_NONE;
bool bRetval(ERRCODE_NONE == mGraphicFilter.ImportGraphic(aGraphic, rURL, aFileStream));
if (!bRetval)
{
// if error occurred, we are done
return bRetval;
}
// if not and we have an embedded Vector Graphic Data, trigger it's interpretation
// to check for error. Graphic with VectorGraphicData (Svg/Emf/Wmf) load without error
// as long as one of the three types gets detected. Thus, cycles like load/save in
// other format will work (what may be wanted). For the test framework it was indirectly
// intended to trigger an error when load in the sense of deep data interpretation fails,
// so we need to trigger this here
if (aGraphic.getVectorGraphicData().get())
{
if (aGraphic.getVectorGraphicData()->getRange().isEmpty())
{
// invalid file or file with no content
return false;
}
}
return true;
}
void VclFiltersTest::testScaling()
......
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