summaryrefslogtreecommitdiff
path: root/vcl/qa/cppunit/outdev.cxx
diff options
context:
space:
mode:
authorChris Sherlock <chris.sherlock79@gmail.com>2021-09-29 17:06:19 +1000
committerTomaž Vajngerl <quikee@gmail.com>2021-10-06 14:07:23 +0200
commitf4d5be05f643e9a483fcbb8441faa4a89c0cb280 (patch)
tree1ef3b1b1cacd1a3dd8128580f4b7c4dd6e998ebc /vcl/qa/cppunit/outdev.cxx
parentd4b68f063cbb3c490e1ad084c3f9eb30c6a8c93a (diff)
vcl: test OutputDevice::DrawRect()
Change-Id: Ic9ed566d171b3059fbe6de9fcc32ca0af6db7a2d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122820 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'vcl/qa/cppunit/outdev.cxx')
-rw-r--r--vcl/qa/cppunit/outdev.cxx40
1 files changed, 40 insertions, 0 deletions
diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx
index 9a93d8402b95..93ae28e3a732 100644
--- a/vcl/qa/cppunit/outdev.cxx
+++ b/vcl/qa/cppunit/outdev.cxx
@@ -70,6 +70,7 @@ public:
void testGetWaveLineSize();
void testDrawPixel();
void testDrawLine();
+ void testDrawRect();
CPPUNIT_TEST_SUITE(VclOutdevTest);
CPPUNIT_TEST(testVirtualDevice);
@@ -111,6 +112,7 @@ public:
CPPUNIT_TEST(testGetWaveLineSize);
CPPUNIT_TEST(testDrawPixel);
CPPUNIT_TEST(testDrawLine);
+ CPPUNIT_TEST(testDrawRect);
CPPUNIT_TEST_SUITE_END();
};
@@ -1127,6 +1129,44 @@ void VclOutdevTest::testDrawLine()
}
}
+void VclOutdevTest::testDrawRect()
+{
+ {
+ ScopedVclPtrInstance<VirtualDevice> pVDev;
+ GDIMetaFile aMtf;
+ aMtf.Record(pVDev.get());
+
+ pVDev->SetOutputSizePixel(Size(1, 100));
+ pVDev->DrawRect(tools::Rectangle(Point(0, 0), Size(50, 60)));
+
+ MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rect action", MetaActionType::RECT, pAction->GetType());
+ MetaRectAction* pRectAction = dynamic_cast<MetaRectAction*>(pAction);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Rectangle wrong", tools::Rectangle(Point(0, 0), Size(50, 60)),
+ pRectAction->GetRect());
+ }
+
+ {
+ ScopedVclPtrInstance<VirtualDevice> pVDev;
+ GDIMetaFile aMtf;
+ aMtf.Record(pVDev.get());
+
+ pVDev->SetOutputSizePixel(Size(1, 100));
+ pVDev->DrawRect(tools::Rectangle(Point(0, 0), Size(50, 60)), 5, 10);
+
+ MetaAction* pAction = aMtf.GetAction(aMtf.GetActionSize() - 1);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Not a rect action", MetaActionType::ROUNDRECT,
+ pAction->GetType());
+ MetaRoundRectAction* pRectAction = dynamic_cast<MetaRoundRectAction*>(pAction);
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Rectangle wrong", tools::Rectangle(Point(0, 0), Size(50, 60)),
+ pRectAction->GetRect());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Rectangle wrong", static_cast<sal_uInt32>(5),
+ pRectAction->GetHorzRound());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Rectangle wrong", static_cast<sal_uInt32>(10),
+ pRectAction->GetVertRound());
+ }
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(VclOutdevTest);
CPPUNIT_PLUGIN_IMPLEMENT();