vcl/qa/cppunit/BitmapTest.cxx | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
New commits: commit af05c3a9a7672c2233f7df7729736259f7b0f0dc Author: Chris Sherlock <chris.sherloc...@gmail.com> AuthorDate: Fri Dec 18 16:08:11 2020 +1100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sat Dec 19 04:15:19 2020 +0100 vcl: add unit test for certain sizes of bitmaps to be dithered Change-Id: I9e40c8536c86468040bde56c569e7c69ad8f745b Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107947 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx index 67f897cd9ef4..8a931df524eb 100644 --- a/vcl/qa/cppunit/BitmapTest.cxx +++ b/vcl/qa/cppunit/BitmapTest.cxx @@ -1,4 +1,3 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * @@ -46,6 +45,7 @@ class BitmapTest : public CppUnit::TestFixture void testBitmap32(); void testOctree(); void testEmptyAccess(); + void testDitherSize(); CPPUNIT_TEST_SUITE(BitmapTest); CPPUNIT_TEST(testCreation); @@ -61,6 +61,7 @@ class BitmapTest : public CppUnit::TestFixture CPPUNIT_TEST(testBitmap32); CPPUNIT_TEST(testOctree); CPPUNIT_TEST(testEmptyAccess); + CPPUNIT_TEST(testDitherSize); CPPUNIT_TEST_SUITE_END(); }; @@ -650,6 +651,38 @@ void BitmapTest::testEmptyAccess() CPPUNIT_ASSERT_EQUAL(tools::Long(0), access.Height()); } +void BitmapTest::testDitherSize() +{ + // no need to do anything for a 1x1 pixel bitmap + { + Bitmap aBitmap(Size(1, 1), 24); + CPPUNIT_ASSERT(aBitmap.Dither()); + } + + // cannot dither a bitmap with a width of 2 or 3 pixels + { + Bitmap aBitmap(Size(2, 4), 24); + CPPUNIT_ASSERT(!aBitmap.Dither()); + } + + { + Bitmap aBitmap(Size(3, 4), 24); + CPPUNIT_ASSERT(!aBitmap.Dither()); + } + + // cannot dither a bitmap with a height of 2 pixels + { + Bitmap aBitmap(Size(4, 2), 24); + CPPUNIT_ASSERT(!aBitmap.Dither()); + } + + // only dither bitmaps with a width > 3 pixels and height > 2 pixels + { + Bitmap aBitmap(Size(4, 3), 24); + CPPUNIT_ASSERT(aBitmap.Dither()); + } +} + } // namespace CPPUNIT_TEST_SUITE_REGISTRATION(BitmapTest); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits