summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2023-10-10 14:02:39 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2023-10-10 21:35:50 +0200
commit0cd5b97acbb3419eb7f550e39a291691373bd878 (patch)
tree4caa7ac69d35ec0174ef8b92acce2184a8a13639
parent27b05720c99b933a6cbb7a881433a70766962195 (diff)
tdf#157502, tdf#157652: sd_png_export: Add unittest
Change-Id: I19bf2738496e0289e9fe07ac5241781b4c0bc416 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157758 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
-rw-r--r--sd/qa/unit/PNGExportTests.cxx48
-rw-r--r--sd/qa/unit/data/odp/tdf157652.odpbin0 -> 14767 bytes
2 files changed, 48 insertions, 0 deletions
diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx
index 58cd828b677b..7c28b7d51654 100644
--- a/sd/qa/unit/PNGExportTests.cxx
+++ b/sd/qa/unit/PNGExportTests.cxx
@@ -202,6 +202,54 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf136632)
CPPUNIT_ASSERT(!pReadAccess);
}
+CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf157652)
+{
+ loadFromURL(u"odp/tdf157652.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))
+ };
+
+ 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[ffffffff]
+ // - Actual : rgba[ff953eff]
+ CPPUNIT_ASSERT_EQUAL(COL_WHITE, aColor);
+ }
+ }
+}
+
CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf157635)
{
loadFromURL(u"pptx/tdf157635.pptx");
diff --git a/sd/qa/unit/data/odp/tdf157652.odp b/sd/qa/unit/data/odp/tdf157652.odp
new file mode 100644
index 000000000000..11fb34b0c38d
--- /dev/null
+++ b/sd/qa/unit/data/odp/tdf157652.odp
Binary files differ