[Libreoffice-commits] core.git: vcl/qa
Xisco Fauli (via logerrit)
logerrit at kemper.freedesktop.org
Wed Dec 16 11:43:57 UTC 2020
vcl/qa/cppunit/jpeg/JpegReaderTest.cxx | 29 +++++++++++++++++++++++++++++
vcl/qa/cppunit/jpeg/data/tdf138950.jpeg |binary
2 files changed, 29 insertions(+)
New commits:
commit 2ecdaa672b0362eb314afeea811c72cfa06bb20a
Author: Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Tue Dec 15 22:10:59 2020 +0100
Commit: Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Wed Dec 16 12:43:18 2020 +0100
tdf#138950: vcl_jpeg_read_write: Add unittest
Change-Id: Ia1adcac3e10d1aa17281963d27718a37bf37b953
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107814
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
diff --git a/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx b/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx
index 78124beef5f3..9c01583d1f8c 100644
--- a/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx
+++ b/vcl/qa/cppunit/jpeg/JpegReaderTest.cxx
@@ -28,11 +28,13 @@ public:
void testReadRGB();
void testReadGray();
void testReadCMYK();
+ void testTdf138950();
CPPUNIT_TEST_SUITE(JpegReaderTest);
CPPUNIT_TEST(testReadRGB);
CPPUNIT_TEST(testReadGray);
CPPUNIT_TEST(testReadCMYK);
+ CPPUNIT_TEST(testTdf138950);
CPPUNIT_TEST_SUITE_END();
};
@@ -162,6 +164,33 @@ void JpegReaderTest::testReadCMYK()
CPPUNIT_ASSERT_EQUAL(4, getNumberOfImageComponents(aGraphic));
}
+void JpegReaderTest::testTdf138950()
+{
+ Graphic aGraphic = loadJPG(getFullUrl("tdf138950.jpeg"));
+ Bitmap aBitmap = aGraphic.GetBitmapEx().GetBitmap();
+ Size aSize = aBitmap.GetSizePixel();
+ CPPUNIT_ASSERT_EQUAL(tools::Long(720), aSize.Width());
+ CPPUNIT_ASSERT_EQUAL(tools::Long(1280), aSize.Height());
+
+ Bitmap::ScopedReadAccess pReadAccess(aBitmap);
+ int nBlackCount = 0;
+ for (tools::Long nY = 0; nY < aSize.Height(); ++nY)
+ {
+ for (tools::Long nX = 0; nX < aSize.Width(); ++nX)
+ {
+ const Color aColor = pReadAccess->GetColor(nY, nX);
+ if ((aColor.GetRed() == 0x00) && (aColor.GetGreen() == 0x00)
+ && (aColor.GetBlue() == 0x00))
+ ++nBlackCount;
+ }
+ }
+
+ // Without the fix in place, this test would have failed with
+ // - Expected: 0
+ // - Actual : 921600
+ CPPUNIT_ASSERT_EQUAL(0, nBlackCount);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(JpegReaderTest);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/vcl/qa/cppunit/jpeg/data/tdf138950.jpeg b/vcl/qa/cppunit/jpeg/data/tdf138950.jpeg
new file mode 100644
index 000000000000..d0296077c6bb
Binary files /dev/null and b/vcl/qa/cppunit/jpeg/data/tdf138950.jpeg differ
More information about the Libreoffice-commits
mailing list