1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #include <tools/color.hxx>
11 #include <test/bootstrapfixture.hxx>
12 #include <test/outputdevice.hxx>
14 #include <sal/log.hxx>
15 #include <basegfx/matrix/b2dhommatrix.hxx>
16 #include <basegfx/numeric/ftools.hxx>
17 #include <basegfx/polygon/b2dpolygon.hxx>
18 #include <basegfx/polygon/b2dpolypolygon.hxx>
19 #include <basegfx/vector/b2enums.hxx>
21 #include <vcl/gradient.hxx>
22 #include <vcl/lineinfo.hxx>
23 #include <vcl/print.hxx>
24 #include <vcl/rendercontext/RasterOp.hxx>
25 #include <vcl/virdev.hxx>
26 #include <vcl/window.hxx>
27 #include <vcl/gdimtf.hxx>
28 #include <vcl/metaact.hxx>
30 #include <vcl/BitmapWriteAccess.hxx>
31 #include <bufferdevice.hxx>
34 const size_t INITIAL_SETUP_ACTION_COUNT
= 5;
36 class VclOutdevTest
: public test::BootstrapFixture
40 : BootstrapFixture(true, false)
45 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testGetReadableFontColorPrinter
)
47 ScopedVclPtrInstance
<Printer
> pPrinter
;
48 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, pPrinter
->GetReadableFontColor(COL_WHITE
, COL_WHITE
));
51 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testGetReadableFontColorWindow
)
53 ScopedVclPtrInstance
<vcl::Window
> pWindow(nullptr, WB_APP
| WB_STDWORK
);
54 CPPUNIT_ASSERT_EQUAL(COL_WHITE
,
55 pWindow
->GetOutDev()->GetReadableFontColor(COL_WHITE
, COL_BLACK
));
56 CPPUNIT_ASSERT_EQUAL(COL_BLACK
,
57 pWindow
->GetOutDev()->GetReadableFontColor(COL_WHITE
, COL_WHITE
));
58 CPPUNIT_ASSERT_EQUAL(COL_WHITE
,
59 pWindow
->GetOutDev()->GetReadableFontColor(COL_BLACK
, COL_BLACK
));
62 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testPrinterBackgroundColor
)
64 ScopedVclPtrInstance
<Printer
> pPrinter
;
65 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, pPrinter
->GetBackgroundColor());
68 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testWindowBackgroundColor
)
70 ScopedVclPtrInstance
<vcl::Window
> pWindow(nullptr, WB_APP
| WB_STDWORK
);
71 pWindow
->SetBackground(Wallpaper(COL_WHITE
));
72 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, pWindow
->GetBackgroundColor());
75 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testVirtualDevice
)
77 // TODO: This unit test is not executed for macOS unless bitmap scaling is implemented
79 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
80 pVDev
->SetOutputSizePixel(Size(32, 32));
81 pVDev
->SetBackground(Wallpaper(COL_WHITE
));
83 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, pVDev
->GetBackgroundColor());
86 pVDev
->DrawPixel(Point(1, 2), COL_BLUE
);
87 pVDev
->DrawPixel(Point(31, 30), COL_RED
);
89 Size aSize
= pVDev
->GetOutputSizePixel();
90 CPPUNIT_ASSERT_EQUAL(Size(32, 32), aSize
);
92 Bitmap aBmp
= pVDev
->GetBitmap(Point(), aSize
);
95 OUString
rFileName("/tmp/foo-unx.png");
97 vcl::PNGWriter
aWriter( aBmp
);
98 SvFileStream
sOutput( rFileName
, StreamMode::WRITE
);
99 aWriter
.Write( sOutput
);
102 SAL_WARN("vcl", "Error writing png to " << rFileName
);
106 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, pVDev
->GetPixel(Point(0, 0)));
107 #if !defined _WIN32 //TODO: various failures on Windows tinderboxes
108 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, pVDev
->GetPixel(Point(1, 2)));
109 CPPUNIT_ASSERT_EQUAL(COL_RED
, pVDev
->GetPixel(Point(31, 30)));
111 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, pVDev
->GetPixel(Point(30, 31)));
113 // Gotcha: y and x swap for BitmapReadAccess: deep joy.
114 BitmapScopedReadAccess
pAcc(aBmp
);
115 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, static_cast<Color
>(pAcc
->GetPixel(0, 0)));
116 #if !defined _WIN32 //TODO: various failures on Windows tinderboxes
117 CPPUNIT_ASSERT_EQUAL(COL_BLUE
, static_cast<Color
>(pAcc
->GetPixel(2, 1)));
118 CPPUNIT_ASSERT_EQUAL(COL_RED
, static_cast<Color
>(pAcc
->GetPixel(30, 31)));
120 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, static_cast<Color
>(pAcc
->GetPixel(31, 30)));
123 VclPtr
<vcl::Window
> pWin
= VclPtr
<WorkWindow
>::Create( (vcl::Window
*)nullptr );
124 CPPUNIT_ASSERT( pWin
);
125 OutputDevice
*pOutDev
= pWin
.get();
130 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testUseAfterDispose
)
132 // Create a virtual device, enable map mode then dispose it.
133 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
135 pVDev
->EnableMapMode();
137 pVDev
->disposeOnce();
139 // Make sure that these don't crash after dispose.
140 pVDev
->GetInverseViewTransformation();
142 pVDev
->GetViewTransformation();
145 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawInvertedBitmap
)
147 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
148 Bitmap
aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP
);
151 aMtf
.Record(pVDev
.get());
153 pVDev
->SetRasterOp(RasterOp::Invert
);
154 pVDev
->DrawBitmap(Point(0, 0), Size(10, 10), Point(0, 0), Size(10, 10), aBitmap
,
155 MetaActionType::BMP
);
157 MetaAction
* pAction
= aMtf
.GetAction(0);
158 CPPUNIT_ASSERT_EQUAL(MetaActionType::RASTEROP
, pAction
->GetType());
159 auto pRasterOpAction
= static_cast<MetaRasterOpAction
*>(pAction
);
160 CPPUNIT_ASSERT_EQUAL(RasterOp::Invert
, pRasterOpAction
->GetRasterOp());
162 pAction
= aMtf
.GetAction(1);
163 CPPUNIT_ASSERT_EQUAL(MetaActionType::RECT
, pAction
->GetType());
164 auto pRectAction
= static_cast<MetaRectAction
*>(pAction
);
165 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, 0), Size(10, 10)), pRectAction
->GetRect());
168 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawBlackBitmap
)
170 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
171 Bitmap
aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP
);
172 aBitmap
.Erase(COL_RED
);
175 aMtf
.Record(pVDev
.get());
177 pVDev
->SetDrawMode(DrawModeFlags::BlackBitmap
);
178 pVDev
->DrawBitmap(Point(0, 0), Size(10, 10), Point(0, 0), Size(10, 10), aBitmap
,
179 MetaActionType::BMP
);
181 MetaAction
* pAction
= aMtf
.GetAction(0);
182 CPPUNIT_ASSERT_EQUAL(MetaActionType::PUSH
, pAction
->GetType());
183 auto pPushAction
= static_cast<MetaPushAction
*>(pAction
);
185 = ((vcl::PushFlags::LINECOLOR
| vcl::PushFlags::FILLCOLOR
) == pPushAction
->GetFlags());
186 CPPUNIT_ASSERT_MESSAGE("Push flags not LINECOLOR | FILLCOLOR", bLineFillFlag
);
188 pAction
= aMtf
.GetAction(1);
189 CPPUNIT_ASSERT_EQUAL(MetaActionType::LINECOLOR
, pAction
->GetType());
190 auto pLineColorAction
= static_cast<MetaLineColorAction
*>(pAction
);
191 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, pLineColorAction
->GetColor());
193 pAction
= aMtf
.GetAction(2);
194 CPPUNIT_ASSERT_EQUAL(MetaActionType::FILLCOLOR
, pAction
->GetType());
195 auto pFillColorAction
= static_cast<MetaFillColorAction
*>(pAction
);
196 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, pFillColorAction
->GetColor());
198 pAction
= aMtf
.GetAction(3);
199 CPPUNIT_ASSERT_EQUAL(MetaActionType::RECT
, pAction
->GetType());
200 auto pRectAction
= static_cast<MetaRectAction
*>(pAction
);
201 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, 0), Size(10, 10)), pRectAction
->GetRect());
203 pAction
= aMtf
.GetAction(4);
204 CPPUNIT_ASSERT_EQUAL(MetaActionType::POP
, pAction
->GetType());
206 // test to see if the color is black
207 Bitmap
aBlackBmp(pVDev
->GetBitmap(Point(0, 0), Size(10, 10)));
208 BitmapScopedReadAccess
pReadAccess(aBlackBmp
);
209 const BitmapColor aColor
= pReadAccess
->GetColor(0, 0);
210 CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_BLACK
), aColor
);
213 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawWhiteBitmap
)
215 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
216 Bitmap
aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP
);
219 aMtf
.Record(pVDev
.get());
221 pVDev
->SetDrawMode(DrawModeFlags::WhiteBitmap
);
222 pVDev
->DrawBitmap(Point(0, 0), Size(10, 10), Point(0, 0), Size(10, 10), aBitmap
,
223 MetaActionType::BMP
);
225 MetaAction
* pAction
= aMtf
.GetAction(0);
226 CPPUNIT_ASSERT_EQUAL(MetaActionType::PUSH
, pAction
->GetType());
227 auto pPushAction
= static_cast<MetaPushAction
*>(pAction
);
229 = ((vcl::PushFlags::LINECOLOR
| vcl::PushFlags::FILLCOLOR
) == pPushAction
->GetFlags());
230 CPPUNIT_ASSERT_MESSAGE("Push flags not LINECOLOR | FILLCOLOR", bLineFillFlag
);
232 pAction
= aMtf
.GetAction(1);
233 CPPUNIT_ASSERT_EQUAL(MetaActionType::LINECOLOR
, pAction
->GetType());
234 auto pLineColorAction
= static_cast<MetaLineColorAction
*>(pAction
);
235 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, pLineColorAction
->GetColor());
237 pAction
= aMtf
.GetAction(2);
238 CPPUNIT_ASSERT_EQUAL(MetaActionType::FILLCOLOR
, pAction
->GetType());
239 auto pFillColorAction
= static_cast<MetaFillColorAction
*>(pAction
);
240 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, pFillColorAction
->GetColor());
242 pAction
= aMtf
.GetAction(3);
243 CPPUNIT_ASSERT_EQUAL(MetaActionType::RECT
, pAction
->GetType());
244 auto pRectAction
= static_cast<MetaRectAction
*>(pAction
);
245 CPPUNIT_ASSERT_EQUAL(tools::Rectangle(Point(0, 0), Size(10, 10)), pRectAction
->GetRect());
247 pAction
= aMtf
.GetAction(4);
248 CPPUNIT_ASSERT_EQUAL(MetaActionType::POP
, pAction
->GetType());
250 // test to see if the color is white
251 Bitmap
aWhiteBmp(pVDev
->GetBitmap(Point(0, 0), Size(10, 10)));
252 BitmapScopedReadAccess
pReadAccess(aWhiteBmp
);
253 const BitmapColor aColor
= pReadAccess
->GetColor(0, 0);
254 CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_WHITE
), aColor
);
257 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawBitmap
)
259 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
260 Bitmap
aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP
);
263 aMtf
.Record(pVDev
.get());
265 pVDev
->DrawBitmap(Point(0, 0), Size(10, 10), Point(0, 0), Size(10, 10), aBitmap
,
266 MetaActionType::BMP
);
268 MetaAction
* pAction
= aMtf
.GetAction(0);
269 CPPUNIT_ASSERT_EQUAL(MetaActionType::BMP
, pAction
->GetType());
270 auto pBmpAction
= static_cast<MetaBmpAction
*>(pAction
);
271 CPPUNIT_ASSERT_EQUAL(Size(16, 16), pBmpAction
->GetBitmap().GetSizePixel());
272 CPPUNIT_ASSERT_EQUAL(Point(0, 0), pBmpAction
->GetPoint());
275 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawScaleBitmap
)
277 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
278 Bitmap
aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP
);
281 aMtf
.Record(pVDev
.get());
283 pVDev
->DrawBitmap(Point(5, 5), Size(10, 10), Point(0, 0), Size(10, 10), aBitmap
,
284 MetaActionType::BMPSCALE
);
286 MetaAction
* pAction
= aMtf
.GetAction(0);
287 CPPUNIT_ASSERT_EQUAL(MetaActionType::BMPSCALE
, pAction
->GetType());
288 auto pBmpScaleAction
= static_cast<MetaBmpScaleAction
*>(pAction
);
289 CPPUNIT_ASSERT_EQUAL(Size(16, 16), pBmpScaleAction
->GetBitmap().GetSizePixel());
290 CPPUNIT_ASSERT_EQUAL(Point(5, 5), pBmpScaleAction
->GetPoint());
291 CPPUNIT_ASSERT_EQUAL(Size(10, 10), pBmpScaleAction
->GetSize());
294 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawScalePartBitmap
)
296 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
297 Bitmap
aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP
);
300 aMtf
.Record(pVDev
.get());
302 pVDev
->DrawBitmap(Point(0, 0), Size(10, 10), Point(5, 5), Size(10, 10), aBitmap
,
303 MetaActionType::BMPSCALEPART
);
305 MetaAction
* pAction
= aMtf
.GetAction(0);
306 CPPUNIT_ASSERT_EQUAL(MetaActionType::BMPSCALEPART
, pAction
->GetType());
307 auto pBmpScalePartAction
= static_cast<MetaBmpScalePartAction
*>(pAction
);
308 CPPUNIT_ASSERT_EQUAL(Size(16, 16), pBmpScalePartAction
->GetBitmap().GetSizePixel());
309 CPPUNIT_ASSERT_EQUAL(Point(5, 5), pBmpScalePartAction
->GetSrcPoint());
310 CPPUNIT_ASSERT_EQUAL(Size(10, 10), pBmpScalePartAction
->GetSrcSize());
311 CPPUNIT_ASSERT_EQUAL(Point(0, 0), pBmpScalePartAction
->GetDestPoint());
312 CPPUNIT_ASSERT_EQUAL(Size(10, 10), pBmpScalePartAction
->GetDestSize());
315 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawGrayBitmap
)
317 // draw a red 1x1 bitmap
318 Bitmap
aBmp(Size(1, 1), vcl::PixelFormat::N24_BPP
);
321 // check to ensure that the bitmap is red
323 BitmapScopedReadAccess
pReadAccess(aBmp
);
324 const BitmapColor aColor
= pReadAccess
->GetColor(0, 0);
325 CPPUNIT_ASSERT_EQUAL(BitmapColor(COL_RED
), aColor
);
328 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
330 pVDev
->SetDrawMode(DrawModeFlags::GrayBitmap
);
331 pVDev
->DrawBitmap(Point(0, 0), Size(1, 1), Point(0, 0), Size(1, 1), aBmp
, MetaActionType::BMP
);
334 Bitmap
aVDevBmp(pVDev
->GetBitmap(Point(), Size(1, 1)));
336 BitmapScopedReadAccess
pReadAccess(aVDevBmp
);
337 const BitmapColor aColor
= pReadAccess
->GetColor(0, 0);
338 CPPUNIT_ASSERT_EQUAL(BitmapColor(0x26, 0x26, 0x26), aColor
);
342 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawTransformedBitmapEx
)
344 // Create a virtual device, and connect a metafile to it.
345 // Also create a 16x16 bitmap.
346 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
347 Bitmap
aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP
);
349 // Fill the top left quarter with black.
350 BitmapScopedWriteAccess
pWriteAccess(aBitmap
);
351 pWriteAccess
->Erase(COL_WHITE
);
352 for (int i
= 0; i
< 8; ++i
)
354 for (int j
= 0; j
< 8; ++j
)
356 pWriteAccess
->SetPixel(j
, i
, COL_BLACK
);
360 BitmapEx
aBitmapEx(aBitmap
);
361 basegfx::B2DHomMatrix aMatrix
;
363 // Rotate 90 degrees clockwise, so the black part goes to the top right.
364 aMatrix
.rotate(M_PI
/ 2);
366 aMtf
.Record(pVDev
.get());
368 // Draw the rotated bitmap on the vdev.
369 pVDev
->DrawTransformedBitmapEx(aMatrix
, aBitmapEx
);
370 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aMtf
.GetActionSize());
371 MetaAction
* pAction
= aMtf
.GetAction(0);
372 CPPUNIT_ASSERT_EQUAL(MetaActionType::BMPEXSCALE
, pAction
->GetType());
373 auto pBitmapAction
= static_cast<MetaBmpExScaleAction
*>(pAction
);
374 const BitmapEx
& rBitmapEx
= pBitmapAction
->GetBitmapEx();
375 Size aTransformedSize
= rBitmapEx
.GetSizePixel();
376 // Without the accompanying fix in place, this test would have failed with:
379 // I.e. the bitmap before scaling was already scaled down, just because it was rotated.
380 CPPUNIT_ASSERT_EQUAL(Size(16, 16), aTransformedSize
);
382 aBitmap
= rBitmapEx
.GetBitmap();
383 BitmapScopedReadAccess
pAccess(aBitmap
);
384 for (int i
= 0; i
< 16; ++i
)
386 for (int j
= 0; j
< 16; ++j
)
388 BitmapColor aColor
= pAccess
->GetPixel(j
, i
);
389 Color aExpected
= i
>= 8 && j
< 8 ? COL_BLACK
: COL_WHITE
;
390 std::stringstream ss
;
391 ss
<< "Color is expected to be ";
392 ss
<< ((aExpected
== COL_WHITE
) ? "white" : "black");
393 ss
<< ", is " << aColor
.AsRGBHexString();
394 ss
<< " (row " << j
<< ", col " << i
<< ")";
395 // Without the accompanying fix in place, this test would have failed with:
396 // - Expected: c[00000000]
397 // - Actual : c[ffffff00]
398 // - Color is expected to be black, is ffffff (row 0, col 8)
399 // i.e. the top right quarter of the image was not fully black, there was a white first
401 CPPUNIT_ASSERT_EQUAL_MESSAGE(ss
.str(), aExpected
, Color(aColor
));
406 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawTransformedBitmapExFlip
)
408 // Create a virtual device, and connect a metafile to it.
409 // Also create a 16x16 bitmap.
410 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
411 Bitmap
aBitmap(Size(16, 16), vcl::PixelFormat::N24_BPP
);
413 // Fill the top left quarter with black.
414 BitmapScopedWriteAccess
pWriteAccess(aBitmap
);
415 pWriteAccess
->Erase(COL_WHITE
);
416 for (int i
= 0; i
< 8; ++i
)
418 for (int j
= 0; j
< 8; ++j
)
420 pWriteAccess
->SetPixel(j
, i
, COL_BLACK
);
424 BitmapEx
aBitmapEx(aBitmap
);
425 basegfx::B2DHomMatrix aMatrix
;
426 // Negative y scale: bitmap should be upside down, so the black part goes to the bottom left.
427 aMatrix
.scale(8, -8);
428 // Rotate 90 degrees clockwise, so the black part goes back to the top left.
429 aMatrix
.rotate(M_PI
/ 2);
431 aMtf
.Record(pVDev
.get());
433 // Draw the scaled and rotated bitmap on the vdev.
434 pVDev
->DrawTransformedBitmapEx(aMatrix
, aBitmapEx
);
435 CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aMtf
.GetActionSize());
436 MetaAction
* pAction
= aMtf
.GetAction(0);
437 CPPUNIT_ASSERT_EQUAL(MetaActionType::BMPEXSCALE
, pAction
->GetType());
438 auto pBitmapAction
= static_cast<MetaBmpExScaleAction
*>(pAction
);
439 const BitmapEx
& rBitmapEx
= pBitmapAction
->GetBitmapEx();
441 aBitmap
= rBitmapEx
.GetBitmap();
442 BitmapScopedReadAccess
pAccess(aBitmap
);
445 BitmapColor aColor
= pAccess
->GetPixel(nY
, nX
);
446 std::stringstream ss
;
447 ss
<< "Color is expected to be black, is " << aColor
.AsRGBHexString();
448 ss
<< " (row " << nY
<< ", col " << nX
<< ")";
449 // Without the accompanying fix in place, this test would have failed with:
450 // - Expected: c[00000000]
451 // - Actual : c[ffffff00]
452 // - Color is expected to be black, is ffffff (row 2, col 2)
453 // i.e. the top left quarter of the image was not black, due to a missing flip.
454 CPPUNIT_ASSERT_EQUAL_MESSAGE(ss
.str(), COL_BLACK
, Color(aColor
));
457 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testRTL
)
459 ScopedVclPtrInstance
<vcl::Window
> pWindow(nullptr, WB_APP
| WB_STDWORK
);
460 pWindow
->EnableRTL();
461 vcl::RenderContext
& rRenderContext
= *pWindow
->GetOutDev();
462 vcl::BufferDevice
pBuffer(pWindow
, rRenderContext
);
464 // Without the accompanying fix in place, this test would have failed, because the RTL status
465 // from pWindow was not propagated to pBuffer.
466 CPPUNIT_ASSERT(pBuffer
->IsRTLEnabled());
469 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testRTLGuard
)
471 ScopedVclPtrInstance
<vcl::Window
> pWindow(nullptr, WB_APP
| WB_STDWORK
);
472 pWindow
->EnableRTL();
473 pWindow
->RequestDoubleBuffering(true);
474 ImplFrameData
* pFrameData
= pWindow
->ImplGetWindowImpl()->mpFrameData
;
475 vcl::PaintBufferGuard
aGuard(pFrameData
, pWindow
);
476 // Without the accompanying fix in place, this test would have failed, because the RTL status
477 // from pWindow was not propagated to aGuard.
478 CPPUNIT_ASSERT(aGuard
.GetRenderContext()->IsRTLEnabled());
481 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDefaultFillColor
)
483 // Create a virtual device, and connect a metafile to it.
484 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
487 aMtf
.Record(pVDev
.get());
489 CPPUNIT_ASSERT(pVDev
->IsFillColor());
490 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, pVDev
->GetFillColor());
492 pVDev
->SetFillColor();
493 CPPUNIT_ASSERT(!pVDev
->IsFillColor());
494 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT
, pVDev
->GetFillColor());
495 MetaAction
* pAction
= aMtf
.GetAction(0);
496 CPPUNIT_ASSERT_EQUAL(MetaActionType::FILLCOLOR
, pAction
->GetType());
497 auto pFillAction
= static_cast<MetaFillColorAction
*>(pAction
);
498 const Color
& rColor
= pFillAction
->GetColor();
499 CPPUNIT_ASSERT_EQUAL(Color(), rColor
);
502 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testTransparentFillColor
)
504 // Create a virtual device, and connect a metafile to it.
505 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
508 aMtf
.Record(pVDev
.get());
510 CPPUNIT_ASSERT(pVDev
->IsFillColor());
511 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, pVDev
->GetFillColor());
513 pVDev
->SetFillColor(COL_TRANSPARENT
);
514 CPPUNIT_ASSERT(!pVDev
->IsFillColor());
515 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT
, pVDev
->GetFillColor());
516 MetaAction
* pAction
= aMtf
.GetAction(0);
517 CPPUNIT_ASSERT_EQUAL(MetaActionType::FILLCOLOR
, pAction
->GetType());
518 auto pFillAction
= static_cast<MetaFillColorAction
*>(pAction
);
519 const Color
& rColor
= pFillAction
->GetColor();
520 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT
, rColor
);
523 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testFillColor
)
525 // Create a virtual device, and connect a metafile to it.
526 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
529 aMtf
.Record(pVDev
.get());
531 CPPUNIT_ASSERT(pVDev
->IsFillColor());
532 CPPUNIT_ASSERT_EQUAL(COL_WHITE
, pVDev
->GetFillColor());
534 pVDev
->SetFillColor(COL_RED
);
535 CPPUNIT_ASSERT(pVDev
->IsFillColor());
536 CPPUNIT_ASSERT_EQUAL(COL_RED
, pVDev
->GetFillColor());
537 MetaAction
* pAction
= aMtf
.GetAction(0);
538 CPPUNIT_ASSERT_EQUAL(MetaActionType::FILLCOLOR
, pAction
->GetType());
539 auto pFillAction
= static_cast<MetaFillColorAction
*>(pAction
);
540 const Color
& rColor
= pFillAction
->GetColor();
541 CPPUNIT_ASSERT_EQUAL(COL_RED
, rColor
);
544 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDefaultLineColor
)
546 // Create a virtual device, and connect a metafile to it.
547 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
550 aMtf
.Record(pVDev
.get());
552 CPPUNIT_ASSERT(pVDev
->IsLineColor());
553 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, pVDev
->GetLineColor());
555 pVDev
->SetLineColor();
556 CPPUNIT_ASSERT(!pVDev
->IsLineColor());
557 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT
, pVDev
->GetLineColor());
558 MetaAction
* pAction
= aMtf
.GetAction(0);
559 CPPUNIT_ASSERT_EQUAL(MetaActionType::LINECOLOR
, pAction
->GetType());
560 auto pLineAction
= static_cast<MetaLineColorAction
*>(pAction
);
561 const Color
& rColor
= pLineAction
->GetColor();
562 CPPUNIT_ASSERT_EQUAL(Color(), rColor
);
565 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testTransparentLineColor
)
567 // Create a virtual device, and connect a metafile to it.
568 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
571 aMtf
.Record(pVDev
.get());
573 CPPUNIT_ASSERT(pVDev
->IsLineColor());
574 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, pVDev
->GetLineColor());
576 pVDev
->SetLineColor(COL_TRANSPARENT
);
577 CPPUNIT_ASSERT(!pVDev
->IsLineColor());
578 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT
, pVDev
->GetLineColor());
579 MetaAction
* pAction
= aMtf
.GetAction(0);
580 CPPUNIT_ASSERT_EQUAL(MetaActionType::LINECOLOR
, pAction
->GetType());
581 auto pLineAction
= static_cast<MetaLineColorAction
*>(pAction
);
582 const Color
& rColor
= pLineAction
->GetColor();
583 CPPUNIT_ASSERT_EQUAL(COL_TRANSPARENT
, rColor
);
586 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testLineColor
)
588 // Create a virtual device, and connect a metafile to it.
589 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
592 aMtf
.Record(pVDev
.get());
594 CPPUNIT_ASSERT(pVDev
->IsLineColor());
595 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, pVDev
->GetLineColor());
597 pVDev
->SetLineColor(COL_RED
);
598 CPPUNIT_ASSERT(pVDev
->IsLineColor());
599 CPPUNIT_ASSERT_EQUAL(COL_RED
, pVDev
->GetLineColor());
600 MetaAction
* pAction
= aMtf
.GetAction(0);
601 CPPUNIT_ASSERT_EQUAL(MetaActionType::LINECOLOR
, pAction
->GetType());
602 auto pLineAction
= static_cast<MetaLineColorAction
*>(pAction
);
603 const Color
& rColor
= pLineAction
->GetColor();
604 CPPUNIT_ASSERT_EQUAL(COL_RED
, rColor
);
607 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testFont
)
609 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
611 // Use Dejavu fonts, they are shipped with LO, so they should be ~always available.
612 // Use Sans variant for simpler glyph shapes (no serifs).
613 vcl::Font
font(u
"DejaVu Sans"_ustr
, u
"Book"_ustr
, Size(0, 36));
614 font
.SetColor(COL_BLACK
);
615 font
.SetFillColor(COL_RED
);
618 aMtf
.Record(pVDev
.get());
620 pVDev
->SetFont(font
);
621 bool bSameFont(font
== pVDev
->GetFont());
622 CPPUNIT_ASSERT_MESSAGE("Font is not the same", bSameFont
);
626 // 2. Text alignment action
627 // 3. Text fill color action
628 // 4. As not COL_TRANSPARENT (means use system font color), font color action
629 size_t nActionsExpected
= 4;
630 CPPUNIT_ASSERT_EQUAL(nActionsExpected
, aMtf
.GetActionSize());
632 MetaAction
* pAction
= aMtf
.GetAction(0);
633 CPPUNIT_ASSERT_EQUAL(MetaActionType::FONT
, pAction
->GetType());
634 auto pFontAction
= static_cast<MetaFontAction
*>(pAction
);
635 bool bSameMetaFont
= (font
== pFontAction
->GetFont());
636 CPPUNIT_ASSERT_MESSAGE("Metafile font is not the same", bSameMetaFont
);
638 pAction
= aMtf
.GetAction(1);
639 CPPUNIT_ASSERT_EQUAL(MetaActionType::TEXTALIGN
, pAction
->GetType());
640 auto pTextAlignAction
= static_cast<MetaTextAlignAction
*>(pAction
);
641 CPPUNIT_ASSERT_EQUAL(font
.GetAlignment(), pTextAlignAction
->GetTextAlign());
643 pAction
= aMtf
.GetAction(2);
644 CPPUNIT_ASSERT_EQUAL(MetaActionType::TEXTFILLCOLOR
, pAction
->GetType());
645 auto pTextFillColorAction
= static_cast<MetaTextFillColorAction
*>(pAction
);
646 CPPUNIT_ASSERT_EQUAL(COL_RED
, pTextFillColorAction
->GetColor());
648 pAction
= aMtf
.GetAction(3);
649 CPPUNIT_ASSERT_EQUAL(MetaActionType::TEXTCOLOR
, pAction
->GetType());
650 auto pTextColorAction
= static_cast<MetaTextColorAction
*>(pAction
);
651 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, pTextColorAction
->GetColor());
654 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testTransparentFont
)
656 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
658 // Use Dejavu fonts, they are shipped with LO, so they should be ~always available.
659 // Use Sans variant for simpler glyph shapes (no serifs).
660 vcl::Font
font(u
"DejaVu Sans"_ustr
, u
"Book"_ustr
, Size(0, 36));
661 font
.SetColor(COL_TRANSPARENT
);
664 aMtf
.Record(pVDev
.get());
666 pVDev
->SetFont(font
);
668 // three actions as it sets the colour to the default system color (and doesn't add a text color action):
670 // 2. Text alignment action
671 // 3. Text fill color action
672 size_t nActionsExpected
= 3;
673 CPPUNIT_ASSERT_EQUAL(nActionsExpected
, aMtf
.GetActionSize());
676 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDefaultRefPoint
)
678 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
681 aMtf
.Record(pVDev
.get());
683 pVDev
->SetRefPoint();
685 CPPUNIT_ASSERT(!pVDev
->IsRefPoint());
686 CPPUNIT_ASSERT_EQUAL(Point(), pVDev
->GetRefPoint());
688 MetaAction
* pAction
= aMtf
.GetAction(0);
689 CPPUNIT_ASSERT_EQUAL(MetaActionType::REFPOINT
, pAction
->GetType());
690 auto pRefPointAction
= static_cast<MetaRefPointAction
*>(pAction
);
691 CPPUNIT_ASSERT_EQUAL(Point(), pRefPointAction
->GetRefPoint());
694 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testRefPoint
)
696 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
699 aMtf
.Record(pVDev
.get());
701 pVDev
->SetRefPoint(Point(10, 20));
703 CPPUNIT_ASSERT(pVDev
->IsRefPoint());
704 CPPUNIT_ASSERT_EQUAL(Point(10, 20), pVDev
->GetRefPoint());
706 MetaAction
* pAction
= aMtf
.GetAction(0);
707 CPPUNIT_ASSERT_EQUAL(MetaActionType::REFPOINT
, pAction
->GetType());
708 auto pRefPointAction
= static_cast<MetaRefPointAction
*>(pAction
);
709 CPPUNIT_ASSERT_EQUAL(Point(10, 20), pRefPointAction
->GetRefPoint());
712 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testRasterOp
)
714 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
717 aMtf
.Record(pVDev
.get());
719 pVDev
->SetRasterOp(RasterOp::Invert
);
721 CPPUNIT_ASSERT_EQUAL(RasterOp::Invert
, pVDev
->GetRasterOp());
722 CPPUNIT_ASSERT(pVDev
->IsLineColor());
723 CPPUNIT_ASSERT(pVDev
->IsFillColor());
725 MetaAction
* pAction
= aMtf
.GetAction(0);
726 CPPUNIT_ASSERT_EQUAL(MetaActionType::RASTEROP
, pAction
->GetType());
727 auto pRasterOpAction
= static_cast<MetaRasterOpAction
*>(pAction
);
728 CPPUNIT_ASSERT_EQUAL(RasterOp::Invert
, pRasterOpAction
->GetRasterOp());
731 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testOutputFlag
)
733 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
735 CPPUNIT_ASSERT(pVDev
->IsOutputEnabled());
736 CPPUNIT_ASSERT(pVDev
->IsDeviceOutputNecessary());
738 pVDev
->EnableOutput(false);
740 CPPUNIT_ASSERT(!pVDev
->IsOutputEnabled());
741 CPPUNIT_ASSERT(!pVDev
->IsDeviceOutputNecessary());
744 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testAntialias
)
746 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
748 CPPUNIT_ASSERT_EQUAL(AntialiasingFlags::NONE
, pVDev
->GetAntialiasing());
750 pVDev
->SetAntialiasing(AntialiasingFlags::Enable
);
752 CPPUNIT_ASSERT_EQUAL(AntialiasingFlags::Enable
, pVDev
->GetAntialiasing());
755 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawMode
)
757 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
759 CPPUNIT_ASSERT_EQUAL(DrawModeFlags::Default
, pVDev
->GetDrawMode());
761 pVDev
->SetDrawMode(DrawModeFlags::BlackLine
);
763 CPPUNIT_ASSERT_EQUAL(DrawModeFlags::BlackLine
, pVDev
->GetDrawMode());
766 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testLayoutMode
)
768 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
771 aMtf
.Record(pVDev
.get());
773 CPPUNIT_ASSERT_EQUAL(vcl::text::ComplexTextLayoutFlags::Default
, pVDev
->GetLayoutMode());
775 pVDev
->SetLayoutMode(vcl::text::ComplexTextLayoutFlags::BiDiRtl
);
777 CPPUNIT_ASSERT_EQUAL(vcl::text::ComplexTextLayoutFlags::BiDiRtl
, pVDev
->GetLayoutMode());
779 MetaAction
* pAction
= aMtf
.GetAction(0);
780 CPPUNIT_ASSERT_EQUAL(MetaActionType::LAYOUTMODE
, pAction
->GetType());
781 auto pLayoutModeAction
= static_cast<MetaLayoutModeAction
*>(pAction
);
782 CPPUNIT_ASSERT_EQUAL(vcl::text::ComplexTextLayoutFlags::BiDiRtl
,
783 pLayoutModeAction
->GetLayoutMode());
786 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDigitLanguage
)
788 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
791 aMtf
.Record(pVDev
.get());
793 CPPUNIT_ASSERT_EQUAL(LANGUAGE_SYSTEM
, pVDev
->GetDigitLanguage());
795 pVDev
->SetDigitLanguage(LANGUAGE_GERMAN
);
797 CPPUNIT_ASSERT_EQUAL(LANGUAGE_GERMAN
, pVDev
->GetDigitLanguage());
799 MetaAction
* pAction
= aMtf
.GetAction(0);
800 CPPUNIT_ASSERT_EQUAL(MetaActionType::TEXTLANGUAGE
, pAction
->GetType());
801 auto pTextLanguageAction
= static_cast<MetaTextLanguageAction
*>(pAction
);
802 CPPUNIT_ASSERT_EQUAL(LANGUAGE_GERMAN
, pTextLanguageAction
->GetTextLanguage());
805 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testStackFunctions
)
807 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
809 aMtf
.Record(pVDev
.get());
812 MetaAction
* pAction
= aMtf
.GetAction(0);
813 CPPUNIT_ASSERT_EQUAL_MESSAGE("Push action", MetaActionType::PUSH
, pAction
->GetType());
815 pVDev
->SetLineColor(COL_RED
);
816 pVDev
->SetFillColor(COL_GREEN
);
817 pVDev
->SetTextColor(COL_BROWN
);
818 pVDev
->SetTextFillColor(COL_BLUE
);
819 pVDev
->SetTextLineColor(COL_MAGENTA
);
820 pVDev
->SetOverlineColor(COL_YELLOW
);
821 pVDev
->SetTextAlign(TextAlign::ALIGN_TOP
);
822 pVDev
->SetLayoutMode(vcl::text::ComplexTextLayoutFlags::BiDiRtl
);
823 pVDev
->SetDigitLanguage(LANGUAGE_FRENCH
);
824 pVDev
->SetRasterOp(RasterOp::N0
);
825 pVDev
->SetMapMode(MapMode(MapUnit::MapTwip
));
826 pVDev
->SetRefPoint(Point(10, 10));
828 CPPUNIT_ASSERT_EQUAL_MESSAGE("Text color", COL_BROWN
, pVDev
->GetTextColor());
829 CPPUNIT_ASSERT_EQUAL_MESSAGE("Text fill color", COL_BLUE
, pVDev
->GetTextFillColor());
830 CPPUNIT_ASSERT_EQUAL_MESSAGE("Text line color", COL_MAGENTA
, pVDev
->GetTextLineColor());
831 CPPUNIT_ASSERT_EQUAL_MESSAGE("Text overline color", COL_YELLOW
, pVDev
->GetOverlineColor());
832 CPPUNIT_ASSERT_EQUAL_MESSAGE("Layout mode", vcl::text::ComplexTextLayoutFlags::BiDiRtl
,
833 pVDev
->GetLayoutMode());
834 CPPUNIT_ASSERT_EQUAL_MESSAGE("Language", LANGUAGE_FRENCH
, pVDev
->GetDigitLanguage());
835 CPPUNIT_ASSERT_EQUAL_MESSAGE("Raster operation", RasterOp::N0
, pVDev
->GetRasterOp());
836 CPPUNIT_ASSERT_EQUAL_MESSAGE("Map mode", MapMode(MapUnit::MapTwip
), pVDev
->GetMapMode());
837 CPPUNIT_ASSERT_EQUAL_MESSAGE("Ref point", Point(10, 10), pVDev
->GetRefPoint());
840 pAction
= aMtf
.GetAction(13);
841 CPPUNIT_ASSERT_EQUAL_MESSAGE("Pop action", MetaActionType::POP
, pAction
->GetType());
843 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default line color", COL_BLACK
, pVDev
->GetLineColor());
844 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default fill color", COL_WHITE
, pVDev
->GetFillColor());
845 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default text color", COL_BLACK
, pVDev
->GetTextColor());
846 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default text fill color", Color(ColorTransparency
, 0xFFFFFFFF),
847 pVDev
->GetTextFillColor());
848 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default text line color", Color(ColorTransparency
, 0xFFFFFFFF),
849 pVDev
->GetTextLineColor());
850 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default overline color", Color(ColorTransparency
, 0xFFFFFFFF),
851 pVDev
->GetOverlineColor());
852 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default layout mode", vcl::text::ComplexTextLayoutFlags::Default
,
853 pVDev
->GetLayoutMode());
854 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default language", LANGUAGE_SYSTEM
, pVDev
->GetDigitLanguage());
855 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default raster operation", RasterOp::OverPaint
,
856 pVDev
->GetRasterOp());
857 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default map mode", MapMode(MapUnit::MapPixel
),
858 pVDev
->GetMapMode());
859 CPPUNIT_ASSERT_EQUAL_MESSAGE("Default ref point", Point(0, 0), pVDev
->GetRefPoint());
862 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testSystemTextColor
)
865 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
867 pVDev
->SetSystemTextColor(SystemTextColorFlags::NONE
, true);
868 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, pVDev
->GetTextColor());
869 pVDev
->SetSystemTextColor(SystemTextColorFlags::Mono
, false);
870 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, pVDev
->GetTextColor());
874 ScopedVclPtrInstance
<Printer
> pPrinter
;
875 pPrinter
->SetSystemTextColor(SystemTextColorFlags::NONE
, true);
876 CPPUNIT_ASSERT_EQUAL(COL_BLACK
, pPrinter
->GetTextColor());
882 class WaveLineTester
: public OutputDevice
886 : OutputDevice(OUTDEV_VIRDEV
)
890 bool AcquireGraphics() const { return true; }
891 void ReleaseGraphics(bool) {}
892 bool UsePolyPolygonForComplexGradient() { return false; }
894 bool testShouldDrawWavePixelAsRect(tools::Long nLineWidth
)
896 return shouldDrawWavePixelAsRect(nLineWidth
);
899 Size
testGetWaveLineSize(tools::Long nLineWidth
) { return GetWaveLineSize(nLineWidth
); }
902 class WaveLineTesterPrinter
: public Printer
905 WaveLineTesterPrinter() {}
907 bool AcquireGraphics() const { return true; }
908 void ReleaseGraphics(bool) {}
909 bool UsePolyPolygonForComplexGradient() { return false; }
911 Size
testGetWaveLineSize(tools::Long nLineWidth
) { return GetWaveLineSize(nLineWidth
); }
915 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testShouldDrawWavePixelAsRect
)
917 ScopedVclPtrInstance
<WaveLineTester
> pTestOutDev
;
919 CPPUNIT_ASSERT(!pTestOutDev
->testShouldDrawWavePixelAsRect(0));
920 CPPUNIT_ASSERT(!pTestOutDev
->testShouldDrawWavePixelAsRect(1));
922 CPPUNIT_ASSERT(pTestOutDev
->testShouldDrawWavePixelAsRect(10));
925 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testGetWaveLineSize
)
928 ScopedVclPtrInstance
<WaveLineTester
> pTestOutDev
;
930 pTestOutDev
->SetDPIX(96);
931 pTestOutDev
->SetDPIY(96);
933 CPPUNIT_ASSERT_EQUAL(Size(1, 1), pTestOutDev
->testGetWaveLineSize(0));
934 CPPUNIT_ASSERT_EQUAL(Size(1, 1), pTestOutDev
->testGetWaveLineSize(1));
936 CPPUNIT_ASSERT_EQUAL(Size(10, 10), pTestOutDev
->testGetWaveLineSize(10));
940 ScopedVclPtrInstance
<WaveLineTesterPrinter
> pTestOutDev
;
942 pTestOutDev
->SetDPIX(96);
943 pTestOutDev
->SetDPIY(96);
945 CPPUNIT_ASSERT_EQUAL(Size(0, 0), pTestOutDev
->testGetWaveLineSize(0));
946 CPPUNIT_ASSERT_EQUAL(Size(1, 1), pTestOutDev
->testGetWaveLineSize(1));
948 CPPUNIT_ASSERT_EQUAL(Size(10, 10), pTestOutDev
->testGetWaveLineSize(10));
952 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testErase
)
954 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
956 aMtf
.Record(pVDev
.get());
958 // this actually triggers Erase()
959 pVDev
->SetOutputSizePixel(Size(10, 10));
962 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
963 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line color action (start)", MetaActionType::LINECOLOR
,
966 pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
+ 1);
967 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action (start)", MetaActionType::FILLCOLOR
,
970 pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
+ 2);
971 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rect action", MetaActionType::RECT
, pAction
->GetType());
973 pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
+ 3);
974 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line color action (end)", MetaActionType::LINECOLOR
,
977 pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
+ 4);
978 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action (end)", MetaActionType::FILLCOLOR
,
982 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawPixel
)
985 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
987 aMtf
.Record(pVDev
.get());
989 // triggers an Erase()
990 pVDev
->SetOutputSizePixel(Size(10, 10));
991 pVDev
->SetLineColor(COL_RED
);
992 pVDev
->DrawPixel(Point(0, 0), COL_GREEN
);
994 CPPUNIT_ASSERT_EQUAL_MESSAGE("Color not green", COL_GREEN
, pVDev
->GetPixel(Point(0, 0)));
996 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
+ 1);
997 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a pixel action", MetaActionType::PIXEL
,
999 MetaPixelAction
* pPixelAction
= dynamic_cast<MetaPixelAction
*>(pAction
);
1000 CPPUNIT_ASSERT_EQUAL_MESSAGE("Pixel action has incorrect position", Point(0, 0),
1001 pPixelAction
->GetPoint());
1002 CPPUNIT_ASSERT_EQUAL_MESSAGE("Pixel action is wrong color", COL_GREEN
,
1003 pPixelAction
->GetColor());
1007 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1009 aMtf
.Record(pVDev
.get());
1011 pVDev
->SetOutputSizePixel(Size(1, 1));
1012 pVDev
->SetLineColor(COL_RED
);
1013 pVDev
->DrawPixel(Point(0, 0));
1015 CPPUNIT_ASSERT_EQUAL_MESSAGE("Color not red", COL_RED
, pVDev
->GetPixel(Point(0, 0)));
1017 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
+ 1);
1018 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a point action", MetaActionType::POINT
,
1019 pAction
->GetType());
1020 MetaPointAction
* pPointAction
= dynamic_cast<MetaPointAction
*>(pAction
);
1021 CPPUNIT_ASSERT_EQUAL_MESSAGE("Pixel action has incorrect position", Point(0, 0),
1022 pPointAction
->GetPoint());
1026 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawLine
)
1029 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1031 aMtf
.Record(pVDev
.get());
1033 pVDev
->SetOutputSizePixel(Size(10, 100));
1034 pVDev
->DrawLine(Point(0, 0), Point(0, 50));
1036 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1037 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line action", MetaActionType::LINE
, pAction
->GetType());
1038 MetaLineAction
* pLineAction
= dynamic_cast<MetaLineAction
*>(pAction
);
1039 CPPUNIT_ASSERT_EQUAL_MESSAGE("Line start has incorrect position", Point(0, 0),
1040 pLineAction
->GetStartPoint());
1041 CPPUNIT_ASSERT_EQUAL_MESSAGE("Line start has incorrect position", Point(0, 50),
1042 pLineAction
->GetEndPoint());
1046 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1048 aMtf
.Record(pVDev
.get());
1050 LineInfo
aLineInfo(LineStyle::Dash
, 10);
1051 aLineInfo
.SetDashCount(5);
1052 aLineInfo
.SetDashLen(10);
1053 aLineInfo
.SetDotCount(3);
1054 aLineInfo
.SetDotLen(13);
1055 aLineInfo
.SetDistance(8);
1056 aLineInfo
.SetLineJoin(basegfx::B2DLineJoin::Bevel
);
1057 aLineInfo
.SetLineCap(css::drawing::LineCap_BUTT
);
1059 pVDev
->SetOutputSizePixel(Size(100, 100));
1060 pVDev
->DrawLine(Point(0, 0), Point(0, 50), aLineInfo
);
1062 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1063 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line action", MetaActionType::LINE
, pAction
->GetType());
1064 MetaLineAction
* pLineAction
= dynamic_cast<MetaLineAction
*>(pAction
);
1065 CPPUNIT_ASSERT_EQUAL_MESSAGE("Line start has incorrect position", Point(0, 0),
1066 pLineAction
->GetStartPoint());
1067 CPPUNIT_ASSERT_EQUAL_MESSAGE("Line start has incorrect position", Point(0, 50),
1068 pLineAction
->GetEndPoint());
1069 CPPUNIT_ASSERT_EQUAL_MESSAGE("Dash count wrong", static_cast<sal_uInt16
>(5),
1070 pLineAction
->GetLineInfo().GetDashCount());
1071 CPPUNIT_ASSERT_EQUAL_MESSAGE("Dash len wrong", static_cast<double>(10),
1072 pLineAction
->GetLineInfo().GetDashLen());
1073 CPPUNIT_ASSERT_EQUAL_MESSAGE("Dot count wrong", static_cast<sal_uInt16
>(3),
1074 pLineAction
->GetLineInfo().GetDotCount());
1075 CPPUNIT_ASSERT_EQUAL_MESSAGE("Dot len wrong", static_cast<double>(13),
1076 pLineAction
->GetLineInfo().GetDotLen());
1077 CPPUNIT_ASSERT_EQUAL_MESSAGE("Distance wrong", static_cast<double>(8),
1078 pLineAction
->GetLineInfo().GetDistance());
1079 CPPUNIT_ASSERT_EQUAL_MESSAGE("Line join", basegfx::B2DLineJoin::Bevel
,
1080 pLineAction
->GetLineInfo().GetLineJoin());
1081 CPPUNIT_ASSERT_EQUAL_MESSAGE("Line cap", css::drawing::LineCap_BUTT
,
1082 pLineAction
->GetLineInfo().GetLineCap());
1086 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawRect
)
1089 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1091 aMtf
.Record(pVDev
.get());
1093 pVDev
->SetOutputSizePixel(Size(100, 100));
1094 pVDev
->DrawRect(tools::Rectangle(Point(0, 0), Size(50, 60)));
1096 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1097 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rect action", MetaActionType::RECT
, pAction
->GetType());
1098 MetaRectAction
* pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1099 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rectangle wrong", tools::Rectangle(Point(0, 0), Size(50, 60)),
1100 pRectAction
->GetRect());
1104 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1106 aMtf
.Record(pVDev
.get());
1108 pVDev
->SetOutputSizePixel(Size(100, 100));
1109 pVDev
->DrawRect(tools::Rectangle(Point(0, 0), Size(50, 60)), 5, 10);
1111 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1112 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rect action", MetaActionType::ROUNDRECT
,
1113 pAction
->GetType());
1114 MetaRoundRectAction
* pRectAction
= dynamic_cast<MetaRoundRectAction
*>(pAction
);
1115 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rectangle wrong", tools::Rectangle(Point(0, 0), Size(50, 60)),
1116 pRectAction
->GetRect());
1117 CPPUNIT_ASSERT_EQUAL_MESSAGE("Horizontal round rect wrong", static_cast<sal_uInt32
>(5),
1118 pRectAction
->GetHorzRound());
1119 CPPUNIT_ASSERT_EQUAL_MESSAGE("Vertical round rect wrong", static_cast<sal_uInt32
>(10),
1120 pRectAction
->GetVertRound());
1124 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawEllipse
)
1126 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1128 aMtf
.Record(pVDev
.get());
1130 pVDev
->SetOutputSizePixel(Size(100, 100));
1131 pVDev
->DrawEllipse(tools::Rectangle(Point(0, 0), Size(50, 60)));
1133 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1134 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a ellipse action", MetaActionType::ELLIPSE
,
1135 pAction
->GetType());
1136 MetaEllipseAction
* pEllipseAction
= dynamic_cast<MetaEllipseAction
*>(pAction
);
1137 CPPUNIT_ASSERT_EQUAL_MESSAGE("Ellipse rect wrong", tools::Rectangle(Point(0, 0), Size(50, 60)),
1138 pEllipseAction
->GetRect());
1141 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawPie
)
1143 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1145 aMtf
.Record(pVDev
.get());
1147 tools::Rectangle
aRect(Point(0, 0), Size(50, 60));
1149 pVDev
->SetOutputSizePixel(Size(100, 100));
1150 pVDev
->DrawPie(aRect
, aRect
.TopRight(), aRect
.TopCenter());
1152 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1153 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a pie action", MetaActionType::PIE
, pAction
->GetType());
1154 MetaPieAction
* pPieAction
= dynamic_cast<MetaPieAction
*>(pAction
);
1155 CPPUNIT_ASSERT_EQUAL_MESSAGE("Pie rect wrong", aRect
, pPieAction
->GetRect());
1156 CPPUNIT_ASSERT_EQUAL_MESSAGE("Pie start point wrong", aRect
.TopRight(),
1157 pPieAction
->GetStartPoint());
1158 CPPUNIT_ASSERT_EQUAL_MESSAGE("Pie end point wrong", aRect
.TopCenter(),
1159 pPieAction
->GetEndPoint());
1162 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawChord
)
1164 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1166 aMtf
.Record(pVDev
.get());
1168 tools::Rectangle
aRect(Point(21, 22), Size(4, 4));
1169 pVDev
->SetOutputSizePixel(Size(100, 100));
1170 pVDev
->DrawChord(aRect
, Point(30, 31), Point(32, 33));
1172 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1173 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a chord action", MetaActionType::CHORD
, pAction
->GetType());
1174 MetaChordAction
* pChordAction
= dynamic_cast<MetaChordAction
*>(pAction
);
1175 CPPUNIT_ASSERT_EQUAL_MESSAGE("Chord rect wrong", aRect
, pChordAction
->GetRect());
1176 CPPUNIT_ASSERT_EQUAL_MESSAGE("Chord start point wrong", Point(30, 31),
1177 pChordAction
->GetStartPoint());
1178 CPPUNIT_ASSERT_EQUAL_MESSAGE("Chord end point wrong", Point(32, 33),
1179 pChordAction
->GetEndPoint());
1182 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawArc
)
1184 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1186 aMtf
.Record(pVDev
.get());
1188 tools::Rectangle
aRect(Point(1, 2), Size(4, 4));
1190 pVDev
->SetOutputSizePixel(Size(100, 100));
1191 pVDev
->DrawArc(aRect
, Point(10, 11), Point(12, 13));
1193 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1194 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a arc action", MetaActionType::ARC
, pAction
->GetType());
1195 MetaArcAction
* pArcAction
= dynamic_cast<MetaArcAction
*>(pAction
);
1196 CPPUNIT_ASSERT_EQUAL_MESSAGE("Arc rect wrong", aRect
, pArcAction
->GetRect());
1197 CPPUNIT_ASSERT_EQUAL_MESSAGE("Arc start point wrong", Point(10, 11),
1198 pArcAction
->GetStartPoint());
1199 CPPUNIT_ASSERT_EQUAL_MESSAGE("Arc end point wrong", Point(12, 13), pArcAction
->GetEndPoint());
1202 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawCheckered
)
1204 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1206 aMtf
.Record(pVDev
.get());
1208 pVDev
->SetOutputSizePixel(Size(100, 100));
1209 pVDev
->DrawCheckered(Point(0, 0), Size(100, 100), 20, COL_BLACK
, COL_WHITE
);
1211 size_t nIndex
= INITIAL_SETUP_ACTION_COUNT
;
1213 MetaAction
* pAction
= aMtf
.GetAction(nIndex
);
1214 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not push action", MetaActionType::PUSH
, pAction
->GetType());
1217 pAction
= aMtf
.GetAction(nIndex
);
1218 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line color", MetaActionType::LINECOLOR
, pAction
->GetType());
1222 pAction
= aMtf
.GetAction(nIndex
);
1223 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 1, rect 1",
1224 MetaActionType::FILLCOLOR
, pAction
->GetType());
1225 MetaFillColorAction
* pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1226 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 1, rect 1", COL_WHITE
,
1227 pFillColorAction
->GetColor());
1230 pAction
= aMtf
.GetAction(nIndex
);
1231 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not first rect, row 1", MetaActionType::RECT
, pAction
->GetType());
1232 MetaRectAction
* pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1233 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 1, row 1 not correct",
1234 tools::Rectangle(Point(0, 0), Size(21, 21)),
1235 pRectAction
->GetRect());
1238 pAction
= aMtf
.GetAction(nIndex
);
1239 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 1, rect 2",
1240 MetaActionType::FILLCOLOR
, pAction
->GetType());
1241 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1242 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 1, rect 1", COL_BLACK
,
1243 pFillColorAction
->GetColor());
1246 pAction
= aMtf
.GetAction(nIndex
);
1247 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not second rect, row 1", MetaActionType::RECT
,
1248 pAction
->GetType());
1249 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1250 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 2, row 1 not correct",
1251 tools::Rectangle(Point(0, 20), Size(21, 21)),
1252 pRectAction
->GetRect());
1255 pAction
= aMtf
.GetAction(nIndex
);
1256 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 1, rect 3",
1257 MetaActionType::FILLCOLOR
, pAction
->GetType());
1258 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1259 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 1, rect 1", COL_WHITE
,
1260 pFillColorAction
->GetColor());
1263 pAction
= aMtf
.GetAction(nIndex
);
1264 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not third rect, row 1", MetaActionType::RECT
, pAction
->GetType());
1265 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1266 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 3, row 1 not correct",
1267 tools::Rectangle(Point(0, 40), Size(21, 21)),
1268 pRectAction
->GetRect());
1271 pAction
= aMtf
.GetAction(nIndex
);
1272 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 1, rect 4",
1273 MetaActionType::FILLCOLOR
, pAction
->GetType());
1274 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1275 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 1, rect 4", COL_BLACK
,
1276 pFillColorAction
->GetColor());
1279 pAction
= aMtf
.GetAction(nIndex
);
1280 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not fourth rect, row 1", MetaActionType::RECT
,
1281 pAction
->GetType());
1282 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1283 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 4, row 1 not correct",
1284 tools::Rectangle(Point(0, 60), Size(21, 21)),
1285 pRectAction
->GetRect());
1288 pAction
= aMtf
.GetAction(nIndex
);
1289 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 1, rect 5",
1290 MetaActionType::FILLCOLOR
, pAction
->GetType());
1291 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1292 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 1, rect 5", COL_WHITE
,
1293 pFillColorAction
->GetColor());
1296 pAction
= aMtf
.GetAction(nIndex
);
1297 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not fifth rect, row 1", MetaActionType::RECT
, pAction
->GetType());
1298 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1299 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 5, row 1 not correct",
1300 tools::Rectangle(Point(0, 80), Size(21, 21)),
1301 pRectAction
->GetRect());
1305 pAction
= aMtf
.GetAction(nIndex
);
1306 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 2, rect 1",
1307 MetaActionType::FILLCOLOR
, pAction
->GetType());
1308 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1309 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 2, rect 1", COL_BLACK
,
1310 pFillColorAction
->GetColor());
1313 pAction
= aMtf
.GetAction(nIndex
);
1314 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 2, first rect", MetaActionType::RECT
, pAction
->GetType());
1315 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1316 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 1, row 2 not correct",
1317 tools::Rectangle(Point(20, 0), Size(21, 21)),
1318 pRectAction
->GetRect());
1321 pAction
= aMtf
.GetAction(nIndex
);
1322 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 2, rect 2",
1323 MetaActionType::FILLCOLOR
, pAction
->GetType());
1324 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1325 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 2, rect 1", COL_WHITE
,
1326 pFillColorAction
->GetColor());
1329 pAction
= aMtf
.GetAction(nIndex
);
1330 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 2, second rect", MetaActionType::RECT
,
1331 pAction
->GetType());
1332 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1333 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 2, row 2 not correct",
1334 tools::Rectangle(Point(20, 20), Size(21, 21)),
1335 pRectAction
->GetRect());
1338 pAction
= aMtf
.GetAction(nIndex
);
1339 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 2, rect 3",
1340 MetaActionType::FILLCOLOR
, pAction
->GetType());
1341 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1342 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 2, rect 1", COL_BLACK
,
1343 pFillColorAction
->GetColor());
1346 pAction
= aMtf
.GetAction(nIndex
);
1347 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 2, third rect", MetaActionType::RECT
, pAction
->GetType());
1348 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1349 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 3, row 2 not correct",
1350 tools::Rectangle(Point(20, 40), Size(21, 21)),
1351 pRectAction
->GetRect());
1354 pAction
= aMtf
.GetAction(nIndex
);
1355 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 2, rect 4",
1356 MetaActionType::FILLCOLOR
, pAction
->GetType());
1357 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1358 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 2, rect 4", COL_WHITE
,
1359 pFillColorAction
->GetColor());
1362 pAction
= aMtf
.GetAction(nIndex
);
1363 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 2, fourth rect", MetaActionType::RECT
,
1364 pAction
->GetType());
1365 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1366 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 4, row 2 not correct",
1367 tools::Rectangle(Point(20, 60), Size(21, 21)),
1368 pRectAction
->GetRect());
1371 pAction
= aMtf
.GetAction(nIndex
);
1372 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 2, rect 5",
1373 MetaActionType::FILLCOLOR
, pAction
->GetType());
1374 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1375 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 2, rect 5", COL_BLACK
,
1376 pFillColorAction
->GetColor());
1379 pAction
= aMtf
.GetAction(nIndex
);
1380 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 2, fifth rect", MetaActionType::RECT
, pAction
->GetType());
1381 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1382 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 5, row 2 not correct",
1383 tools::Rectangle(Point(20, 80), Size(21, 21)),
1384 pRectAction
->GetRect());
1388 pAction
= aMtf
.GetAction(nIndex
);
1389 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 3, rect 1",
1390 MetaActionType::FILLCOLOR
, pAction
->GetType());
1391 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1392 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 3, rect 1", COL_WHITE
,
1393 pFillColorAction
->GetColor());
1396 pAction
= aMtf
.GetAction(nIndex
);
1397 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 3, first rect", MetaActionType::RECT
, pAction
->GetType());
1398 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1399 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 1, row 3 not correct",
1400 tools::Rectangle(Point(40, 0), Size(21, 21)),
1401 pRectAction
->GetRect());
1404 pAction
= aMtf
.GetAction(nIndex
);
1405 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 3, rect 2",
1406 MetaActionType::FILLCOLOR
, pAction
->GetType());
1407 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1408 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 3, rect 1", COL_BLACK
,
1409 pFillColorAction
->GetColor());
1412 pAction
= aMtf
.GetAction(nIndex
);
1413 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 3, second rect", MetaActionType::RECT
,
1414 pAction
->GetType());
1415 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1416 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 2, row 3 not correct",
1417 tools::Rectangle(Point(40, 20), Size(21, 21)),
1418 pRectAction
->GetRect());
1421 pAction
= aMtf
.GetAction(nIndex
);
1422 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 3, rect 3",
1423 MetaActionType::FILLCOLOR
, pAction
->GetType());
1424 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1425 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 3, rect 1", COL_WHITE
,
1426 pFillColorAction
->GetColor());
1429 pAction
= aMtf
.GetAction(nIndex
);
1430 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 3, third rect", MetaActionType::RECT
, pAction
->GetType());
1431 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1432 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 3, row 3 not correct",
1433 tools::Rectangle(Point(40, 40), Size(21, 21)),
1434 pRectAction
->GetRect());
1437 pAction
= aMtf
.GetAction(nIndex
);
1438 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 3, rect 4",
1439 MetaActionType::FILLCOLOR
, pAction
->GetType());
1440 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1441 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 3, rect 4", COL_BLACK
,
1442 pFillColorAction
->GetColor());
1445 pAction
= aMtf
.GetAction(nIndex
);
1446 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 3, fourth rect", MetaActionType::RECT
,
1447 pAction
->GetType());
1448 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1449 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 4, row 3 not correct",
1450 tools::Rectangle(Point(40, 60), Size(21, 21)),
1451 pRectAction
->GetRect());
1454 pAction
= aMtf
.GetAction(nIndex
);
1455 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 3, rect 5",
1456 MetaActionType::FILLCOLOR
, pAction
->GetType());
1457 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1458 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 3, rect 5", COL_WHITE
,
1459 pFillColorAction
->GetColor());
1462 pAction
= aMtf
.GetAction(nIndex
);
1463 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 3, fifth rect", MetaActionType::RECT
, pAction
->GetType());
1464 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1465 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 5, row 3 not correct",
1466 tools::Rectangle(Point(40, 80), Size(21, 21)),
1467 pRectAction
->GetRect());
1471 pAction
= aMtf
.GetAction(nIndex
);
1472 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 4, rect 1",
1473 MetaActionType::FILLCOLOR
, pAction
->GetType());
1474 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1475 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 4, rect 1", COL_BLACK
,
1476 pFillColorAction
->GetColor());
1479 pAction
= aMtf
.GetAction(nIndex
);
1480 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 4, first rect", MetaActionType::RECT
, pAction
->GetType());
1481 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1482 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 1, row 4 not correct",
1483 tools::Rectangle(Point(60, 0), Size(21, 21)),
1484 pRectAction
->GetRect());
1487 pAction
= aMtf
.GetAction(nIndex
);
1488 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 4, rect 2",
1489 MetaActionType::FILLCOLOR
, pAction
->GetType());
1490 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1491 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 4, rect 1", COL_WHITE
,
1492 pFillColorAction
->GetColor());
1495 pAction
= aMtf
.GetAction(nIndex
);
1496 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 4, second rect", MetaActionType::RECT
,
1497 pAction
->GetType());
1498 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1499 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 2, row 2 not correct",
1500 tools::Rectangle(Point(60, 20), Size(21, 21)),
1501 pRectAction
->GetRect());
1504 pAction
= aMtf
.GetAction(nIndex
);
1505 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 4, rect 3",
1506 MetaActionType::FILLCOLOR
, pAction
->GetType());
1507 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1508 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 4, rect 1", COL_BLACK
,
1509 pFillColorAction
->GetColor());
1512 pAction
= aMtf
.GetAction(nIndex
);
1513 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 4, third rect", MetaActionType::RECT
, pAction
->GetType());
1514 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1515 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 3, row 4 not correct",
1516 tools::Rectangle(Point(60, 40), Size(21, 21)),
1517 pRectAction
->GetRect());
1520 pAction
= aMtf
.GetAction(nIndex
);
1521 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 4, rect 4",
1522 MetaActionType::FILLCOLOR
, pAction
->GetType());
1523 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1524 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 4, rect 4", COL_WHITE
,
1525 pFillColorAction
->GetColor());
1528 pAction
= aMtf
.GetAction(nIndex
);
1529 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 4, fourth rect", MetaActionType::RECT
,
1530 pAction
->GetType());
1531 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1532 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 4, row 4 not correct",
1533 tools::Rectangle(Point(60, 60), Size(21, 21)),
1534 pRectAction
->GetRect());
1537 pAction
= aMtf
.GetAction(nIndex
);
1538 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 4, rect 5",
1539 MetaActionType::FILLCOLOR
, pAction
->GetType());
1540 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1541 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 4, rect 5", COL_BLACK
,
1542 pFillColorAction
->GetColor());
1545 pAction
= aMtf
.GetAction(nIndex
);
1546 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 4, fifth rect", MetaActionType::RECT
, pAction
->GetType());
1547 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1548 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 5, row 4 not correct",
1549 tools::Rectangle(Point(60, 80), Size(21, 21)),
1550 pRectAction
->GetRect());
1554 pAction
= aMtf
.GetAction(nIndex
);
1555 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 5, rect 1",
1556 MetaActionType::FILLCOLOR
, pAction
->GetType());
1557 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1558 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 5, rect 1", COL_WHITE
,
1559 pFillColorAction
->GetColor());
1562 pAction
= aMtf
.GetAction(nIndex
);
1563 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 5, first rect", MetaActionType::RECT
, pAction
->GetType());
1564 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1565 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 1, row 5 not correct",
1566 tools::Rectangle(Point(80, 0), Size(21, 21)),
1567 pRectAction
->GetRect());
1570 pAction
= aMtf
.GetAction(nIndex
);
1571 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 5, rect 2",
1572 MetaActionType::FILLCOLOR
, pAction
->GetType());
1573 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1574 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 5, rect 1", COL_BLACK
,
1575 pFillColorAction
->GetColor());
1578 pAction
= aMtf
.GetAction(nIndex
);
1579 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 2, second rect", MetaActionType::RECT
,
1580 pAction
->GetType());
1581 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1582 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 2, row 2 not correct",
1583 tools::Rectangle(Point(80, 20), Size(21, 21)),
1584 pRectAction
->GetRect());
1587 pAction
= aMtf
.GetAction(nIndex
);
1588 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 2, rect 3",
1589 MetaActionType::FILLCOLOR
, pAction
->GetType());
1590 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1591 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 2, rect 1", COL_WHITE
,
1592 pFillColorAction
->GetColor());
1595 pAction
= aMtf
.GetAction(nIndex
);
1596 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 2, third rect", MetaActionType::RECT
, pAction
->GetType());
1597 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1598 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 3, row 2 not correct",
1599 tools::Rectangle(Point(80, 40), Size(21, 21)),
1600 pRectAction
->GetRect());
1603 pAction
= aMtf
.GetAction(nIndex
);
1604 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 2, rect 4",
1605 MetaActionType::FILLCOLOR
, pAction
->GetType());
1606 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1607 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 2, rect 4", COL_BLACK
,
1608 pFillColorAction
->GetColor());
1611 pAction
= aMtf
.GetAction(nIndex
);
1612 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 2, fourth rect", MetaActionType::RECT
,
1613 pAction
->GetType());
1614 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1615 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 4, row 2 not correct",
1616 tools::Rectangle(Point(80, 60), Size(21, 21)),
1617 pRectAction
->GetRect());
1620 pAction
= aMtf
.GetAction(nIndex
);
1621 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action for row 2, rect 5",
1622 MetaActionType::FILLCOLOR
, pAction
->GetType());
1623 pFillColorAction
= dynamic_cast<MetaFillColorAction
*>(pAction
);
1624 CPPUNIT_ASSERT_EQUAL_MESSAGE("Fill color wrong for row 2, rect 5", COL_WHITE
,
1625 pFillColorAction
->GetColor());
1628 pAction
= aMtf
.GetAction(nIndex
);
1629 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not row 2, fifth rect", MetaActionType::RECT
, pAction
->GetType());
1630 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1631 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rect 5, row 2 not correct",
1632 tools::Rectangle(Point(80, 80), Size(21, 21)),
1633 pRectAction
->GetRect());
1636 pAction
= aMtf
.GetAction(nIndex
);
1637 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not pop", MetaActionType::POP
, pAction
->GetType());
1640 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawBorder
)
1642 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1644 aMtf
.Record(pVDev
.get());
1646 pVDev
->SetOutputSizePixel(Size(100, 100));
1647 pVDev
->DrawBorder(tools::Rectangle(Point(0, 0), Size(50, 60)));
1649 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1650 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line color action (light gray)", MetaActionType::LINECOLOR
,
1651 pAction
->GetType());
1652 MetaLineColorAction
* pLineColorAction
= dynamic_cast<MetaLineColorAction
*>(pAction
);
1653 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not light gray", COL_LIGHTGRAY
, pLineColorAction
->GetColor());
1655 pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
+ 1);
1656 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rect action (light gray border)", MetaActionType::RECT
,
1657 pAction
->GetType());
1658 MetaRectAction
* pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1659 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rectangle wrong", tools::Rectangle(Point(1, 1), Size(49, 59)),
1660 pRectAction
->GetRect());
1662 pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
+ 2);
1663 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line color action (gray)", MetaActionType::LINECOLOR
,
1664 pAction
->GetType());
1665 pLineColorAction
= dynamic_cast<MetaLineColorAction
*>(pAction
);
1666 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not gray", COL_GRAY
, pLineColorAction
->GetColor());
1668 pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
+ 3);
1669 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rect action (gray border)", MetaActionType::RECT
,
1670 pAction
->GetType());
1671 pRectAction
= dynamic_cast<MetaRectAction
*>(pAction
);
1672 CPPUNIT_ASSERT_EQUAL_MESSAGE("Rectangle wrong", tools::Rectangle(Point(0, 0), Size(49, 59)),
1673 pRectAction
->GetRect());
1676 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawWaveLine
)
1678 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1680 aMtf
.Record(pVDev
.get());
1682 pVDev
->SetOutputSizePixel(Size(100, 100));
1683 pVDev
->DrawWaveLine(Point(0, 0), Point(50, 0));
1685 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1686 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a bitmap action", MetaActionType::BMPEXSCALEPART
,
1687 pAction
->GetType());
1690 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawPolyLine
)
1693 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1695 aMtf
.Record(pVDev
.get());
1697 pVDev
->SetOutputSizePixel(Size(100, 100));
1698 tools::Polygon
aPolygon(vcl::test::OutputDeviceTestCommon::createClosedBezierLoop(
1699 tools::Rectangle(Point(10, 10), Size(80, 8))));
1701 pVDev
->DrawPolyLine(aPolygon
);
1703 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1704 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polygon action", MetaActionType::POLYLINE
,
1705 pAction
->GetType());
1706 MetaPolyLineAction
* pPolyLineAction
= dynamic_cast<MetaPolyLineAction
*>(pAction
);
1707 CPPUNIT_ASSERT_EQUAL_MESSAGE("Polygon in polyline action is wrong", aPolygon
,
1708 pPolyLineAction
->GetPolygon());
1712 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1714 aMtf
.Record(pVDev
.get());
1716 pVDev
->SetOutputSizePixel(Size(100, 100));
1718 tools::Polygon
aPolygon(vcl::test::OutputDeviceTestCommon::createClosedBezierLoop(
1719 tools::Rectangle(Point(10, 10), Size(80, 8))));
1721 LineInfo
aLineInfo(LineStyle::Dash
, 10);
1722 aLineInfo
.SetDashCount(5);
1723 aLineInfo
.SetDashLen(10);
1724 aLineInfo
.SetDotCount(3);
1725 aLineInfo
.SetDotLen(13);
1726 aLineInfo
.SetDistance(8);
1727 aLineInfo
.SetLineJoin(basegfx::B2DLineJoin::Bevel
);
1728 aLineInfo
.SetLineCap(css::drawing::LineCap_BUTT
);
1730 pVDev
->DrawPolyLine(aPolygon
, aLineInfo
);
1732 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1733 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polygon action", MetaActionType::POLYLINE
,
1734 pAction
->GetType());
1735 MetaPolyLineAction
* pPolyLineAction
= dynamic_cast<MetaPolyLineAction
*>(pAction
);
1736 CPPUNIT_ASSERT_EQUAL_MESSAGE("Polygon in polyline action is wrong", aPolygon
,
1737 pPolyLineAction
->GetPolygon());
1739 CPPUNIT_ASSERT_EQUAL_MESSAGE("Dash count wrong", static_cast<sal_uInt16
>(5),
1740 pPolyLineAction
->GetLineInfo().GetDashCount());
1741 CPPUNIT_ASSERT_EQUAL_MESSAGE("Dash len wrong", static_cast<double>(10),
1742 pPolyLineAction
->GetLineInfo().GetDashLen());
1743 CPPUNIT_ASSERT_EQUAL_MESSAGE("Dot count wrong", static_cast<sal_uInt16
>(3),
1744 pPolyLineAction
->GetLineInfo().GetDotCount());
1745 CPPUNIT_ASSERT_EQUAL_MESSAGE("Dot len wrong", static_cast<double>(13),
1746 pPolyLineAction
->GetLineInfo().GetDotLen());
1747 CPPUNIT_ASSERT_EQUAL_MESSAGE("Distance wrong", static_cast<double>(8),
1748 pPolyLineAction
->GetLineInfo().GetDistance());
1749 CPPUNIT_ASSERT_EQUAL_MESSAGE("Line join", basegfx::B2DLineJoin::Bevel
,
1750 pPolyLineAction
->GetLineInfo().GetLineJoin());
1751 CPPUNIT_ASSERT_EQUAL_MESSAGE("Line cap", css::drawing::LineCap_BUTT
,
1752 pPolyLineAction
->GetLineInfo().GetLineCap());
1756 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1758 aMtf
.Record(pVDev
.get());
1760 pVDev
->SetOutputSizePixel(Size(100, 100));
1762 basegfx::B2DPolygon
aPolygon(vcl::test::OutputDeviceTestCommon::createClosedBezierLoop(
1763 tools::Rectangle(Point(10, 10), Size(80, 8)))
1766 LineInfo
aLineInfo(LineStyle::Dash
, 10);
1767 aLineInfo
.SetDashCount(5);
1768 aLineInfo
.SetDashLen(10);
1769 aLineInfo
.SetDotCount(3);
1770 aLineInfo
.SetDotLen(13);
1771 aLineInfo
.SetDistance(8);
1772 aLineInfo
.SetLineJoin(basegfx::B2DLineJoin::Bevel
);
1773 aLineInfo
.SetLineCap(css::drawing::LineCap_BUTT
);
1775 pVDev
->DrawPolyLine(aPolygon
, 3, basegfx::B2DLineJoin::Bevel
, css::drawing::LineCap_BUTT
,
1776 basegfx::deg2rad(15.0));
1778 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1779 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polygon action", MetaActionType::POLYLINE
,
1780 pAction
->GetType());
1781 MetaPolyLineAction
* pPolyLineAction
= dynamic_cast<MetaPolyLineAction
*>(pAction
);
1782 CPPUNIT_ASSERT_EQUAL_MESSAGE("Polygon in polyline action is wrong", aPolygon
,
1783 pPolyLineAction
->GetPolygon().getB2DPolygon());
1785 CPPUNIT_ASSERT_EQUAL_MESSAGE("Width wrong", static_cast<double>(3),
1786 pPolyLineAction
->GetLineInfo().GetWidth());
1787 CPPUNIT_ASSERT_EQUAL_MESSAGE("Dash count wrong", static_cast<sal_uInt16
>(0),
1788 pPolyLineAction
->GetLineInfo().GetDashCount());
1789 CPPUNIT_ASSERT_EQUAL_MESSAGE("Dash len wrong", static_cast<double>(0),
1790 pPolyLineAction
->GetLineInfo().GetDashLen());
1791 CPPUNIT_ASSERT_EQUAL_MESSAGE("Dot count wrong", static_cast<sal_uInt16
>(0),
1792 pPolyLineAction
->GetLineInfo().GetDotCount());
1793 CPPUNIT_ASSERT_EQUAL_MESSAGE("Dot len wrong", static_cast<double>(0),
1794 pPolyLineAction
->GetLineInfo().GetDotLen());
1795 CPPUNIT_ASSERT_EQUAL_MESSAGE("Distance wrong", static_cast<double>(0),
1796 pPolyLineAction
->GetLineInfo().GetDistance());
1797 CPPUNIT_ASSERT_EQUAL_MESSAGE("Line join", basegfx::B2DLineJoin::Bevel
,
1798 pPolyLineAction
->GetLineInfo().GetLineJoin());
1799 CPPUNIT_ASSERT_EQUAL_MESSAGE("Line cap", css::drawing::LineCap_BUTT
,
1800 pPolyLineAction
->GetLineInfo().GetLineCap());
1804 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawPolygon
)
1807 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1809 aMtf
.Record(pVDev
.get());
1811 pVDev
->SetOutputSizePixel(Size(100, 100));
1812 tools::Polygon
aPolygon(vcl::test::OutputDeviceTestCommon::createClosedBezierLoop(
1813 tools::Rectangle(Point(10, 10), Size(80, 8))));
1815 pVDev
->DrawPolygon(aPolygon
);
1817 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1818 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polygon action", MetaActionType::POLYGON
,
1819 pAction
->GetType());
1820 MetaPolygonAction
* pPolygonAction
= dynamic_cast<MetaPolygonAction
*>(pAction
);
1821 CPPUNIT_ASSERT_EQUAL_MESSAGE("Polygon in polygon action is wrong", aPolygon
,
1822 pPolygonAction
->GetPolygon());
1826 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1828 aMtf
.Record(pVDev
.get());
1830 pVDev
->SetOutputSizePixel(Size(100, 100));
1831 tools::Polygon
aPolygon(vcl::test::OutputDeviceTestCommon::createClosedBezierLoop(
1832 tools::Rectangle(Point(10, 10), Size(80, 8))));
1834 pVDev
->DrawPolygon(aPolygon
);
1836 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1837 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polygon action", MetaActionType::POLYGON
,
1838 pAction
->GetType());
1839 MetaPolygonAction
* pPolygonAction
= dynamic_cast<MetaPolygonAction
*>(pAction
);
1840 CPPUNIT_ASSERT_EQUAL_MESSAGE("Polygon in polygon action is wrong", aPolygon
,
1841 pPolygonAction
->GetPolygon());
1845 static tools::PolyPolygon
createPolyPolygon()
1847 tools::Polygon
aPolygon(4);
1849 aPolygon
.SetPoint(Point(1, 8), 0);
1850 aPolygon
.SetPoint(Point(2, 7), 1);
1851 aPolygon
.SetPoint(Point(3, 6), 2);
1852 aPolygon
.SetPoint(Point(4, 5), 3);
1854 tools::PolyPolygon
aPolyPolygon(aPolygon
);
1855 aPolyPolygon
.Optimize(PolyOptimizeFlags::CLOSE
);
1857 return aPolyPolygon
;
1860 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawPolyPolygon
)
1863 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1865 aMtf
.Record(pVDev
.get());
1867 pVDev
->SetOutputSizePixel(Size(100, 100));
1869 tools::PolyPolygon aPolyPolygon
= createPolyPolygon();
1871 pVDev
->DrawPolyPolygon(aPolyPolygon
);
1873 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1874 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polypolygon action", MetaActionType::POLYPOLYGON
,
1875 pAction
->GetType());
1877 MetaPolyPolygonAction
* pPolyPolygonAction
= dynamic_cast<MetaPolyPolygonAction
*>(pAction
);
1878 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not the same polypolygon in polypolygon action", aPolyPolygon
,
1879 pPolyPolygonAction
->GetPolyPolygon());
1883 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1885 aMtf
.Record(pVDev
.get());
1887 pVDev
->SetOutputSizePixel(Size(100, 100));
1889 tools::PolyPolygon aPolyPolygon
= createPolyPolygon();
1891 basegfx::B2DPolyPolygon
aB2DPolyPolygon(aPolyPolygon
.getB2DPolyPolygon());
1893 pVDev
->DrawPolyPolygon(aB2DPolyPolygon
);
1895 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1896 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polypolygon action", MetaActionType::POLYPOLYGON
,
1897 pAction
->GetType());
1899 /* these should match, but the equality operator does not work on PolyPolygon for some reason
1901 MetaPolyPolygonAction* pPolyPolygonAction = dynamic_cast<MetaPolyPolygonAction*>(pAction);
1902 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not the same polypolygon in polypolygon action", aPolyPolygon,
1903 pPolyPolygonAction->GetPolyPolygon());
1908 static size_t ClipGradientTest(GDIMetaFile
& rMtf
, size_t nIndex
)
1910 MetaAction
* pAction
= rMtf
.GetAction(nIndex
);
1911 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a comment action", MetaActionType::COMMENT
,
1912 pAction
->GetType());
1915 pAction
= rMtf
.GetAction(nIndex
);
1916 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a gradientex action", MetaActionType::GRADIENTEX
,
1917 pAction
->GetType());
1921 pAction
= rMtf
.GetAction(nIndex
);
1922 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a push action", MetaActionType::PUSH
, pAction
->GetType());
1923 MetaPushAction
* pPushAction
= dynamic_cast<MetaPushAction
*>(pAction
);
1924 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not using CLIPREGION push flags", vcl::PushFlags::CLIPREGION
,
1925 pPushAction
->GetFlags());
1928 pAction
= rMtf
.GetAction(nIndex
);
1929 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a CLIPREGION action", MetaActionType::CLIPREGION
,
1930 pAction
->GetType());
1933 pAction
= rMtf
.GetAction(nIndex
);
1934 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a gradient action", MetaActionType::GRADIENT
,
1935 pAction
->GetType());
1938 pAction
= rMtf
.GetAction(nIndex
);
1939 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a pop action", MetaActionType::POP
, pAction
->GetType());
1942 pAction
= rMtf
.GetAction(nIndex
);
1943 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a comment action", MetaActionType::COMMENT
,
1944 pAction
->GetType());
1949 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawGradient_drawmode
)
1951 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1953 aMtf
.Record(pVDev
.get());
1955 pVDev
->SetOutputSizePixel(Size(100, 100));
1956 pVDev
->SetDrawMode(DrawModeFlags::BlackGradient
);
1958 tools::Rectangle
aRect(Point(10, 10), Size(40, 40));
1959 pVDev
->DrawGradient(aRect
, Gradient());
1960 MetaAction
* pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
);
1961 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a push action (drawmode is black gradient)",
1962 MetaActionType::PUSH
, pAction
->GetType());
1963 MetaPushAction
* pPushAction
= dynamic_cast<MetaPushAction
*>(pAction
);
1964 vcl::PushFlags eFlags
= vcl::PushFlags::LINECOLOR
| vcl::PushFlags::FILLCOLOR
;
1965 CPPUNIT_ASSERT_EQUAL_MESSAGE("Push flags wrong (drawmode is black gradient)", eFlags
,
1966 pPushAction
->GetFlags());
1968 pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
+ 1);
1969 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a line color action (drawmode is black gradient)",
1970 MetaActionType::LINECOLOR
, pAction
->GetType());
1971 pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
+ 2);
1972 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a fill color action (drawmode is black gradient)",
1973 MetaActionType::FILLCOLOR
, pAction
->GetType());
1974 pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
+ 3);
1975 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a polypolygon action (drawmode is black gradient)",
1976 MetaActionType::POLYPOLYGON
, pAction
->GetType());
1977 pAction
= aMtf
.GetAction(INITIAL_SETUP_ACTION_COUNT
+ 4);
1978 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a pop action (drawmode is black gradient)",
1979 MetaActionType::POP
, pAction
->GetType());
1982 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawGradient_rect_linear
)
1984 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
1986 aMtf
.Record(pVDev
.get());
1988 tools::Rectangle
aRect(Point(10, 10), Size(40, 40));
1989 pVDev
->SetOutputSizePixel(Size(100, 100));
1991 Gradient
aGradient(css::awt::GradientStyle_LINEAR
, COL_RED
, COL_WHITE
);
1992 aGradient
.SetBorder(100);
1994 pVDev
->DrawGradient(aRect
, aGradient
);
1996 size_t nIndex
= INITIAL_SETUP_ACTION_COUNT
;
1998 MetaAction
* pAction
= aMtf
.GetAction(nIndex
);
1999 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a gradient action (rectangle area)", MetaActionType::GRADIENT
,
2000 pAction
->GetType());
2003 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawGradient_rect_axial
)
2005 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
2007 aMtf
.Record(pVDev
.get());
2009 tools::Rectangle
aRect(Point(10, 10), Size(40, 40));
2010 pVDev
->SetOutputSizePixel(Size(100, 100));
2012 Gradient
aGradient(css::awt::GradientStyle_AXIAL
, COL_RED
, COL_WHITE
);
2013 aGradient
.SetBorder(100);
2015 pVDev
->DrawGradient(aRect
, aGradient
);
2017 size_t nIndex
= INITIAL_SETUP_ACTION_COUNT
;
2019 MetaAction
* pAction
= aMtf
.GetAction(nIndex
);
2020 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a gradient action (rectangle area)", MetaActionType::GRADIENT
,
2021 pAction
->GetType());
2024 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawGradient_polygon_linear
)
2026 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
2028 aMtf
.Record(pVDev
.get());
2030 tools::PolyPolygon aPolyPolygon
= createPolyPolygon();
2032 pVDev
->SetOutputSizePixel(Size(100, 100));
2034 Gradient
aGradient(css::awt::GradientStyle_LINEAR
, COL_RED
, COL_WHITE
);
2035 aGradient
.SetBorder(100);
2037 pVDev
->DrawGradient(aPolyPolygon
, aGradient
);
2039 ClipGradientTest(aMtf
, INITIAL_SETUP_ACTION_COUNT
);
2042 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawGradient_polygon_axial
)
2044 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
2046 aMtf
.Record(pVDev
.get());
2048 tools::PolyPolygon aPolyPolygon
= createPolyPolygon();
2050 pVDev
->SetOutputSizePixel(Size(100, 100));
2052 Gradient
aGradient(css::awt::GradientStyle_AXIAL
, COL_RED
, COL_WHITE
);
2053 aGradient
.SetBorder(100);
2055 pVDev
->DrawGradient(aPolyPolygon
, aGradient
);
2057 ClipGradientTest(aMtf
, INITIAL_SETUP_ACTION_COUNT
);
2060 CPPUNIT_TEST_FIXTURE(VclOutdevTest
, testDrawGradient_rect_complex
)
2062 ScopedVclPtrInstance
<VirtualDevice
> pVDev
;
2064 aMtf
.Record(pVDev
.get());
2066 tools::Rectangle
aRect(Point(10, 10), Size(40, 40));
2067 pVDev
->SetOutputSizePixel(Size(1000, 1000));
2069 Gradient
aGradient(css::awt::GradientStyle_SQUARE
, COL_RED
, COL_WHITE
);
2070 aGradient
.SetBorder(10);
2071 pVDev
->DrawGradient(aRect
, aGradient
);
2073 size_t nIndex
= INITIAL_SETUP_ACTION_COUNT
;
2075 MetaAction
* pAction
= aMtf
.GetAction(nIndex
);
2076 CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a gradient action (rectangle area)", MetaActionType::GRADIENT
,
2077 pAction
->GetType());
2080 CPPUNIT_PLUGIN_IMPLEMENT();
2082 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */