diff options
author | homeboy445 <akshitsan13@gmail.com> | 2021-07-17 17:46:10 +0530 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2021-08-26 07:07:46 +0200 |
commit | dbca6679aa40f65a67264f416d20d1434f6a926d (patch) | |
tree | 0c92c373cde28eff98c43e5c4c37263f4dab4b7d /vcl/backendtest/outputdevice/common.cxx | |
parent | c3a7edad85ec22fa4dac372da9e0b36d02efbfc4 (diff) |
backendtest: Intersecting Rectangles Drawing test
This test intends to test the even-odd filling rule by
testing if the intersecting rectangles have been filled
accordingly to the rule or not.
Change-Id: I0fb7f115a25476cc38e8bec5cd02737aea3c0316
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119098
Tested-by: Jenkins
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/backendtest/outputdevice/common.cxx')
-rw-r--r-- | vcl/backendtest/outputdevice/common.cxx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/vcl/backendtest/outputdevice/common.cxx b/vcl/backendtest/outputdevice/common.cxx index b548571e22bb..2aa7de78a294 100644 --- a/vcl/backendtest/outputdevice/common.cxx +++ b/vcl/backendtest/outputdevice/common.cxx @@ -968,6 +968,54 @@ TestResult OutputDeviceTestCommon::checkTextLocation(Bitmap& rBitmap) return aResult; } +TestResult OutputDeviceTestCommon::checkIntersectingRecs(Bitmap& rBitmap, int aLayerNumber, + Color aExpected) +{ + BitmapScopedWriteAccess pAccess(rBitmap); + + TestResult aResult = TestResult::Passed; + int nNumberOfQuirks = 0; + int nNumberOfErrors = 0; + + for (int x = 4; x <= 19; ++x) + { + checkValue(pAccess, x, aLayerNumber, aExpected, nNumberOfQuirks, nNumberOfErrors, true); + } + + if (nNumberOfQuirks > 0) + aResult = TestResult::PassedWithQuirks; + if (nNumberOfErrors > 0) + aResult = TestResult::Failed; + return aResult; +} + +TestResult OutputDeviceTestCommon::checkEvenOddRuleInIntersectingRecs(Bitmap& rBitmap) +{ + /* + The even-odd rule would be tested via the below pattern as layers both of the + constFillColor & constBackgroundColor appears in an even-odd fashion. + */ + std::vector<Color> aExpectedColors + = { constBackgroundColor, constBackgroundColor, constLineColor, constFillColor, + constFillColor, constLineColor, constBackgroundColor, constBackgroundColor, + constLineColor, constFillColor, constFillColor, constLineColor, + constBackgroundColor, constBackgroundColor, constLineColor, constFillColor, + constFillColor, constLineColor, constBackgroundColor, constBackgroundColor, + constLineColor, constFillColor, constLineColor }; + + TestResult aReturnValue = TestResult::Passed; + for (size_t i = 0; i < aExpectedColors.size(); i++) + { + TestResult eResult = checkIntersectingRecs(rBitmap, i, aExpectedColors[i]); + + if (eResult == TestResult::Failed) + aReturnValue = TestResult::Failed; + if (eResult == TestResult::PassedWithQuirks && aReturnValue != TestResult::Failed) + aReturnValue = TestResult::PassedWithQuirks; + } + return aReturnValue; +} + // Check 'count' pixels from (x,y) in (addX,addY) direction, the color values must not decrease. static bool checkGradient(BitmapScopedWriteAccess& pAccess, int x, int y, int count, int addX, int addY) { |