From 7fd1516ed3eeb6523276eabbf9d7f8fcb246e96a Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Wed, 28 Sep 2016 17:16:16 +0200 Subject: sw lok: fix one view inserting a comment, other view jumping there as well Views are expected to be more or less independent. So when one view inserts a comment, don't emit cursor callbacks in the other views, so that the other views don't jump to the comment position. Change-Id: I5e4eadccef971dce2b7c759f3094f6d348d07645 --- desktop/qa/desktop_lib/test_desktop_lib.cxx | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'desktop') diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 3456576c63e0..1425c1cf6e84 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -1572,19 +1572,24 @@ void DesktopLOKTest::testPaintPartTile() void DesktopLOKTest::testWriterCommentInsertCursor() { - // Load a document and type a character into the body text. + // Load a document and type a character into the body text of the second view. comphelper::LibreOfficeKit::setActive(); LibLODocument_Impl* pDocument = loadDoc("blank_text.odt"); pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); ViewCallback aView1; pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView1); + pDocument->m_pDocumentClass->createView(pDocument); + pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); + ViewCallback aView2; + pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView2); pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'x', 0); pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 'x', 0); Scheduler::ProcessEventsToIdle(); - Rectangle aBodyCursor = aView1.m_aOwnCursor; + Rectangle aBodyCursor = aView2.m_aOwnCursor; // Now insert a comment and make sure that the comment's cursor is shown, // not the body text's one. + aView1.m_aOwnCursor.SetEmpty(); const int nCtrlAltC = KEY_MOD1 + KEY_MOD2 + 512 + 'c' - 'a'; pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYINPUT, 'c', nCtrlAltC); pDocument->m_pDocumentClass->postKeyEvent(pDocument, LOK_KEYEVENT_KEYUP, 'c', nCtrlAltC); @@ -1594,7 +1599,13 @@ void DesktopLOKTest::testWriterCommentInsertCursor() osl::Thread::wait(std::chrono::seconds(1)); Scheduler::ProcessEventsToIdle(); // This failed: the body cursor was shown right after inserting a comment. - CPPUNIT_ASSERT(aView1.m_aOwnCursor.getX() > aBodyCursor.getX()); + CPPUNIT_ASSERT(aView2.m_aOwnCursor.getX() > aBodyCursor.getX()); + // This failed, the first view's cursor also jumped when the second view + // inserted the comment. + CPPUNIT_ASSERT(aView1.m_aOwnCursor.IsEmpty()); + + mxComponent->dispose(); + mxComponent.clear(); comphelper::LibreOfficeKit::setActive(false); } -- cgit