From 5f50890d06a411323e5e60098901be4911ef1356 Mon Sep 17 00:00:00 2001 From: Chris Sherlock Date: Wed, 25 Aug 2021 16:38:17 +1000 Subject: vcl: Add unit test for SetRefPoint(), IsRefPoint() and GetRefPoint() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I4fbc85015326b03fba15daf73176826669a16210 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121017 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- vcl/qa/cppunit/outdev.cxx | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'vcl/qa') diff --git a/vcl/qa/cppunit/outdev.cxx b/vcl/qa/cppunit/outdev.cxx index adbf72751b4c..1857b4555c8a 100644 --- a/vcl/qa/cppunit/outdev.cxx +++ b/vcl/qa/cppunit/outdev.cxx @@ -54,6 +54,8 @@ public: void testLineColor(); void testFont(); void testTransparentFont(); + void testDefaultRefPoint(); + void testRefPoint(); void testSystemTextColor(); void testShouldDrawWavePixelAsRect(); void testGetWaveLineSize(); @@ -84,6 +86,8 @@ public: CPPUNIT_TEST(testLineColor); CPPUNIT_TEST(testFont); CPPUNIT_TEST(testTransparentFont); + CPPUNIT_TEST(testDefaultRefPoint); + CPPUNIT_TEST(testRefPoint); CPPUNIT_TEST(testSystemTextColor); CPPUNIT_TEST(testShouldDrawWavePixelAsRect); CPPUNIT_TEST(testGetWaveLineSize); @@ -725,6 +729,42 @@ void VclOutdevTest::testTransparentFont() CPPUNIT_ASSERT_EQUAL(nActionsExpected, aMtf.GetActionSize()); } +void VclOutdevTest::testDefaultRefPoint() +{ + ScopedVclPtrInstance pVDev; + + GDIMetaFile aMtf; + aMtf.Record(pVDev.get()); + + pVDev->SetRefPoint(); + + CPPUNIT_ASSERT(!pVDev->IsRefPoint()); + CPPUNIT_ASSERT_EQUAL(Point(), pVDev->GetRefPoint()); + + MetaAction* pAction = aMtf.GetAction(0); + CPPUNIT_ASSERT_EQUAL(MetaActionType::REFPOINT, pAction->GetType()); + auto pRefPointAction = static_cast(pAction); + CPPUNIT_ASSERT_EQUAL(Point(), pRefPointAction->GetRefPoint()); +} + +void VclOutdevTest::testRefPoint() +{ + ScopedVclPtrInstance pVDev; + + GDIMetaFile aMtf; + aMtf.Record(pVDev.get()); + + pVDev->SetRefPoint(Point(10, 20)); + + CPPUNIT_ASSERT(pVDev->IsRefPoint()); + CPPUNIT_ASSERT_EQUAL(Point(10, 20), pVDev->GetRefPoint()); + + MetaAction* pAction = aMtf.GetAction(0); + CPPUNIT_ASSERT_EQUAL(MetaActionType::REFPOINT, pAction->GetType()); + auto pRefPointAction = static_cast(pAction); + CPPUNIT_ASSERT_EQUAL(Point(10, 20), pRefPointAction->GetRefPoint()); +} + void VclOutdevTest::testSystemTextColor() { { -- cgit