summaryrefslogtreecommitdiff
path: root/sd/qa/unit
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2020-09-22 12:32:01 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2020-09-22 15:51:49 +0200
commit0e66570eeb97d2c6779383d5b2f027e99f661c1d (patch)
tree3ee60e14a2587985963a2cdad543c68ebabbf58f /sd/qa/unit
parent6ca5d784e2212a91b70a6eb3e343bcaa2db8e99c (diff)
tdf#104722: sd_import_tests: Add unittest
Change-Id: I94b28074a773cec99227bbaae4a82bd085e17a94 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103159 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sd/qa/unit')
-rw-r--r--sd/qa/unit/data/pptx/tdf104722.pptxbin0 -> 40497 bytes
-rw-r--r--sd/qa/unit/import-tests.cxx70
2 files changed, 70 insertions, 0 deletions
diff --git a/sd/qa/unit/data/pptx/tdf104722.pptx b/sd/qa/unit/data/pptx/tdf104722.pptx
new file mode 100644
index 000000000000..27ea41958029
--- /dev/null
+++ b/sd/qa/unit/data/pptx/tdf104722.pptx
Binary files differ
diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx
index 97b82150cdee..ccb45ce56695 100644
--- a/sd/qa/unit/import-tests.cxx
+++ b/sd/qa/unit/import-tests.cxx
@@ -173,6 +173,7 @@ public:
void testTdf93097();
void testTdf62255();
void testTdf93124();
+ void testTdf104722();
void testTdf99729();
void testTdf89927();
void testTdf93868();
@@ -284,6 +285,7 @@ public:
CPPUNIT_TEST(testTdf93097);
CPPUNIT_TEST(testTdf62255);
CPPUNIT_TEST(testTdf93124);
+ CPPUNIT_TEST(testTdf104722);
CPPUNIT_TEST(testTdf99729);
CPPUNIT_TEST(testTdf89927);
CPPUNIT_TEST(testTdf93868);
@@ -1613,6 +1615,74 @@ void SdImportTest::testTdf93124()
xDocShRef->DoClose();
}
+void SdImportTest::testTdf104722()
+{
+ sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/pptx/tdf104722.pptx"), PPTX);
+ uno::Reference < uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
+ uno::Reference< drawing::XGraphicExportFilter > xGraphicExporter = drawing::GraphicExportFilter::create(xContext);
+
+ uno::Sequence< beans::PropertyValue > aFilterData(2);
+ aFilterData[0].Name = "PixelWidth";
+ aFilterData[0].Value <<= sal_Int32(320);
+ aFilterData[1].Name = "PixelHeight";
+ aFilterData[1].Value <<= sal_Int32(180);
+
+ utl::TempFile aTempFile;
+ aTempFile.EnableKillingFile();
+
+ uno::Sequence< beans::PropertyValue > aDescriptor(3);
+ aDescriptor[0].Name = "URL";
+ aDescriptor[0].Value <<= aTempFile.GetURL();
+ aDescriptor[1].Name = "FilterName";
+ aDescriptor[1].Value <<= OUString("PNG");
+ aDescriptor[2].Name = "FilterData";
+ aDescriptor[2].Value <<= aFilterData;
+
+ uno::Reference< lang::XComponent > xPage(getPage(0, xDocShRef), uno::UNO_QUERY);
+ xGraphicExporter->setSourceDocument(xPage);
+ xGraphicExporter->filter(aDescriptor);
+
+ SvFileStream aFileStream(aTempFile.GetURL(), StreamMode::READ);
+ vcl::PNGReader aPNGReader(aFileStream);
+ BitmapEx aBMPEx = aPNGReader.Read();
+
+ // make sure the bitmap is not empty and correct size (PNG export->import was successful)
+ CPPUNIT_ASSERT_EQUAL(Size(320, 180), aBMPEx.GetSizePixel());
+ Bitmap aBMP = aBMPEx.GetBitmap();
+ Bitmap::ScopedReadAccess pReadAccess(aBMP);
+
+ {
+ int nNonWhiteCount = 0;
+ // Check the left part of the document has text. 0,45 to 80,90
+ for (long nY = 45; nY < 90; ++nY)
+ {
+ for (long nX = 0; nX < 80; ++nX)
+ {
+ const Color aColor = pReadAccess->GetColor(nY, nX);
+ if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) || (aColor.GetBlue() != 0xff))
+ ++nNonWhiteCount;
+ }
+ }
+ CPPUNIT_ASSERT_MESSAGE("Tdf104722: horizontal alignment of text is incorrect!", nNonWhiteCount > 300);
+ }
+ {
+ int nNonWhiteCount = 0;
+ // Check the right part of the document has text. 240,45 to 320,90
+ for (long nY = 45; nY < 90; ++nY)
+ {
+ for (long nX = 240; nX < 320; ++nX)
+ {
+ const Color aColor = pReadAccess->GetColor(nY, nX);
+ if ((aColor.GetRed() != 0xff) || (aColor.GetGreen() != 0xff) || (aColor.GetBlue() != 0xff))
+ ++nNonWhiteCount;
+ }
+ }
+ // Without the fix in place, this test would have failed here as the text would have been shifted to the left
+ CPPUNIT_ASSERT_MESSAGE("Tdf104722: horizontal alignment of text is incorrect!", nNonWhiteCount > 300);
+ }
+ xDocShRef->DoClose();
+}
+
void SdImportTest::testTdf99729()
{
const OUString filenames[] = { "/sd/qa/unit/data/odp/tdf99729-new.odp", "/sd/qa/unit/data/odp/tdf99729-legacy.odp" };