summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2020-12-18 16:08:11 +1100
committerTomaž Vajngerl <quikee@gmail.com>2020-12-19 04:15:19 +0100
commitaf05c3a9a7672c2233f7df7729736259f7b0f0dc (patch)
treee45b68937c238826c99fa28cba4f6507d7bb7bff /vcl
parenta08e356e1afdf7d79d508570bec409436e237dbd (diff)
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 <quikee@gmail.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/qa/cppunit/BitmapTest.cxx35
1 files changed, 34 insertions, 1 deletions
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);