diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-02-02 18:57:07 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-02-03 17:39:44 +0100 |
commit | 772460f5cc61035a5b10bdf55a71f2a03f88af73 (patch) | |
tree | 3a5f1709b60754c945d9d4917d7f27ba81d9053c /vcl | |
parent | f6180e3e8725687605027815b4e878dc83b300b0 (diff) |
vcl: simplify assertColorsAreSimilar
Change-Id: Ifd25bf75c5e173a7db4778713f1d371e9ee24ac1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129381
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qa/cppunit/BitmapScaleTest.cxx | 21 | ||||
-rw-r--r-- | vcl/qa/cppunit/BitmapTest.cxx | 9 |
2 files changed, 6 insertions, 24 deletions
diff --git a/vcl/qa/cppunit/BitmapScaleTest.cxx b/vcl/qa/cppunit/BitmapScaleTest.cxx index 0cf65ca798da..ce8f67437d9d 100644 --- a/vcl/qa/cppunit/BitmapScaleTest.cxx +++ b/vcl/qa/cppunit/BitmapScaleTest.cxx @@ -55,28 +55,17 @@ bool checkBitmapColor(Bitmap const& rBitmap, Color const& rExpectedColor) return bResult; } -void assertColorsAreSimilar(int maxDifference, const std::string& message, - const BitmapColor& expected, const BitmapColor& actual) +void assertColorsAreSimilar(int maxDifference, int line, const BitmapColor& expected, + const BitmapColor& actual) { // Check that the two colors match or are reasonably similar. - if (expected == actual) + if (expected.GetColorError(actual) <= maxDifference) return; - if (abs(expected.GetRed() - actual.GetRed()) <= maxDifference - && abs(expected.GetGreen() - actual.GetGreen()) <= maxDifference - && abs(expected.GetBlue() - actual.GetBlue()) <= maxDifference - && abs(expected.GetAlpha() - actual.GetAlpha()) <= maxDifference) - { - return; - } - CPPUNIT_ASSERT_EQUAL_MESSAGE(message, expected, actual); -} -void assertColorsAreSimilar(int maxDifference, int line, const BitmapColor& expected, - const BitmapColor& actual) -{ std::stringstream stream; stream << "Line: " << line; - assertColorsAreSimilar(maxDifference, stream.str(), expected, actual); + + CPPUNIT_ASSERT_EQUAL_MESSAGE(stream.str(), expected, actual); } void BitmapScaleTest::testScale() diff --git a/vcl/qa/cppunit/BitmapTest.cxx b/vcl/qa/cppunit/BitmapTest.cxx index 9d4cbb592f68..79f779f2a809 100644 --- a/vcl/qa/cppunit/BitmapTest.cxx +++ b/vcl/qa/cppunit/BitmapTest.cxx @@ -73,15 +73,8 @@ void assertColorsAreSimilar(int maxDifference, const std::string& message, const BitmapColor& expected, const BitmapColor& actual) { // Check that the two colors match or are reasonably similar. - if (expected == actual) + if (expected.GetColorError(actual) <= maxDifference) return; - if (abs(expected.GetRed() - actual.GetRed()) <= maxDifference - && abs(expected.GetGreen() - actual.GetGreen()) <= maxDifference - && abs(expected.GetBlue() - actual.GetBlue()) <= maxDifference - && abs(expected.GetAlpha() - actual.GetAlpha()) <= maxDifference) - { - return; - } CPPUNIT_ASSERT_EQUAL_MESSAGE(message, expected, actual); } |