vcl/qa/cppunit/outdev.cxx | 40 ++++++++++++++++++++++++++++++++++++++++ vcl/source/outdev/outdev.cxx | 3 --- 2 files changed, 40 insertions(+), 3 deletions(-)
New commits: commit 5f50890d06a411323e5e60098901be4911ef1356 Author: Chris Sherlock <chris.sherloc...@gmail.com> AuthorDate: Wed Aug 25 16:38:17 2021 +1000 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sat Sep 4 05:54:27 2021 +0200 vcl: Add unit test for SetRefPoint(), IsRefPoint() and GetRefPoint() Change-Id: I4fbc85015326b03fba15daf73176826669a16210 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121017 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> 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<VirtualDevice> 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<MetaRefPointAction*>(pAction); + CPPUNIT_ASSERT_EQUAL(Point(), pRefPointAction->GetRefPoint()); +} + +void VclOutdevTest::testRefPoint() +{ + ScopedVclPtrInstance<VirtualDevice> 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<MetaRefPointAction*>(pAction); + CPPUNIT_ASSERT_EQUAL(Point(10, 20), pRefPointAction->GetRefPoint()); +} + void VclOutdevTest::testSystemTextColor() { { diff --git a/vcl/source/outdev/outdev.cxx b/vcl/source/outdev/outdev.cxx index 71ec101f4dd1..eaef70931062 100644 --- a/vcl/source/outdev/outdev.cxx +++ b/vcl/source/outdev/outdev.cxx @@ -287,7 +287,6 @@ css::uno::Any OutputDevice::GetSystemGfxDataAny() const void OutputDevice::SetRefPoint() { - if ( mpMetaFile ) mpMetaFile->AddAction( new MetaRefPointAction( Point(), false ) ); @@ -298,10 +297,8 @@ void OutputDevice::SetRefPoint() if( mpAlphaVDev ) mpAlphaVDev->SetRefPoint(); } - void OutputDevice::SetRefPoint( const Point& rRefPoint ) { - if ( mpMetaFile ) mpMetaFile->AddAction( new MetaRefPointAction( rRefPoint, true ) );