[Libreoffice-commits] core.git: vcl/qa
Noel Grandin (via logerrit)
logerrit at kemper.freedesktop.org
Mon Feb 10 08:33:02 UTC 2020
vcl/qa/cppunit/ScanlineToolsTest.cxx | 42 +++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
New commits:
commit 157abc56d634e72e0654dc0cf88d0092744ac19c
Author: Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Mon Feb 10 09:30:24 2020 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Mon Feb 10 09:32:26 2020 +0100
restore unit test code accidentally deleted
in c05680bd27f0f9fc9d5371f4ef97fd45184de1c6
Change-Id: I8d35ed9411c51b8bfffc2ca67d9d8de94ba067dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88355
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/vcl/qa/cppunit/ScanlineToolsTest.cxx b/vcl/qa/cppunit/ScanlineToolsTest.cxx
index 9a0ad213e7cc..bf053d3bc890 100644
--- a/vcl/qa/cppunit/ScanlineToolsTest.cxx
+++ b/vcl/qa/cppunit/ScanlineToolsTest.cxx
@@ -20,12 +20,14 @@ class ScanlineToolsTest : public CppUnit::TestFixture
void ScanlineTransformer_32_ARGB();
void ScanlineTransformer_24_BGR();
void ScanlineTransformer_8bit_Palette();
+ void ScanlineTransformer_4bit_Palette();
void ScanlineTransformer_1bit_Palette();
CPPUNIT_TEST_SUITE(ScanlineToolsTest);
CPPUNIT_TEST(ScanlineTransformer_32_ARGB);
CPPUNIT_TEST(ScanlineTransformer_24_BGR);
CPPUNIT_TEST(ScanlineTransformer_8bit_Palette);
+ CPPUNIT_TEST(ScanlineTransformer_4bit_Palette);
CPPUNIT_TEST(ScanlineTransformer_1bit_Palette);
CPPUNIT_TEST_SUITE_END();
};
@@ -124,6 +126,46 @@ void ScanlineToolsTest::ScanlineTransformer_8bit_Palette()
}
}
+void ScanlineToolsTest::ScanlineTransformer_4bit_Palette()
+{
+ std::vector<Color> aColors{
+ Color(10, 250, 120), Color(30, 230, 110), Color(50, 210, 100),
+ Color(70, 190, 90), Color(90, 170, 80), Color(110, 150, 70),
+ };
+
+ BitmapPalette aPalette(16);
+ for (size_t i = 0; i < aColors.size(); ++i)
+ {
+ aPalette[i] = aColors[i];
+ }
+
+ std::unique_ptr<vcl::bitmap::ScanlineTransformer> pScanlineTransformer
+ = vcl::bitmap::getScanlineTransformer(4, aPalette);
+
+ std::vector<sal_uInt8> aScanLine(3, 0); // 6 * 0.5 BytesPerPixel
+ pScanlineTransformer->startLine(aScanLine.data());
+
+ for (Color const& aColor : aColors)
+ {
+ pScanlineTransformer->writePixel(aColor);
+ }
+
+ std::vector<sal_uInt8> aExpectedBytes{ 0x01, 0x23, 0x45 };
+
+ for (size_t i = 0; i < aScanLine.size(); ++i)
+ {
+ CPPUNIT_ASSERT_EQUAL(int(aExpectedBytes[i]), int(aScanLine[i]));
+ }
+
+ pScanlineTransformer->startLine(aScanLine.data());
+
+ for (size_t i = 0; i < aColors.size(); ++i)
+ {
+ Color aColor = pScanlineTransformer->readPixel();
+ CPPUNIT_ASSERT_EQUAL(aColors[i], aColor);
+ }
+}
+
void ScanlineToolsTest::ScanlineTransformer_1bit_Palette()
{
std::vector<Color> aColors{
More information about the Libreoffice-commits
mailing list