summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorXisco Fauli <xiscofauli@libreoffice.org>2022-04-28 13:45:38 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2022-04-28 21:20:15 +0200
commit49ce19a824700b2011334a6739ae2749e781155f (patch)
tree96ff4738362c37ff652e3eb6f3ece33d42ffa06c /vcl
parentd9c3f05dcb6c03633bbcc8d88e55237a0855d9a5 (diff)
tdf#74331: vcl_filters: Add unittest
Change-Id: Ia93f5f5f3ca5b4ddd51d68335af7f1c7b79b5c31 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133551 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/graphicfilter/data/tiff/tdf74331.tifbin0 -> 80146 bytes
-rw-r--r--vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx51
2 files changed, 51 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/graphicfilter/data/tiff/tdf74331.tif b/vcl/qa/cppunit/graphicfilter/data/tiff/tdf74331.tif
new file mode 100644
index 000000000000..702b8218ca5f
--- /dev/null
+++ b/vcl/qa/cppunit/graphicfilter/data/tiff/tdf74331.tif
Binary files differ
diff --git a/vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx b/vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx
index 24ce5492d3be..77e412088bf3 100644
--- a/vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx
+++ b/vcl/qa/cppunit/graphicfilter/filters-tiff-test.cxx
@@ -45,6 +45,7 @@ public:
void testTdf126460();
void testTdf115863();
void testTdf138818();
+ void testTdf74331();
void testRoundtrip();
void testRGB8bits();
void testRGB16bits();
@@ -54,6 +55,7 @@ public:
CPPUNIT_TEST(testTdf126460);
CPPUNIT_TEST(testTdf115863);
CPPUNIT_TEST(testTdf138818);
+ CPPUNIT_TEST(testTdf74331);
CPPUNIT_TEST(testRoundtrip);
CPPUNIT_TEST(testRGB8bits);
CPPUNIT_TEST(testRGB16bits);
@@ -128,6 +130,55 @@ void TiffFilterTest::testTdf138818()
CPPUNIT_ASSERT_EQUAL(sal_uInt32(46428), aGraphic.GetGfxLink().GetDataSize());
}
+void TiffFilterTest::testTdf74331()
+{
+ OUString aURL = getUrl() + "tdf74331.tif";
+ SvFileStream aFileStream(aURL, StreamMode::READ);
+ Graphic aGraphic;
+ GraphicFilter& rFilter = GraphicFilter::GetGraphicFilter();
+
+ ErrCode bResult = rFilter.ImportGraphic(aGraphic, aURL, aFileStream);
+
+ CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, bResult);
+
+ Bitmap aBitmap = aGraphic.GetBitmapEx().GetBitmap();
+ Size aSize = aBitmap.GetSizePixel();
+ CPPUNIT_ASSERT_EQUAL(tools::Long(200), aSize.Width());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(200), aSize.Height());
+
+ Bitmap::ScopedReadAccess pReadAccess(aBitmap);
+
+ // Check the image contains different kinds of grays
+ int nGrayCount = 0;
+ int nGray3Count = 0;
+ int nGray7Count = 0;
+ int nLightGrayCount = 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_GRAY)
+ ++nGrayCount;
+ else if (aColor == COL_GRAY3)
+ ++nGray3Count;
+ else if (aColor == COL_GRAY7)
+ ++nGray7Count;
+ else if (aColor == COL_LIGHTGRAY)
+ ++nLightGrayCount;
+ }
+ }
+
+ // Without the fix in place, this test would have failed with
+ // - Expected: 313
+ // - Actual : 0
+ CPPUNIT_ASSERT_EQUAL(313, nGrayCount);
+ CPPUNIT_ASSERT_EQUAL(71, nGray3Count);
+ CPPUNIT_ASSERT_EQUAL(227, nGray7Count);
+ CPPUNIT_ASSERT_EQUAL(165, nLightGrayCount);
+}
+
void TiffFilterTest::testRoundtrip()
{
Bitmap aBitmap(Size(2, 2), vcl::PixelFormat::N24_BPP);