Kaydet (Commit) 9a4a48d2 authored tarafından Tomaž Vajngerl's avatar Tomaž Vajngerl

vcl emf test: test clip region is correct for problematic files

Change-Id: I60caf9ebcff417e0f87bae9c6b5d308b5e2f0b37
üst fc83bf8b
...@@ -27,37 +27,46 @@ using namespace css; ...@@ -27,37 +27,46 @@ using namespace css;
class WmfTest : public test::BootstrapFixture, public XmlTestTools class WmfTest : public test::BootstrapFixture, public XmlTestTools
{ {
OUString maDataUrl;
OUString getFullUrl(OUString sFileName)
{
return getURLFromSrc(maDataUrl) + sFileName;
}
public: public:
WmfTest() : WmfTest() :
BootstrapFixture(true, false) BootstrapFixture(true, false),
maDataUrl("/vcl/qa/cppunit/wmf/data/")
{} {}
void testNonPlaceableWmf(); void testNonPlaceableWmf();
void testSine();
void testEmfProblem();
CPPUNIT_TEST_SUITE(WmfTest); CPPUNIT_TEST_SUITE(WmfTest);
CPPUNIT_TEST(testNonPlaceableWmf); CPPUNIT_TEST(testNonPlaceableWmf);
CPPUNIT_TEST(testSine);
CPPUNIT_TEST(testEmfProblem);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
}; };
void WmfTest::testNonPlaceableWmf() void WmfTest::testNonPlaceableWmf()
{ {
OUString aUrl = getURLFromSrc("/vcl/qa/cppunit/wmf/data/"); SvFileStream aFileStream(getFullUrl("visio_import_source.wmf"), STREAM_READ);
SvFileStream aFileStream(aUrl + "visio_import_source.wmf", STREAM_READ);
GDIMetaFile aGDIMetaFile; GDIMetaFile aGDIMetaFile;
ReadWindowMetafile(aFileStream, aGDIMetaFile); ReadWindowMetafile(aFileStream, aGDIMetaFile);
boost::scoped_ptr<SvMemoryStream> aStream(new SvMemoryStream); SvMemoryStream aStream;
MetafileXmlDump dumper(*aStream); MetafileXmlDump dumper(aStream);
dumper.filterAllActionTypes(); dumper.filterAllActionTypes();
dumper.filterActionType(META_POLYLINE_ACTION, false); dumper.filterActionType(META_POLYLINE_ACTION, false);
dumper.dump(aGDIMetaFile); dumper.dump(aGDIMetaFile);
aStream->WriteChar(0); aStream.Seek(STREAM_SEEK_TO_BEGIN);
aStream->Seek(STREAM_SEEK_TO_BEGIN);
xmlDocPtr pDoc = parseXmlStream(aStream.get()); xmlDocPtr pDoc = parseXmlStream(&aStream);
CPPUNIT_ASSERT (pDoc); CPPUNIT_ASSERT (pDoc);
...@@ -77,6 +86,61 @@ void WmfTest::testNonPlaceableWmf() ...@@ -77,6 +86,61 @@ void WmfTest::testNonPlaceableWmf()
assertXPath(pDoc, "/metafile/polyline[1]/point[5]", "y", "1003"); assertXPath(pDoc, "/metafile/polyline[1]/point[5]", "y", "1003");
} }
void WmfTest::testSine()
{
SvFileStream aFileStream(getFullUrl("sine_wave.emf"), STREAM_READ);
GDIMetaFile aGDIMetaFile;
ReadWindowMetafile(aFileStream, aGDIMetaFile);
SvMemoryStream aStream;
MetafileXmlDump dumper(aStream);
dumper.filterAllActionTypes();
dumper.filterActionType(META_ISECTRECTCLIPREGION_ACTION, false);
dumper.dump(aGDIMetaFile);
aStream.Seek(STREAM_SEEK_TO_BEGIN);
xmlDocPtr pDoc = parseXmlStream(&aStream);
CPPUNIT_ASSERT (pDoc);
assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "top", "0");
assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "left", "0");
assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "bottom", "1155947");
assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "right", "1155378");
assertXPath(pDoc, "/metafile/sectrectclipregion[2]", "top", "1411");
assertXPath(pDoc, "/metafile/sectrectclipregion[2]", "left", "2962");
assertXPath(pDoc, "/metafile/sectrectclipregion[2]", "bottom", "16651");
assertXPath(pDoc, "/metafile/sectrectclipregion[2]", "right", "20698");
}
void WmfTest::testEmfProblem()
{
SvFileStream aFileStream(getFullUrl("computer_mail.emf"), STREAM_READ);
GDIMetaFile aGDIMetaFile;
ReadWindowMetafile(aFileStream, aGDIMetaFile);
SvMemoryStream aStream;
MetafileXmlDump dumper(aStream);
dumper.filterAllActionTypes();
dumper.filterActionType(META_ISECTRECTCLIPREGION_ACTION, false);
dumper.dump(aGDIMetaFile);
aStream.Seek(STREAM_SEEK_TO_BEGIN);
xmlDocPtr pDoc = parseXmlStream(&aStream);
CPPUNIT_ASSERT (pDoc);
assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "top", "427");
assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "left", "740");
assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "bottom", "2823");
assertXPath(pDoc, "/metafile/sectrectclipregion[1]", "right", "1876");
}
CPPUNIT_TEST_SUITE_REGISTRATION(WmfTest); CPPUNIT_TEST_SUITE_REGISTRATION(WmfTest);
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
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