Tip for debugging CppunitTest_sd_tiledrendering failure

Miklos Vajna vmiklos at collabora.co.uk
Tue Nov 22 09:44:40 UTC 2016

Hi Khaled,

On Tue, Nov 22, 2016 at 08:55:33AM +0200, Khaled Hosny <khaledhosny at eglug.org> wrote:
> Thanks for the pointer. Incrementing the Y position by at least 1 fixes
> the test, but I’m still not sure what the position is supposed to be in
> the first place and why line spacing would matter.

Indeed it should not matter. SdTiledRenderingTest::testPostMouseEvent()
loads an Impress document, presses "x" (which in that context stars the
text edit of the only shape on the first slide), gets the position of
the cursor and then clicks to the same place, but 1000 mm100 away
towards the left edge of the slide.

Then it asserts that after the mouse click the cursor is no longer
after the "x" but before it.

The 1000 mm100 is indeed just something I came up with, assuming it is
larger than the width of "x" and smaller than the total width of the
text area of the shape. But in case it helps, feel free to tweak it,
just make sure that the asserts still pass:
rEditView.GetSelection().nStartPos should be "1" before clicking with
the mouse and it should be "0" after.

Maybe CPPUNIT_ASSERT(pView->GetTextEditObject()) currently fails as
after your changes the text area rectangle is changed, and 1000 is large
enough that it clicks outside the text area, finishing the whole text
edit, instead of just moving the cursor before "x"?

Another option: given that you mention incrementing Y by 1 changes the
situation, it would be fine to work with the "vertical center" of the
cursor not the "top" of it when we decide the click position.

Does this help? It would be no problem to include this change.

diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx
index 2d2cc99..4122adc 100644
--- a/sd/qa/unit/tiledrendering/tiledrendering.cxx
+++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx
@@ -351,7 +351,7 @@ void SdTiledRenderingTest::testPostMouseEvent()
     CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), rEditView.GetSelection().nStartPos);
     vcl::Cursor* pCursor = rEditView.GetCursor();
-    Point aPosition = pCursor->GetPos();
+    Point aPosition(pCursor->GetPos().getX(), pCursor->GetPos().getY() + pCursor->GetSize().Height() / 2);
     aPosition.setX(aPosition.getX() - 1000);
                                       convertMm100ToTwip(aPosition.getX()), convertMm100ToTwip(aPosition.getY()),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20161122/a118a4c0/attachment.sig>

More information about the LibreOffice mailing list