diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-02-10 09:30:24 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-02-10 09:32:26 +0100 |
commit | 157abc56d634e72e0654dc0cf88d0092744ac19c (patch) | |
tree | 1e69048134323d6e1495fe9eb6b2b441d7c4f03c /vcl | |
parent | 85a2ef5cd1b3c06277422b7068eaf1ddc79efdcb (diff) |
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@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/ScanlineToolsTest.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
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{ |