From fe70fa98ef53e5dc054d86c7cb857e41d6c3e6d6 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 16 Aug 2019 14:52:14 +0200 Subject: CppunitTest_sw_uiwriter: get rid of hardcoded 1418 in testImageComment See a different value at and the intention is to make sure the comment anchor and the fly frame position matches, not to check the actual value. Change-Id: I28eb39cfe5cbb57713b2c642a703e8509da25323 Reviewed-on: https://gerrit.libreoffice.org/77582 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- sw/qa/extras/uiwriter/uiwriter2.cxx | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx index 6f314401f7e7..d2035512c393 100644 --- a/sw/qa/extras/uiwriter/uiwriter2.cxx +++ b/sw/qa/extras/uiwriter/uiwriter2.cxx @@ -1616,6 +1616,17 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testImageComment) pView->GetViewFrame()->GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); #if !defined(MACOSX) + // Calc the left edge of the as-char frame. + SwRootFrame* pLayout = pWrtShell->GetLayout(); + SwFrame* pPage = pLayout->GetLower(); + SwFrame* pBody = pPage->GetLower(); + SwFrame* pTextFrame = pBody->GetLower(); + CPPUNIT_ASSERT(pTextFrame->GetDrawObjs()); + const SwSortedObjs& rAnchored = *pTextFrame->GetDrawObjs(); + CPPUNIT_ASSERT_GREATER(static_cast(0), rAnchored.size()); + SwAnchoredObject* pObject = rAnchored[0]; + long nFrameLeft = pObject->GetObjRect().Left(); + // Make sure that the anchor points to the bottom left corner of the image. // Without the accompanying fix in place, this test would have failed with: // - Expected less or equal than: 1418 @@ -1626,7 +1637,7 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testImageComment) for (const auto& pItem : *pPostItMgr) { const SwRect& rAnchor = pItem->pPostIt->GetAnchorRect(); - CPPUNIT_ASSERT_LESSEQUAL(static_cast(1418), rAnchor.Left()); + CPPUNIT_ASSERT_EQUAL(nFrameLeft, rAnchor.Left()); } // Test the comment anchor we expose via the LOK API. @@ -1645,7 +1656,12 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testImageComment) { const boost::property_tree::ptree& rComment = rValue.second; OString aAnchorPos(rComment.get("anchorPos").c_str()); - CPPUNIT_ASSERT_EQUAL(OString("1418, 1418, 0, 0"), aAnchorPos); + OString aExpected; + aExpected += OString::number(nFrameLeft); + aExpected += ", "; + aExpected += OString::number(nFrameLeft); + aExpected += ", 0, 0"; + CPPUNIT_ASSERT_EQUAL(aExpected, aAnchorPos); } #endif -- cgit