diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-01-31 16:44:49 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-01-31 20:44:05 +0100 |
commit | 98d6ed2aeb22b27fddf716a372f483b89ecea841 (patch) | |
tree | a1d3d244454ad1d92e70fd4e1b55ccf67a0fade8 /sd | |
parent | 1a1e9f6b5929d5abeceeb49d0a7135bcd728ef7d (diff) |
tdf#123973: sd_png_export_tests: Add unittest
Change-Id: I4e3f97aef0865a00a771d8fa959422203a8f08f1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129228
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/PNGExportTests.cxx | 55 | ||||
-rw-r--r-- | sd/qa/unit/data/odp/tdf123973.odp | bin | 0 -> 11372 bytes |
2 files changed, 55 insertions, 0 deletions
diff --git a/sd/qa/unit/PNGExportTests.cxx b/sd/qa/unit/PNGExportTests.cxx index 7e7d984f0fcb..0bc829ffaf78 100644 --- a/sd/qa/unit/PNGExportTests.cxx +++ b/sd/qa/unit/PNGExportTests.cxx @@ -101,6 +101,61 @@ CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf113163) } } +CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf123973) +{ + mxComponent + = loadFromDesktop(m_directories.getURLFromSrc(u"/sd/qa/unit/data/odp/tdf123973.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", true), + }; + + utl::TempFile aTempFile; + aTempFile.EnableKillingFile(); + + uno::Sequence<beans::PropertyValue> aDescriptor{ + comphelper::makePropertyValue("URL", aTempFile.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(aTempFile.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) + { + // Check all pixels in the image are black + // Without the fix in place, this test would have failed with + // - Expected: Color: R:0 G:0 B:0 A:0 + // - Actual : Color: R:255 G:255 B:255 A:0 + const Color aColor = pReadAccess->GetColor(nX, nY); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, aColor); + } + } + } +} + CPPUNIT_TEST_FIXTURE(SdPNGExportTest, testTdf93124) { mxComponent diff --git a/sd/qa/unit/data/odp/tdf123973.odp b/sd/qa/unit/data/odp/tdf123973.odp Binary files differnew file mode 100644 index 000000000000..a3bd9455efd5 --- /dev/null +++ b/sd/qa/unit/data/odp/tdf123973.odp |