diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-10-10 16:33:25 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-10-11 11:39:00 +0200 |
commit | 40641b868b20c73e694770c2c7ea71e232514fa1 (patch) | |
tree | d4b8ea4e367e8fddf13fd0f824da4a68fbd5f145 /sd | |
parent | 6f45c0cf86b21772740bb0cafb3d462b058523f3 (diff) |
tdf#156808: sd_png_export: Add unittest
Change-Id: I64b1f1f179e263962394afbbebd0be5486720e75
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157763
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/PNGExportTests.cxx | 48 | ||||
-rw-r--r-- | sd/qa/unit/data/pptx/tdf156808.pptx | bin | 0 -> 19449 bytes |
2 files changed, 48 insertions, 0 deletions
diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx index 7c28b7d51654..04fbed439a41 100644 --- a/sd/qa/unit/PNGExportTests.cxx +++ b/sd/qa/unit/PNGExportTests.cxx @@ -250,6 +250,54 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf157652) } } +CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf156808) +{ + loadFromURL(u"pptx/tdf156808.pptx"); + uno::Reference<uno::XComponentContext> xContext = getComponentContext(); + CPPUNIT_ASSERT(xContext.is()); + uno::Reference<drawing::XGraphicExportFilter> xGraphicExporter + = drawing::GraphicExportFilter::create(xContext); + + uno::Sequence<beans::PropertyValue> aFilterData{ + comphelper::makePropertyValue("PixelWidth", sal_Int32(100)), + comphelper::makePropertyValue("PixelHeight", sal_Int32(100)) + }; + + uno::Sequence<beans::PropertyValue> aDescriptor{ + comphelper::makePropertyValue("URL", maTempFile.GetURL()), + comphelper::makePropertyValue("FilterName", OUString("PNG")), + comphelper::makePropertyValue("FilterData", aFilterData) + }; + + uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<lang::XComponent> xPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0), + uno::UNO_QUERY); + xGraphicExporter->setSourceDocument(xPage); + xGraphicExporter->filter(aDescriptor); + + SvFileStream aFileStream(maTempFile.GetURL(), StreamMode::READ); + vcl::PngImageReader aPNGReader(aFileStream); + BitmapEx aBMPEx = aPNGReader.read(); + + // make sure the bitmap is not empty and correct size (PNG export->import was successful) + Size aSize = aBMPEx.GetSizePixel(); + CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize); + Bitmap aBMP = aBMPEx.GetBitmap(); + Bitmap::ScopedReadAccess pReadAccess(aBMP); + for (tools::Long nX = 2; nX < aSize.Width() - 2; ++nX) + { + for (tools::Long nY = 1; nY < aSize.Height() - 1; ++nY) + { + const Color aColor = pReadAccess->GetColor(nY, nX); + + // Without the fix in place, this test would have failed with + // - Expected: rgba[000000ff] + // - Actual : rgba[ffffffff] + CPPUNIT_ASSERT_EQUAL(COL_BLACK, aColor); + } + } +} + CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf157635) { loadFromURL(u"pptx/tdf157635.pptx"); diff --git a/sd/qa/unit/data/pptx/tdf156808.pptx b/sd/qa/unit/data/pptx/tdf156808.pptx Binary files differnew file mode 100644 index 000000000000..34256151b60b --- /dev/null +++ b/sd/qa/unit/data/pptx/tdf156808.pptx |