summaryrefslogtreecommitdiff
path: root/sd/qa/unit/PNGExportTests.cxx
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-10-09 11:49:56 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-10-09 14:03:03 +0200
commit4e1aec7937c0ccd9aa3c5c34091e94786f16e145 (patch)
treef1d10a17a653afcebfb87590788c0a5d6d4ead6d /sd/qa/unit/PNGExportTests.cxx
parent7fee80fdf4625af4bb8c4273e2cab7bf8b9b46df (diff)
tdf#49253, tdf#157635, tdf#157576: sd_png_export: Add unittest
Change-Id: I59b869c84381e2904edbc399b3d1598896e1dd29 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157699 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sd/qa/unit/PNGExportTests.cxx')
-rw-r--r--sd/qa/unit/PNGExportTests.cxx51
1 files changed, 51 insertions, 0 deletions
diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx
index 58ec8d6077cc..58cd828b677b 100644
--- a/sd/qa/unit/PNGExportTests.cxx
+++ b/sd/qa/unit/PNGExportTests.cxx
@@ -202,6 +202,57 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf136632)
CPPUNIT_ASSERT(!pReadAccess);
}
+CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf157635)
+{
+ loadFromURL(u"pptx/tdf157635.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 nBlackCount = 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 == COL_BLACK)
+ ++nBlackCount;
+ }
+ }
+
+ // Without the fix in place, this test would have failed with
+ // - Expected greater than: 7100
+ // - Actual : 0
+ CPPUNIT_ASSERT_GREATER(7100, nBlackCount);
+}
+
CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf113163)
{
loadFromURL(u"pptx/tdf113163.pptx");