vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx | 46 ++++++++++++++++++----- 1 file changed, 36 insertions(+), 10 deletions(-)
New commits: commit 39cab14ce5a8d12b0656f0dce13c08a8f81a5dbb Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu Apr 18 21:35:46 2019 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Apr 19 10:04:38 2019 +0200 vcl: Allow for rounding errors on Win32 in testAlphaVirtualDevice Windows Tinerbox fails because of rounding error in blending (but only in some environments), so allow for a small rounding error in colors. Change-Id: If45ae99a445e9d6f795d06d88c902a723913b9a6 Reviewed-on: https://gerrit.libreoffice.org/70932 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx index b363da7386a1..cfb1143f3e02 100644 --- a/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx +++ b/vcl/qa/cppunit/bitmaprender/BitmapRenderTest.cxx @@ -151,6 +151,22 @@ void BitmapRenderTest::testDrawAlphaBitmapEx() #endif } +#ifdef _WIN32 + +namespace +{ +int deltaColor(BitmapColor aColor1, BitmapColor aColor2) +{ + int deltaR = std::abs(aColor1.GetRed() - aColor2.GetRed()); + int deltaG = std::abs(aColor1.GetGreen() - aColor2.GetGreen()); + int deltaB = std::abs(aColor1.GetBlue() - aColor2.GetBlue()); + + return std::max(std::max(deltaR, deltaG), deltaB); +} +} + +#endif + void BitmapRenderTest::testAlphaVirtualDevice() { // Create an alpha virtual device @@ -167,17 +183,20 @@ void BitmapRenderTest::testAlphaVirtualDevice() CPPUNIT_ASSERT_EQUAL(long(4), aBitmap.GetSizePixel().Width()); CPPUNIT_ASSERT_EQUAL(long(4), aBitmap.GetSizePixel().Height()); Color aColor = aBitmap.GetPixelColor(1, 1); - CPPUNIT_ASSERT_EQUAL(Color(0xff, 0xff, 0xff, 0xff), aColor); + CPPUNIT_ASSERT_EQUAL(Color(0xffffffff), aColor); // Draw an opaque pixel to the VirDev - pAlphaVirtualDevice->DrawPixel(Point(1, 1), Color(0x00, 0x22, 0xff, 0x55)); + pAlphaVirtualDevice->DrawPixel(Point(1, 1), Color(0x0022ff55)); + aColor = pAlphaVirtualDevice->GetPixel(Point(1, 1)); // Read back the opaque pixel #ifdef MACOSX // Oh no.. what we input is not the same as what we get out! - CPPUNIT_ASSERT_EQUAL(Color(0x00, 0x2C, 0xff, 0x44), pAlphaVirtualDevice->GetPixel(Point(1, 1))); + CPPUNIT_ASSERT_EQUAL(Color(0x002Cff44), aColor); +#elif defined _WIN32 + CPPUNIT_ASSERT_LESS(3, deltaColor(Color(0x0022ff55), aColor)); #else - CPPUNIT_ASSERT_EQUAL(Color(0x00, 0x22, 0xff, 0x55), pAlphaVirtualDevice->GetPixel(Point(1, 1))); + CPPUNIT_ASSERT_EQUAL(Color(0x0022ff55), aColor); #endif // Read back the BitmapEx and check the opaque pixel @@ -188,20 +207,25 @@ void BitmapRenderTest::testAlphaVirtualDevice() aColor = aBitmap.GetPixelColor(1, 1); #ifdef MACOSX // Oh no.. what we input is not the same as what we get out! - CPPUNIT_ASSERT_EQUAL(Color(0x00, 0x2C, 0xff, 0x44), aColor); + CPPUNIT_ASSERT_EQUAL(Color(0x002Cff44), aColor); +#elif defined _WIN32 + CPPUNIT_ASSERT_LESS(3, deltaColor(Color(0x0022ff55), aColor)); #else - CPPUNIT_ASSERT_EQUAL(Color(0x00, 0x22, 0xff, 0x55), aColor); + CPPUNIT_ASSERT_EQUAL(Color(0x0022ff55), aColor); #endif // Draw an semi-transparent pixel pAlphaVirtualDevice->DrawPixel(Point(0, 0), Color(0x44, 0x22, 0xff, 0x55)); + aColor = pAlphaVirtualDevice->GetPixel(Point(0, 0)); // Read back the semi-transparent pixel #ifdef MACOSX // Oh no.. what we input is not the same as what we get out! - CPPUNIT_ASSERT_EQUAL(Color(0x34, 0x2C, 0xFF, 0x44), pAlphaVirtualDevice->GetPixel(Point(0, 0))); + CPPUNIT_ASSERT_EQUAL(Color(0x342CFF44), aColor); +#elif defined _WIN32 + CPPUNIT_ASSERT_LESS(3, deltaColor(Color(0x4422FF55), aColor)); #else - CPPUNIT_ASSERT_EQUAL(Color(0x44, 0x22, 0xFF, 0x55), pAlphaVirtualDevice->GetPixel(Point(0, 0))); + CPPUNIT_ASSERT_EQUAL(Color(0x4422FF55), aColor); #endif // Read back the BitmapEx and check the semi-transparent pixel @@ -212,9 +236,11 @@ void BitmapRenderTest::testAlphaVirtualDevice() aColor = aBitmap.GetPixelColor(0, 0); #ifdef MACOSX // Oh no.. what we input is not the same as what we get out! - CPPUNIT_ASSERT_EQUAL(Color(0x34, 0x2C, 0xFF, 0x44), aColor); + CPPUNIT_ASSERT_EQUAL(Color(0x342CFF44), aColor); +#elif defined _WIN32 + CPPUNIT_ASSERT_LESS(3, deltaColor(Color(0x4422FF55), aColor)); #else - CPPUNIT_ASSERT_EQUAL(Color(0x44, 0x22, 0xFF, 0x55), aColor); + CPPUNIT_ASSERT_EQUAL(Color(0x4422FF55), aColor); #endif } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits