android: Update app icon to new startcenter icon
[LibreOffice.git] / vcl / backendtest / outputdevice / common.cxx
blobd85791e4074527a9f978fe6164fe0af03bfeb52a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 */
11 #include <test/outputdevice.hxx>
13 #include <bitmap/BitmapWriteAccess.hxx>
14 #include <salgdi.hxx>
16 namespace vcl::test {
18 namespace
22 int deltaColor(BitmapColor aColor1, BitmapColor aColor2)
24 int deltaR = std::abs(aColor1.GetRed() - aColor2.GetRed());
25 int deltaG = std::abs(aColor1.GetGreen() - aColor2.GetGreen());
26 int deltaB = std::abs(aColor1.GetBlue() - aColor2.GetBlue());
28 return std::max(std::max(deltaR, deltaG), deltaB);
31 void checkValue(BitmapScopedWriteAccess& pAccess, int x, int y, Color aExpected,
32 int& nNumberOfQuirks, int& nNumberOfErrors, bool bQuirkMode, int nColorDeltaThresh = 0)
34 const bool bColorize = false;
35 Color aColor = pAccess->GetPixel(y, x);
36 int nColorDelta = deltaColor(aColor, aExpected);
38 if (nColorDelta <= nColorDeltaThresh)
40 if (bColorize)
41 pAccess->SetPixel(y, x, COL_LIGHTGREEN);
43 else if (bQuirkMode)
45 nNumberOfQuirks++;
46 if (bColorize)
47 pAccess->SetPixel(y, x, COL_YELLOW);
49 else
51 nNumberOfErrors++;
52 if (bColorize)
53 pAccess->SetPixel(y, x, COL_LIGHTRED);
57 void checkValue(BitmapScopedWriteAccess& pAccess, const Point& point, Color aExpected,
58 int& nNumberOfQuirks, int& nNumberOfErrors, bool bQuirkMode, int nColorDeltaThresh = 0)
60 checkValue(pAccess, point.getX(), point.getY(), aExpected, nNumberOfQuirks, nNumberOfErrors, bQuirkMode, nColorDeltaThresh);
63 void checkValue(BitmapScopedWriteAccess& pAccess, int x, int y, Color aExpected,
64 int& nNumberOfQuirks, int& nNumberOfErrors, int nColorDeltaThresh, int nColorDeltaThreshQuirk = 0)
66 const bool bColorize = false;
67 Color aColor = pAccess->GetPixel(y, x);
68 int nColorDelta = deltaColor(aColor, aExpected);
69 nColorDeltaThreshQuirk = std::max( nColorDeltaThresh, nColorDeltaThreshQuirk);
71 if (nColorDelta <= nColorDeltaThresh)
73 if (bColorize)
74 pAccess->SetPixel(y, x, COL_LIGHTGREEN);
76 else if (nColorDelta <= nColorDeltaThreshQuirk)
78 nNumberOfQuirks++;
79 if (bColorize)
80 pAccess->SetPixel(y, x, COL_YELLOW);
82 else
84 nNumberOfErrors++;
85 if (bColorize)
86 pAccess->SetPixel(y, x, COL_LIGHTRED);
90 char returnDominantColor(Color aColor)
92 int aRed = aColor.GetRed();
93 int aGreen = aColor.GetGreen();
94 int aBlue = aColor.GetBlue();
95 if (aRed > aGreen && aRed > aBlue)
96 return 'R';
98 if (aGreen > aRed && aGreen > aBlue)
99 return 'G';
101 if(aBlue > aRed && aBlue > aGreen)
102 return 'B';
104 return 'X'; //No Dominant Color.
107 void checkValueAA(BitmapScopedWriteAccess& pAccess, int x, int y, Color aExpected,
108 int& nNumberOfQuirks, int& nNumberOfErrors, int nColorDeltaThresh = 64)
110 const bool bColorize = false;
111 Color aColor = pAccess->GetPixel(y, x);
112 bool aColorResult = returnDominantColor(aExpected) == returnDominantColor(aColor);
113 int nColorDelta = deltaColor(aColor, aExpected);
115 if (nColorDelta <= nColorDeltaThresh && aColorResult)
117 if (bColorize)
118 pAccess->SetPixel(y, x, COL_LIGHTGREEN);
120 else if (aColorResult)
122 nNumberOfQuirks++;
123 if (bColorize)
124 pAccess->SetPixel(y, x, COL_YELLOW);
126 else
128 nNumberOfErrors++;
129 if (bColorize)
130 pAccess->SetPixel(y, x, COL_LIGHTRED);
134 // Return all colors in the rectangle and their count.
135 std::map<Color, int> collectColors(Bitmap& bitmap, const tools::Rectangle& rectangle)
137 std::map<Color, int> colors;
138 BitmapScopedWriteAccess pAccess(bitmap);
139 for (tools::Long y = rectangle.Top(); y < rectangle.Bottom(); ++y)
140 for (tools::Long x = rectangle.Left(); x < rectangle.Right(); ++x)
141 ++colors[pAccess->GetPixel(y, x)]; // operator[] initializes to 0 (default ctor) if creating
142 return colors;
145 bool checkConvexHullProperty(Bitmap& bitmap, Color constLineColor, int nWidthOffset,
146 int nHeightOffset)
148 BitmapScopedWriteAccess pAccess(bitmap);
149 tools::Long thresholdWidth = pAccess->Width() - nWidthOffset;
150 tools::Long thresholdHeight = pAccess->Height() - nHeightOffset;
151 for (tools::Long y = 0; y < pAccess->Height(); ++y)
153 for (tools::Long x = 0; x < pAccess->Width(); ++x)
156 If the shape exceeds the threshold limit of height or width or both,
157 this would indicate that the bezier curve is not within its convex polygon and
158 hence is faulty.
160 if (pAccess->GetPixel(y, x) == constLineColor
161 && (thresholdHeight < y || thresholdWidth < x))
163 return false;
167 return true;
170 TestResult checkRect(Bitmap& rBitmap, int aLayerNumber, Color aExpectedColor)
172 BitmapScopedWriteAccess pAccess(rBitmap);
173 tools::Long nHeight = pAccess->Height();
174 tools::Long nWidth = pAccess->Width();
176 tools::Long firstX = 0 + aLayerNumber;
177 tools::Long firstY = 0 + aLayerNumber;
179 tools::Long lastX = nWidth - aLayerNumber - 1;
180 tools::Long lastY = nHeight - aLayerNumber - 1;
182 TestResult aResult = TestResult::Passed;
183 int nNumberOfQuirks = 0;
184 int nNumberOfErrors = 0;
186 // check corner quirks
187 checkValue(pAccess, firstX, firstY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true);
188 checkValue(pAccess, lastX, firstY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true);
189 checkValue(pAccess, firstX, lastY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true);
190 checkValue(pAccess, lastX, lastY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true);
192 for (tools::Long y = firstY + 1; y <= lastY - 1; y++)
194 checkValue(pAccess, firstX, y, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false);
195 checkValue(pAccess, lastX, y, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false);
197 for (tools::Long x = firstX + 1; x <= lastX - 1; x++)
199 checkValue(pAccess, x, firstY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false);
200 checkValue(pAccess, x, lastY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false);
202 if (nNumberOfQuirks > 0)
203 aResult = TestResult::PassedWithQuirks;
204 if (nNumberOfErrors > 0)
205 aResult = TestResult::Failed;
206 return aResult;
209 TestResult checkHorizontalVerticalDiagonalLines(Bitmap& rBitmap, Color aExpectedColor, int nColorThresh)
211 BitmapScopedWriteAccess pAccess(rBitmap);
212 tools::Long nWidth = pAccess->Width();
213 tools::Long nHeight = pAccess->Height();
215 TestResult aResult = TestResult::Passed;
216 int nNumberOfQuirks = 0;
217 int nNumberOfErrors = 0;
219 // check horizontal line
221 tools::Long startX = 4;
222 tools::Long endX = nWidth - 2;
224 tools::Long y = 1;
226 checkValue(pAccess, startX, y, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true, nColorThresh);
227 checkValue(pAccess, endX, y, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true, nColorThresh);
229 for (tools::Long x = startX + 1; x <= endX - 1; x++)
231 checkValue(pAccess, x, y, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false, nColorThresh);
235 // check vertical line
237 tools::Long startY = 4;
238 tools::Long endY = nHeight - 2;
240 tools::Long x = 1;
242 checkValue(pAccess, x, startY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true, nColorThresh);
243 checkValue(pAccess, x, endY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true, nColorThresh);
245 for (tools::Long y = startY + 1; y <= endY - 1; y++)
247 checkValue(pAccess, x, y, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false, nColorThresh);
251 // check diagonal line
253 tools::Long startX = 1;
254 tools::Long endX = nWidth - 2;
256 tools::Long startY = 1;
257 tools::Long endY = nHeight - 2;
259 tools::Long x = startX;
260 tools::Long y = startY;
262 checkValue(pAccess, startX, startY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true, nColorThresh);
263 checkValue(pAccess, endX, endY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true, nColorThresh);
265 x++; y++;
267 while(y <= endY - 1 && x <= endX - 1)
269 checkValue(pAccess, x, y, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false, nColorThresh);
270 x++; y++;
274 if (nNumberOfQuirks > 0)
275 aResult = TestResult::PassedWithQuirks;
276 if (nNumberOfErrors > 0)
277 aResult = TestResult::Failed;
278 return aResult;
281 TestResult checkDiamondLine(Bitmap& rBitmap, int aLayerNumber, Color aExpectedColor)
283 BitmapScopedWriteAccess pAccess(rBitmap);
284 tools::Long nHeight = pAccess->Height();
285 tools::Long nWidth = pAccess->Width();
287 tools::Long midX = nWidth / 2;
288 tools::Long midY = nHeight / 2;
290 tools::Long firstX = aLayerNumber;
291 tools::Long lastX = nWidth - aLayerNumber - 1;
293 tools::Long firstY = aLayerNumber;
294 tools::Long lastY = nHeight - aLayerNumber - 1;
296 tools::Long offsetFromMid = 0;
298 TestResult aResult = TestResult::Passed;
299 int nNumberOfQuirks = 0;
300 int nNumberOfErrors = 0;
302 checkValue(pAccess, firstX, midY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true);
303 checkValue(pAccess, lastX, midY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true);
304 checkValue(pAccess, midX, firstY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true);
305 checkValue(pAccess, midX, lastY, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, true);
307 offsetFromMid = 1;
308 for (tools::Long x = firstX + 1; x <= midX - 1; x++)
310 checkValue(pAccess, x, midY - offsetFromMid, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false);
311 checkValue(pAccess, x, midY + offsetFromMid, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false);
313 offsetFromMid++;
316 offsetFromMid = midY - aLayerNumber - 1;
318 for (tools::Long x = midX + 1; x <= lastX - 1; x++)
320 checkValue(pAccess, x, midY - offsetFromMid, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false);
321 checkValue(pAccess, x, midY + offsetFromMid, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false);
323 offsetFromMid--;
326 if (nNumberOfQuirks > 0)
327 aResult = TestResult::PassedWithQuirks;
328 if (nNumberOfErrors > 0)
329 aResult = TestResult::Failed;
330 return aResult;
333 } // end anonymous namespace
335 const Color OutputDeviceTestCommon::constBackgroundColor(COL_LIGHTGRAY);
336 const Color OutputDeviceTestCommon::constLineColor(COL_LIGHTBLUE);
337 const Color OutputDeviceTestCommon::constFillColor(COL_BLUE);
339 OutputDeviceTestCommon::OutputDeviceTestCommon()
342 OUString OutputDeviceTestCommon::getRenderBackendName() const
344 if (mpVirtualDevice && mpVirtualDevice->GetGraphics())
346 SalGraphics const * pGraphics = mpVirtualDevice->GetGraphics();
347 return pGraphics->getRenderBackendName();
349 return OUString();
352 void OutputDeviceTestCommon::initialSetup(tools::Long nWidth, tools::Long nHeight, Color aColor, bool bEnableAA, bool bAlphaVirtualDevice)
354 if (bAlphaVirtualDevice)
355 mpVirtualDevice = VclPtr<VirtualDevice>::Create(DeviceFormat::WITH_ALPHA);
356 else
357 mpVirtualDevice = VclPtr<VirtualDevice>::Create(DeviceFormat::WITHOUT_ALPHA);
359 maVDRectangle = tools::Rectangle(Point(), Size (nWidth, nHeight));
360 mpVirtualDevice->SetOutputSizePixel(maVDRectangle.GetSize());
361 if (bEnableAA)
362 mpVirtualDevice->SetAntialiasing(AntialiasingFlags::Enable | AntialiasingFlags::PixelSnapHairline);
363 else
364 mpVirtualDevice->SetAntialiasing(AntialiasingFlags::NONE);
365 mpVirtualDevice->SetBackground(Wallpaper(aColor));
366 mpVirtualDevice->Erase();
369 TestResult OutputDeviceTestCommon::checkLines(Bitmap& rBitmap)
371 return checkHorizontalVerticalDiagonalLines(rBitmap, constLineColor, 0);
374 TestResult OutputDeviceTestCommon::checkAALines(Bitmap& rBitmap)
376 return checkHorizontalVerticalDiagonalLines(rBitmap, constLineColor, 30); // 30 color values threshold delta
379 static void checkResult(TestResult eResult, TestResult & eTotal)
381 if (eTotal == TestResult::Failed)
382 return;
384 if (eResult == TestResult::Failed)
385 eTotal = TestResult::Failed;
387 if (eResult == TestResult::PassedWithQuirks)
388 eTotal = TestResult::PassedWithQuirks;
391 TestResult OutputDeviceTestCommon::checkInvertRectangle(Bitmap& aBitmap)
393 TestResult aReturnValue = TestResult::Passed;
394 TestResult eResult;
396 std::vector<Color> aExpected{ COL_WHITE, COL_WHITE };
397 eResult = checkRectangles(aBitmap, aExpected);
398 checkResult(eResult, aReturnValue);
400 eResult = checkFilled(aBitmap, tools::Rectangle(Point(2, 2), Size(8, 8)), COL_LIGHTCYAN);
401 checkResult(eResult, aReturnValue);
403 eResult = checkFilled(aBitmap, tools::Rectangle(Point(10, 2), Size(8, 8)), COL_LIGHTMAGENTA);
404 checkResult(eResult, aReturnValue);
406 eResult = checkFilled(aBitmap, tools::Rectangle(Point(2, 10), Size(8, 8)), COL_YELLOW);
407 checkResult(eResult, aReturnValue);
409 eResult = checkFilled(aBitmap, tools::Rectangle(Point(10, 10), Size(8, 8)), COL_BLACK);
410 checkResult(eResult, aReturnValue);
412 return aReturnValue;
415 TestResult OutputDeviceTestCommon::checkChecker(Bitmap& rBitmap, sal_Int32 nStartX, sal_Int32 nEndX, sal_Int32 nStartY, sal_Int32 nEndY, std::vector<Color> const & rExpected)
417 TestResult aReturnValue = TestResult::Passed;
419 int choice = 0;
420 for (sal_Int32 y = nStartY; y <= nEndY; ++y)
422 for (sal_Int32 x = nStartX; x <= nEndX; ++x)
424 TestResult eResult = checkFilled(rBitmap, tools::Rectangle(Point(x, y), Size(1, 1)), rExpected[choice % 2]);
425 checkResult(eResult, aReturnValue);
426 choice++;
428 choice++;
430 return aReturnValue;
433 TestResult OutputDeviceTestCommon::checkInvertN50Rectangle(Bitmap& aBitmap)
435 TestResult aReturnValue = TestResult::Passed;
436 TestResult eResult;
438 std::vector<Color> aExpected{ COL_WHITE, COL_WHITE };
439 eResult = checkRectangles(aBitmap, aExpected);
440 checkResult(eResult, aReturnValue);
442 eResult = checkChecker(aBitmap, 2, 9, 2, 9, { COL_LIGHTCYAN, COL_LIGHTRED });
443 checkResult(eResult, aReturnValue);
444 eResult = checkChecker(aBitmap, 2, 9, 10, 17, { COL_YELLOW, COL_LIGHTBLUE });
445 checkResult(eResult, aReturnValue);
446 eResult = checkChecker(aBitmap, 10, 17, 2, 9, { COL_LIGHTMAGENTA, COL_LIGHTGREEN });
447 checkResult(eResult, aReturnValue);
448 eResult = checkChecker(aBitmap, 10, 17, 10, 17, { COL_BLACK, COL_WHITE });
449 checkResult(eResult, aReturnValue);
451 return aReturnValue;
454 TestResult OutputDeviceTestCommon::checkInvertTrackFrameRectangle(Bitmap& aBitmap)
456 std::vector<Color> aExpected
458 COL_WHITE, COL_WHITE
460 return checkRectangles(aBitmap, aExpected);
463 TestResult OutputDeviceTestCommon::checkRectangle(Bitmap& aBitmap)
465 std::vector<Color> aExpected
467 constBackgroundColor, constBackgroundColor, constLineColor,
468 constBackgroundColor, constBackgroundColor, constLineColor, constBackgroundColor
470 return checkRectangles(aBitmap, aExpected);
473 TestResult OutputDeviceTestCommon::checkRectangles(Bitmap& rBitmap, bool aEnableAA)
475 BitmapScopedWriteAccess pAccess(rBitmap);
477 TestResult aResult = TestResult::Passed;
478 int nNumberOfQuirks = 0;
479 int nNumberOfErrors = 0;
481 std::vector<Color> aExpected = { constBackgroundColor, constLineColor, constLineColor };
483 for (size_t aLayerNumber = 0; aLayerNumber < aExpected.size(); aLayerNumber++)
485 tools::Long startX = aLayerNumber, endX = pAccess->Width() / 2 - aLayerNumber + 1;
486 tools::Long startY = aLayerNumber, endY = pAccess->Height() - aLayerNumber - 1;
488 for (tools::Long ptX = startX; ptX <= endX; ++ptX)
490 if (aEnableAA)
492 checkValueAA(pAccess, ptX, startY + (aLayerNumber == 2 ? 2 : 0),
493 aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors);
494 checkValueAA(pAccess, ptX, endY - (aLayerNumber == 2 ? 2 : 0),
495 aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors);
497 else
499 checkValue(pAccess, ptX, startY + (aLayerNumber == 2 ? 2 : 0),
500 aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors, true);
501 checkValue(pAccess, ptX, endY - (aLayerNumber == 2 ? 2 : 0),
502 aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors, true);
505 for (tools::Long ptY = startY + (aLayerNumber == 2 ? 2 : 0);
506 ptY <= endY - (aLayerNumber == 2 ? 2 : 0); ++ptY)
508 if (aEnableAA)
510 checkValueAA(pAccess, startX, ptY, aExpected[aLayerNumber], nNumberOfQuirks,
511 nNumberOfErrors);
512 checkValueAA(pAccess, endX, ptY, aExpected[aLayerNumber], nNumberOfQuirks,
513 nNumberOfErrors);
515 else
517 checkValue(pAccess, startX, ptY, aExpected[aLayerNumber], nNumberOfQuirks,
518 nNumberOfErrors, true);
519 checkValue(pAccess, endX, ptY, aExpected[aLayerNumber], nNumberOfQuirks,
520 nNumberOfErrors, true);
524 if (nNumberOfQuirks > 0)
525 aResult = TestResult::PassedWithQuirks;
526 if (nNumberOfErrors > 0)
527 aResult = TestResult::Failed;
528 return aResult;
531 TestResult OutputDeviceTestCommon::checkRectangleAA(Bitmap& aBitmap)
533 return checkRectangles(aBitmap, true);
536 TestResult OutputDeviceTestCommon::checkFilledRectangle(Bitmap& aBitmap, bool useLineColor)
538 std::vector<Color> aExpected{ constBackgroundColor,
539 useLineColor ? constLineColor : constFillColor, constFillColor,
540 constFillColor, constFillColor };
542 BitmapScopedWriteAccess pAccess(aBitmap);
544 TestResult aResult = TestResult::Passed;
545 int nNumberOfQuirks = 0;
546 int nNumberOfErrors = 0;
548 for (size_t aLayerNumber = 0; aLayerNumber < aExpected.size(); aLayerNumber++)
550 tools::Long startX = aLayerNumber, endX = pAccess->Width() / 2 - aLayerNumber + 1;
551 tools::Long startY = aLayerNumber, endY = pAccess->Height() - aLayerNumber - 1;
553 for (tools::Long ptX = startX; ptX <= endX; ++ptX)
555 checkValue(pAccess, ptX, startY, aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors,
556 true);
557 checkValue(pAccess, ptX, endY, aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors, true);
559 for (tools::Long ptY = startY; ptY <= endY; ++ptY)
561 checkValue(pAccess, startX, ptY, aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors,
562 true);
563 checkValue(pAccess, endX, ptY, aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors, true);
566 if (nNumberOfQuirks > 0)
567 aResult = TestResult::PassedWithQuirks;
568 if (nNumberOfErrors > 0)
569 aResult = TestResult::Failed;
570 return aResult;
573 TestResult OutputDeviceTestCommon::checkFilled(Bitmap& rBitmap, tools::Rectangle aRectangle, Color aExpectedColor)
575 BitmapScopedWriteAccess pAccess(rBitmap);
577 TestResult aResult = TestResult::Passed;
578 int nNumberOfQuirks = 0;
579 int nNumberOfErrors = 0;
581 for (tools::Long y = aRectangle.Top(); y < aRectangle.Top() + aRectangle.GetHeight(); y++)
583 for (tools::Long x = aRectangle.Left(); x < aRectangle.Left() + aRectangle.GetWidth(); x++)
585 checkValue(pAccess, x, y, aExpectedColor, nNumberOfQuirks, nNumberOfErrors, false);
589 if (nNumberOfQuirks > 0)
590 aResult = TestResult::PassedWithQuirks;
592 if (nNumberOfErrors > 0)
593 aResult = TestResult::Failed;
595 return aResult;
598 TestResult OutputDeviceTestCommon::checkRectangles(Bitmap& aBitmap, std::vector<Color>& aExpectedColors)
600 TestResult aReturnValue = TestResult::Passed;
601 for (size_t i = 0; i < aExpectedColors.size(); i++)
603 TestResult eResult = checkRect(aBitmap, i, aExpectedColors[i]);
605 if (eResult == TestResult::Failed)
606 aReturnValue = TestResult::Failed;
607 if (eResult == TestResult::PassedWithQuirks && aReturnValue != TestResult::Failed)
608 aReturnValue = TestResult::PassedWithQuirks;
610 return aReturnValue;
613 TestResult OutputDeviceTestCommon::checkRectangle(Bitmap& rBitmap, int aLayerNumber, Color aExpectedColor)
615 return checkRect(rBitmap, aLayerNumber, aExpectedColor);
618 tools::Rectangle OutputDeviceTestCommon::alignToCenter(tools::Rectangle aRect1, tools::Rectangle aRect2)
620 Point aPoint((aRect1.GetWidth() / 2.0) - (aRect2.GetWidth() / 2.0),
621 (aRect1.GetHeight() / 2.0) - (aRect2.GetHeight() / 2.0));
623 return tools::Rectangle(aPoint, aRect2.GetSize());
626 TestResult OutputDeviceTestCommon::checkDiamond(Bitmap& rBitmap)
628 return checkDiamondLine(rBitmap, 1, constLineColor);
631 void OutputDeviceTestCommon::createDiamondPoints(tools::Rectangle rRect, int nOffset,
632 Point& rPoint1, Point& rPoint2,
633 Point& rPoint3, Point& rPoint4)
635 tools::Long midPointX = rRect.Left() + (rRect.Right() - rRect.Left()) / 2.0;
636 tools::Long midPointY = rRect.Top() + (rRect.Bottom() - rRect.Top()) / 2.0;
638 rPoint1 = Point(midPointX , midPointY - nOffset);
639 rPoint2 = Point(midPointX + nOffset, midPointY );
640 rPoint3 = Point(midPointX , midPointY + nOffset);
641 rPoint4 = Point(midPointX - nOffset, midPointY );
644 tools::Polygon OutputDeviceTestCommon::createDropShapePolygon()
646 tools::Polygon aPolygon(15);
648 aPolygon.SetPoint(Point(10, 2), 0);
649 aPolygon.SetFlags(0, PolyFlags::Normal);
650 aPolygon.SetPoint(Point(14, 2), 1);
651 aPolygon.SetFlags(1, PolyFlags::Control);
652 aPolygon.SetPoint(Point(18, 6), 2);
653 aPolygon.SetFlags(2, PolyFlags::Control);
654 aPolygon.SetPoint(Point(18, 10), 3);
656 aPolygon.SetFlags(3, PolyFlags::Normal);
657 aPolygon.SetPoint(Point(18, 10), 4);
658 aPolygon.SetFlags(4, PolyFlags::Normal);
659 aPolygon.SetPoint(Point(18, 14), 5);
660 aPolygon.SetFlags(5, PolyFlags::Control);
661 aPolygon.SetPoint(Point(14, 18), 6);
662 aPolygon.SetFlags(6, PolyFlags::Control);
663 aPolygon.SetPoint(Point(10, 18), 7);
664 aPolygon.SetFlags(7, PolyFlags::Normal);
666 aPolygon.SetPoint(Point(10, 18), 8);
667 aPolygon.SetFlags(8, PolyFlags::Normal);
668 aPolygon.SetPoint(Point(6, 18), 9);
669 aPolygon.SetFlags(9, PolyFlags::Control);
670 aPolygon.SetPoint(Point(2, 14), 10);
671 aPolygon.SetFlags(10, PolyFlags::Control);
672 aPolygon.SetPoint(Point(2, 10), 11);
673 aPolygon.SetFlags(11, PolyFlags::Normal);
675 aPolygon.SetPoint(Point(2, 10), 12);
676 aPolygon.SetFlags(12, PolyFlags::Normal);
677 aPolygon.SetPoint(Point(2, 2), 13);
678 aPolygon.SetFlags(13, PolyFlags::Normal);
679 aPolygon.SetPoint(Point(10, 2), 14);
680 aPolygon.SetFlags(14, PolyFlags::Normal);
682 aPolygon.Optimize(PolyOptimizeFlags::CLOSE);
684 return aPolygon;
687 basegfx::B2DPolygon OutputDeviceTestCommon::createHalfEllipsePolygon()
689 basegfx::B2DPolygon aPolygon;
691 aPolygon.append({ 9.0, 1.0 });
692 aPolygon.append({ 17.0, 10.0 });
693 aPolygon.append({ 1.0, 10.0 });
694 aPolygon.setClosed(true);
696 aPolygon.setControlPoints(0, { 1.5, 1.5 }, { 16.5, 1.5 });
698 return aPolygon;
701 tools::Polygon OutputDeviceTestCommon::createClosedBezierLoop(const tools::Rectangle& rRect)
703 tools::Long minX = rRect.Left();
704 tools::Long maxX = rRect.Right() - 2;
705 tools::Long minY = rRect.Top();
706 tools::Long maxY = rRect.Bottom() - 2;
708 tools::Polygon aPolygon(4);
710 aPolygon.SetPoint(Point((maxX / 2.0), maxY), 0);
711 aPolygon.SetFlags(0, PolyFlags::Normal);
712 aPolygon.SetPoint(Point(maxX, minY), 1);
713 aPolygon.SetFlags(1, PolyFlags::Control);
714 aPolygon.SetPoint(Point(minX, minY), 2);
715 aPolygon.SetFlags(2, PolyFlags::Control);
716 aPolygon.SetPoint(Point((maxX / 2.0), maxY), 3);
717 aPolygon.SetFlags(3, PolyFlags::Normal);
719 aPolygon.Optimize(PolyOptimizeFlags::CLOSE);
721 return aPolygon;
724 basegfx::B2DPolygon OutputDeviceTestCommon::createOpenPolygon(const tools::Rectangle& rRect, int nOffset)
726 int nMidOffset = rRect.GetWidth() / 2;
727 basegfx::B2DPolygon aPolygon{
728 basegfx::B2DPoint(rRect.Left() + nOffset - (nOffset + 1) / 2, rRect.Top() + nOffset - 1),
729 basegfx::B2DPoint(rRect.Left() + nOffset - (nOffset + 1) / 2, rRect.Bottom() - nOffset + 1),
730 basegfx::B2DPoint(rRect.Right() - nMidOffset - nOffset / 3, rRect.Bottom() - nOffset + 1),
731 basegfx::B2DPoint(rRect.Right() - nMidOffset - nOffset / 3, rRect.Top() + nOffset - 1),
733 aPolygon.setClosed(false);
734 return aPolygon;
737 basegfx::B2DPolygon OutputDeviceTestCommon::createOpenBezier()
739 basegfx::B2DPolygon aPolygon;
741 aPolygon.append({ 5.0, 2.0 });
742 aPolygon.append({ 3.0, 14.0 });
743 aPolygon.setClosed(false);
745 aPolygon.setControlPoints(0, { 15.0, 2.0 }, { 15.0, 15.0 });
747 return aPolygon;
750 TestResult OutputDeviceTestCommon::checkDropShape(Bitmap& rBitmap, bool aEnableAA)
752 BitmapScopedWriteAccess pAccess(rBitmap);
754 TestResult aResult = TestResult::Passed;
755 int nNumberOfQuirks = 0;
756 int nNumberOfErrors = 0;
758 std::map<std::pair<int, int>, bool> SetPixels
759 = { { { 2, 2 }, true }, { { 3, 2 }, true }, { { 4, 2 }, true }, { { 5, 2 }, true },
760 { { 6, 2 }, true }, { { 7, 2 }, true }, { { 8, 2 }, true }, { { 9, 2 }, true },
761 { { 10, 2 }, true }, { { 11, 2 }, true }, { { 12, 2 }, true }, { { 2, 3 }, true },
762 { { 13, 3 }, true }, { { 14, 3 }, true }, { { 2, 4 }, true }, { { 15, 4 }, true },
763 { { 2, 5 }, true }, { { 16, 5 }, true }, { { 2, 6 }, true }, { { 17, 6 }, true },
764 { { 2, 7 }, true }, { { 17, 7 }, true }, { { 2, 8 }, true }, { { 18, 8 }, true },
765 { { 2, 9 }, true }, { { 18, 9 }, true }, { { 2, 10 }, true }, { { 18, 10 }, true },
766 { { 2, 11 }, true }, { { 18, 11 }, true }, { { 2, 12 }, true }, { { 18, 12 }, true },
767 { { 3, 13 }, true }, { { 17, 13 }, true }, { { 3, 14 }, true }, { { 17, 14 }, true },
768 { { 4, 15 }, true }, { { 16, 15 }, true }, { { 5, 16 }, true }, { { 15, 16 }, true },
769 { { 6, 17 }, true }, { { 7, 17 }, true }, { { 13, 17 }, true }, { { 14, 17 }, true },
770 { { 8, 18 }, true }, { { 9, 18 }, true }, { { 10, 18 }, true }, { { 11, 18 }, true },
771 { { 12, 18 }, true } };
773 for (tools::Long x = 0; x < pAccess->Width(); x++)
775 for (tools::Long y = 0; y < pAccess->Height(); y++)
777 if (SetPixels[{ x, y }])
779 if (aEnableAA)
781 // coverity[swapped_arguments : FALSE] - this is in the correct order
782 checkValueAA(pAccess, y, x, constLineColor, nNumberOfQuirks, nNumberOfErrors);
784 else
785 checkValue(pAccess, y, x, constLineColor, nNumberOfQuirks, nNumberOfErrors,
786 true);
788 else
790 if (!aEnableAA)
791 checkValue(pAccess, y, x, constBackgroundColor, nNumberOfQuirks, nNumberOfErrors,
792 true);
797 if (nNumberOfQuirks > 0)
798 aResult = TestResult::PassedWithQuirks;
799 if (nNumberOfErrors > 0)
800 aResult = TestResult::Failed;
801 return aResult;
804 void OutputDeviceTestCommon::createHorizontalVerticalDiagonalLinePoints(tools::Rectangle rRect,
805 Point& rHorizontalLinePoint1, Point& rHorizontalLinePoint2,
806 Point& rVerticalLinePoint1, Point& rVerticalLinePoint2,
807 Point& rDiagonalLinePoint1, Point& rDiagonalLinePoint2)
809 rHorizontalLinePoint1 = Point(4, 1);
810 rHorizontalLinePoint2 = Point(rRect.Right() - 1, 1);
812 rVerticalLinePoint1 = Point(1, 4);
813 rVerticalLinePoint2 = Point(1,rRect.Bottom() - 1);
815 rDiagonalLinePoint1 = Point(1, 1);
816 rDiagonalLinePoint2 = Point(rRect.Right() - 1, rRect.Bottom() - 1);
819 TestResult OutputDeviceTestCommon::checkBezier(Bitmap& rBitmap)
821 std::vector<Color> aExpected
823 constBackgroundColor, constBackgroundColor
825 // Check the bezier doesn't go over to the margins first
826 // TODO extend the check with more exact assert
827 return checkRectangles(rBitmap, aExpected);
830 TestResult OutputDeviceTestCommon::checkHalfEllipse(Bitmap& rBitmap, bool aEnableAA)
832 BitmapScopedWriteAccess pAccess(rBitmap);
834 TestResult aResult = TestResult::Passed;
835 int nNumberOfQuirks = 0;
836 int nNumberOfErrors = 0;
838 std::map<std::pair<tools::Long, tools::Long>, bool> SetPixels = {
839 { { 8, 1 }, true }, { { 9, 1 }, true }, { { 10, 1 }, true }, { { 6, 2 }, true },
840 { { 7, 2 }, true }, { { 10, 2 }, true }, { { 4, 3 }, true }, { { 5, 3 }, true },
841 { { 10, 3 }, true }, { { 3, 4 }, true }, { { 10, 4 }, true }, { { 2, 5 }, true },
842 { { 10, 5 }, true }, { { 2, 6 }, true }, { { 10, 6 }, true }, { { 1, 7 }, true },
843 { { 10, 7 }, true }, { { 1, 8 }, true }, { { 10, 8 }, true }, { { 1, 9 }, true },
844 { { 10, 9 }, true }, { { 1, 10 }, true }, { { 10, 10 }, true }, { { 1, 11 }, true },
845 { { 10, 11 }, true }, { { 2, 12 }, true }, { { 10, 12 }, true }, { { 2, 13 }, true },
846 { { 10, 13 }, true }, { { 3, 14 }, true }, { { 10, 14 }, true }, { { 4, 15 }, true },
847 { { 5, 15 }, true }, { { 10, 15 }, true }, { { 6, 16 }, true }, { { 7, 16 }, true },
848 { { 10, 16 }, true }, { { 8, 17 }, true }, { { 9, 17 }, true }, { { 10, 17 }, true }
851 for (tools::Long x = 0; x < pAccess->Width(); x++)
853 for (tools::Long y = 0; y < pAccess->Height(); ++y)
855 // coverity[swapped_arguments : FALSE] - this is in the correct order
856 if (SetPixels[{ y, x }])
858 if (aEnableAA)
859 checkValueAA(pAccess, x, y, constLineColor, nNumberOfQuirks, nNumberOfErrors);
860 else
861 checkValue(pAccess, x, y, constLineColor, nNumberOfQuirks, nNumberOfErrors,
862 true);
864 else
866 if (!aEnableAA)
867 checkValue(pAccess, x, y, constBackgroundColor, nNumberOfQuirks,
868 nNumberOfErrors, true);
873 if (nNumberOfQuirks > 0)
874 aResult = TestResult::PassedWithQuirks;
875 if (nNumberOfErrors > 0)
876 aResult = TestResult::Failed;
877 return aResult;
880 TestResult OutputDeviceTestCommon::checkClosedBezier(Bitmap& rBitmap)
882 BitmapScopedWriteAccess pAccess(rBitmap);
884 TestResult aResult = TestResult::Passed;
885 int nNumberOfQuirks = 0;
886 int nNumberOfErrors = 0;
888 std::map<std::pair<tools::Long, tools::Long>, bool> SetPixels
889 = { { { 3, 8 }, true }, { { 3, 9 }, true }, { { 3, 10 }, true }, { { 4, 7 }, true },
890 { { 4, 8 }, true }, { { 4, 9 }, true }, { { 4, 10 }, true }, { { 4, 11 }, true },
891 { { 5, 7 }, true }, { { 5, 11 }, true }, { { 6, 6 }, true }, { { 6, 12 }, true },
892 { { 7, 6 }, true }, { { 7, 12 }, true }, { { 8, 7 }, true }, { { 8, 11 }, true },
893 { { 9, 7 }, true }, { { 9, 11 }, true }, { { 10, 7 }, true }, { { 10, 11 }, true },
894 { { 11, 8 }, true }, { { 11, 9 }, true }, { { 11, 10 }, true }, { { 12, 8 }, true },
895 { { 12, 9 }, true }, { { 12, 10 }, true }, { { 13, 9 }, true } };
897 for (tools::Long x = 0; x < pAccess->Width(); x++)
899 for (tools::Long y = 0; y < pAccess->Height(); ++y)
901 // coverity[swapped_arguments : FALSE] - this is in the correct order
902 if (SetPixels[{ y, x }])
904 checkValue(pAccess, x, y, constLineColor, nNumberOfQuirks, nNumberOfErrors, true);
906 else
908 checkValue(pAccess, x, y, constBackgroundColor, nNumberOfQuirks, nNumberOfErrors,
909 true);
914 if (nNumberOfQuirks > 0)
915 aResult = TestResult::PassedWithQuirks;
916 if (nNumberOfErrors > 0 || !checkConvexHullProperty(rBitmap, constLineColor, 2, 2))
917 aResult = TestResult::Failed;
918 return aResult;
921 TestResult OutputDeviceTestCommon::checkOpenBezier(Bitmap& rBitmap)
923 BitmapScopedWriteAccess pAccess(rBitmap);
925 TestResult aResult = TestResult::Passed;
926 int nNumberOfQuirks = 0;
927 int nNumberOfErrors = 0;
929 std::map<std::pair<int, int>, bool> SetPixels
930 = { { { 14, 3 }, true }, { { 14, 4 }, true }, { { 14, 5 }, true }, { { 3, 6 }, true },
931 { { 4, 6 }, true }, { { 14, 6 }, true }, { { 4, 7 }, true }, { { 5, 7 }, true },
932 { { 13, 7 }, true }, { { 6, 8 }, true }, { { 7, 8 }, true }, { { 12, 8 }, true },
933 { { 13, 8 }, true }, { { 8, 9 }, true }, { { 9, 9 }, true }, { { 10, 9 }, true },
934 { { 11, 9 }, true }, { { 12, 9 }, true } };
936 for (tools::Long x = 0; x < pAccess->Width(); x++)
938 for (tools::Long y = 0; y < pAccess->Height(); ++y)
940 // coverity[swapped_arguments : FALSE] - this is in the correct order
941 if (SetPixels[{ y, x }])
943 checkValue(pAccess, x, y, constLineColor, nNumberOfQuirks, nNumberOfErrors, true);
945 else
947 checkValue(pAccess, x, y, constBackgroundColor, nNumberOfQuirks, nNumberOfErrors,
948 true);
952 if (nNumberOfQuirks > 0)
953 aResult = TestResult::PassedWithQuirks;
954 if (nNumberOfErrors > 0 || !checkConvexHullProperty(rBitmap, constLineColor, 2, 5))
955 aResult = TestResult::Failed;
956 return aResult;
959 TestResult OutputDeviceTestCommon::checkFilledAsymmetricalDropShape(Bitmap& rBitmap)
961 BitmapScopedWriteAccess pAccess(rBitmap);
963 TestResult aResult = TestResult::Passed;
964 int nNumberOfQuirks = 0;
965 int nNumberOfErrors = 0;
967 std::map<std::pair<tools::Long, tools::Long>, bool> SetPixels
968 = { { { 2, 2 }, true }, { { 3, 2 }, true }, { { 4, 2 }, true }, { { 5, 2 }, true },
969 { { 6, 2 }, true }, { { 7, 2 }, true }, { { 8, 2 }, true }, { { 9, 2 }, true },
970 { { 10, 2 }, true }, { { 11, 2 }, true }, { { 2, 3 }, true }, { { 3, 3 }, true },
971 { { 4, 3 }, true }, { { 5, 3 }, true }, { { 6, 3 }, true }, { { 7, 3 }, true },
972 { { 8, 3 }, true }, { { 9, 3 }, true }, { { 10, 3 }, true }, { { 11, 3 }, true },
973 { { 12, 3 }, true }, { { 13, 3 }, true }, { { 2, 4 }, true }, { { 3, 4 }, true },
974 { { 4, 4 }, true }, { { 5, 4 }, true }, { { 6, 4 }, true }, { { 7, 4 }, true },
975 { { 8, 4 }, true }, { { 9, 4 }, true }, { { 10, 4 }, true }, { { 11, 4 }, true },
976 { { 12, 4 }, true }, { { 13, 4 }, true }, { { 14, 4 }, true }, { { 15, 4 }, true },
977 { { 2, 5 }, true }, { { 3, 5 }, true }, { { 4, 5 }, true }, { { 5, 5 }, true },
978 { { 6, 5 }, true }, { { 7, 5 }, true }, { { 8, 5 }, true }, { { 9, 5 }, true },
979 { { 10, 5 }, true }, { { 11, 5 }, true }, { { 12, 5 }, true }, { { 13, 5 }, true },
980 { { 14, 5 }, true }, { { 15, 5 }, true }, { { 2, 6 }, true }, { { 3, 6 }, true },
981 { { 4, 6 }, true }, { { 5, 6 }, true }, { { 6, 6 }, true }, { { 7, 6 }, true },
982 { { 8, 6 }, true }, { { 9, 6 }, true }, { { 10, 6 }, true }, { { 11, 6 }, true },
983 { { 12, 6 }, true }, { { 13, 6 }, true }, { { 14, 6 }, true }, { { 15, 6 }, true },
984 { { 16, 6 }, true }, { { 2, 7 }, true }, { { 3, 7 }, true }, { { 4, 7 }, true },
985 { { 5, 7 }, true }, { { 6, 7 }, true }, { { 7, 7 }, true }, { { 8, 7 }, true },
986 { { 9, 7 }, true }, { { 10, 7 }, true }, { { 11, 7 }, true }, { { 12, 7 }, true },
987 { { 13, 7 }, true }, { { 14, 7 }, true }, { { 15, 7 }, true }, { { 16, 7 }, true },
988 { { 2, 8 }, true }, { { 3, 8 }, true }, { { 4, 8 }, true }, { { 5, 8 }, true },
989 { { 6, 8 }, true }, { { 7, 8 }, true }, { { 8, 8 }, true }, { { 9, 8 }, true },
990 { { 10, 8 }, true }, { { 11, 8 }, true }, { { 12, 8 }, true }, { { 13, 8 }, true },
991 { { 14, 8 }, true }, { { 15, 8 }, true }, { { 16, 8 }, true }, { { 17, 8 }, true },
992 { { 2, 9 }, true }, { { 3, 9 }, true }, { { 4, 9 }, true }, { { 5, 9 }, true },
993 { { 6, 9 }, true }, { { 7, 9 }, true }, { { 8, 9 }, true }, { { 9, 9 }, true },
994 { { 10, 9 }, true }, { { 11, 9 }, true }, { { 12, 9 }, true }, { { 13, 9 }, true },
995 { { 14, 9 }, true }, { { 15, 9 }, true }, { { 16, 9 }, true }, { { 17, 9 }, true },
996 { { 2, 10 }, true }, { { 3, 10 }, true }, { { 4, 10 }, true }, { { 5, 10 }, true },
997 { { 6, 10 }, true }, { { 7, 10 }, true }, { { 8, 10 }, true }, { { 9, 10 }, true },
998 { { 10, 10 }, true }, { { 11, 10 }, true }, { { 12, 10 }, true }, { { 13, 10 }, true },
999 { { 14, 10 }, true }, { { 15, 10 }, true }, { { 16, 10 }, true }, { { 17, 10 }, true },
1000 { { 2, 11 }, true }, { { 3, 11 }, true }, { { 4, 11 }, true }, { { 5, 11 }, true },
1001 { { 6, 11 }, true }, { { 7, 11 }, true }, { { 8, 11 }, true }, { { 9, 11 }, true },
1002 { { 10, 11 }, true }, { { 11, 11 }, true }, { { 12, 11 }, true }, { { 13, 11 }, true },
1003 { { 14, 11 }, true }, { { 15, 11 }, true }, { { 16, 11 }, true }, { { 17, 11 }, true },
1004 { { 3, 12 }, true }, { { 4, 12 }, true }, { { 5, 12 }, true }, { { 6, 12 }, true },
1005 { { 7, 12 }, true }, { { 8, 12 }, true }, { { 9, 12 }, true }, { { 10, 12 }, true },
1006 { { 11, 12 }, true }, { { 12, 12 }, true }, { { 13, 12 }, true }, { { 14, 12 }, true },
1007 { { 15, 12 }, true }, { { 16, 12 }, true }, { { 3, 13 }, true }, { { 4, 13 }, true },
1008 { { 5, 13 }, true }, { { 6, 13 }, true }, { { 7, 13 }, true }, { { 8, 13 }, true },
1009 { { 9, 13 }, true }, { { 10, 13 }, true }, { { 11, 13 }, true }, { { 12, 13 }, true },
1010 { { 13, 13 }, true }, { { 14, 13 }, true }, { { 15, 13 }, true }, { { 16, 13 }, true },
1011 { { 4, 14 }, true }, { { 5, 14 }, true }, { { 6, 14 }, true }, { { 7, 14 }, true },
1012 { { 8, 14 }, true }, { { 9, 14 }, true }, { { 10, 14 }, true }, { { 11, 14 }, true },
1013 { { 12, 14 }, true }, { { 13, 14 }, true }, { { 14, 14 }, true }, { { 15, 14 }, true },
1014 { { 5, 15 }, true }, { { 6, 15 }, true }, { { 7, 15 }, true }, { { 8, 15 }, true },
1015 { { 9, 15 }, true }, { { 10, 15 }, true }, { { 11, 15 }, true }, { { 12, 15 }, true },
1016 { { 13, 15 }, true }, { { 14, 15 }, true }, { { 15, 15 }, true }, { { 6, 16 }, true },
1017 { { 7, 16 }, true }, { { 8, 16 }, true }, { { 9, 16 }, true }, { { 10, 16 }, true },
1018 { { 11, 16 }, true }, { { 12, 16 }, true }, { { 13, 16 }, true }, { { 8, 17 }, true },
1019 { { 9, 17 }, true }, { { 10, 17 }, true }, { { 11, 17 }, true } };
1021 for (tools::Long x = 0; x < pAccess->Width(); x++)
1023 for (tools::Long y = 0; y < pAccess->Height(); ++y)
1025 if (SetPixels[{ x, y }])
1027 checkValue(pAccess, y, x, constFillColor, nNumberOfQuirks, nNumberOfErrors, true);
1029 else
1031 checkValue(pAccess, y, x, constBackgroundColor, nNumberOfQuirks, nNumberOfErrors, true);
1036 if (nNumberOfQuirks > 0)
1037 aResult = TestResult::PassedWithQuirks;
1038 if (nNumberOfErrors > 0)
1039 aResult = TestResult::Failed;
1040 return aResult;
1043 TestResult OutputDeviceTestCommon::checkTextLocation(Bitmap& rBitmap)
1045 BitmapScopedWriteAccess pAccess(rBitmap);
1047 TestResult aResult = TestResult::Passed;
1049 //The limit to which error would be tolerated.
1050 tools::Long textThreshold = 3;
1051 tools::Long textWidth = 3, textHeight = 8;
1052 tools::Long deviationX = 0, deviationY = 0;
1053 tools::Long verticalStart = 0, verticalEnd = 0;
1054 tools::Long horizontalStart = 0, horizontalEnd = 0;
1055 tools::Long midX = pAccess->Width() / 2.0;
1056 tools::Long midY = pAccess->Height() / 2.0;
1057 bool insideFlag = false;
1059 //Traversing horizontally
1060 for (tools::Long x = 0, y = pAccess->Height() / 2.0; x < pAccess->Width(); ++x)
1062 if (pAccess->GetPixel(y, x) != constBackgroundColor)
1064 if (!insideFlag)
1066 horizontalStart = x;
1067 insideFlag = true;
1069 else
1071 horizontalEnd = x;
1076 deviationX = abs(midX - horizontalStart);
1077 midY -= midY / 2.0;
1078 midY += 1;
1080 insideFlag = false;
1081 //Traversing vertically
1082 for (tools::Long x = 0, y = pAccess->Height() / 2.0; x < pAccess->Height(); ++x)
1084 if (pAccess->GetPixel(x, y) != constBackgroundColor)
1086 if (!insideFlag)
1088 verticalStart = x;
1089 insideFlag = true;
1091 else
1093 verticalEnd = x;
1098 deviationY = abs(midY - verticalStart);
1100 if (deviationX != 0 || deviationY != 0 || abs(horizontalStart - horizontalEnd) + 1 != textWidth
1101 || abs(verticalStart - verticalEnd) + 1 != textHeight)
1103 aResult = TestResult::PassedWithQuirks;
1106 if (deviationX > textThreshold || deviationY > textThreshold
1107 || abs((abs(horizontalStart - horizontalEnd) + 1) - textWidth) > textThreshold
1108 || abs((abs(verticalStart - verticalEnd) + 1) - textHeight) > textThreshold)
1110 aResult = TestResult::Failed;
1113 return aResult;
1116 TestResult OutputDeviceTestCommon::checkIntersectingRecs(Bitmap& rBitmap, int aLayerNumber,
1117 Color aExpected)
1119 BitmapScopedWriteAccess pAccess(rBitmap);
1121 TestResult aResult = TestResult::Passed;
1122 int nNumberOfQuirks = 0;
1123 int nNumberOfErrors = 0;
1125 for (int x = 4; x <= 19; ++x)
1127 checkValue(pAccess, x, aLayerNumber, aExpected, nNumberOfQuirks, nNumberOfErrors, true);
1130 if (nNumberOfQuirks > 0)
1131 aResult = TestResult::PassedWithQuirks;
1132 if (nNumberOfErrors > 0)
1133 aResult = TestResult::Failed;
1134 return aResult;
1137 TestResult OutputDeviceTestCommon::checkEvenOddRuleInIntersectingRecs(Bitmap& rBitmap)
1140 The even-odd rule would be tested via the below pattern as layers both of the
1141 constFillColor & constBackgroundColor appears in an even-odd fashion.
1143 std::vector<Color> aExpectedColors
1144 = { constBackgroundColor, constBackgroundColor, constLineColor, constFillColor,
1145 constFillColor, constLineColor, constBackgroundColor, constBackgroundColor,
1146 constLineColor, constFillColor, constFillColor, constLineColor,
1147 constBackgroundColor, constBackgroundColor, constLineColor, constFillColor,
1148 constFillColor, constLineColor, constBackgroundColor, constBackgroundColor,
1149 constLineColor, constFillColor, constLineColor };
1151 TestResult aReturnValue = TestResult::Passed;
1152 for (size_t i = 0; i < aExpectedColors.size(); i++)
1154 TestResult eResult = checkIntersectingRecs(rBitmap, i, aExpectedColors[i]);
1156 if (eResult == TestResult::Failed)
1157 aReturnValue = TestResult::Failed;
1158 if (eResult == TestResult::PassedWithQuirks && aReturnValue != TestResult::Failed)
1159 aReturnValue = TestResult::PassedWithQuirks;
1161 return aReturnValue;
1164 TestResult OutputDeviceTestCommon::checkOpenPolygon(Bitmap& rBitmap, bool aEnableAA)
1166 std::vector<Color> aExpected = { constBackgroundColor, constLineColor, constLineColor };
1168 BitmapScopedWriteAccess pAccess(rBitmap);
1170 TestResult aResult = TestResult::Passed;
1171 int nNumberOfQuirks = 0;
1172 int nNumberOfErrors = 0;
1174 for (size_t aLayerNumber = 0; aLayerNumber < aExpected.size(); aLayerNumber++)
1176 tools::Long startX = aLayerNumber + 1, endX = pAccess->Width() / 2 - aLayerNumber;
1177 tools::Long startY = aLayerNumber + 2, endY = pAccess->Height() - aLayerNumber - 3;
1179 for (tools::Long ptX = startX; ptX <= endX; ++ptX)
1181 if (aEnableAA)
1183 checkValueAA(pAccess, ptX, endY - (aLayerNumber == 2 ? 2 : 0),
1184 aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors);
1186 else
1188 checkValue(pAccess, ptX, endY - (aLayerNumber == 2 ? 2 : 0),
1189 aExpected[aLayerNumber], nNumberOfQuirks, nNumberOfErrors, true);
1192 for (tools::Long ptY = startY + (aLayerNumber == 2 ? 2 : 0);
1193 ptY <= endY - (aLayerNumber == 2 ? 2 : 0); ++ptY)
1195 if (aEnableAA)
1197 checkValueAA(pAccess, startX, ptY, aExpected[aLayerNumber], nNumberOfQuirks,
1198 nNumberOfErrors);
1199 checkValueAA(pAccess, endX, ptY, aExpected[aLayerNumber], nNumberOfQuirks,
1200 nNumberOfErrors);
1202 else
1204 checkValue(pAccess, startX, ptY, aExpected[aLayerNumber], nNumberOfQuirks,
1205 nNumberOfErrors, true);
1206 checkValue(pAccess, endX, ptY, aExpected[aLayerNumber], nNumberOfQuirks,
1207 nNumberOfErrors, true);
1212 if (nNumberOfQuirks > 0)
1213 aResult = TestResult::PassedWithQuirks;
1214 if (nNumberOfErrors > 0)
1215 aResult = TestResult::Failed;
1216 return aResult;
1219 // Check 'count' pixels from (x,y) in (addX,addY) direction, the color values must not decrease.
1220 static bool checkGradient(BitmapScopedWriteAccess& pAccess, int x, int y, int count, int addX, int addY)
1222 const bool bColorize = false;
1223 Color maxColor = COL_BLACK;
1224 for( int i = 0; i < count; ++i )
1226 Color color = pAccess->GetPixel(y, x);
1227 if( color.GetRed() < maxColor.GetRed() || color.GetGreen() < maxColor.GetGreen() || color.GetBlue() < maxColor.GetBlue())
1229 if (bColorize)
1230 pAccess->SetPixel(y, x, COL_RED);
1231 return false;
1233 maxColor = color;
1234 if (bColorize)
1235 pAccess->SetPixel(y, x, COL_LIGHTGREEN);
1236 x += addX;
1237 y += addY;
1239 return true;
1242 TestResult OutputDeviceTestCommon::checkLinearGradient(Bitmap& bitmap)
1244 BitmapScopedWriteAccess pAccess(bitmap);
1245 TestResult aResult = TestResult::Passed;
1246 int nNumberOfQuirks = 0;
1247 int nNumberOfErrors = 0;
1249 // The lowest line is missing in the default VCL implementation => quirk.
1250 checkValue(pAccess, 1, 10, COL_WHITE, nNumberOfQuirks, nNumberOfErrors, true, 255 / 10);
1251 checkValue(pAccess, 10, 10, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, true, 255 / 10);
1252 for(int y = 1; y < 10; ++y)
1254 checkValue(pAccess, 1, y, COL_WHITE, nNumberOfQuirks, nNumberOfErrors, 255 / 10);
1255 checkValue(pAccess, 10, y, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, 255 / 10);
1257 for(int y = 1; y < 10; ++y)
1258 if( !checkGradient( pAccess, 10, y, 10, -1, 0 ))
1259 return TestResult::Failed;
1260 if (nNumberOfQuirks > 0)
1261 checkResult(TestResult::PassedWithQuirks, aResult);
1262 if (nNumberOfErrors > 0)
1263 checkResult(TestResult::Failed, aResult);
1264 return aResult;
1267 TestResult OutputDeviceTestCommon::checkLinearGradientAngled(Bitmap& bitmap)
1269 BitmapScopedWriteAccess pAccess(bitmap);
1270 TestResult aResult = TestResult::Passed;
1271 int nNumberOfQuirks = 0;
1272 int nNumberOfErrors = 0;
1274 // The top-left pixel is not white but gray in the default VCL implementation => quirk.
1275 checkValue(pAccess, 1, 1, COL_WHITE, nNumberOfQuirks, nNumberOfErrors, 50);
1276 checkValue(pAccess, 10, 10, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, 0, 255 / 10); // Bottom-right.
1277 // Main diagonal.
1278 if( !checkGradient( pAccess, 10, 10, 10, -1, -1 ))
1279 return TestResult::Failed;
1280 if (nNumberOfQuirks > 0)
1281 checkResult(TestResult::PassedWithQuirks, aResult);
1282 if (nNumberOfErrors > 0)
1283 checkResult(TestResult::Failed, aResult);
1284 return TestResult::Passed;
1287 TestResult OutputDeviceTestCommon::checkLinearGradientBorder(Bitmap& bitmap)
1289 TestResult aResult = TestResult::Passed;
1290 // Top half is border.
1291 checkResult(checkFilled(bitmap, tools::Rectangle(Point(1, 1), Size(10, 5)), COL_WHITE), aResult);
1292 BitmapScopedWriteAccess pAccess(bitmap);
1293 int nNumberOfQuirks = 0;
1294 int nNumberOfErrors = 0;
1295 for(int x = 1; x <= 10; ++x)
1297 checkValue(pAccess, x, 10, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
1298 if( !checkGradient( pAccess, x, 10, 5, 0, -1 ))
1299 return TestResult::Failed;
1301 if (nNumberOfQuirks > 0)
1302 checkResult(TestResult::PassedWithQuirks, aResult);
1303 if (nNumberOfErrors > 0)
1304 checkResult(TestResult::Failed, aResult);
1305 return aResult;
1308 TestResult OutputDeviceTestCommon::checkLinearGradientIntensity(Bitmap& bitmap)
1310 BitmapScopedWriteAccess pAccess(bitmap);
1311 TestResult aResult = TestResult::Passed;
1312 int nNumberOfQuirks = 0;
1313 int nNumberOfErrors = 0;
1315 for(int x = 1; x <= 10; ++x)
1317 // The gradient starts at half intensity, i.e. white's 255's are halved.
1318 checkValue(pAccess, x, 1, Color(128,128,128), nNumberOfQuirks, nNumberOfErrors, false, 10);
1319 checkValue(pAccess, x, 10, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, 255 / 10);
1320 if( !checkGradient( pAccess, x, 10, 10, 0, -1 ))
1321 return TestResult::Failed;
1323 if (nNumberOfQuirks > 0)
1324 checkResult(TestResult::PassedWithQuirks, aResult);
1325 if (nNumberOfErrors > 0)
1326 checkResult(TestResult::Failed, aResult);
1327 return aResult;
1330 TestResult OutputDeviceTestCommon::checkLinearGradientSteps(Bitmap& bitmap)
1332 // Reuse the basic linear gradient check.
1333 TestResult aResult = checkLinearGradient(bitmap);
1334 // Only 4 steps in the gradient, there should be only 4 colors.
1335 if( collectColors( bitmap, tools::Rectangle( Point( 1, 1 ), Size( 10, 10 ))).size() != 4 )
1336 return TestResult::Failed;
1337 return aResult;
1340 TestResult OutputDeviceTestCommon::checkAxialGradient(Bitmap& bitmap)
1342 BitmapScopedWriteAccess pAccess(bitmap);
1343 TestResult aResult = TestResult::Passed;
1344 int nNumberOfQuirks = 0;
1345 int nNumberOfErrors = 0;
1347 for(int y = 1; y <= 11; ++y)
1349 // Middle horizontal line is white, gradients to the sides.
1350 checkValue(pAccess, 6, y, COL_WHITE, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
1351 checkValue(pAccess, 1, y, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
1352 checkValue(pAccess, 11, y, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
1353 if( !checkGradient( pAccess, 1, y, 6, 1, 0 ))
1354 return TestResult::Failed;
1355 if( !checkGradient( pAccess, 11, y, 6, -1, 0 ))
1356 return TestResult::Failed;
1358 if (nNumberOfQuirks > 0)
1359 checkResult(TestResult::PassedWithQuirks, aResult);
1360 if (nNumberOfErrors > 0)
1361 checkResult(TestResult::Failed, aResult);
1362 return aResult;
1365 TestResult OutputDeviceTestCommon::checkRadialGradient(Bitmap& bitmap)
1367 BitmapScopedWriteAccess pAccess(bitmap);
1368 TestResult aResult = TestResult::Passed;
1369 int nNumberOfQuirks = 0;
1370 int nNumberOfErrors = 0;
1371 // The default VCL implementation is off-center in the direction to the top-left.
1372 // This means not all corners will be pure white => quirks.
1373 checkValue(pAccess, 1, 1, COL_WHITE, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 2);
1374 checkValue(pAccess, 1, 10, COL_WHITE, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
1375 checkValue(pAccess, 10, 1, COL_WHITE, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
1376 checkValue(pAccess, 10, 10, COL_WHITE, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
1377 // And not all centers will be pure black => quirks.
1378 checkValue(pAccess, 5, 5, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
1379 checkValue(pAccess, 5, 6, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 3);
1380 checkValue(pAccess, 6, 5, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 3);
1381 checkValue(pAccess, 6, 6, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 2);
1382 // Check diagonals, from the offset center.
1383 if(!checkGradient(pAccess, 5, 5, 5, -1, -1))
1384 return TestResult::Failed;
1385 if(!checkGradient(pAccess, 5, 5, 6, 1, 1))
1386 return TestResult::Failed;
1387 if(!checkGradient(pAccess, 5, 5, 5, 1, -1))
1388 return TestResult::Failed;
1389 if(!checkGradient(pAccess, 5, 5, 5, -1, 1))
1390 return TestResult::Failed;
1391 if (nNumberOfQuirks > 0)
1392 checkResult(TestResult::PassedWithQuirks, aResult);
1393 if (nNumberOfErrors > 0)
1394 checkResult(TestResult::Failed, aResult);
1395 return aResult;
1398 TestResult OutputDeviceTestCommon::checkRadialGradientOfs(Bitmap& bitmap)
1400 BitmapScopedWriteAccess pAccess(bitmap);
1401 TestResult aResult = TestResult::Passed;
1402 int nNumberOfQuirks = 0;
1403 int nNumberOfErrors = 0;
1404 checkValue(pAccess, 1, 1, COL_WHITE, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
1405 checkValue(pAccess, 10, 1, COL_WHITE, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
1406 checkValue(pAccess, 1, 10, COL_WHITE, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
1407 checkValue(pAccess, 10, 10, COL_BLACK, nNumberOfQuirks, nNumberOfErrors, 255 / 10, 255 / 5);
1408 // Check gradients from the center (=bottom-right corner).
1409 if(!checkGradient(pAccess, 10, 10, 10, -1, -1))
1410 return TestResult::Failed;
1411 if(!checkGradient(pAccess, 10, 10, 10, -1, 0))
1412 return TestResult::Failed;
1413 if(!checkGradient(pAccess, 10, 10, 10, 0, -1))
1414 return TestResult::Failed;
1415 if (nNumberOfQuirks > 0)
1416 checkResult(TestResult::PassedWithQuirks, aResult);
1417 if (nNumberOfErrors > 0)
1418 checkResult(TestResult::Failed, aResult);
1419 return aResult;
1422 constexpr int CAPSHRINK = 25;
1423 constexpr int CAPWIDTH = 20;
1424 TestResult OutputDeviceTestCommon::checkLineCap(Bitmap& rBitmap, css::drawing::LineCap lineCap)
1426 BitmapScopedWriteAccess access(rBitmap);
1427 tools::Rectangle rectangle( Point( 0, 0 ), Size( 101, 101 ));
1428 rectangle.shrink(CAPSHRINK);
1429 rectangle = tools::Rectangle( Point(rectangle.LeftCenter().getX(), rectangle.LeftCenter().getY() - CAPWIDTH / 2),
1430 Point(rectangle.RightCenter().getX(), rectangle.RightCenter().getY() + CAPWIDTH / 2));
1431 rectangle.shrink(1);
1432 TestResult aResult = TestResult::Passed;
1433 int nNumberOfQuirks = 0;
1434 int nNumberOfErrors = 0;
1436 // the line itself
1437 checkValue(access, rectangle.TopLeft(), constLineColor, nNumberOfQuirks, nNumberOfErrors, false);
1438 checkValue(access, rectangle.TopRight(), constLineColor, nNumberOfQuirks, nNumberOfErrors, false);
1439 checkValue(access, rectangle.BottomLeft(), constLineColor, nNumberOfQuirks, nNumberOfErrors, false);
1440 checkValue(access, rectangle.BottomRight(), constLineColor, nNumberOfQuirks, nNumberOfErrors, false);
1442 // the cap in the middle
1443 Color color = ( lineCap == css::drawing::LineCap_BUTT ) ? constBackgroundColor : constLineColor;
1444 checkValue(access, rectangle.LeftCenter() - Point(CAPWIDTH/2, 0), color, nNumberOfQuirks, nNumberOfErrors, false);
1445 checkValue(access, rectangle.RightCenter() + Point(CAPWIDTH/2, 0), color, nNumberOfQuirks, nNumberOfErrors, false);
1447 // the cap corners
1448 color = ( lineCap == css::drawing::LineCap_SQUARE ) ? constLineColor : constBackgroundColor;
1449 checkValue(access, rectangle.TopLeft() - Point(CAPWIDTH/2, 0), color, nNumberOfQuirks, nNumberOfErrors, false);
1450 checkValue(access, rectangle.TopRight() + Point(CAPWIDTH/2, 0), color, nNumberOfQuirks, nNumberOfErrors, false);
1451 checkValue(access, rectangle.BottomLeft() - Point(CAPWIDTH/2, 0), color, nNumberOfQuirks, nNumberOfErrors, false);
1452 checkValue(access, rectangle.BottomRight() + Point(CAPWIDTH/2, 0), color, nNumberOfQuirks, nNumberOfErrors, false);
1454 if (nNumberOfQuirks > 0)
1455 checkResult(TestResult::PassedWithQuirks, aResult);
1456 if (nNumberOfErrors > 0)
1457 checkResult(TestResult::Failed, aResult);
1458 return aResult;
1461 TestResult OutputDeviceTestCommon::checkLineJoin(Bitmap& rBitmap, basegfx::B2DLineJoin lineJoin)
1463 BitmapScopedWriteAccess access(rBitmap);
1464 tools::Rectangle rectangle( Point( 0, 0 ), Size( 101, 101 ));
1465 rectangle.shrink(CAPSHRINK);
1466 tools::Rectangle rectangle1( Point(rectangle.TopLeft().getX(), rectangle.TopLeft().getY() - CAPWIDTH / 2),
1467 Point(rectangle.TopRight().getX(), rectangle.TopRight().getY() + CAPWIDTH / 2));
1468 tools::Rectangle rectangle2( Point(rectangle.TopRight().getX() - CAPWIDTH / 2, rectangle.TopRight().getY()),
1469 Point(rectangle.BottomRight().getX() + CAPWIDTH / 2, rectangle.BottomRight().getY()));
1470 rectangle1.shrink(1);
1471 rectangle2.shrink(1);
1472 TestResult aResult = TestResult::Passed;
1473 int nNumberOfQuirks = 0;
1474 int nNumberOfErrors = 0;
1476 // the lines themselves
1477 checkValue(access, rectangle1.TopLeft(), constLineColor, nNumberOfQuirks, nNumberOfErrors, false);
1478 checkValue(access, rectangle1.TopRight(), constLineColor, nNumberOfQuirks, nNumberOfErrors, false);
1479 checkValue(access, rectangle1.BottomLeft(), constLineColor, nNumberOfQuirks, nNumberOfErrors, false);
1480 checkValue(access, rectangle1.BottomRight(), constLineColor, nNumberOfQuirks, nNumberOfErrors, false);
1481 checkValue(access, rectangle2.TopLeft(), constLineColor, nNumberOfQuirks, nNumberOfErrors, false);
1482 checkValue(access, rectangle2.TopRight(), constLineColor, nNumberOfQuirks, nNumberOfErrors, false);
1483 checkValue(access, rectangle2.BottomLeft(), constLineColor, nNumberOfQuirks, nNumberOfErrors, false);
1484 checkValue(access, rectangle2.BottomRight(), constLineColor, nNumberOfQuirks, nNumberOfErrors, false);
1486 // Only miter has the corner point.
1487 Color color = ( lineJoin == basegfx::B2DLineJoin::Miter ) ? constLineColor : constBackgroundColor;
1488 checkValue(access, rectangle2.Right(), rectangle1.Top(), color, nNumberOfQuirks, nNumberOfErrors, false);
1490 // Round reaches a bit past the diagonal.
1491 Point midDiagonal = (Point( rectangle2.Right(), rectangle1.Top()) + rectangle.TopRight()) / 2;
1492 if( lineJoin == basegfx::B2DLineJoin::Round)
1493 color = constLineColor;
1494 checkValue(access, midDiagonal + Point( 2, -2 ), color, nNumberOfQuirks, nNumberOfErrors, false);
1495 // Bevel is the diagonal.
1496 if( lineJoin == basegfx::B2DLineJoin::Bevel)
1497 color = constLineColor;
1498 checkValue(access, midDiagonal + Point( -1, 1 ), color, nNumberOfQuirks, nNumberOfErrors, false);
1499 // Everything except None has at least some line join.
1500 checkValue(access, rectangle.TopRight() + Point( 1, -1 ), color, nNumberOfQuirks, nNumberOfErrors, false);
1502 if (nNumberOfQuirks > 0)
1503 checkResult(TestResult::PassedWithQuirks, aResult);
1504 if (nNumberOfErrors > 0)
1505 checkResult(TestResult::Failed, aResult);
1506 return aResult;
1509 TestResult OutputDeviceTestAnotherOutDev::checkDrawOutDev(Bitmap& rBitmap)
1511 std::vector<Color> aExpected
1513 constBackgroundColor, constBackgroundColor,
1514 constFillColor, constFillColor, constFillColor, constFillColor, constFillColor
1516 return checkRectangles(rBitmap, aExpected);
1519 TestResult OutputDeviceTestAnotherOutDev::checkDrawOutDevScaledClipped(Bitmap& rBitmap)
1521 TestResult aReturnValue = TestResult::Passed;
1522 TestResult eResult;
1524 eResult = checkRect(rBitmap, 0, constBackgroundColor); // outer line
1525 checkResult(eResult, aReturnValue);
1526 eResult = checkRect(rBitmap, 1, constBackgroundColor); // next outer line
1527 checkResult(eResult, aReturnValue);
1528 eResult = checkFilled(rBitmap, tools::Rectangle(Point(2, 2), Size(4, 8)), constBackgroundColor);
1529 checkResult(eResult, aReturnValue);
1530 eResult = checkFilled(rBitmap, tools::Rectangle(Point(6, 2), Size(4, 8)), constFillColor);
1531 checkResult(eResult, aReturnValue);
1533 return aReturnValue;
1536 TestResult OutputDeviceTestAnotherOutDev::checkDrawOutDevSelf(Bitmap& rBitmap)
1538 TestResult aReturnValue = TestResult::Passed;
1539 TestResult eResult;
1541 eResult = checkRect(rBitmap, 0, constBackgroundColor); // outer line
1542 checkResult(eResult, aReturnValue);
1543 eResult = checkFilled(rBitmap, tools::Rectangle(Point(1, 1), Size(4, 4)), constBackgroundColor);
1544 checkResult(eResult, aReturnValue);
1545 eResult = checkFilled(rBitmap, tools::Rectangle(Point(8, 8), Size(4, 4)), constBackgroundColor);
1546 checkResult(eResult, aReturnValue);
1548 eResult = checkFilled(rBitmap, tools::Rectangle(Point(11, 1), Size(1, 1)), COL_YELLOW);
1549 checkResult(eResult, aReturnValue);
1550 eResult = checkFilled(rBitmap, tools::Rectangle(Point(7, 5), Size(1, 1)), COL_YELLOW);
1551 checkResult(eResult, aReturnValue);
1552 eResult = checkFilled(rBitmap, tools::Rectangle(Point(1, 11), Size(1, 1)), COL_YELLOW);
1553 checkResult(eResult, aReturnValue);
1555 eResult = checkFilled(rBitmap, tools::Rectangle(Point(1, 5), Size(6, 6)), constFillColor);
1556 checkResult(eResult, aReturnValue);
1557 eResult = checkFilled(rBitmap, tools::Rectangle(Point(2, 6), Size(6, 6)), constFillColor);
1558 checkResult(eResult, aReturnValue);
1559 eResult = checkFilled(rBitmap, tools::Rectangle(Point(5, 1), Size(6, 4)), constFillColor);
1560 checkResult(eResult, aReturnValue);
1561 eResult = checkFilled(rBitmap, tools::Rectangle(Point(8, 2), Size(4, 6)), constFillColor);
1562 checkResult(eResult, aReturnValue);
1564 return aReturnValue;
1567 TestResult OutputDeviceTestAnotherOutDev::checkXOR(Bitmap& rBitmap)
1569 Color xorColor( constBackgroundColor.GetRed() ^ constFillColor.GetRed(),
1570 constBackgroundColor.GetGreen() ^ constFillColor.GetGreen(),
1571 constBackgroundColor.GetBlue() ^ constFillColor.GetBlue());
1572 std::vector<Color> aExpected
1574 constBackgroundColor, xorColor,
1575 constBackgroundColor, constBackgroundColor,
1576 constFillColor, constFillColor,
1577 constFillColor
1579 return checkRectangles(rBitmap, aExpected);
1583 TestResult OutputDeviceTestBitmap::checkTransformedBitmap(Bitmap& rBitmap)
1585 std::vector<Color> aExpected
1587 constBackgroundColor, constBackgroundColor,
1588 COL_YELLOW, constFillColor, COL_YELLOW, constFillColor, constFillColor
1590 return checkRectangles(rBitmap, aExpected);
1593 TestResult OutputDeviceTestBitmap::checkComplexTransformedBitmap(Bitmap& rBitmap)
1595 TestResult aReturnValue = TestResult::Passed;
1596 TestResult eResult;
1597 eResult = checkRectangle(rBitmap, 0, constBackgroundColor); // outer line not affected
1598 checkResult(eResult, aReturnValue);
1599 // empty "corners" should not be affected
1600 eResult = checkFilled(rBitmap, tools::Rectangle(Point(1, 11), Size(2, 2)), constBackgroundColor);
1601 checkResult(eResult, aReturnValue);
1602 eResult = checkFilled(rBitmap, tools::Rectangle(Point(14, 1), Size(2, 2)), constBackgroundColor);
1603 // check the middle
1604 eResult = checkFilled(rBitmap, tools::Rectangle(Point(4, 3), Size(9, 8)), constFillColor);
1605 checkResult(eResult, aReturnValue);
1606 checkResult(eResult, aReturnValue);
1607 int nNumberOfQuirks = 0;
1608 int nNumberOfErrors = 0;
1609 BitmapScopedWriteAccess pAccess(rBitmap);
1610 // starting and ending corner, headless draws with AA, so be lenient
1611 checkValue(pAccess, 1, 1, constFillColor, nNumberOfQuirks, nNumberOfErrors, 0, 192);
1612 checkValue(pAccess, 2, 2, constFillColor, nNumberOfQuirks, nNumberOfErrors, 0, 16);
1613 checkValue(pAccess, 14, 11, constFillColor, nNumberOfQuirks, nNumberOfErrors, 0, 16);
1614 checkValue(pAccess, 15, 12, constFillColor, nNumberOfQuirks, nNumberOfErrors, 0, 192);
1615 if (nNumberOfQuirks > 0)
1616 checkResult(TestResult::PassedWithQuirks, aReturnValue);
1617 if (nNumberOfErrors > 0)
1618 checkResult(TestResult::Failed, aReturnValue);
1619 return aReturnValue;
1622 TestResult OutputDeviceTestBitmap::checkTransformedBitmap8bppGreyScale(Bitmap& rBitmap)
1624 std::vector<Color> aExpected
1626 Color(0xC0,0xC0,0xC0), Color(0xC0,0xC0,0xC0),
1627 Color(0xE2,0xE2,0xE2), Color(0xE,0xE,0xE), Color(0xE2,0xE2,0xE2), Color(0xE,0xE,0xE), Color(0xE,0xE,0xE)
1629 return checkRectangles(rBitmap, aExpected);
1632 TestResult OutputDeviceTestBitmap::checkBitmapExWithAlpha(Bitmap& rBitmap)
1634 const Color aBlendedColor(0xEE, 0xEE, 0x33);
1636 std::vector<Color> aExpected
1638 constBackgroundColor, constBackgroundColor,
1639 aBlendedColor, constBackgroundColor, constBackgroundColor,
1640 aBlendedColor, constBackgroundColor
1642 return checkRectangles(rBitmap, aExpected);
1645 TestResult OutputDeviceTestBitmap::checkMask(Bitmap& rBitmap)
1647 return checkRectangle(rBitmap);
1650 TestResult OutputDeviceTestBitmap::checkBlend(const BitmapEx& rBitmapEx)
1652 const Color aBlendedColor(0xEE, 0xEE, 0x33);
1654 std::vector<Color> aExpected
1656 COL_WHITE, COL_WHITE, COL_YELLOW, constBackgroundColor,
1657 constBackgroundColor, aBlendedColor, constBackgroundColor
1659 Bitmap aBitmap(rBitmapEx.GetBitmap());
1660 return checkRectangles(aBitmap, aExpected);
1664 } // end namespace vcl::test
1666 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */