From 33324a41869817832d57accae5aa5d4c1d813309 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Tue, 23 Mar 2021 12:06:57 +0100 Subject: sd_import_tests: simplify test Change-Id: Idf1bae6bfb8a41d2bea65c4e1848368d2a2abd14 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112984 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sd/qa/unit/import-tests.cxx | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'sd/qa') diff --git a/sd/qa/unit/import-tests.cxx b/sd/qa/unit/import-tests.cxx index cce54cb16e4f..19fda935620a 100644 --- a/sd/qa/unit/import-tests.cxx +++ b/sd/qa/unit/import-tests.cxx @@ -1618,21 +1618,23 @@ void SdImportTest::testTdf113163() BitmapEx aBMPEx = aPNGReader.read(); // make sure the bitmap is not empty and correct size (PNG export->import was successful) - CPPUNIT_ASSERT_EQUAL(Size(100, 100), aBMPEx.GetSizePixel()); + Size aSize = aBMPEx.GetSizePixel(); + CPPUNIT_ASSERT_EQUAL(Size(100, 100), aSize); Bitmap aBMP = aBMPEx.GetBitmap(); { Bitmap::ScopedReadAccess pReadAccess(aBMP); - int nNonBlackCount = 0; - for (tools::Long nY = 1; nY < 99; ++nY) + for (tools::Long nX = 1; nX < aSize.Width() - 1; ++nX) { - for (tools::Long nX = 1; nX < 99; ++nX) + for (tools::Long nY = 1; nY < aSize.Height() - 1; ++nY) { - const Color aColor = pReadAccess->GetColor(nY, nX); - if ((aColor.GetRed() != 0x00) || (aColor.GetGreen() != 0x00) || (aColor.GetBlue() != 0x00)) - ++nNonBlackCount; + // Check all pixels in the image are black + // Without the fix in place, this test would have failed with + // - Expected: 0 + // - Actual : 16777215 + const Color aColor = pReadAccess->GetColor(nX, nY); + CPPUNIT_ASSERT_EQUAL(COL_BLACK, aColor); } } - CPPUNIT_ASSERT_EQUAL_MESSAGE("Tdf113163: EMF image is not transparent", 0, nNonBlackCount); } xDocShRef->DoClose(); } -- cgit v1.2.3