summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-10-23 11:19:33 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-10-23 15:28:07 +0200
commit4d0e2203d1ccceb4a742b02c267e613b50ca9370 (patch)
tree7bcd9500d56fd3f9cb00bd38557560bf52b4a9a4
parent4648764378f42df7dee4a4cf7d1614ee64e1d1a3 (diff)
tdf#157793: sd_png_export: Add unittest
Change-Id: I9a602a5da35146c103b7c21a00067f80f4922ac2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/158341 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sd/qa/unit/PNGExportTests.cxx51
-rw-r--r--sd/qa/unit/data/pptx/tdf157793.pptxbin0 -> 42199 bytes
2 files changed, 51 insertions, 0 deletions
diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx
index a5b705c19f39..af48ecbdd713 100644
--- a/sd/qa/unit/PNGExportTests.cxx
+++ b/sd/qa/unit/PNGExportTests.cxx
@@ -401,6 +401,57 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf157636)
CPPUNIT_ASSERT_GREATER(6600, nBlackCount);
}
+CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf157793)
+{
+ loadFromURL(u"pptx/tdf157793.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);
+ int nLightGrayCount = 0;
+ 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);
+ if (aColor == 0xfefefe)
+ ++nLightGrayCount;
+ }
+ }
+
+ // Without the fix in place, this test would have failed with
+ // - Expected greater than: 8500
+ // - Actual : 0
+ CPPUNIT_ASSERT_GREATER(8500, nLightGrayCount);
+}
+
CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf157635)
{
loadFromURL(u"pptx/tdf157635.pptx");
diff --git a/sd/qa/unit/data/pptx/tdf157793.pptx b/sd/qa/unit/data/pptx/tdf157793.pptx
new file mode 100644
index 000000000000..b1c4f200b86d
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf157793.pptx
Binary files differ