diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-10-23 12:50:12 +0200 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2023-10-23 15:27:00 +0200 |
commit | 4648764378f42df7dee4a4cf7d1614ee64e1d1a3 (patch) | |
tree | 476e2ef4465e2c9af1ca91707cb80afd3fe60064 /sd | |
parent | ea8023f6bb9b623014a6db867fb9d46be7b7266f (diff) |
tdf#105362: sd_png_export: Add unittest
Change-Id: I1d6cc72738e3120c10e6d978dad18ec2fb36edd8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158346
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/PNGExportTests.cxx | 49 | ||||
-rw-r--r-- | sd/qa/unit/data/odp/tdf105362.odp | bin | 0 -> 13288 bytes |
2 files changed, 49 insertions, 0 deletions
diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx index c141c0ddeeb0..a5b705c19f39 100644 --- a/sd/qa/unit/PNGExportTests.cxx +++ b/sd/qa/unit/PNGExportTests.cxx @@ -301,6 +301,55 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf156808) CPPUNIT_ASSERT_GREATER(9000, nBlackCount); } +CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf105362) +{ + loadFromURL(u"odp/tdf105362.odp"); + 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)), + comphelper::makePropertyValue("Translucent", sal_Int32(1)), + }; + + 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 = 1; nX < aSize.Width() - 1; ++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, testTdf157636) { loadFromURL(u"ppt/tdf157636.ppt"); diff --git a/sd/qa/unit/data/odp/tdf105362.odp b/sd/qa/unit/data/odp/tdf105362.odp Binary files differnew file mode 100644 index 000000000000..1f0a83e85d1f --- /dev/null +++ b/sd/qa/unit/data/odp/tdf105362.odp |